From 7eee13861a728ad900facff9fba08e13827e23fc Mon Sep 17 00:00:00 2001 From: togami2864 Date: Thu, 25 Apr 2024 20:27:34 +0900 Subject: [PATCH] feat: rename rule --- .../biome_configuration/src/linter/rules.rs | 49 +++++++++++-------- crates/biome_css_analyze/src/lint/nursery.rs | 4 +- ...y_keyword.rs => use_generic_font_names.rs} | 11 +++-- crates/biome_css_analyze/src/options.rs | 3 +- .../invalid.css | 0 .../invalid.css.snap | 14 +++--- .../valid.css | 0 .../valid.css.snap | 0 .../src/categories.rs | 1 + .../@biomejs/backend-jsonrpc/src/workspace.ts | 9 ++-- .../@biomejs/biome/configuration_schema.json | 14 +++--- 11 files changed, 58 insertions(+), 47 deletions(-) rename crates/biome_css_analyze/src/lint/nursery/{no_missing_generic_family_keyword.rs => use_generic_font_names.rs} (95%) rename crates/biome_css_analyze/tests/specs/nursery/{noMissingGenericFamilyKeyword => useGenericFontNames}/invalid.css (100%) rename crates/biome_css_analyze/tests/specs/nursery/{noMissingGenericFamilyKeyword => useGenericFontNames}/invalid.css.snap (73%) rename crates/biome_css_analyze/tests/specs/nursery/{noMissingGenericFamilyKeyword => useGenericFontNames}/valid.css (100%) rename crates/biome_css_analyze/tests/specs/nursery/{noMissingGenericFamilyKeyword => useGenericFontNames}/valid.css.snap (100%) diff --git a/crates/biome_configuration/src/linter/rules.rs b/crates/biome_configuration/src/linter/rules.rs index 2578888576f1..7c0dbd715ac8 100644 --- a/crates/biome_configuration/src/linter/rules.rs +++ b/crates/biome_configuration/src/linter/rules.rs @@ -2687,9 +2687,6 @@ pub struct Nursery { #[doc = "Checks that the assertion function, for example expect, is placed inside an it() function call."] #[serde(skip_serializing_if = "Option::is_none")] pub no_misplaced_assertion: Option>, - #[doc = "Disallow a missing generic family keyword within font families."] - #[serde(skip_serializing_if = "Option::is_none")] - pub no_missing_generic_family_keyword: Option>, #[doc = "Forbid the use of Node.js builtin modules."] #[serde(skip_serializing_if = "Option::is_none")] pub no_nodejs_modules: Option>, @@ -2708,6 +2705,9 @@ pub struct Nursery { #[doc = "Enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt."] #[serde(skip_serializing_if = "Option::is_none")] pub use_consistent_new_builtin: Option>, + #[doc = "Disallow a missing generic family keyword within font families."] + #[serde(skip_serializing_if = "Option::is_none")] + pub use_generic_font_names: Option>, #[doc = "Disallows package private imports."] #[serde(skip_serializing_if = "Option::is_none")] pub use_import_restrictions: Option>, @@ -2745,13 +2745,13 @@ impl Nursery { "noFlatMapIdentity", "noImportantInKeyframe", "noMisplacedAssertion", - "noMissingGenericFamilyKeyword", "noNodejsModules", "noReactSpecificProps", "noRestrictedImports", "noUndeclaredDependencies", "noUnknownUnit", "useConsistentNewBuiltin", + "useGenericFontNames", "useImportRestrictions", "useSortedClasses", ]; @@ -2766,6 +2766,7 @@ impl Nursery { "noFlatMapIdentity", "noImportantInKeyframe", "noUnknownUnit", + "useGenericFontNames", ]; const RECOMMENDED_RULES_AS_FILTERS: &'static [RuleFilter<'static>] = &[ RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[3]), @@ -2777,7 +2778,8 @@ impl Nursery { RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[11]), - RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18]), + RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17]), + RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19]), ]; const ALL_RULES_AS_FILTERS: &'static [RuleFilter<'static>] = &[ RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0]), @@ -2885,30 +2887,35 @@ impl Nursery { } if let Some(rule) = self.no_nodejs_modules.as_ref() { if rule.is_enabled() { - index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14])); + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[13])); } } if let Some(rule) = self.no_react_specific_props.as_ref() { if rule.is_enabled() { - index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15])); + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14])); } } if let Some(rule) = self.no_restricted_imports.as_ref() { if rule.is_enabled() { - index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16])); + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15])); } } if let Some(rule) = self.no_undeclared_dependencies.as_ref() { if rule.is_enabled() { - index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17])); + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16])); } } if let Some(rule) = self.no_unknown_unit.as_ref() { if rule.is_enabled() { - index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18])); + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17])); } } if let Some(rule) = self.use_consistent_new_builtin.as_ref() { + if rule.is_enabled() { + index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18])); + } + } + if let Some(rule) = self.use_generic_font_names.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19])); } @@ -2992,37 +2999,37 @@ impl Nursery { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[12])); } } - if let Some(rule) = self.no_missing_generic_family_keyword.as_ref() { + if let Some(rule) = self.no_nodejs_modules.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[13])); } } - if let Some(rule) = self.no_nodejs_modules.as_ref() { + if let Some(rule) = self.no_react_specific_props.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14])); } } - if let Some(rule) = self.no_react_specific_props.as_ref() { + if let Some(rule) = self.no_restricted_imports.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15])); } } - if let Some(rule) = self.no_restricted_imports.as_ref() { + if let Some(rule) = self.no_undeclared_dependencies.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16])); } } - if let Some(rule) = self.no_undeclared_dependencies.as_ref() { + if let Some(rule) = self.no_unknown_unit.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17])); } } - if let Some(rule) = self.no_unknown_unit.as_ref() { + if let Some(rule) = self.use_consistent_new_builtin.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18])); } } - if let Some(rule) = self.use_consistent_new_builtin.as_ref() { + if let Some(rule) = self.use_generic_font_names.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19])); } @@ -3125,10 +3132,6 @@ impl Nursery { .no_misplaced_assertion .as_ref() .map(|conf| (conf.level(), conf.get_options())), - "noMissingGenericFamilyKeyword" => self - .no_missing_generic_family_keyword - .as_ref() - .map(|conf| (conf.level(), conf.get_options())), "noNodejsModules" => self .no_nodejs_modules .as_ref() @@ -3153,6 +3156,10 @@ impl Nursery { .use_consistent_new_builtin .as_ref() .map(|conf| (conf.level(), conf.get_options())), + "useGenericFontNames" => self + .use_generic_font_names + .as_ref() + .map(|conf| (conf.level(), conf.get_options())), "useImportRestrictions" => self .use_import_restrictions .as_ref() diff --git a/crates/biome_css_analyze/src/lint/nursery.rs b/crates/biome_css_analyze/src/lint/nursery.rs index 522ccd3c4d0e..3fb4c1408b76 100644 --- a/crates/biome_css_analyze/src/lint/nursery.rs +++ b/crates/biome_css_analyze/src/lint/nursery.rs @@ -7,8 +7,8 @@ pub mod no_css_empty_block; pub mod no_duplicate_font_names; pub mod no_duplicate_selectors_keyframe_block; pub mod no_important_in_keyframe; -pub mod no_missing_generic_family_keyword; pub mod no_unknown_unit; +pub mod use_generic_font_names; declare_group! { pub Nursery { @@ -19,8 +19,8 @@ declare_group! { self :: no_duplicate_font_names :: NoDuplicateFontNames , self :: no_duplicate_selectors_keyframe_block :: NoDuplicateSelectorsKeyframeBlock , self :: no_important_in_keyframe :: NoImportantInKeyframe , - self :: no_missing_generic_family_keyword :: NoMissingGenericFamilyKeyword , self :: no_unknown_unit :: NoUnknownUnit , + self :: use_generic_font_names :: UseGenericFontNames , ] } } diff --git a/crates/biome_css_analyze/src/lint/nursery/no_missing_generic_family_keyword.rs b/crates/biome_css_analyze/src/lint/nursery/use_generic_font_names.rs similarity index 95% rename from crates/biome_css_analyze/src/lint/nursery/no_missing_generic_family_keyword.rs rename to crates/biome_css_analyze/src/lint/nursery/use_generic_font_names.rs index 8dba520a3754..769306d398f0 100644 --- a/crates/biome_css_analyze/src/lint/nursery/no_missing_generic_family_keyword.rs +++ b/crates/biome_css_analyze/src/lint/nursery/use_generic_font_names.rs @@ -1,4 +1,4 @@ -use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic}; +use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic, RuleSource}; use biome_console::markup; use biome_css_syntax::{ AnyCssAtRule, AnyCssGenericComponentValue, AnyCssValue, CssAtRule, @@ -57,14 +57,15 @@ declare_rule! { /// @font-face { font-family: Gentium; } /// ``` /// - pub NoMissingGenericFamilyKeyword { + pub UseGenericFontNames { version: "next", - name: "noMissingGenericFamilyKeyword", - recommended: false, + name: "useGenericFontNames", + recommended: true, + sources: &[RuleSource::Stylelint("font-family-no-missing-generic-family-keyword")], } } -impl Rule for NoMissingGenericFamilyKeyword { +impl Rule for UseGenericFontNames { type Query = Ast; type State = TextRange; type Signals = Option; diff --git a/crates/biome_css_analyze/src/options.rs b/crates/biome_css_analyze/src/options.rs index 331ecb2fa763..f6f52b17766b 100644 --- a/crates/biome_css_analyze/src/options.rs +++ b/crates/biome_css_analyze/src/options.rs @@ -10,6 +10,7 @@ pub type NoDuplicateFontNames = ::Options; pub type NoDuplicateSelectorsKeyframeBlock = < lint :: nursery :: no_duplicate_selectors_keyframe_block :: NoDuplicateSelectorsKeyframeBlock as biome_analyze :: Rule > :: Options ; pub type NoImportantInKeyframe = < lint :: nursery :: no_important_in_keyframe :: NoImportantInKeyframe as biome_analyze :: Rule > :: Options ; -pub type NoMissingGenericFamilyKeyword = < lint :: nursery :: no_missing_generic_family_keyword :: NoMissingGenericFamilyKeyword as biome_analyze :: Rule > :: Options ; pub type NoUnknownUnit = ::Options; +pub type UseGenericFontNames = + ::Options; diff --git a/crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/invalid.css b/crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/invalid.css similarity index 100% rename from crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/invalid.css rename to crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/invalid.css diff --git a/crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/invalid.css.snap b/crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/invalid.css.snap similarity index 73% rename from crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/invalid.css.snap rename to crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/invalid.css.snap index 76c30081623e..1eab83cfb450 100644 --- a/crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/invalid.css.snap +++ b/crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/invalid.css.snap @@ -15,7 +15,7 @@ a { font: 1em Lucida Grande, Arial, "sans-serif" } # Diagnostics ``` -invalid.css:1:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:1:18 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -37,7 +37,7 @@ invalid.css:1:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:2:44 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:2:44 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -60,7 +60,7 @@ invalid.css:2:44 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:3:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:3:18 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -84,7 +84,7 @@ invalid.css:3:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:4:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:4:18 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -108,7 +108,7 @@ invalid.css:4:18 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:5:39 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:5:39 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -132,7 +132,7 @@ invalid.css:5:39 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:6:43 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:6:43 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. @@ -155,7 +155,7 @@ invalid.css:6:43 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━ ``` ``` -invalid.css:7:37 lint/nursery/noMissingGenericFamilyKeyword ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.css:7:37 lint/nursery/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Generic font family missing. diff --git a/crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/valid.css b/crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/valid.css similarity index 100% rename from crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/valid.css rename to crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/valid.css diff --git a/crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/valid.css.snap b/crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/valid.css.snap similarity index 100% rename from crates/biome_css_analyze/tests/specs/nursery/noMissingGenericFamilyKeyword/valid.css.snap rename to crates/biome_css_analyze/tests/specs/nursery/useGenericFontNames/valid.css.snap diff --git a/crates/biome_diagnostics_categories/src/categories.rs b/crates/biome_diagnostics_categories/src/categories.rs index 5ae4ac66baf9..8c53dc968e89 100644 --- a/crates/biome_diagnostics_categories/src/categories.rs +++ b/crates/biome_diagnostics_categories/src/categories.rs @@ -132,6 +132,7 @@ define_categories! { "lint/nursery/noUnknownUnit": "https://biomejs.dev/linter/rules/no-unknown-unit", "lint/nursery/useBiomeSuppressionComment": "https://biomejs.dev/linter/rules/use-biome-suppression-comment", "lint/nursery/useConsistentNewBuiltin": "https://biomejs.dev/linter/rules/use-consistent-new-builtin", + "lint/nursery/useGenericFontNames": "https://biomejs.dev/linter/rules/use-generic-font-names", "lint/nursery/useImportRestrictions": "https://biomejs.dev/linter/rules/use-import-restrictions", "lint/nursery/useSortedClasses": "https://biomejs.dev/linter/rules/use-sorted-classes", "lint/performance/noAccumulatingSpread": "https://biomejs.dev/linter/rules/no-accumulating-spread", diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index d12f0f24a676..35c633554192 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -960,10 +960,6 @@ export interface Nursery { * Checks that the assertion function, for example expect, is placed inside an it() function call. */ noMisplacedAssertion?: RuleConfiguration_for_Null; - /** - * Disallow a missing generic family keyword within font families. - */ - noMissingGenericFamilyKeyword?: RuleConfiguration_for_Null; /** * Forbid the use of Node.js builtin modules. */ @@ -992,6 +988,10 @@ export interface Nursery { * Enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt. */ useConsistentNewBuiltin?: RuleConfiguration_for_Null; + /** + * Disallow a missing generic family keyword within font families. + */ + useGenericFontNames?: RuleConfiguration_for_Null; /** * Disallows package private imports. */ @@ -1987,6 +1987,7 @@ export type Category = | "lint/nursery/noUnknownUnit" | "lint/nursery/useBiomeSuppressionComment" | "lint/nursery/useConsistentNewBuiltin" + | "lint/nursery/useGenericFontNames" | "lint/nursery/useImportRestrictions" | "lint/nursery/useSortedClasses" | "lint/performance/noAccumulatingSpread" diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index e390e1ca2dc6..93c5be880081 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -1524,13 +1524,6 @@ { "type": "null" } ] }, - "noMissingGenericFamilyKeyword": { - "description": "Disallow a missing generic family keyword within font families.", - "anyOf": [ - { "$ref": "#/definitions/RuleConfiguration" }, - { "type": "null" } - ] - }, "noNodejsModules": { "description": "Forbid the use of Node.js builtin modules.", "anyOf": [ @@ -1577,6 +1570,13 @@ { "type": "null" } ] }, + "useGenericFontNames": { + "description": "Disallow a missing generic family keyword within font families.", + "anyOf": [ + { "$ref": "#/definitions/RuleConfiguration" }, + { "type": "null" } + ] + }, "useImportRestrictions": { "description": "Disallows package private imports.", "anyOf": [