Skip to content

feat: add support for Import Attributes and RegExp Modifiers #19076

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

Merged
merged 10 commits into from
Nov 1, 2024

Conversation

mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Oct 29, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

Closes #19014
Closes #19073

What changes did you make? (Give an overview)

  • Updated eslint/js dependencies: espree, eslint-scope, eslint-visitor-keys.
  • Updated the following naming convention to ignore import attribute keys in both static and dynamic imports: camelcase, id-denylist, id-length, id-match.
  • Added tests for no-underscore-dangle to verify that it ignores import attribute keys (this rule actually ignores object properties except methods).
  • Added tests for astUtils.needsPrecedingSemicolon (since there are no unit tests, I added tests for the no-array-constructor rule) to verify it returns false for nodes after import/export declarations with attributes.
  • Added tests for prefer-regex-literals and prefer-named-capture-group rules to verify behavior with regex pattern modifiers.

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

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Oct 29, 2024
@github-actions github-actions bot added the rule Relates to ESLint's core rules label Oct 29, 2024
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 474a29c
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/67234c38fddb0000089f8b5e

@mdjermanovic mdjermanovic added new syntax This issue is related to new syntax that has reached stage 4 accepted There is consensus among the team that this change meets the criteria for inclusion and removed rule Relates to ESLint's core rules labels Oct 29, 2024
@github-actions github-actions bot added the rule Relates to ESLint's core rules label Oct 29, 2024
This was referenced Oct 29, 2024
@mdjermanovic mdjermanovic marked this pull request as ready for review October 29, 2024 21:15
@mdjermanovic mdjermanovic requested a review from a team as a code owner October 29, 2024 21:15
@mdjermanovic
Copy link
Member Author

Browser test is now constantly failing in CI:

 "concise" Reporter:
========= Your concise report ==========
undefined
❌ Failed to setup tests, no tests found

It works for me locally.

@christian-bromann any ideas what might be causing this?

@christian-bromann
Copy link
Contributor

christian-bromann commented Oct 30, 2024

any ideas what might be causing this?

Yes, we unfortunately pushed a buggy version. I triggered a new release which is available on NPM (v9.2.7) which should have a fix for this.

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.

Overall LGTM. Just one spot for a bit of refactoring.

(parent.key === node || parent.value === node && parent.shorthand && !parent.method) &&
parent.parent.type === "ObjectExpression"
) {
const objectExpression = parent.parent;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you're only using this to get objectExpression.parent below. Maybe we could simplify by setting this to:

Suggested change
const objectExpression = parent.parent;
const objectExpressionParent = parent.parent.parent;

And then just using objectExpressionParent below?

Copy link
Member Author

Choose a reason for hiding this comment

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

objectExpression is used here, on the right side:

objectExpression.parent.options === objectExpression

Copy link
Member

Choose a reason for hiding this comment

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

Ah good call. There's still five references to objectExpression.parent, though, so I'd still like to see us eliminate unnecessary prototype lookups for the number of times this will be called.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 474a29c

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. Giving another day so others have a chance to review.

@mdjermanovic mdjermanovic merged commit 3fa009f into main Nov 1, 2024
26 checks passed
@mdjermanovic mdjermanovic deleted the import-attributes-regexp-modifiers branch November 1, 2024 17:50
@allstarschh allstarschh mentioned this pull request Jan 28, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Support RegExp Modifiers Support Import Attributes
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy