Skip to content
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

Merged
merged 9 commits into from
Oct 8, 2024

Conversation

fireairforce
Copy link
Member

Summary

closes: #4059

Test Plan

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Sep 27, 2024
Copy link

codspeed-hq bot commented Sep 27, 2024

CodSpeed Performance Report

Merging #4107 will not alter performance

Comparing fireairforce:fix-4059 (ecd4cd1) with main (d7cc01f)

Summary

✅ 105 untouched benchmarks

@@ -401,3 +415,7 @@ impl Rule for NoUselessFragments {
}))
}
}

fn contains_html_entity(s: &str) -> bool {
s.contains('&') && s.contains(';')
Copy link
Member

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

Copy link
Member Author

@fireairforce fireairforce Sep 27, 2024

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated~

@ematipico
Copy link
Member

I need to review some code, waiting to merge

@ematipico
Copy link
Member

@fireairforce I added a comment to explain the allocation of a new string and the trimming in 02824b1 (#4107)

@ematipico ematipico merged commit f8d9173 into biomejs:main Oct 8, 2024
2 checks passed
@fireairforce
Copy link
Member Author

thank u~learn from this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 lint/complexity/noUselessFragments recommends removing useful fragments
3 participants