Cache is deleted when linting text
See original GitHub issueWhat version of ESLint are you using? Master
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration: N/A
What did you do? Please include the actual source code causing the issue.
Given a directory with a file and an .eslintcache
:
> tree -a
.
├── .eslintcache
└── foo.js
Running eslint on text with --stdin
causes the .eslintcache
file to be deleted:
> echo "var foo=42;" | eslint --stdin
> tree -a
.
└── foo.js
What did you expect to happen?
Since the cache is only used when executing on files, I would not expect the .eslintcache
file to be deleted. This causes problems when using eslint in a text editor like Atom, because it means as soon as a file is opened (and therefore linted), the cache file is deleted (see https://github.com/AtomLinter/linter-eslint/issues/587).
I believe this is because the code which deletes the cache is too high in the CLIEngine execution right after instantiation. It could likely be moved into executeOnFiles
as an else
to this check.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
To give a little more explanation, I run eslint in my editor (Atom), which lints using
--stdin
and--stdin-filename
. Linting there is quick, because it only runs on one file-worth of text at a time. When I’m ready to commit changes, I run an npm script which lints the entire codebase with--cache
. I would like the cache to persist between mynpm run lint
executions, because without it linting can take quite a while.Sure, this should be pretty straight-forward, I think.