Closed michaelfaith closed 1 month ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 94.95%. Comparing base (
61f02a2
) to head (250571e
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Note: I broke the change to utils/hash
out as its own commit, so that it can be released separately.
Published v2.12.0 of eslint-module-utils already; this PR will be merged once CI passes.
Discovered this issue in https://github.com/import-js/eslint-plugin-import/pull/2996#issuecomment-2372522774.
This change improves the logic for generating the cache key used for both the ExportMap cache and the resolver cache when using flat config. Prior to this change, the cache key was a combination of the
parserPath
, a hash of theparserOptions
, a hash of the plugin settings, and the path of the file. When using flat config,parserPath
isn't provided. So, there's the possibility of incorrect / stale cache objects being used if someone ran with this plugin using different parsers within the same lint execution, ifparserOptions
and settings are the same.For flat config, we can achieve similar results by constructing the cacheKey using
languageOptions
as a component of the key, rather thanparserPath
andparserOptions
. One caveat is that theparser
property oflanguageOptions
is an object that oftentimes has the same two functions (parse
andparseForESLint
). This won't be reliably distinct when using the baseJSON.stringify
function to detect changes. So, this implementation uses a replacer function along withJSON.stringify
to stringify function properties along with other property types in order to detect different parsers.To ensure that this works properly with v9, I also tested this against https://github.com/import-js/eslint-plugin-import/pull/2996 with v9 installed. Not only does it pass all tests in that branch, but it also removes the need to add this exception: https://github.com/import-js/eslint-plugin-import/pull/2996#discussion_r1774135785