From 7b3e87a5aaefbe0e7f0fb74812f128a0722151e8 Mon Sep 17 00:00:00 2001 From: isnakode Date: Sat, 20 Apr 2024 13:50:11 +0800 Subject: [PATCH] test: add more test cases --- .../biome_configuration/src/linter/rules.rs | 4 +- .../invalid.css | 10 ++- .../invalid.css.snap | 82 ++++++++++++++++++- .../valid.css | 4 +- .../valid.css.snap | 4 +- .../@biomejs/backend-jsonrpc/src/workspace.ts | 2 +- .../@biomejs/biome/configuration_schema.json | 2 +- 7 files changed, 97 insertions(+), 11 deletions(-) diff --git a/crates/biome_configuration/src/linter/rules.rs b/crates/biome_configuration/src/linter/rules.rs index 01b36bf50bdf..bf0ce4e26aea 100644 --- a/crates/biome_configuration/src/linter/rules.rs +++ b/crates/biome_configuration/src/linter/rules.rs @@ -2671,7 +2671,7 @@ pub struct Nursery { #[doc = "Disallow two keys with the same name inside a JSON object."] #[serde(skip_serializing_if = "Option::is_none")] pub no_duplicate_json_keys: Option>, - #[doc = "Succinct description of the rule."] + #[doc = "Disallow duplicate selectors within keyframe blocks."] #[serde(skip_serializing_if = "Option::is_none")] pub no_duplicate_selectors_keyframe_block: Option>, @@ -2745,6 +2745,7 @@ impl Nursery { "noDuplicateElseIf", "noDuplicateFontNames", "noDuplicateJsonKeys", + "noDuplicateSelectorsKeyframeBlock", "noEvolvingAny", "noFlatMapIdentity", ]; @@ -2754,6 +2755,7 @@ impl Nursery { RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7]), + RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[8]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10]), ]; diff --git a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css index 0bff9d28dbaf..e0129b4dae15 100644 --- a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css +++ b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css @@ -2,4 +2,12 @@ @keyframes foo { from {} FROM {}} -@keyframes foo { 0% {} 0% {}} \ No newline at end of file +@keyframes foo { 0% {} 0% {}} + +@keyframes foo { from {} to {} to {} } + +@keyframes foo { 0% {} 0% {} 100% {} } + +@-webkit-keyframes foo { 0% {} 0% {} 100% {} } + +@-moz-keyframes foo { 0% {} 0% {} 100% {} } \ No newline at end of file diff --git a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css.snap b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css.snap index 0c114b169089..b3ea2083dd9e 100644 --- a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css.snap +++ b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/invalid.css.snap @@ -9,6 +9,14 @@ expression: invalid.css @keyframes foo { from {} FROM {}} @keyframes foo { 0% {} 0% {}} + +@keyframes foo { from {} to {} to {} } + +@keyframes foo { 0% {} 0% {} 100% {} } + +@-webkit-keyframes foo { 0% {} 0% {} 100% {} } + +@-moz-keyframes foo { 0% {} 0% {} 100% {} } ``` # Diagnostics @@ -22,7 +30,7 @@ invalid.css:1:26 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━ 2 │ 3 │ @keyframes foo { from {} FROM {}} - i Consider using different selector here! + i Consider using a different percentage value or keyword to avoid duplication ``` @@ -39,7 +47,7 @@ invalid.css:3:26 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━ 4 │ 5 │ @keyframes foo { 0% {} 0% {}} - i Consider using different selector here! + i Consider using a different percentage value or keyword to avoid duplication ``` @@ -53,8 +61,76 @@ invalid.css:5:24 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━ 4 │ > 5 │ @keyframes foo { 0% {} 0% {}} │ ^^ + 6 │ + 7 │ @keyframes foo { from {} to {} to {} } + + i Consider using a different percentage value or keyword to avoid duplication + + +``` + +``` +invalid.css:7:32 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Unexpected duplicate selector: to + + 5 │ @keyframes foo { 0% {} 0% {}} + 6 │ + > 7 │ @keyframes foo { from {} to {} to {} } + │ ^^ + 8 │ + 9 │ @keyframes foo { 0% {} 0% {} 100% {} } + + i Consider using a different percentage value or keyword to avoid duplication + + +``` + +``` +invalid.css:9:24 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Unexpected duplicate selector: 0% + + 7 │ @keyframes foo { from {} to {} to {} } + 8 │ + > 9 │ @keyframes foo { 0% {} 0% {} 100% {} } + │ ^^ + 10 │ + 11 │ @-webkit-keyframes foo { 0% {} 0% {} 100% {} } + + i Consider using a different percentage value or keyword to avoid duplication + + +``` + +``` +invalid.css:11:32 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Unexpected duplicate selector: 0% + + 9 │ @keyframes foo { 0% {} 0% {} 100% {} } + 10 │ + > 11 │ @-webkit-keyframes foo { 0% {} 0% {} 100% {} } + │ ^^ + 12 │ + 13 │ @-moz-keyframes foo { 0% {} 0% {} 100% {} } + + i Consider using a different percentage value or keyword to avoid duplication + + +``` + +``` +invalid.css:13:29 lint/nursery/noDuplicateSelectorsKeyframeBlock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Unexpected duplicate selector: 0% + + 11 │ @-webkit-keyframes foo { 0% {} 0% {} 100% {} } + 12 │ + > 13 │ @-moz-keyframes foo { 0% {} 0% {} 100% {} } + │ ^^ - i Consider using different selector here! + i Consider using a different percentage value or keyword to avoid duplication ``` diff --git a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css index 3bee56441a9a..2738fb8ee135 100644 --- a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css +++ b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css @@ -1,3 +1,3 @@ -@keyframes foo { from {} to {}} +@keyframes foo { from {} to {} } -@keyframes foo { 0% {} 100% {}} \ No newline at end of file +@keyframes foo { 0% {} 100% {} } \ No newline at end of file diff --git a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css.snap b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css.snap index 6758ac4cd89d..23106e800bbf 100644 --- a/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css.snap +++ b/crates/biome_css_analyze/tests/specs/nursery/noDuplicateSelectorsKeyframeBlock/valid.css.snap @@ -4,7 +4,7 @@ expression: valid.css --- # Input ```css -@keyframes foo { from {} to {}} +@keyframes foo { from {} to {} } -@keyframes foo { 0% {} 100% {}} +@keyframes foo { 0% {} 100% {} } ``` diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index ce7f7885fe0a..00e25c38cb25 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -941,7 +941,7 @@ export interface Nursery { */ noDuplicateJsonKeys?: RuleConfiguration_for_Null; /** - * Succinct description of the rule. + * Disallow duplicate selectors within keyframe blocks. */ noDuplicateSelectorsKeyframeBlock?: RuleConfiguration_for_Null; /** diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index 5387ceddf91e..8179aed4c82a 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -1490,7 +1490,7 @@ ] }, "noDuplicateSelectorsKeyframeBlock": { - "description": "Succinct description of the rule.", + "description": "Disallow duplicate selectors within keyframe blocks.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" }