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

feat(biome_css_analyzer): implement noUnknownMediaFeatureName #2751

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 49 additions & 30 deletions crates/biome_configuration/src/linter/rules.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 74 additions & 4 deletions crates/biome_css_analyze/src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ pub const OTHER_PSEUDO_ELEMENTS: [&str; 18] = [
"view-transition-old",
];

pub const VENDER_PREFIXES: [&str; 4] = ["-webkit-", "-moz-", "-ms-", "-o-"];
pub const VENDOR_PREFIXES: [&str; 4] = ["-webkit-", "-moz-", "-ms-", "-o-"];

// https://github.com/known-css/known-css-properties/blob/master/source/w3c.json
pub const KNOWN_PROPERTIES: [&str; 588] = [
Expand Down Expand Up @@ -3826,7 +3826,7 @@ pub const KNOWN_SAFARI_PROPERTIES: [&str; 644] = [
];

// https://github.com/known-css/known-css-properties/blob/master/source/browsers/samsung_internet-23.0.json
pub const KNOWN_SUMSUNG_INTERNET_PROPERTIES: [&str; 608] = [
pub const KNOWN_SAMSUNG_INTERNET_PROPERTIES: [&str; 608] = [
"-webkit-align-content",
"-webkit-align-items",
"-webkit-align-self",
Expand Down Expand Up @@ -4958,14 +4958,77 @@ pub const KNOWN_US_BROWSER_PROPERTIES: [&str; 517] = [
"zoom",
];

pub const MEDIA_FEATURE_NAMES: [&str; 60] = [
"any-hover",
"any-pointer",
"aspect-ratio",
"color",
"color-gamut",
"color-index",
"device-aspect-ratio",
"device-height",
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
"device-posture",
"device-width",
"display-mode",
"dynamic-range",
"environment-blending",
"forced-colors",
"grid",
"height",
"horizontal-viewport-segments",
"hover",
"inverted-colors",
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
"light-level",
"max-aspect-ratio",
"max-color",
"max-color-index",
"max-device-aspect-ratio",
"max-device-height",
"max-device-width",
"max-height",
"max-monochrome",
"max-resolution",
"max-width",
"min-aspect-ratio",
"min-color",
"min-color-index",
"min-device-aspect-ratio",
"min-device-height",
"min-device-width",
"min-height",
"min-monochrome",
"min-resolution",
"min-width",
"monochrome",
"nav-controls",
"orientation",
"overflow-block",
"overflow-inline",
"pointer",
"prefers-color-scheme",
"prefers-contrast",
"prefers-reduced-data",
"prefers-reduced-motion",
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
"prefers-reduded-transparency",
"resolution",
"scan",
"screen-spanning",
"scripting",
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
"update",
"vertical-viewport-segments",
"video-color-gamut",
"video-dynamic-range",
Kazuhiro-Mimaki marked this conversation as resolved.
Show resolved Hide resolved
"width",
];

#[cfg(test)]
mod tests {
use std::collections::HashSet;

use super::{
FUNCTION_KEYWORDS, KNOWN_EDGE_PROPERTIES, KNOWN_EXPLORER_PROPERTIES,
KNOWN_FIREFOX_PROPERTIES, KNOWN_PROPERTIES, KNOWN_SAFARI_PROPERTIES,
KNOWN_SUMSUNG_INTERNET_PROPERTIES, KNOWN_US_BROWSER_PROPERTIES,
KNOWN_SAMSUNG_INTERNET_PROPERTIES, KNOWN_US_BROWSER_PROPERTIES, MEDIA_FEATURE_NAMES,
};

#[test]
Expand Down Expand Up @@ -5019,7 +5082,7 @@ mod tests {

#[test]
fn test_kown_sumsung_internet_properties_order() {
for items in KNOWN_SUMSUNG_INTERNET_PROPERTIES.windows(2) {
for items in KNOWN_SAMSUNG_INTERNET_PROPERTIES.windows(2) {
assert!(items[0] < items[1], "{} < {}", items[0], items[1]);
}
}
Expand All @@ -5030,4 +5093,11 @@ mod tests {
assert!(items[0] < items[1], "{} < {}", items[0], items[1]);
}
}

#[test]
fn test_media_feature_names_order() {
for items in MEDIA_FEATURE_NAMES.windows(2) {
assert!(items[0] < items[1], "{} < {}", items[0], items[1]);
}
}
}
2 changes: 2 additions & 0 deletions crates/biome_css_analyze/src/lint/nursery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod no_duplicate_selectors_keyframe_block;
pub mod no_important_in_keyframe;
pub mod no_invalid_position_at_import_rule;
pub mod no_unknown_function;
pub mod no_unknown_media_feature_name;
pub mod no_unknown_property;
pub mod no_unknown_selector_pseudo_element;
pub mod no_unknown_unit;
Expand All @@ -28,6 +29,7 @@ declare_group! {
self :: no_important_in_keyframe :: NoImportantInKeyframe ,
self :: no_invalid_position_at_import_rule :: NoInvalidPositionAtImportRule ,
self :: no_unknown_function :: NoUnknownFunction ,
self :: no_unknown_media_feature_name :: NoUnknownMediaFeatureName ,
self :: no_unknown_property :: NoUnknownProperty ,
self :: no_unknown_selector_pseudo_element :: NoUnknownSelectorPseudoElement ,
self :: no_unknown_unit :: NoUnknownUnit ,
Expand Down
Loading