From 6e1170e37f67309918efdca8f93455ed0370a5cc Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Mon, 14 Oct 2024 14:48:46 +0800 Subject: [PATCH] fix(linter): noUnknownFunction support calc-size function (#4283) --- CHANGELOG.md | 10 ++++++++++ crates/biome_css_analyze/src/keywords.rs | 16 +++++++++++++++- .../correctness/noUnknownFunction/valid.css | 3 ++- .../correctness/noUnknownFunction/valid.css.snap | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1373f21642ec..bad7a4598a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -156,6 +156,16 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b Contributed by @Conaclos +- [noUnknownFunction](https://biomejs.dev/linter/rules/no-unknown-function/) correctly handles `calc-size` function ([#4212](https://github.com/biomejs/biome/issues/4212)). + + The following code `calc-size` is no longer reported as unknown: + + ```css + .a { height: calc-size(0px); } + ``` + + Contributed by @fireairforce + ### Parser #### Bug Fixes diff --git a/crates/biome_css_analyze/src/keywords.rs b/crates/biome_css_analyze/src/keywords.rs index 08c87bb74044..d98bc52db30f 100644 --- a/crates/biome_css_analyze/src/keywords.rs +++ b/crates/biome_css_analyze/src/keywords.rs @@ -85,7 +85,7 @@ pub const LINE_HEIGHT_KEYWORDS: [&str; 1] = ["normal"]; /// List of known CSS value functions sourced from [`css-functions-list`](https://www.npmjs.com/package/css-functions-list). /// See the original list [here](https://github.com/niksy/css-functions-list/blob/master/index.json). -pub const FUNCTION_KEYWORDS: [&str; 671] = [ +pub const FUNCTION_KEYWORDS: [&str; 685] = [ "-moz-abs", "-moz-acos", "-moz-anchor", @@ -98,6 +98,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-moz-blur", "-moz-brightness", "-moz-calc", + "-moz-calc-size", "-moz-character-variant", "-moz-circle", "-moz-clamp", @@ -190,6 +191,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-moz-scroll", "-moz-selector", "-moz-sepia", + "-moz-shape", "-moz-sign", "-moz-sin", "-moz-skew", @@ -233,6 +235,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-ms-blur", "-ms-brightness", "-ms-calc", + "-ms-calc-size", "-ms-character-variant", "-ms-circle", "-ms-clamp", @@ -264,6 +267,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-ms-hwb", "-ms-hypot", "-ms-image", + "-ms-image-rect", "-ms-image-set", "-ms-inset", "-ms-invert", @@ -324,6 +328,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-ms-scroll", "-ms-selector", "-ms-sepia", + "-ms-shape", "-ms-sign", "-ms-sin", "-ms-skew", @@ -367,6 +372,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-o-blur", "-o-brightness", "-o-calc", + "-o-calc-size", "-o-character-variant", "-o-circle", "-o-clamp", @@ -398,6 +404,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-o-hwb", "-o-hypot", "-o-image", + "-o-image-rect", "-o-image-set", "-o-inset", "-o-invert", @@ -458,6 +465,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-o-scroll", "-o-selector", "-o-sepia", + "-o-shape", "-o-sign", "-o-sin", "-o-skew", @@ -501,6 +509,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-webkit-blur", "-webkit-brightness", "-webkit-calc", + "-webkit-calc-size", "-webkit-character-variant", "-webkit-circle", "-webkit-clamp", @@ -532,6 +541,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-webkit-hwb", "-webkit-hypot", "-webkit-image", + "-webkit-image-rect", "-webkit-image-set", "-webkit-inset", "-webkit-invert", @@ -592,6 +602,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "-webkit-scroll", "-webkit-selector", "-webkit-sepia", + "-webkit-shape", "-webkit-sign", "-webkit-sin", "-webkit-skew", @@ -635,6 +646,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "blur", "brightness", "calc", + "calc-size", "character-variant", "circle", "clamp", @@ -666,6 +678,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "hwb", "hypot", "image", + "image-rect", "image-set", "inset", "invert", @@ -726,6 +739,7 @@ pub const FUNCTION_KEYWORDS: [&str; 671] = [ "scroll", "selector", "sepia", + "shape", "sign", "sin", "skew", diff --git a/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css b/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css index fbc8032c3864..48294b6f66fb 100644 --- a/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css +++ b/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css @@ -10,4 +10,5 @@ a { min-width: anchor-size(--button width); } a { transform: color.adjust(1px); transform: rgb(color.adjust(1px)); } a { color: light-dark(#777, #000); } a { offset-path: xywh(20px 30% 150% 200%); } -a { animation-timing-function: linear(0, 0.25, 1); } \ No newline at end of file +a { animation-timing-function: linear(0, 0.25, 1); } +a { height: calc-size(0px); } \ No newline at end of file diff --git a/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css.snap b/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css.snap index 56b98b74a22d..1133a3b93b10 100644 --- a/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css.snap +++ b/crates/biome_css_analyze/tests/specs/correctness/noUnknownFunction/valid.css.snap @@ -17,4 +17,5 @@ a { transform: color.adjust(1px); transform: rgb(color.adjust(1px)); } a { color: light-dark(#777, #000); } a { offset-path: xywh(20px 30% 150% 200%); } a { animation-timing-function: linear(0, 0.25, 1); } +a { height: calc-size(0px); } ```