Skip to content

feat: add support for Import Attributes and RegExp Modifiers - #639

Merged
mdjermanovic merged 3 commits into
eslint:mainfrom
ota-meshi:es2025-oct
Oct 29, 2024
Merged

feat: add support for Import Attributes and RegExp Modifiers#639
mdjermanovic merged 3 commits into
eslint:mainfrom
ota-meshi:es2025-oct

Conversation

@ota-meshi

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

Copy link
Copy Markdown
Member

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

@nzakas nzakas left a comment

Copy link
Copy Markdown
Member

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.

@mdjermanovic mdjermanovic left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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

@ota-meshi

Copy link
Copy Markdown
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
Copy Markdown
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)

@mdjermanovic mdjermanovic left a comment

Copy link
Copy Markdown
Member

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
@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