From c991d50fbe8cf90f18c32af8bf4f8a1b853c5319 Mon Sep 17 00:00:00 2001 From: Kazuhiro-Mimaki Date: Tue, 23 Apr 2024 09:27:00 +0900 Subject: [PATCH] chore: rename the rule from `noArrayConstructor` to `useArrayLiterals` ref: https://github.com/biomejs/biome/issues/2532 --- .../migrate/eslint_any_rule_to_biome.rs | 2 +- .../biome_configuration/src/linter/rules.rs | 90 +++++++++---------- .../src/categories.rs | 2 +- crates/biome_js_analyze/src/lint/nursery.rs | 4 +- ...y_constructor.rs => use_array_literals.rs} | 6 +- crates/biome_js_analyze/src/options.rs | 4 +- .../invalid.js | 0 .../invalid.js.snap | 12 +-- .../valid.js | 0 .../valid.js.snap | 0 .../@biomejs/backend-jsonrpc/src/workspace.ts | 10 +-- .../@biomejs/biome/configuration_schema.json | 14 +-- 12 files changed, 72 insertions(+), 72 deletions(-) rename crates/biome_js_analyze/src/lint/nursery/{no_array_constructor.rs => use_array_literals.rs} (97%) rename crates/biome_js_analyze/tests/specs/nursery/{noArrayConstructor => useArrayLiterals}/invalid.js (100%) rename crates/biome_js_analyze/tests/specs/nursery/{noArrayConstructor => useArrayLiterals}/invalid.js.snap (77%) rename crates/biome_js_analyze/tests/specs/nursery/{noArrayConstructor => useArrayLiterals}/valid.js (100%) rename crates/biome_js_analyze/tests/specs/nursery/{noArrayConstructor => useArrayLiterals}/valid.js.snap (100%) diff --git a/crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs b/crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs index 57b41a1fe6d8..a4fa85c3f6c6 100644 --- a/crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs +++ b/crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs @@ -602,7 +602,7 @@ pub(crate) fn migrate_eslint_any_rule( return false; } let group = rules.nursery.get_or_insert_with(Default::default); - let rule = group.no_array_constructor.get_or_insert(Default::default()); + let rule = group.use_array_literals.get_or_insert(Default::default()); rule.set_level(rule_severity.into()); } "no-async-promise-executor" => { diff --git a/crates/biome_configuration/src/linter/rules.rs b/crates/biome_configuration/src/linter/rules.rs index feccbe316aab..b84a614bdf67 100644 --- a/crates/biome_configuration/src/linter/rules.rs +++ b/crates/biome_configuration/src/linter/rules.rs @@ -2647,9 +2647,6 @@ pub struct Nursery { #[doc = r" It enables ALL rules for this group."] #[serde(skip_serializing_if = "Option::is_none")] pub all: Option, - #[doc = "Disallow Array constructors."] - #[serde(skip_serializing_if = "Option::is_none")] - pub no_array_constructor: Option>, #[doc = "WIP: This rule hasn't been implemented yet."] #[serde(skip_serializing_if = "Option::is_none")] pub no_color_invalid_hex: Option>, @@ -2702,6 +2699,9 @@ pub struct Nursery { #[doc = "Disallow the use of dependencies that aren't specified in the package.json."] #[serde(skip_serializing_if = "Option::is_none")] pub no_undeclared_dependencies: Option>, + #[doc = "Disallow Array constructors."] + #[serde(skip_serializing_if = "Option::is_none")] + pub use_array_literals: Option>, #[doc = "Disallows package private imports."] #[serde(skip_serializing_if = "Option::is_none")] pub use_import_restrictions: Option>, @@ -2726,7 +2726,6 @@ impl DeserializableValidator for Nursery { impl Nursery { const GROUP_NAME: &'static str = "nursery"; pub(crate) const GROUP_RULES: &'static [&'static str] = &[ - "noArrayConstructor", "noColorInvalidHex", "noConsole", "noConstantMathMinMaxClamp", @@ -2744,6 +2743,7 @@ impl Nursery { "noReactSpecificProps", "noRestrictedImports", "noUndeclaredDependencies", + "useArrayLiterals", "useImportRestrictions", "useSortedClasses", ]; @@ -2759,6 +2759,7 @@ impl Nursery { "noImportantInKeyframe", ]; const RECOMMENDED_RULES_AS_FILTERS: &'static [RuleFilter<'static>] = &[ + RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[3]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[4]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5]), RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6]), @@ -2767,7 +2768,6 @@ 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[12]), ]; const ALL_RULES_AS_FILTERS: &'static [RuleFilter<'static>] = &[ RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0]), @@ -2806,92 +2806,92 @@ impl Nursery { } pub(crate) fn get_enabled_rules(&self) -> IndexSet { let mut index_set = IndexSet::new(); - if let Some(rule) = self.no_array_constructor.as_ref() { + if let Some(rule) = self.no_color_invalid_hex.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0])); } } - if let Some(rule) = self.no_color_invalid_hex.as_ref() { + if let Some(rule) = self.no_console.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[1])); } } - if let Some(rule) = self.no_console.as_ref() { + if let Some(rule) = self.no_constant_math_min_max_clamp.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[2])); } } - if let Some(rule) = self.no_constant_math_min_max_clamp.as_ref() { + if let Some(rule) = self.no_css_empty_block.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[3])); } } - if let Some(rule) = self.no_css_empty_block.as_ref() { + if let Some(rule) = self.no_done_callback.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[4])); } } - if let Some(rule) = self.no_done_callback.as_ref() { + if let Some(rule) = self.no_duplicate_else_if.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5])); } } - if let Some(rule) = self.no_duplicate_else_if.as_ref() { + if let Some(rule) = self.no_duplicate_font_names.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6])); } } - if let Some(rule) = self.no_duplicate_font_names.as_ref() { + if let Some(rule) = self.no_duplicate_json_keys.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7])); } } - if let Some(rule) = self.no_duplicate_json_keys.as_ref() { + if let Some(rule) = self.no_duplicate_selectors_keyframe_block.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[8])); } } - if let Some(rule) = self.no_duplicate_selectors_keyframe_block.as_ref() { + if let Some(rule) = self.no_evolving_any.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9])); } } - if let Some(rule) = self.no_evolving_any.as_ref() { + if let Some(rule) = self.no_flat_map_identity.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10])); } } - if let Some(rule) = self.no_flat_map_identity.as_ref() { + if let Some(rule) = self.no_important_in_keyframe.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[11])); } } - if let Some(rule) = self.no_important_in_keyframe.as_ref() { + if let Some(rule) = self.no_misplaced_assertion.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[12])); } } - if let Some(rule) = self.no_misplaced_assertion.as_ref() { + 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[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_enabled() { 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_enabled() { 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_enabled() { 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.use_array_literals.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17])); } @@ -2910,92 +2910,92 @@ impl Nursery { } pub(crate) fn get_disabled_rules(&self) -> IndexSet { let mut index_set = IndexSet::new(); - if let Some(rule) = self.no_array_constructor.as_ref() { + if let Some(rule) = self.no_color_invalid_hex.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0])); } } - if let Some(rule) = self.no_color_invalid_hex.as_ref() { + if let Some(rule) = self.no_console.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[1])); } } - if let Some(rule) = self.no_console.as_ref() { + if let Some(rule) = self.no_constant_math_min_max_clamp.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[2])); } } - if let Some(rule) = self.no_constant_math_min_max_clamp.as_ref() { + if let Some(rule) = self.no_css_empty_block.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[3])); } } - if let Some(rule) = self.no_css_empty_block.as_ref() { + if let Some(rule) = self.no_done_callback.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[4])); } } - if let Some(rule) = self.no_done_callback.as_ref() { + if let Some(rule) = self.no_duplicate_else_if.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5])); } } - if let Some(rule) = self.no_duplicate_else_if.as_ref() { + if let Some(rule) = self.no_duplicate_font_names.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6])); } } - if let Some(rule) = self.no_duplicate_font_names.as_ref() { + if let Some(rule) = self.no_duplicate_json_keys.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7])); } } - if let Some(rule) = self.no_duplicate_json_keys.as_ref() { + if let Some(rule) = self.no_duplicate_selectors_keyframe_block.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[8])); } } - if let Some(rule) = self.no_duplicate_selectors_keyframe_block.as_ref() { + if let Some(rule) = self.no_evolving_any.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9])); } } - if let Some(rule) = self.no_evolving_any.as_ref() { + if let Some(rule) = self.no_flat_map_identity.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10])); } } - if let Some(rule) = self.no_flat_map_identity.as_ref() { + if let Some(rule) = self.no_important_in_keyframe.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[11])); } } - if let Some(rule) = self.no_important_in_keyframe.as_ref() { + if let Some(rule) = self.no_misplaced_assertion.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[12])); } } - if let Some(rule) = self.no_misplaced_assertion.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.use_array_literals.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17])); } @@ -3046,10 +3046,6 @@ impl Nursery { rule_name: &str, ) -> Option<(RulePlainConfiguration, Option)> { match rule_name { - "noArrayConstructor" => self - .no_array_constructor - .as_ref() - .map(|conf| (conf.level(), conf.get_options())), "noColorInvalidHex" => self .no_color_invalid_hex .as_ref() @@ -3118,6 +3114,10 @@ impl Nursery { .no_undeclared_dependencies .as_ref() .map(|conf| (conf.level(), conf.get_options())), + "useArrayLiterals" => self + .use_array_literals + .as_ref() + .map(|conf| (conf.level(), conf.get_options())), "useImportRestrictions" => self .use_import_restrictions .as_ref() diff --git a/crates/biome_diagnostics_categories/src/categories.rs b/crates/biome_diagnostics_categories/src/categories.rs index 9ac07cf9787f..776b5beed11a 100644 --- a/crates/biome_diagnostics_categories/src/categories.rs +++ b/crates/biome_diagnostics_categories/src/categories.rs @@ -110,7 +110,7 @@ define_categories! { "lint/correctness/useValidForDirection": "https://biomejs.dev/linter/rules/use-valid-for-direction", "lint/correctness/useYield": "https://biomejs.dev/linter/rules/use-yield", "lint/nursery/colorNoInvalidHex": "https://biomejs.dev/linter/rules/color-no-invalid-hex", - "lint/nursery/noArrayConstructor": "https://biomejs.dev/linter/rules/no-array-constructor", + "lint/nursery/useArrayLiterals": "https://biomejs.dev/linter/rules/no-array-constructor", "lint/nursery/noColorInvalidHex": "https://biomejs.dev/linter/rules/no-color-invalid-hex", "lint/nursery/noConsole": "https://biomejs.dev/linter/rules/no-console", "lint/nursery/noConstantMathMinMaxClamp": "https://biomejs.dev/linter/rules/no-constant-math-min-max-clamp", diff --git a/crates/biome_js_analyze/src/lint/nursery.rs b/crates/biome_js_analyze/src/lint/nursery.rs index f243ffed72e6..b88c03e4baad 100644 --- a/crates/biome_js_analyze/src/lint/nursery.rs +++ b/crates/biome_js_analyze/src/lint/nursery.rs @@ -2,7 +2,6 @@ use biome_analyze::declare_group; -pub mod no_array_constructor; pub mod no_console; pub mod no_constant_math_min_max_clamp; pub mod no_done_callback; @@ -14,6 +13,7 @@ pub mod no_nodejs_modules; pub mod no_react_specific_props; pub mod no_restricted_imports; pub mod no_undeclared_dependencies; +pub mod use_array_literals; pub mod use_import_restrictions; pub mod use_sorted_classes; @@ -21,7 +21,6 @@ declare_group! { pub Nursery { name : "nursery" , rules : [ - self :: no_array_constructor :: NoArrayConstructor , self :: no_console :: NoConsole , self :: no_constant_math_min_max_clamp :: NoConstantMathMinMaxClamp , self :: no_done_callback :: NoDoneCallback , @@ -33,6 +32,7 @@ declare_group! { self :: no_react_specific_props :: NoReactSpecificProps , self :: no_restricted_imports :: NoRestrictedImports , self :: no_undeclared_dependencies :: NoUndeclaredDependencies , + self :: use_array_literals :: UseArrayLiterals , self :: use_import_restrictions :: UseImportRestrictions , self :: use_sorted_classes :: UseSortedClasses , ] diff --git a/crates/biome_js_analyze/src/lint/nursery/no_array_constructor.rs b/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs similarity index 97% rename from crates/biome_js_analyze/src/lint/nursery/no_array_constructor.rs rename to crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs index b58a3a885ddb..62e9734a06a3 100644 --- a/crates/biome_js_analyze/src/lint/nursery/no_array_constructor.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs @@ -41,16 +41,16 @@ declare_rule! { /// [0, 1, 2]; /// ``` /// - pub NoArrayConstructor { + pub UseArrayLiterals { version: "next", - name: "noArrayConstructor", + name: "useArrayLiterals", sources: &[RuleSource::Eslint("no-array-constructor")], recommended: false, fix_kind: FixKind::Unsafe, } } -impl Rule for NoArrayConstructor { +impl Rule for UseArrayLiterals { type Query = Ast; type State = (); type Signals = Option; diff --git a/crates/biome_js_analyze/src/options.rs b/crates/biome_js_analyze/src/options.rs index 01c4beaa0459..d679622acba7 100644 --- a/crates/biome_js_analyze/src/options.rs +++ b/crates/biome_js_analyze/src/options.rs @@ -8,8 +8,6 @@ pub type NoApproximativeNumericConstant = < lint :: suspicious :: no_approximati pub type NoArguments = ::Options; pub type NoAriaHiddenOnFocusable = < lint :: a11y :: no_aria_hidden_on_focusable :: NoAriaHiddenOnFocusable as biome_analyze :: Rule > :: Options ; pub type NoAriaUnsupportedElements = < lint :: a11y :: no_aria_unsupported_elements :: NoAriaUnsupportedElements as biome_analyze :: Rule > :: Options ; -pub type NoArrayConstructor = - ::Options; pub type NoArrayIndexKey = ::Options; pub type NoAssignInExpressions = < lint :: suspicious :: no_assign_in_expressions :: NoAssignInExpressions as biome_analyze :: Rule > :: Options ; @@ -247,6 +245,8 @@ pub type UseAnchorContent = pub type UseAriaActivedescendantWithTabindex = < lint :: a11y :: use_aria_activedescendant_with_tabindex :: UseAriaActivedescendantWithTabindex as biome_analyze :: Rule > :: Options ; pub type UseAriaPropsForRole = ::Options; +pub type UseArrayLiterals = + ::Options; pub type UseArrowFunction = ::Options; pub type UseAsConstAssertion = diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js b/crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/invalid.js similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js rename to crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/invalid.js diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/invalid.js.snap similarity index 77% rename from crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap rename to crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/invalid.js.snap index 504138cfdd2c..5f5132fadc63 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/invalid.js.snap @@ -20,7 +20,7 @@ new Array(...args); # Diagnostics ``` -invalid.js:1:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:1:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. @@ -37,7 +37,7 @@ invalid.js:1:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━ ``` ``` -invalid.js:3:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:3:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. @@ -56,7 +56,7 @@ invalid.js:3:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━ ``` ``` -invalid.js:5:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:5:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. @@ -75,7 +75,7 @@ invalid.js:5:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━ ``` ``` -invalid.js:7:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:7:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. @@ -94,7 +94,7 @@ invalid.js:7:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━ ``` ``` -invalid.js:9:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:9:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. @@ -113,7 +113,7 @@ invalid.js:9:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━ ``` ``` -invalid.js:11:1 lint/nursery/noArrayConstructor ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:11:1 lint/nursery/useArrayLiterals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Don't use Array constructors. diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js b/crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/valid.js similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js rename to crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/valid.js diff --git a/crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/valid.js.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noArrayConstructor/valid.js.snap rename to crates/biome_js_analyze/tests/specs/nursery/useArrayLiterals/valid.js.snap diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index ed544209bab8..dc791d7ca5b8 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -908,10 +908,6 @@ export interface Nursery { * It enables ALL rules for this group. */ all?: boolean; - /** - * Disallow Array constructors. - */ - noArrayConstructor?: RuleConfiguration_for_Null; /** * WIP: This rule hasn't been implemented yet. */ @@ -984,6 +980,10 @@ export interface Nursery { * It enables the recommended rules for this group */ recommended?: boolean; + /** + * Disallow Array constructors. + */ + useArrayLiterals?: RuleConfiguration_for_Null; /** * Disallows package private imports. */ @@ -1952,7 +1952,7 @@ export type Category = | "lint/correctness/useValidForDirection" | "lint/correctness/useYield" | "lint/nursery/colorNoInvalidHex" - | "lint/nursery/noArrayConstructor" + | "lint/nursery/useArrayLiterals" | "lint/nursery/noColorInvalidHex" | "lint/nursery/noConsole" | "lint/nursery/noConstantMathMinMaxClamp" diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index 12c4f5eff768..6de7338afcab 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -1433,13 +1433,6 @@ "description": "It enables ALL rules for this group.", "type": ["boolean", "null"] }, - "noArrayConstructor": { - "description": "Disallow Array constructors.", - "anyOf": [ - { "$ref": "#/definitions/RuleConfiguration" }, - { "type": "null" } - ] - }, "noColorInvalidHex": { "description": "WIP: This rule hasn't been implemented yet.", "anyOf": [ @@ -1563,6 +1556,13 @@ "description": "It enables the recommended rules for this group", "type": ["boolean", "null"] }, + "useArrayLiterals": { + "description": "Disallow Array constructors.", + "anyOf": [ + { "$ref": "#/definitions/RuleConfiguration" }, + { "type": "null" } + ] + }, "useImportRestrictions": { "description": "Disallows package private imports.", "anyOf": [