Skip to content

Add caching based on file content and external references #752

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

Merged
merged 42 commits into from
Feb 12, 2021
Merged

Conversation

ajafff
Copy link
Member

@ajafff ajafff commented Jan 28, 2021

Checklist

Overview of change

Adds a new CI option --cache. If enabled, it looks for a cache file tsconfig.fimbullintercache and tries to reuse the results from that file. If any file that affects global scope (or dependencies thereof) have changed, or TypeScript version or compilerOptions changed, the cache is discarded entirely.
For each file it checks if the file or the linter configuration didn't change and all external references resolve to the same files with identical content as last time. It handles ambient modules and module augmentations like compiler does.
If compilerOption assumeChangeOnlyAffectDirectDependencies is enabled, the cache also stops at the first level of dependencies.
After linting the updated cache is written back to disk.
If --fix is enabled, fixing a file invalidates the results from other files linted before if those files may be affected by the change. These results are still reported in CLI output, but not included in the new cache. The affected files will be linted again on the next run.
If the cache was generated without --fix and is then run again with --fix, fixes are applied from cache without initially linting the file again.

The cache contains only paths relative to the tsconfig.json. That means you can check the cache file into VCS so CI and your collegues can benefit from a warm linter start.

This does change the language service plugin.

The following situations (currently) don't work well with the cache:

  • updating the linter, rules or any dependency thereof doesn't invalidate the cache
  • rules accessing external files
    • provide an API on RuleContext that allows the rule to access the file system and track that as dependency
  • rules accessing other files in the program that are not a (transitive) dependency of the currently linted file
    • provide an API on RuleContext where rules can report this behavior
    • or simply create a wrapper for Program that tracks random access to source files
  • linting the same project with different configurations

@ajafff ajafff marked this pull request as ready for review February 12, 2021 15:43
@ajafff ajafff merged commit 265546e into master Feb 12, 2021
@ajafff ajafff deleted the cache branch February 12, 2021 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Caching lint results
1 participant