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 detect-unsafe-regex rule #285

Closed
wants to merge 1 commit into from

Conversation

bdougherty
Copy link

@bdougherty bdougherty commented Jan 19, 2018

Decided to go with just a warning for the unoptimized regex plugin since that is the example on the repo. I'll change it if you think it should be an error instead.

@bdougherty
Copy link
Author

Hmm didn't realize the optimize regex plugin requires node >= 6. Let me know if you are ok with bumping the xo requirement or if I should remove that plugin.

@pvdlg
Copy link
Contributor

pvdlg commented Jan 20, 2018

Maybe we can use eslint-plugin-security#detect-unsafe-regex instead of no-unsafe-regex/no-unsafe-regex as the eslint-plugin-security seems better maintained and contains other rules we might want to enable.

Regarding the optimize regex, I'm not sure 1 rule would justify to drop node 4 support (at least while node 4 is still in LTS support).

@sindresorhus
Copy link
Member

We can not drop Node.js 4 support yet.

@bdougherty bdougherty force-pushed the regex-plugins branch 2 times, most recently from ecf10db to f80bccc Compare January 20, 2018 22:06
@bdougherty
Copy link
Author

Updated to use eslint-plugin-security#detect-unsafe-regex.

Found another discussion about that plugin in #205 where you weren't sure about adding the full plugin for just the one rule. Happy to add an unsafe regex rule to eslint-plugin-unicorn if that would be preferable.

@bdougherty bdougherty changed the title Add regex plugins Add detect-unsafe-regex rule Jan 20, 2018
@sindresorhus
Copy link
Member

Happy to add an unsafe regex rule to eslint-plugin-unicorn if that would be preferable.

Yeah, that would be preferable, seeing how it's only a few lines of glue code to the safe-regex module, and that the eslint-plugin-security plugin doesn't seem very actively maintained. I think it would also be a good rule to use Selectors: https://eslint.org/docs/developer-guide/selectors You can just copy-paste this rule and do your changes: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/rules/regex-shorthand.js :)

@bdougherty
Copy link
Author

@bdougherty bdougherty closed this Jan 20, 2018
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.

None yet

3 participants