Skip to content
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

feat: sync upstream changes #4

Merged
merged 50 commits into from
Nov 21, 2024

Conversation

sparten11740
Copy link
Collaborator

Rebase the latest upstream changes

G-Rath and others added 30 commits November 21, 2024 10:36
This change fixes a bug with flat config support.
There is a function called `childContext` that's used by the ExportBuilder to "cleanse" the context object.
This function wasn't including the new `languageOptions` object, which contains the parser.
So by the time this cleansed context made it to the parse function, `languageOptions` wasn't there anymore.

Since `parserPath` was still being included in non-flat config scenarios, the parse function made it through ok and used `parserPath`.
However, once you shift to flat config, `parserPath` is no longer defined, and the actual parser object needs to be there.

Fixes import-js#3051
This change adds helper functions to `eslint-module-utils` in order to add eslint v9 support to `eslint-plugin-import` in a backwards compatible way.

Contributes to import-js#2996
…is both a named and a default export

 - add tests for import-js#1594
This change addresses an issue with using the espree parser with flat config.  `keysFromParser` is responsible for finding the `visitorKeys` from a combination of the parser instance, parserPath, and the results of a call to `parseForESLint`.  When using flat config, the `parserPath` will not be on the context object., and there are no results from `parseForESLint`.  The espree parser _does_ provide visitor keys as a  prop on the parser itself.  However, this logic was only returning it when it found that "espree" was somewhere in the `parserPath` (which doesn't exist on flat config).

I changed it so that it first does the check for the old-school babel parser using parser path, and then just checks the parser instance for the presence of `VisitorKeys`, rather than using parserPath at all. The reason for the re-order is that if the old babel-eslint parser, for some reason has `VisitorKeys`, having the new condition first, would change the behavior.
…ptions`

This change adds `ecmaVersion` and `sourceType` to the options we're passing to the parsers, if they're present on `languageOptions` (which would only be the case for flat config).
soryy708 and others added 20 commits November 21, 2024 10:37
…sults

This change addresses and issue observed with the v9 upgrade, where the ExportMap Cache is being tainted with a bad export map, if the parse doesn't yield a `visitorKeys` (which can happen if an incompatible parser is used (e.g. og babel eslint)) for one run of the no-cycle rule.  If a subsequent test is run with a compatible parser, then the bad export map will be found in the cache and used instead of attempting to proceed with the parse.

I also updated the `getExports` test to use a valid parserPath, rather than a mocked one, so that the tests are acting on a valid parserPath.  Otherwise the export map won't be cached following this change.
Discovered this issue in import-js#2996 (comment)

This change improves the logic for generating the cache key used for both the exportMap cache and resolver cache when using flat config. Prior to this change, the cache key was a combination of the `parserPath`, a hash of the `parserOptions`, 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 cache objects being used if someone ran with this plugin using different parsers within the same lint execution, if parserOptions and settings are the same. The equivalent cacheKey construction when using flat config is to use `languageOptions` as a component of the key, rather than `parserPath` and `parserOptions`. One caveat is that the `parser` property of `languageOptions` is an object that oftentimes has the same two functions (`parse` and `parseForESLint`). This won't be reliably distinct when using the base JSON.stringify function to detect changes. So, this implementation uses a replace function along with `JSON.stringify` to stringify function properties along with other property types.

To ensure that this will work properly with v9, I also tested this against import-js#2996 with v9 installed. Not only does it pass all tests in that branch, but it also removes the need to add this exception: import-js#2996 (comment)
Co-authored-by: Gareth Jones <jones258@gmail.com>
Co-authored-by: michael faith <michaelfaith@users.noreply.github.com>
@sparten11740 sparten11740 self-assigned this Nov 21, 2024
@sparten11740 sparten11740 merged commit 4ddc447 into main Nov 21, 2024
423 of 426 checks passed
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.