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
Rule Change: Suggestions for require-unicode-regexp
#15089
Comments
This seems very dangerous, unless it only does the autofix when the |
I didn’t take in the fact that this flag has side effects when I was writing this issue, but yes, as long as adding the |
This is doable, but seems very complicated. Pattern should not contain anything that matches surrogate code units. That includes The Also, some patterns would have completely different semantics with the |
So, for the fact that it disables Annex B extensions, that should mean that we have to check the regular expression and make sure it isn't something like |
This seems like a risky thing to autofix. Maybe a suggestion would be better? |
require-unicode-regexp
require-unicode-regexp
@eslint/eslint-tsc do we want to make a change here? |
I’m 👍 to suggestion instead of fix. |
Ideally, the rule would autofix regular expressions that will have the same behavior with the If we're not confident that we can determine whether or not the behavior will change, then providing suggestions in both cases might be safer. However, I think that the suggestion message (or the error message itself) should state whether the behavior will change. Otherwise, user may just apply it without thinking about if there's anything that should be additionally changed in the pattern or in the way the regex is used. But, that brings basically the same question as with the autofix - can we reliably know if the behavior will change when the |
I think this is asking too much. The point of suggestions is to provide potential fixes that might change behavior, but I think it’s beyond our scope to indicate how behavior might change. At some point we need to trust that developers have tests that will help them identify runtime errors. |
In that case, the suggestion message would always warn that the suggested fix may change behavior? |
Isn’t that implied? |
No. This is always implied with suggestions. If they didn’t change behavior, then they would be an autofix. The implication of suggestions is that it might change behavior and you should only apply it if you’re sure of what you’re doing. There isn’t any need to add this into every suggestion. |
It isn't implied. Suggestion can retain the same behavior, but it isn't autofix when it doesn't seem that the behavior was intended. In core rules, we have 3 suggestions that don't change behavior: eslint/lib/rules/no-unsafe-negation.js Lines 79 to 80 in 60f6a06
eslint/lib/rules/no-nonoctal-decimal-escape.js Lines 46 to 47 in 60f6a06
eslint/lib/rules/no-useless-escape.js Lines 96 to 97 in 60f6a06
|
Sorry, I’m not quite sure what you’re arguing here. Suggestions don’t need to change behavior, we just know that they might. This is from our website (https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions):
My overall point is that many suggestions change behavior. We can’t start adding this message into one suggestion because then it implies all other suggestions without that message won’t change behavior, which is clearly wrong. So then we would have to update all suggestions to clearly state whether they might change behavior, which we could do for core rules but not for plugin rules. I’d prefer we just not put it in the message and just make sure our documentation about what suggestions are is accurate. |
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
Since we have accepted the same change in the |
Sounds good. |
What rule do you want to change?
require-unicode-regexp
What change to do you want to make?
Implement suggestions
How do you think the change should be implemented?
A new default behavior
Example code
/abc/
What does the rule currently do for this code?
Reports error
What will the rule do after it's changed?
Give user suggestion prompt to convert into:
/abc/u
Participation
Additional comments
N/A
The text was updated successfully, but these errors were encountered: