-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
fix(noMisleadingCharacterClass): properly handle escaping and improve diagnostics #4112
fix(noMisleadingCharacterClass): properly handle escaping and improve diagnostics #4112
Conversation
CodSpeed Performance ReportMerging #4112 will not alter performanceComparing Summary
|
pub const fn at(offset: TextSize, len: TextSize) -> TextRange { | ||
TextRange { | ||
start: offset, | ||
end: TextSize { | ||
raw: offset.raw + len.raw, | ||
}, | ||
} | ||
} |
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.
What's the reason for this change? I think I didn't see anything mentioned in the description
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.
This is not required anymore. I kept it because this makes all constructors const fn
. This seems more consistent with the API of TextRange
because there are already many methods that are const fn
.
Co-authored-by: Emanuele Stoppa <[email protected]>
… diagnostics (biomejs#4112) Co-authored-by: Emanuele Stoppa <[email protected]>
Summary
This PR fixes erroneous handling of escape sequence.
This was a hard fix/refactor because Unicode escape sequence is hard to handle in both regex strings and regex literals. I still think that we should remove support for string regexes in this rule and
noControlCharacterInRegex
. This brings a lot of complexity for a minor improvement in linting.Also, I fixed
noControlCharacterInRegex
: the rule no longer panics on incomplete Unicode escape sequences.I also improved the diagnostics message and refactored the code to allow reporting the precise range of the problematic characters.
To do that I had to compute codepoint on demand instead of “evaluating” the string.
This also avoids a string allocation.
I added missing combining characters: Mongolian Free Variation Selector and Variation Selectors Supplement.
There are more room for improvements. Notably, we could reduce the number of false positives by ensuring that a modifier/combining character actually modifies the preceding character.
Test Plan
I added tests and I updated the snapshots.