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-regex-spaces
support v
flag
#17407
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing with the v
flag is significantly different, so the assumption that unknown flags don't include v
could be problematic. For example, these patterns are parsable without the v
flag, but the consecutive spaces don't end up being in character classes and are therefore reported (and even autofixed in the first case):
/* eslint no-regex-spaces: "error" */
function createRegexes(additionalFlags = "") {
const flags = `${additionalFlags}v`;
return [
new RegExp("[[abc] ]", flags), // false positive, autofixed to "[[abc] {2}]"
new RegExp("[[abc]\\q{ }]", flags) // another false positive
]
}
I'm not sure if there is a good solution aside from ignoring RegExp constructor calls for which the flags cannot be determined.
Thank you for letting me know about that problem! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Would like @mdjermanovic to verify before merging.
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[X] Changes an existing rule (template)
What changes did you make? (Give an overview)
Refs #17223
This PR modifies the
no-regex-space
rule and adds support for regexpv
flag.Is there anything you'd like reviewers to focus on?