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 eslint-plugin-regexp #141
Comments
I think it could be nice addition giving how many RegExps we use. However, we should be careful. I think there could be false positives. For example:
Seems to me syntax is correct and it's impossible in this use case not have capturing group. |
Hi @hudochenkov. - const safeParserExtensionsTest = /\.(css|pcss|postcss)$/i;
+ const safeParserExtensionsTest = /\.(?:css|pcss|postcss)$/i; |
@hudochenkov @ota-meshi Thanks for the feedback! As @ota-meshi suggests, it seems safe to me to add By the way, we'd like to avoid false positives as possible, so are there any rules that should be disabled in the |
@ota-meshi today I learned! Didn't know about non-capturing group :) After some googling I see the difference. Personally, I think capturing group are more understandable by developers and make code easier to read. |
Regarding the rule that verifies only regex, I think that there are almost no false positives because it is also used in Prism, which makes heavy use of regex. (The maintainer who is not me is also the maintainer of Prism.) Looking at this report, I noticed that there was a false positive for I think the
We can turn the rule OFF or ON depending on our preference 😉. (I found out that lot of mistakes in the regex I wrote, so I started creating |
@ota-meshi Thank you so much for the detailed explanation! 👏🏼 My opinions:
|
I've created stylelint/stylelint#5516 as an experiment. Please check it out. 😃 |
SGTM. It found 49 problems in the stylelint code. It can autofix 34 of them, which is nice. It'll be interesting to see if it caught stylelint/stylelint#5128, which is one of our |
This change is created by: - the `npm i eslint-plugin-regexp` command - a few additions to the `.eslintrc.js` file. Close #141
Hi there, thank you for providing feedback! I've created PR #142. |
I'd like to reduce bugs related to a regex and make it safer to write a regex.
I suggest adding the
eslint-plugin-regexp
plugin which is a work by @ota-meshi (a member of our team).The plugin is for "finding RegExp mistakes and RegExp style guide violations."
Demo
I tried the plugin on the
v14
branch of the stylelint/stylelint repository. (HEAD:c1713eac
)npm i -D eslint-plugin-regexp
"plugin:regexp/recommended"
toeslintConfig.extends
inpackage.json
npm run lint:js -- -f codeframe
Result:
Summary:
See also stylelint/stylelint#5516
Resources
The text was updated successfully, but these errors were encountered: