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: no-empty-character-class support v flag #17419

Merged
merged 1 commit into from Jul 27, 2023
Merged

Conversation

mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Jul 26, 2023

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)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Refs #17223

Updates no-empty-character-class to report nested empty character classes.

What changes did you make? (Give an overview)

Before this change, this rule was reporting some but not all empty nested character classes, depending on how its own parsing happened to work with the new syntax. Since the syntax becomes too complicated for analyzing patterns with a regex, I switched the rule to use regexpp. For performance reasons, I also added a quick search for [] to exit early and avoid parsing.

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

Does reporting nested character classes makes sense for this rule? I don't think there's a case where an empty nested character class can be useful.

Note: Allowing empty [^] is existing behavior, it was just undocumented and untested.

Reports nested character classes

Refs #17223
@mdjermanovic mdjermanovic added rule Relates to ESLint's core rules 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 labels Jul 26, 2023
@mdjermanovic mdjermanovic requested a review from a team as a code owner July 26, 2023 09:52
@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 57e0a7a
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64c0ecd70cf7110008dc7b34
😎 Deploy Preview https://deploy-preview-17419--docs-eslint.netlify.app/rules/no-empty-character-class
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdjermanovic mdjermanovic mentioned this pull request Jul 26, 2023
19 tasks
Copy link
Contributor

@snitin315 snitin315 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! Will leave it open for others to review

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. And yes, I think it makes sense for this rule to check for nested empty character classes.

@nzakas nzakas merged commit ee68d1d into main Jul 27, 2023
22 checks passed
@nzakas nzakas deleted the vflag-noemptycharacterclass branch July 27, 2023 17:17
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 24, 2024
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion 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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants