-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
no-regex-spaces
: Add RegExp object form
#3586
Comments
This rule is only designed to test regex literals. It's really hard to do anything for the constructor since you can pass non-literals or expressions. |
Wouldn't it at least be possible to check for spaces in literals within the constructor? Failing that, I think the docs could be clarified that it is a known limitation of the rule, rather than by-design. |
I'm not against adding it, just pointing out that this rule only checked literals by design. It's not a bug. It was intended to map to what JSLint and JSHint do, which only check literals. We can also check strings.
I have no idea what this means. :) |
From the rule docs:
In most of the docs, the "not warnings" section is used to show how to "fix" the code so that the rule will no longer flag. So, what I'm proposing is:
|
"Not warnings" are definitely not "fixes", they are designed to show patterns that won't be flagged either because they are correct or they are not covered by the rule. They are provided to avoid confusion of people saying, "should this be flagged?" |
@IanVS are you still interested in implementing this? |
Yeah, this dropped off my radar. I'll submit a docs PR within the next day or two. |
@IanVS, I'd also like to have this functionality. If you'd like, I could implement it as an enhancement to the rule. I'm not entirely convinced the best option is always to convert a
|
@jacksonrayhamilton Sorry, I guess I'm not exactly sure what enhancement you're proposing. Are you saying you want to teach |
Yep! |
Cool, I'd be all for that, and @nzakas has said
So I'd say go for it. :) |
The docs for this rule specifically call out that the following will not be considered a warning:
This seems to be a limitation, as it is not asserted in the tests, and intuitively it seems that the RegExp object format should be treated the same way as a literal, multiple spaces are equally hard to read in both.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: