ember-cli-eslint: `eslint-plugin-prettier` is failing with a wrong path
After upgrading to ESLint 5 and running ember test in an addon and I have found EslintValidationFilter trying to lint addon/addon/adapters
~/dev/project-123 (master) > ember test
cleaning up...
Build failed.
Build Error (broccoli-persistent-filter:EslintValidationFilter) in addon/adapters/application.js
ENOENT: no such file or directory, scandir '/home/skidder/dev/project-123/addon/addon/adapters'
Stack Trace and Error Report: /tmp/error.dump.66d834709b71560c98ced28c7b8425d9.log
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (7 by maintainers)
Commits related to this issue
- Bump ember-resolver from 4.1.0 to 5.0.1 (#264) Bumps [ember-resolver](https://github.com/ember-cli/ember-resolver) from 4.1.0 to 5.0.1. <details> <summary>Changelog</summary> *Sourced from [embe... — committed to ember-cli/ember-cli-eslint by dependabot[bot] 6 years ago
- Remove ember-cli-eslint to make all tests pass https://github.com/ember-cli/ember-cli-eslint/issues/235 — committed to Teamtailor/ember-justified-layout by himynameisjonas 5 years ago
- Add prettier, and related eslint, packages and config Note: eslint-plugin-prettier is pegged to 2.6.0 because versions after this expose a bug within ember-cli-eslint in which it breaks. See https:/... — committed to chadian/ember-fill-up by chadian 5 years ago
Dove into this a bit and found the underlying issue. The problem is that
broccoli-lint-eslintpasses the wrong file path to ESLint. For instance, in an addon, it passes{pathToProject}/addon/addon/file.jsinstead of{pathToProject/addon/file.js}.This happens because
broccoli-lint-eslintnaively walks up broccoli nodes to find the original input node ({pathToProject}/addon), and doesn’t account for the fact that along the way, various nodes can move around and shift the files. Somewhere along the way, we funnel the addon files:So, when
broccoli-lint-eslintfinally begins transforming the files, it attempts to combine the original tree path, and the new relative path of the file.This bug has been present for some time, but wasn’t being triggered because no eslint plugins were using the file context before the recent change to
eslint-plugin-prettier. I think ultimately we need to either pass in the actual original file path somehow, or we need to pass in the full path to the temp file we’re actually operating on.I couldn’t fix my project by modifying
.editorconfig, but reverting toeslint-plugin-prettier2.6.0 fixes my build.ZOMG thanks @dfreeman! I had completely missed that RFC 😢
Have you considered weighing in over on https://github.com/ember-cli/rfcs/pull/121? I’ve been leaning more and more toward the same conclusion (for all the reasons you mention), but opinions seem to be all over the spectrum over there 🙂