-
-
Notifications
You must be signed in to change notification settings - Fork 533
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(linter): noUselessFragments deal html escapes under fragements wrong #4107
Conversation
CodSpeed Performance ReportMerging #4107 will not alter performanceComparing Summary
|
@@ -401,3 +415,7 @@ impl Rule for NoUselessFragments { | |||
})) | |||
} | |||
} | |||
|
|||
fn contains_html_entity(s: &str) -> bool { | |||
s.contains('&') && s.contains(';') |
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 can cause many false positives, for example <>something & and else;</>
. I would suggest to come up with a stronger solution to check HTML entities
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.
i refer the function from https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs#L520-L524, the case <>something & and else;</>
also need to preserve fragements or it will get an error from parser.
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.
It's still a stronger logic, because it checks their position too
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.
updated~
cb4a041
to
5dd0947
Compare
crates/biome_js_analyze/src/lint/complexity/no_useless_fragments.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/complexity/no_useless_fragments.rs
Outdated
Show resolved
Hide resolved
I need to review some code, waiting to merge |
@fireairforce I added a comment to explain the allocation of a new string and the trimming in |
thank u~learn from this |
Summary
closes: #4059
Test Plan