-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
fix: lint files and create a global cache #79
Conversation
Codecov Report
@@ Coverage Diff @@
## master #79 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 250 262 +12
Branches 70 74 +4
=========================================
+ Hits 250 262 +12
Continue to review full report at Codecov.
|
/cc @alexander-akait Can use the invalid hook to invalidate cache? WDTY? |
|
Can we keep it that way in v2 and fix it in v3? If not, we will have performance problems! Or do you have any idea how to do this? |
I need to look at this issue, I would prefer to return to it in 3 versions, is it not critical now? |
Unfortunately I think this is critical.
what side effects ? |
Because some projects use manually |
@alexander-akait could you provide more details on how this can break this plugin, I'll be happy to investigate. To resolve issue #83 i would suggest using both compilation.hooks.finishModules and compilation.hooks.succeedModule in following manner: const seen = new Set()
compilation.hooks.finishModules.tap(ESLINT_PLUGIN, (modules) => {
/** @type {string[]} */
const files = [];
// @ts-ignore
for (const { resource } of modules) {
if (resource) {
const [file] = resource.split('?');
if (
file &&
!seen.has(file) &&
isMatch(file, wanted) &&
!isMatch(file, exclude)
) {
seen.add(file)
files.push(file);
}
}
}
if (files.length > 0) {
lint(files);
}
});
compilation.hooks.succeedModule.tap(ESLINT_PLUGIN, (module) => {
const { resource } = module
const [file] = resource.split('?'); //? maybe move this to function
if (
file &&
!seen.has(file) &&
isMatch(file, wanted) &&
!isMatch(file, exclude)
) {
seen.add(file)
lint(file)
}
}) "Why don't use only compilation.hooks.succeedModule ?" |
@@ -39,8 +38,6 @@ export default function linter(key, options, compilation) { | |||
/** @type {Promise<LintResult[]>[]} */ | |||
const rawResults = []; | |||
|
|||
const crossRunResultStorage = getResultStorage(compilation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cache held all results that had been computed... invalidations were supposed to be deleted from this and re-run.. so we don't recompute results for files that did not change... but still show them if they had issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related #83
This feels like reinventing the results storage that was removed when all that was needed was to remove results for invalidated entries. |
Just delete entries from it on invalidation events. |
@ricardogobbosouza can we get #79 (comment) into fix-lint-and-cache branch ? |
This PR contains a:
Motivation / Use-Case
Linting the necessary files and create a more intelligent cache of the result
Resolves #75 , #74
Breaking Changes
Additional Info
Thanks @watjurk