-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
The dependencies from package.json
are cached for this rule, but it looks like when eslint is running as a daemon, like an IDE (VSCode or IntelliJ IDEA), the cache is not cleared properly, causing errors to keep showing if package.json is modified.
It looks like Program:exit
is defined in the wrong place in the rule. I'm not sure what the intended behavior was, but to me it looks like a simple bug, as Program:exit
should be returned from create
like so:
create(context) {
[...]
return {
...moduleVisitor((source, node) => {
reportIfMissing(context, deps, depsOptions, node, source.value);
}, { commonjs: true }),
'Program:exit'() {
depFieldCache.clear();
},
}
}
instead, Program:exit
is defined on the same level as create
, causing it to be ignored.
Though as Program:exit
is ran for each file, the cache would be quite useless in this case. Perhaps the file modified time could be checked to trigger a reload, but I'm also not seeing any slowdowns from not caching at all, but that might just be for my use case. (the bulk of the time is spent in reportInMissing
~677ms (because of the typescript resolver) vs ~30ms in getDependencies
(uncached))
Can anyone confirm?