-
Notifications
You must be signed in to change notification settings - Fork 11
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 rules that "eslint-plugin-clean-regex" has #91
Comments
Note: I just found a bug in |
Regarding |
I think we possible to mark no-useless-exactly-quantifier as deprecated and add new rule 😉 |
Regarding
A hybrid approach using the current implementations of Also want to talk about prefixes. If it's ok with you @ota-meshi, then I'll bring over |
I think this idea is good!
Since
I think so, too. As far as I know, I haven't verified the |
I ran the rule on Prism's 2k regexes this is the result:
And then there's
Since That being said, I don't think that this is a huge problem. Prism has literally thousands of complex regexes, the average code base will not see a noticeable performance impact. ESLint also provides options to cache results and to only run on changed files. We should also consider that I agree that users must have the option to turn off advanced analysis if performance was a problem. But we shouldn't hide some of our best features by default.
Implement Don't get me wrong, the |
Regarding There are legitimate use cases for capturing groups that only match a single string so I don't want to just disallow them. |
@RunDevelopment The Do you think we can merge the features of the |
I'm not sure about The problem is that the rule can also add useless escaping (i.e. you can configure it to escape all The reason I added Maybe we could use the fact that Unicode parsing mode basically has the rules for escaping that I want? We could add a new rule With (It even gets rid of the overly complex rule option of |
The Maybe we can use |
That's where I got the idea for the name from :) |
With Thank you very much for your help @ota-meshi! |
Check each rule that eslint-plugin-clean-regex has, add the missing rule, and if eslint-plugin-regexp already has a similar rule, check for missing validation is needed.
Also, if we keep a note of the rule correspondence, it may be a document when creating a migration tool.
If we want to discuss one rule, we can also open a new issue.
Problems
regexp/confusing-quantifier
rule #93 Add new ruleregexp/confusing-quantifier
.no-dupe-disjunctions
#179.regexp/no-empty-alternative
rule #95 Add new ruleregexp/no-empty-alternative
.no-useless-backreference
: Made compatible withclean-regex/no-empty-backreference
#111 makesno-useless-backreference
functionally equivalent toclean-regex/no-empty-backreference
.regexp/no-empty-lookarounds-assertion
, but it doesn't catch potential empty assertions.regexp/no-empty-lookarounds-assertion
needs to be changed. (no-empty-lookarounds-assertion
: Better detection #113)regexp/no-lazy-ends
rule #96 Add new ruleregexp/no-lazy-ends
.regexp/no-obscure-range
rule #122 adds this rule.regexp/no-octal
, but with some differences. We probably need to add options.no-octal
to report more octal escapes #108 makesregexp/no-octal
even stricter thanclean-regex/no-octal-escape
.regexp/no-optional-assertion
rule #135 Add new ruleregexp/no-optional-assertion
.regexp/no-potentially-useless-backreference
rule #136 Add new ruleregexp/no-potentially-useless-backreference
.regexp/no-useless-assertions
rule #137 Add new ruleregexp/no-useless-assertions
.Can check with theregexp/no-useless-exactly-quantifier
rule.regexp/no-useless-exactly-quantifier
rule #199 & Addno-zero-quantifier
rule #200regexp/optimal-lookaround-quantifier
rule #97 Add new ruleregexp/optimal-lookaround-quantifier
.Suggestions
match-any
false negatives and improved fixer #103 handles some of it but we still need to add some options.regexp/strict
rule #220regexp/strict
rule insteadno-assertion-capturing-group
#188 brings over half of the rule.regexp/no-trivially-nested-assertion
rule #120 adds this rule.no-trivially-nested-quantifier
rule #146 adds this rule.regexp/no-useless-character-class
.regexp/no-useless-flag
rule #139 Add new ruleregexp/no-useless-flag
.no-useless-non-capturing-group
rule #154 adds most of the functionality ofclean-regex/no-unnecessary-group
but it doesn't handle empty groups.no-useless-non-greedy
rule #143no-useless-quantifier
rule #197 adds this rule.optimal-quantifier-concatenation
rule #207.no-dupe-characters-character-class
after Updateno-dupe-characters-character-class
#191.no-useless-range
andprefer-range
.prefer-character-class
rule #158 updatesregexp/prefer-character-class
.prefer-predefined-assertion
rule #171 adds this rule.regexp/prefer-w
andregexp/prefer-d
.regexp/prefer-question-quantifier
,regexp/prefer-star-quantifier
, andregexp/prefer-plus-quantifier
.no-useless-two-nums-quantifier
fixable #109 makesno-useless-two-nums-quantifier
functionally equivalent toclean-regex/simple-constant-quantifier
.regexp/sort-flags
rule #164 Add new ruleregexp/sort-flags
.The text was updated successfully, but these errors were encountered: