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: add support for Import Attributes and RegExp Modifiers #639

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi commented Oct 28, 2024

Prerequisites checklist

What is the purpose of this pull request?

Add support for ES2025 import attributes, and add support for RegExp modifiers.

What changes did you make? (Give an overview)

This PR adds support for ES2025 import attributes and RegExp modifiers.

Related Issues

Related to eslint/eslint#19014, eslint/eslint#19073

Is there anything you'd like reviewers to focus on?

nzakas
nzakas previously approved these changes Oct 28, 2024
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Waiting for another approval before merging.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any changes to eslint-scope needed?

If not, can you just add a few tests to confirm? For example:

const type = "json";

import pkg from "./package.json" with { type: "json" }; // not a reference to `type`

export * from "./package.json" with { type: "json" }; // not a reference to `type`

export { default } from "./package.json" with { type: "json" }; // not a reference to `type`

import("./package.json", { with: { type } }); // a reference to `type`

@ota-meshi
Copy link
Member Author

Thank you for the review!
I didn't notice that. I will test it and fix it 😄

@ota-meshi
Copy link
Member Author

I added test cases to eslint-scope.
However, eslint-scope seems to work fine already, probably because the ImportAttribute node's visitor is not defined, so it doesn't get processed.

@mdjermanovic
Copy link
Member

However, eslint-scope seems to work fine already

Yeah, I double-checked the code.

ImportDeclaration is special-handled. It will traverse ImportAttribute nodes and their Identifier nodes but not consider them as references.

ExportNamedDeclaration and ExportAllDeclaration will be just skipped if they have source.

For ImportExpression, eslint-scope doesn't specify a visitor so by default all child nodes will be traversed (esrecurse)

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mdjermanovic mdjermanovic changed the title feat: add support for import attributes and RegExp modifiers feat: add support for Import Attributes and RegExp Modifiers Oct 29, 2024
@mdjermanovic mdjermanovic merged commit 2fd4222 into eslint:main Oct 29, 2024
12 checks passed
@github-actions github-actions bot mentioned this pull request Oct 29, 2024
@ota-meshi ota-meshi deleted the es2025-oct branch October 29, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

3 participants