You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 23, 2024. It is now read-only.
eslint-plugin-prettier is failing with a wrong path #235
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
changed the title [-]ESLint 5 fails on non-existing files[/-][+]ESLint 5 fails on non-existing files causing Error when trying to lint addon/addon/adapters/[/+]on Jun 25, 2018
However, I am suspicious of the root cause being eslint itself. Both before and after the command is run this output the same, notice how in our case there is no eslint version 5 in play:
Traced the issue to eslint-plugin-prettier, the patch version 2.6.1 introduces a config requirement that is either poorly thought out or which we need to fix our default config for.
@rwjblue thinks (suspects, although he's known to be rather spot on in these matters) the issue is that we've been giving bad path data to the plugin all along and now it matters.
changed the title [-]ESLint 5 fails on non-existing files causing Error when trying to lint addon/addon/adapters/[/-][+]`eslint-plugin-prettier` is failing with a wrong path[/+]on Jun 26, 2018
Yep, definitely unrelated to Eslint version. Prior to the most recent eslint-plugin-prettier the editorconfig of the project was never used, now it is..
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:
newFunnel(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.
Reacted by Emory Jensen, Joshua Lawrence, Chris Miller, 0xADADA, Devonte and Makala Noble
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.
What do you think makes more sense? If I understand correctly, we are actually linting the temp file and not the original source file? In this case passing the the path of the temp file probably makes more sense?
- broccoliBuilderErrorStack: Error: ENOENT: no such file or directory, scandir '/Users/janbuschtoens/clark/application/client-packages/addons/ember-clark-sentry/app/app/initializers'
at Object.readdirSync (fs.js:750:3)
at traverseFolder (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:32564:18)
at findRoot (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:32580:10)
at maybeParse (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:32592:16)
at editorconfigSyncNoCache (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:32605:35)
at editorconfigSyncNoCache (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:28538:20)
at /Users/janbuschtoens/clark/application/node_modules/prettier/index.js:34796:14
at Array.map (<anonymous>)
at _resolveConfig (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:34795:40)
at Function.resolveConfig.sync (/Users/janbuschtoens/clark/application/node_modules/prettier/index.js:34831:12)
- codeFrame: ENOENT: no such file or directory, scandir '/Users/janbuschtoens/clark/application/client-packages/addons/ember-clark-sentry/app/app/initializers'
- errorMessage: Build Canceled: Broccoli Builder ran into an error with `broccoli-persistent-filter:EslintValidationFilter` plugin. 💥
Hm, judging by the stack trace the other way around might make more sense? Seems like Prettier tries to resolve some config files.
There just isn't a "correct" way to find a files original source path from within a broccoli tree. Thats what is biting us here. The current implementation in broccoli-lint-eslint is attempting to figure it out, but is doing it wrong (it isn't taking into account the various options to broccoli-funnel and therefore it includes app/ twice..)
However, I’m quite happy with the solution I mentioned above: remove ember-cli-eslint and use eslint directly. It speeds up build time, reduces cognitive overhead, and let’s us leverage industry standard tooling instead of reinventing our own config parsing and caching system...
Have you considered weighing in over on ember-cli/rfcs#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 🙂
@sumeetattree we've gone with the route of just removing ember-cli-eslint in favour of running eslint manually as part of our CI pipeline and also enforcing eslint rules in a pre-commit hook.
Activity
[-]ESLint 5 fails on non-existing files[/-][+]ESLint 5 fails on non-existing files causing Error when trying to lint addon/addon/adapters/[/+]Turbo87 commentedon Jun 25, 2018
@scottkidder can you provide a reproduction repository?
runspired commentedon Jun 25, 2018
This is failing in ember data when we run
yarn install --no-lockfile --non-interactiveExample failure: https://travis-ci.org/emberjs/data/jobs/396554871
However, I am suspicious of the root cause being eslint itself. Both before and after the command is run this output the same, notice how in our case there is no eslint version 5 in play:
runspired commentedon Jun 25, 2018
The following is the diff of all the drift involved that leads to this, have not spotted anything super suspicious. https://gist.github.com/runspired/d1383ce39e37009daf584b6a7705eb92
runspired commentedon Jun 25, 2018
Traced the issue to
eslint-plugin-prettier, the patch version2.6.1introduces a config requirement that is either poorly thought out or which we need to fix our default config for.runspired commentedon Jun 25, 2018
PR that introduces the bug: prettier/eslint-plugin-prettier#92
runspired commentedon Jun 25, 2018
Traced the issue down to how
root = truein.editorconfigis being treated by prettier, removing it causes prettier to work. Isolating why.ezpuzz commentedon Jun 25, 2018
I couldn't fix my project by modifying
.editorconfig, but reverting toeslint-plugin-prettier2.6.0 fixes my build.runspired commentedon Jun 26, 2018
@rwjblue thinks (suspects, although he's known to be rather spot on in these matters) the issue is that we've been giving bad path data to the plugin all along and now it matters.
Turbo87 commentedon Jun 26, 2018
I can confirm, turning the
prettier/prettierrule off seems to "fix" the issue for me. This seems unrelated to the ESLint 5 update.[-]ESLint 5 fails on non-existing files causing Error when trying to lint addon/addon/adapters/[/-][+]`eslint-plugin-prettier` is failing with a wrong path[/+]rwjblue commentedon Jun 26, 2018
Yep, definitely unrelated to Eslint version. Prior to the most recent eslint-plugin-prettier the editorconfig of the project was never used, now it is..
pzuraq commentedon Jun 26, 2018
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.buschtoens commentedon Sep 5, 2018
What do you think makes more sense? If I understand correctly, we are actually linting the temp file and not the original source file? In this case passing the the path of the temp file probably makes more sense?
buschtoens commentedon Sep 5, 2018
Hm, judging by the stack trace the other way around might make more sense? Seems like Prettier tries to resolve some config files.
rwjblue commentedon Sep 5, 2018
Using the temp path doesn't really satisfy what eslint / prettier is trying to do...
rwjblue commentedon Sep 5, 2018
There just isn't a "correct" way to find a files original source path from within a broccoli tree. Thats what is biting us here. The current implementation in broccoli-lint-eslint is attempting to figure it out, but is doing it wrong (it isn't taking into account the various options to
broccoli-funneland therefore it includesapp/twice..)buschtoens commentedon Sep 5, 2018
So the "fix" is taking all options into account?
Or should we add this "feature" to broccoli to expose the original source path?
rwjblue commentedon Sep 5, 2018
A little bit of both I think 😺...
However, I’m quite happy with the solution I mentioned above: remove
ember-cli-eslintand useeslintdirectly. It speeds up build time, reduces cognitive overhead, and let’s us leverage industry standard tooling instead of reinventing our own config parsing and caching system...dfreeman commentedon Sep 6, 2018
Have you considered weighing in over on ember-cli/rfcs#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 🙂
rwjblue commentedon Sep 6, 2018
ZOMG thanks @dfreeman! I had completely missed that RFC 😢
Bump ember-resolver from 4.1.0 to 5.0.1 (#264)
sumeetattree commentedon Apr 3, 2019
So how are fixing this? Just ran into the same build error. Remove
ember-cli-eslintcompletely?jeanduplessis commentedon Apr 3, 2019
@sumeetattree we've gone with the route of just removing ember-cli-eslint in favour of running eslint manually as part of our CI pipeline and also enforcing eslint rules in a pre-commit hook.
Remove ember-cli-eslint to make all tests pass
Add prettier, and related eslint, packages and config