ember-cli-eslint: `eslint-plugin-prettier` is failing with a wrong path

https://eslint.org/docs/user-guide/migrating-to-5.0.0#-linting-nonexistent-files-from-the-command-line-is-now-a-fatal-error

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

Most upvoted comments

Dove into this a bit and found the underlying issue. The problem is that broccoli-lint-eslint passes the wrong file path to ESLint. For instance, in an addon, it passes {pathToProject}/addon/addon/file.js instead of {pathToProject/addon/file.js}.

This happens because broccoli-lint-eslint naively 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:

new Funnel(addonFiles, {
  dest: 'addon'
});

So, when broccoli-lint-eslint finally 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 to eslint-plugin-prettier 2.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 🙂