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

Add regexp/no-extra-lookaround-assertions rule #482

Merged
merged 8 commits into from Nov 21, 2022

Conversation

ota-meshi
Copy link
Owner

close #481

@fisker
Copy link

fisker commented Nov 20, 2022

How about regexp/no-useless-assertions?

@ota-meshi
Copy link
Owner Author

The description of no-useless-assertions says:

Some assertion are unnecessary because the rest of the pattern forces them to always be accept (or reject).

The new rule don't report always accept/reject patterns, so I think the rules have different goals.

lib/rules/no-useless-lookaround-assertions.ts Outdated Show resolved Hide resolved
lib/rules/no-useless-lookaround-assertions.ts Outdated Show resolved Hide resolved
lib/rules/no-useless-lookaround-assertions.ts Outdated Show resolved Hide resolved
@ota-meshi
Copy link
Owner Author

@RunDevelopment Thank you for the your review!
I made changes to this PR. Could you please check again?

@RunDevelopment
Copy link
Collaborator

Thank you @ota-meshi.

I think the rule is implemented correctly, but I think the name/message might be a little confusing. The name "no useless lookaround assertions" and the message "This assertion is useless." might make it seem like reported assertions can be removed. E.g. (?=foo(?=bar)) -> (?=foo). Obviously, this is not what we mean, but I worry that some users might understand that way.

Maybe we could change the message to something like "This assertion is useless and can be inlined" or "This assertion is useless and can be converted into a group"? If we go with those messages, then we should probably also update the docs to use this language too. What do you think?

@ota-meshi
Copy link
Owner Author

ota-meshi commented Nov 21, 2022

I think the message you suggested is good! I will change it to use that message.

Do you have other good ideas for rule name?
What do you think about naming it no-extra-lookaround-assertions, in reference to no-extra-parens?
https://eslint.org/docs/latest/rules/no-extra-parens

@RunDevelopment
Copy link
Collaborator

What do you think about naming it no-extra-lookaround-assertions, in reference to no-extra-parens?

That is a really good idea! Let's go with that.

@ota-meshi ota-meshi changed the title Add regexp/no-useless-lookaround-assertions rule Add regexp/no-extra-lookaround-assertions rule Nov 21, 2022
@ota-meshi
Copy link
Owner Author

I have changed this PR. Could you please check again?

Copy link
Collaborator

@RunDevelopment RunDevelopment left a comment

Choose a reason for hiding this comment

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

Thank you @ota-meshi!

@RunDevelopment RunDevelopment merged commit af2209e into master Nov 21, 2022
@RunDevelopment RunDevelopment deleted the regexp/no-useless-lookaround-assertions branch November 21, 2022 23:32
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.

New rule: no-useless-lookaround-assertions
3 participants