Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-plugin-prettier is failing with a wrong path #235

Closed
scottkidder opened this issue Jun 25, 2018 · 21 comments
Closed

eslint-plugin-prettier is failing with a wrong path #235

scottkidder opened this issue Jun 25, 2018 · 21 comments
Labels

Comments

@scottkidder
Copy link

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
@scottkidder scottkidder 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/ Jun 25, 2018
@Turbo87 Turbo87 added the bug label Jun 25, 2018
@Turbo87
Copy link
Member

Turbo87 commented Jun 25, 2018

@scottkidder can you provide a reproduction repository?

@runspired
Copy link

This is failing in ember data when we run yarn install --no-lockfile --non-interactive

Example 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:

npm ls eslint
ember-data@3.3.0-canary /Users/cthoburn/Github/data
└─┬ ember-cli-eslint@4.2.3
  └─┬ broccoli-lint-eslint@4.2.1
    └── eslint@4.19.1 

@runspired
Copy link

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
Copy link

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.

@runspired
Copy link

PR that introduces the bug: prettier/eslint-plugin-prettier#92

@runspired
Copy link

Traced the issue down to how root = true in .editorconfig is being treated by prettier, removing it causes prettier to work. Isolating why.

@ezpuzz
Copy link

ezpuzz commented Jun 25, 2018

I couldn't fix my project by modifying .editorconfig, but reverting to eslint-plugin-prettier 2.6.0 fixes my build.

@runspired
Copy link

runspired commented 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
Copy link
Member

Turbo87 commented Jun 26, 2018

I can confirm, turning the prettier/prettier rule off seems to "fix" the issue for me. This seems unrelated to the ESLint 5 update.

@Turbo87 Turbo87 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 Jun 26, 2018
@rwjblue
Copy link
Member

rwjblue commented 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
Copy link

pzuraq commented Jun 26, 2018

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.

@buschtoens
Copy link

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?

@buschtoens
Copy link

  - 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.

@rwjblue
Copy link
Member

rwjblue commented Sep 5, 2018

Using the temp path doesn't really satisfy what eslint / prettier is trying to do...

@rwjblue
Copy link
Member

rwjblue commented 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-funnel and therefore it includes app/ twice..)

@buschtoens
Copy link

So the "fix" is taking all options into account?

Or should we add this "feature" to broccoli to expose the original source path?

@rwjblue
Copy link
Member

rwjblue commented Sep 5, 2018

A little bit of both I think 😺...

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...

@dfreeman
Copy link

dfreeman commented 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
Copy link
Member

rwjblue commented Sep 6, 2018

ZOMG thanks @dfreeman! I had completely missed that RFC 😢

Turbo87 pushed a commit that referenced this issue Oct 15, 2018
Bumps [ember-resolver](https://github.com/ember-cli/ember-resolver) from 4.1.0 to 5.0.1.
<details>
<summary>Changelog</summary>

*Sourced from [ember-resolver's changelog](https://github.com/ember-cli/ember-resolver/blob/master/CHANGELOG.md).*

> # Change Log
> 
> ## [v4.5.6](https://github.com/ember-cli/ember-resolver/tree/v4.5.6) (2018-06-13)
> [Full Changelog](ember-cli/ember-resolver@v4.5.5...v4.5.6)
> 
> **Closed issues:**
> 
> - An error occurred in the constructor for ember-resolver [\#234](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/234)
> - emberResolverFeatureFlags\(\) calls project.config\(\) without an environment name [\#233](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/233)
> - ember-cli-react/resolver not found [\#231](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/231)
> - Add ember-cli-eslint [\#200](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/200)
> 
> **Merged pull requests:**
> 
> - cleanup yo [\#240](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/240) ([stefanpenner](https://github.com/stefanpenner))
> - Added config type to module unification config [\#239](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/239) ([chrism](https://github.com/chrism))
> - use flag EMBER\_CLI\_MODULE\_UNIFICATION [\#238](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/238) ([givanse](https://github.com/givanse))
> - Fixup linting issues. [\#236](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/236) ([rwjblue](https://github.com/rwjblue))
> - Update to ember-cli@3.1.4 blueprint. [\#235](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/235) ([rwjblue](https://github.com/rwjblue))
> 
> ## [v4.5.5](https://github.com/ember-cli/ember-resolver/tree/v4.5.5) (2018-03-23)
> [Full Changelog](ember-cli/ember-resolver@v4.5.4...v4.5.5)
> 
> **Closed issues:**
> 
> - \[4.5.3\] Build error [\#227](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/227)
> - Support for RFC 297 - Deprecation of Ember.Logger [\#223](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/223)
> 
> **Merged pull requests:**
> 
> - \[RFC 297\] Updated to conditionally use console rather than using Ember.Logger [\#232](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/232) ([lupestro](https://github.com/lupestro))
> - Update module unification spec link [\#230](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/230) ([josemarluedke](https://github.com/josemarluedke))
> - Use build-time `project.isModuleUnification\(\)` instead of feature flag. [\#228](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/228) ([cibernox](https://github.com/cibernox))
> 
> ## [v4.5.4](https://github.com/ember-cli/ember-resolver/tree/v4.5.4) (2018-03-09)
> [Full Changelog](ember-cli/ember-resolver@v4.5.3...v4.5.4)
> 
> ## [v4.5.3](https://github.com/ember-cli/ember-resolver/tree/v4.5.3) (2018-03-09)
> [Full Changelog](ember-cli/ember-resolver@v4.5.2...v4.5.3)
> 
> **Closed issues:**
> 
> - Namespaces [\#214](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/214)
> 
> **Merged pull requests:**
> 
> - Update MU trees: template-options is now template-compiler [\#226](https://github-redirect.dependabot.com/ember-cli/ember-resolver/pull/226) ([cibernox](https://github.com/cibernox))
> 
> ## [v4.5.2](https://github.com/ember-cli/ember-resolver/tree/v4.5.2) (2018-03-05)
> [Full Changelog](ember-cli/ember-resolver@v4.5.1...v4.5.2)
></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`6303c48`](ember-cli/ember-resolver@6303c48) release v5.0.1 🎉
- [`0ffc530`](ember-cli/ember-resolver@0ffc530) Merge pull request [#243](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/243) from ember-cli/remove-default-resolver
- [`51f92e8`](ember-cli/ember-resolver@51f92e8) release v5.0.0 🎉
- [`df3ef4e`](ember-cli/ember-resolver@df3ef4e) Merge pull request [#244](https://github-redirect.dependabot.com/ember-cli/ember-resolver/issues/244) from ember-cli/chores
- [`1c40ceb`](ember-cli/ember-resolver@1c40ceb) Fix linting
- [`340f2ca`](ember-cli/ember-resolver@340f2ca) upgrade eslint + qunit-dom
- [`793ed30`](ember-cli/ember-resolver@793ed30) Disable not super important test for 3.3 test combat:
- [`777bdf1`](ember-cli/ember-resolver@777bdf1) upgrade CLI
- [`fa0302e`](ember-cli/ember-resolver@fa0302e) upgrades
- [`d63ac09`](ember-cli/ember-resolver@d63ac09) update lockfile (fix node 10 issue)
- Additional commits viewable in [compare view](ember-cli/ember-resolver@v4.1.0...v5.0.1)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=ember-resolver&package-manager=npm_and_yarn&previous-version=4.1.0&new-version=5.0.1)](https://dependabot.com/compatibility-score.html?dependency-name=ember-resolver&package-manager=npm_and_yarn&previous-version=4.1.0&new-version=5.0.1)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

Dependabot will **not** automatically merge this PR because it includes a major update to a development dependency.

---

**Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com).

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
@sumeetattree
Copy link

So how are fixing this? Just ran into the same build error. Remove ember-cli-eslint completely?

@jeanduplessis
Copy link

@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.

himynameisjonas added a commit to Teamtailor/ember-justified-layout that referenced this issue Jun 1, 2019
chadian added a commit to chadian/ember-fill-up that referenced this issue Oct 14, 2019
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 ember-cli/ember-cli-eslint#235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants