-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
feat(biome_css_analyzer): noUnknownSelectorPseudoElement #2655
feat(biome_css_analyzer): noUnknownSelectorPseudoElement #2655
Conversation
CodSpeed Performance ReportMerging #2655 will not alter performanceComparing Summary
|
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.
Thank you!
"backdrop", | ||
"content", | ||
"cue", | ||
"file-selector-button", | ||
"grammar-error", | ||
"highlight", | ||
"marker", | ||
"placeholder", | ||
"selection", | ||
"shadow", | ||
"slotted", | ||
"spelling-error", | ||
"target-text", | ||
"view-transition", | ||
"view-transition-group", | ||
"view-transition-image-pair", | ||
"view-transition-new", | ||
"view-transition-old", |
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.
These values should be defined in keyword.rs
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.
Thank you!
I defined it in keyword.rs
with the following commit.
a9b4e0d
a::PSEUDO { } | ||
a::element { } | ||
a:hover::element { } | ||
a,\nb > .foo::error { } |
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.
a,\nb > .foo::error { } | |
a, | |
b > .foo::error { } |
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 addressed it in the following commit.
48b651f
pub fn vender_prefix(prop: &str) -> String { | ||
let re = Regex::new(r"^(-\w+-)").unwrap(); | ||
let vendor_prefix = re | ||
.captures(prop) | ||
.map(|caps| caps[0].to_string()) | ||
.unwrap_or_default(); | ||
|
||
vendor_prefix | ||
} |
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 think we don't need Regex
since the case is really simple and `Re crate is expensive. We can just define the prefixes in an ordered array, and check against them using the binary search.
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.
Indeed, it seems like it can be implemented without using Regex. Thank you!
The -moz-test
in the test case also needs to be extracted as a vendor prefix. Since I understand that binary_search
cannot perform partial matches, I replaced it with starts_with
for the correction.
b0892bd
@togami2864 |
|
||
// Returns the vendor prefix extracted from an input string. | ||
pub fn vender_prefix(prop: &str) -> String { | ||
let prefixes = ["-webkit-", "-moz-", "-ms-", "-o-"]; |
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.
These prefixes should move to keyword.rs
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.
Oops, I'm sorry.
I fixed it with the following commit.
808cc37
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.
Awesome work!
Summary
close #2624
Implement selector-pseudo-element-no-unknown
Please note that the following is not yet addressed:
sass
andless
Test Plan
added tests and snapshots