ESLint's cache can stop autofixing
See original GitHub issueTell 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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
eslintcache is deleted when auto-fix is performed #635 - GitHub
ESLint since version 3.0.0 will no longer remove the .eslintcache file whenever a file is linted by linter-eslint. (see #587 for discussion ...
Read more >How to delete .eslintcache file in react? - Stack Overflow
I have a problem I can not solve. I have an ".eslintcache" file, which was created for me automatically as soon as I...
Read more >eslint-watch - npm
Fixing problems: --fix Automatically fix problems. --fix-dry-run Automatically fix problems without saving the changes to the file system.
Read more >Command Line Interface - ESLint - Pluggable JavaScript Linter
The CLI has a variety of options that you can pass to configure ESLint. ... Deprecated: Use rules from plugins Fix problems: --fix...
Read more >Remove eslintcache file - keeps appearing on each save all of ...
Add the .eslintcache to your .gitignore file. Run the following command to clear the cache git rm -rf ... Is there a way...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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. 😄