question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do not remove unlinted files from cache if `--cache` is used

See original GitHub issue

First, here’s a little background on the problem I’m trying to solve:

I run a linting step on my entire project prior to every commit. I use --cache to speed up linting and check only the files which have changed. So far so good.

However, between commits I also am saving code in Atom, using linter-eslint’s auto-fix on save option. This executes ESLint without the --cache flag, so my cache is cleared and the next time I manually lint the cache has to be rebuilt, taking much longer than I’d like.

So, I thought I could just add an option in linter-eslint to add the --cache flag (https://github.com/AtomLinter/linter-eslint/issues/635), but I realized this still wouldn’t work, because the cache file will be completely overwritten with the cache results of just the one file that was saved/auto-fixed. Aside: to verify this is the case, lint two files, check that the .eslintcache file contains both filenames, then lint just one of those files (still using --cache), and you’ll see that the other file has disappeared.

So my proposal is this:

Instead of throwing away the old cache file each time, simply update the results for files that are linted in that run. This way, files which were previously linted stay cached. I have submitted https://github.com/royriojas/file-entry-cache/issues/2 upstream to add that possibility in the package we use for our caching, and if that is accepted the only change to ESLint would likely be to update the dependency.

If the upstream change is not accepted, there are still ways we could accomplish the same result (albeit less cleanly) if the team thinks this would be a worthwhile change.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
royriojascommented, Aug 2, 2016

Sure, I don’t anticipate files to grow too much out of control, though. In this case is also pretty easy to just delete the cache file. Prune might also be able to check if files exists and then decide to remove them from the cache. That can probably be added as an option on the file-entry-cache module to avoid adding another flag on eslint. Something that can be done with:

cache.reconcile( { pruneRemoved: true } );

at saving time, entries that were not visited can be check for existence in the file system and be removed if they are not longer found. Will give that a try as well.

1reaction
royriojascommented, Jul 29, 2016

Hi @IanVS, I remembered the reason I didn’t keep the files, it is because otherwise files that were deleted will stay forever in the cache. I might have to find another solution to make sure files are not kept in the cache forever if they are not longer present. Or maybe that’s not an issue and users can simply delete the files manually. It seems the benefits of keeping the files are greater than deleting them.

Will try to give it a try during the weekend.

Regards

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Cached Data and Should You Keep it or Clear it?
It's not bad to clear your cached data now and then. Some refer to this data as “junk files,” meaning it just sits...
Read more >
What Are Junk Files & Is It Safe to Delete Them? - AVG
As long as you regularly clear your browser cache and find and remove your unneeded temporary files, you'll be fine.
Read more >
Clear your junk files - Files by Google Help
On your Android device, open Files by Google Files by Google . On the bottom left, tap Clean Clean . On the "Junk...
Read more >
How to Clear Cache on Android (And When You Should)
Older Android versions gave you the option to delete all cached files at once by going to Settings > Storage > Cached Data....
Read more >
What are junk files and why do you need to remove them?
Find out why you should remove junk files from your devices and how to ... Temporary internet files - also known as cache...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found