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's cache can stop autofixing #10679

Closed
nstepien opened this issue Jul 26, 2018 · 5 comments
Closed

ESLint's cache can stop autofixing #10679

nstepien opened this issue Jul 26, 2018 · 5 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@nstepien
Copy link

Tell us about your environment

  • ESLint Version: 5.2.0
  • Node Version: v10.7.0
  • npm Version: 6.1.0

What parser (default, Babel-ESLint, etc.) are you using?
default or babel-eslint
Please show your full configuration:

Configuration
{
  "rules": {
    "quotes": 1
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

'test'
.\node_modules\.bin\eslint --cache src
.\node_modules\.bin\eslint --fix --cache src

What did you expect to happen?
ESLint should fix the fixable issues.

What actually happened? Please include the actual, raw output from ESLint.

C:\test> .\node_modules\.bin\eslint --cache src

C:\test\src\test.js
  1:1  warning  Strings must use doublequote  quotes

✖ 1 problem (0 errors, 1 warning)
  0 errors and 1 warning potentially fixable with the `--fix` option.

C:\test> .\node_modules\.bin\eslint --fix --cache src

C:\test\src\test.js
  1:1  warning  Strings must use doublequote  quotes

✖ 1 problem (0 errors, 1 warning)
  0 errors and 1 warning potentially fixable with the `--fix` option.

ESLint does not autofix when the cache is populated. If I delete .eslintcache, then ESLint will autofix just fine.
I believe this is a regression since 5.2.0 (81283d0).
ESLint, when autofixing, shouldn't ignore files that are cached, do not invalidate the cache, but are known to have issues.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jul 26, 2018
@nstepien
Copy link
Author

I should add: I like to verify a rule's configuration before running eslint with --fix, but I also want to make use of the cache so eslint doesn't have to re-lint files that have not changed and have no issues.

@aladdin-add aladdin-add added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 26, 2018
@platinumazure
Copy link
Member

Hi @MayhemYDG, thanks for reporting this issue.

The intent was that when a file is autofixed, it wouldn't be written in the cache. I think the problem is that the old cached file information from a previous (non-fix) run is not invalidated explicitly. I was hoping that the file's modification time would be sufficient to invalidate the cache, but maybe we got the sequence of events wrong.

@nstepien
Copy link
Author

@platinumazure I think there might be a little misunderstanding: during the --fix run, the files are not fixed, they're just ignored.

@platinumazure
Copy link
Member

Oh, thanks for clarifying.

I think I know what's going on. The cache info does not contain fix information because it was written when ESLint was run without autofix. When ESLint is run with autofix, it gets the cached lint results which don't have any autofix information, so ESLint decides there are no fixes to apply.

I think the best approach here will be to read from the cache, and if there are errors/warnings and autofix is enabled, we need to ignore the cache results and let the file be linted normally.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 28, 2018
@platinumazure
Copy link
Member

@MayhemYDG I've got a branch up in this repo: "fix-cache" (also represented in PR #10694). If you have a chance, I'd be grateful if you could take a look and see if it might fix this issue. I think I've figured it out, but an extra set of eyes never hurt. 😄

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 28, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

4 participants