From 2c70d3fde5b13ec9ef0915d22837ab8321b6737f Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Tue, 30 Apr 2024 13:55:52 +0200 Subject: [PATCH] release: v1.7.2 (#2651) --- CHANGELOG.md | 41 ++-- .../migrate/eslint_any_rule_to_biome.rs | 4 +- .../biome_configuration/src/linter/rules.rs | 13 +- .../src/categories.rs | 2 +- .../correctness/no_invalid_new_builtin.rs | 3 + crates/biome_js_analyze/src/lint/nursery.rs | 4 +- .../lint/nursery/no_react_specific_props.rs | 2 +- .../no_useless_undefined_initialization.rs | 2 +- .../src/lint/nursery/use_array_literals.rs | 2 +- ...=> use_consistent_builtin_instatiation.rs} | 69 ++++--- .../lint/nursery/use_default_switch_clause.rs | 2 +- crates/biome_js_analyze/src/options.rs | 2 +- .../noUndeclaredVariables/thisInJsx.jsx | 7 - .../noUndeclaredVariables/thisInJsx.jsx.snap | 15 -- .../invalid.js | 6 +- .../invalid.js.snap | 190 +++++++++++------- .../valid.js | 6 +- .../valid.js.snap | 6 +- crates/biome_js_parser/src/syntax/jsx/mod.rs | 6 +- .../@biomejs/backend-jsonrpc/src/workspace.ts | 4 +- .../@biomejs/biome/configuration_schema.json | 2 +- packages/@biomejs/biome/package.json | 2 +- 22 files changed, 216 insertions(+), 174 deletions(-) rename crates/biome_js_analyze/src/lint/nursery/{use_consistent_new_builtin.rs => use_consistent_builtin_instatiation.rs} (85%) delete mode 100644 crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx delete mode 100644 crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx.snap rename crates/biome_js_analyze/tests/specs/nursery/{useConsistentNewBuiltin => useConsistentBuiltinInstatiation}/invalid.js (96%) rename crates/biome_js_analyze/tests/specs/nursery/{useConsistentNewBuiltin => useConsistentBuiltinInstatiation}/invalid.js.snap (59%) rename crates/biome_js_analyze/tests/specs/nursery/{useConsistentNewBuiltin => useConsistentBuiltinInstatiation}/valid.js (97%) rename crates/biome_js_analyze/tests/specs/nursery/{useConsistentNewBuiltin => useConsistentBuiltinInstatiation}/valid.js.snap (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70ecb3209880..3c77d7988c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ New entries must be placed in a section entitled `Unreleased`. Read our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog). -## Unreleased +## 1.7.2 (2024-04-30) ### Analyzer @@ -52,20 +52,31 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b Contributed by @Conaclos -### Configuration - -### Editors - ### Formatter #### Bug fixes - Correctly handle placement of comments inside named import clauses. [#2566](https://github.com/biomejs/biome/pull/2566). Contributed by @ah-yu -### JavaScript APIs - ### Linter +#### New features + +- Add [nusery/noReactSpecificProps](https://biomejs.dev/linter/rules/no-react-specific-props/). + Contributed by @marvin-j97 + +- Add [noUselessUndefinedInitialization](https://biomejs.dev/linter/rules/no-useless-undefined-initialization/). + Contributed by @lutaok + +- Add [nusery/useArrayLiterals](https://biomejs.dev/linter/rules/use-array-literals/). + Contributed by @Kazuhiro-Mimaki + +- Add [nusery/useConsistentBuiltinInstatiation](https://biomejs.dev/linter/rules/use-consistent-builtin-instatiation/). + Contributed by @minht11 + +- Add [nusery/useDefaultSwitchClause](https://biomejs.dev/linter/rules/use-default-switch-clause/). + Contributed by @michellocana + #### Bug fixes - [noDuplicateJsonKeys](https://biomejs.dev/linter/rules/no-duplicate-json-keys/) no longer crashes when a JSON file contains an unterminated string ([#2357](https://github.com/biomejs/biome/issues/2357)). @@ -147,20 +158,6 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b Contributed by @Conaclos -- [noUndeclaredVariables](https://biomejs.dev/linter/rules/no-undeclared-variables/) no longer errors on `this` in JSX tags ([#2636](https://github.com/biomejs/biome/issues/2636)). - - ```jsx - import { Component } from 'react'; - - export class MyComponent extends Component { - render() { - return ; - } - } - ``` - - Contributed by @printfn - - [noMisplacedAssertion](https://biomejs.dev/linter/rules/no-misplaced-assertion/) now allow these matchers - `expect.any()` @@ -178,6 +175,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ### Parser +#### Bug fixes + - The language parsers no longer panic on unterminated strings followed by a newline and a space ([#2606](https://github.com/biomejs/biome/issues/2606), [#2410](https://github.com/biomejs/biome/issues/2410)). The following example is now parsed without making Biome panics: 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 a8b970f2b07b..db3085434c7e 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 @@ -885,7 +885,7 @@ pub(crate) fn migrate_eslint_any_rule( } let group = rules.nursery.get_or_insert_with(Default::default); let rule = group - .use_consistent_new_builtin + .use_consistent_builtin_instatiation .get_or_insert(Default::default()); rule.set_level(rule_severity.into()); } @@ -1271,7 +1271,7 @@ pub(crate) fn migrate_eslint_any_rule( } let group = rules.nursery.get_or_insert_with(Default::default); let rule = group - .use_consistent_new_builtin + .use_consistent_builtin_instatiation .get_or_insert(Default::default()); rule.set_level(rule_severity.into()); } diff --git a/crates/biome_configuration/src/linter/rules.rs b/crates/biome_configuration/src/linter/rules.rs index d89f9fe318c4..dfa7e5c76a04 100644 --- a/crates/biome_configuration/src/linter/rules.rs +++ b/crates/biome_configuration/src/linter/rules.rs @@ -2714,7 +2714,8 @@ pub struct Nursery { pub use_array_literals: Option>, #[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>, + pub use_consistent_builtin_instatiation: + Option>, #[doc = "Require the default clause in switch statements."] #[serde(skip_serializing_if = "Option::is_none")] pub use_default_switch_clause: Option>, @@ -2766,7 +2767,7 @@ impl Nursery { "noUnknownUnit", "noUselessUndefinedInitialization", "useArrayLiterals", - "useConsistentNewBuiltin", + "useConsistentBuiltinInstatiation", "useDefaultSwitchClause", "useGenericFontNames", "useImportRestrictions", @@ -2948,7 +2949,7 @@ impl Nursery { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[20])); } } - if let Some(rule) = self.use_consistent_new_builtin.as_ref() { + if let Some(rule) = self.use_consistent_builtin_instatiation.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[21])); } @@ -3082,7 +3083,7 @@ impl Nursery { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[20])); } } - if let Some(rule) = self.use_consistent_new_builtin.as_ref() { + if let Some(rule) = self.use_consistent_builtin_instatiation.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[21])); } @@ -3227,8 +3228,8 @@ impl Nursery { .use_array_literals .as_ref() .map(|conf| (conf.level(), conf.get_options())), - "useConsistentNewBuiltin" => self - .use_consistent_new_builtin + "useConsistentBuiltinInstatiation" => self + .use_consistent_builtin_instatiation .as_ref() .map(|conf| (conf.level(), conf.get_options())), "useDefaultSwitchClause" => self diff --git a/crates/biome_diagnostics_categories/src/categories.rs b/crates/biome_diagnostics_categories/src/categories.rs index 0c517cef9c81..c13d7e6ad234 100644 --- a/crates/biome_diagnostics_categories/src/categories.rs +++ b/crates/biome_diagnostics_categories/src/categories.rs @@ -134,7 +134,7 @@ define_categories! { "lint/nursery/noUselessUndefinedInitialization": "https://biomejs.dev/linter/rules/no-useless-undefined-initialization", "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/useConsistentBuiltinInstatiation": "https://biomejs.dev/linter/rules/use-consistent-new-builtin", "lint/nursery/useGenericFontNames": "https://biomejs.dev/linter/rules/use-generic-font-names", "lint/nursery/useDefaultSwitchClause": "https://biomejs.dev/linter/rules/use-default-switch-clause", "lint/nursery/useImportRestrictions": "https://biomejs.dev/linter/rules/use-import-restrictions", diff --git a/crates/biome_js_analyze/src/lint/correctness/no_invalid_new_builtin.rs b/crates/biome_js_analyze/src/lint/correctness/no_invalid_new_builtin.rs index 79a205e3d67c..1a53fbe45229 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_invalid_new_builtin.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_invalid_new_builtin.rs @@ -52,8 +52,11 @@ declare_rule! { pub NoInvalidNewBuiltin { version: "1.3.0", name: "noInvalidNewBuiltin", + // TODO: Remove this source once `useConsistentBuiltinInstatiation` is stable sources: &[RuleSource::Eslint("no-new-native-nonconstructor")], recommended: true, + // TODO: Deprecate this source once `useConsistentBuiltinInstatiation` is stable + //deprecated: "Use the rule useConsistentBuiltinInstatiation instead.", fix_kind: FixKind::Unsafe, } } diff --git a/crates/biome_js_analyze/src/lint/nursery.rs b/crates/biome_js_analyze/src/lint/nursery.rs index 1e5ccd6bce2f..1b2576ac7cff 100644 --- a/crates/biome_js_analyze/src/lint/nursery.rs +++ b/crates/biome_js_analyze/src/lint/nursery.rs @@ -15,7 +15,7 @@ pub mod no_restricted_imports; pub mod no_undeclared_dependencies; pub mod no_useless_undefined_initialization; pub mod use_array_literals; -pub mod use_consistent_new_builtin; +pub mod use_consistent_builtin_instatiation; pub mod use_default_switch_clause; pub mod use_import_restrictions; pub mod use_sorted_classes; @@ -37,7 +37,7 @@ declare_group! { self :: no_undeclared_dependencies :: NoUndeclaredDependencies , self :: no_useless_undefined_initialization :: NoUselessUndefinedInitialization , self :: use_array_literals :: UseArrayLiterals , - self :: use_consistent_new_builtin :: UseConsistentNewBuiltin , + self :: use_consistent_builtin_instatiation :: UseConsistentBuiltinInstatiation , self :: use_default_switch_clause :: UseDefaultSwitchClause , self :: use_import_restrictions :: UseImportRestrictions , self :: use_sorted_classes :: UseSortedClasses , diff --git a/crates/biome_js_analyze/src/lint/nursery/no_react_specific_props.rs b/crates/biome_js_analyze/src/lint/nursery/no_react_specific_props.rs index 9cc55cd99f8c..37c589a04417 100644 --- a/crates/biome_js_analyze/src/lint/nursery/no_react_specific_props.rs +++ b/crates/biome_js_analyze/src/lint/nursery/no_react_specific_props.rs @@ -27,7 +27,7 @@ declare_rule! { /// /// ``` pub NoReactSpecificProps { - version: "next", + version: "1.7.2", name: "noReactSpecificProps", sources: &[RuleSource::EslintSolid("no-react-specific-props")], recommended: false, diff --git a/crates/biome_js_analyze/src/lint/nursery/no_useless_undefined_initialization.rs b/crates/biome_js_analyze/src/lint/nursery/no_useless_undefined_initialization.rs index dc7ac99529e0..4bb0d671d7e5 100644 --- a/crates/biome_js_analyze/src/lint/nursery/no_useless_undefined_initialization.rs +++ b/crates/biome_js_analyze/src/lint/nursery/no_useless_undefined_initialization.rs @@ -47,7 +47,7 @@ declare_rule! { /// ``` /// pub NoUselessUndefinedInitialization { - version: "next", + version: "1.7.2", name: "noUselessUndefinedInitialization", sources: &[RuleSource::Eslint("no-undef-init")], source_kind: RuleSourceKind::Inspired, diff --git a/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs b/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs index 2890e1d619e4..5fa71e147044 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_array_literals.rs @@ -42,7 +42,7 @@ declare_rule! { /// ``` /// pub UseArrayLiterals { - version: "next", + version: "1.7.2", name: "useArrayLiterals", sources: &[RuleSource::Eslint("no-array-constructor")], recommended: false, diff --git a/crates/biome_js_analyze/src/lint/nursery/use_consistent_new_builtin.rs b/crates/biome_js_analyze/src/lint/nursery/use_consistent_builtin_instatiation.rs similarity index 85% rename from crates/biome_js_analyze/src/lint/nursery/use_consistent_new_builtin.rs rename to crates/biome_js_analyze/src/lint/nursery/use_consistent_builtin_instatiation.rs index cc9579ebca3c..b329249ab0a3 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_consistent_new_builtin.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_consistent_builtin_instatiation.rs @@ -11,12 +11,12 @@ use biome_js_syntax::{ use biome_rowan::{chain_trivia_pieces, AstNode, BatchMutationExt, TriviaPieceKind}; declare_rule! { - /// Enforce the use of new for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. + /// Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. /// /// `new Builtin()` and `Builtin()` work the same, but new should be preferred for consistency with other constructors. /// Enforces the use of new for following builtins: /// - /// - Object + /// - AggregateError /// - Array /// - ArrayBuffer /// - BigInt64Array @@ -24,39 +24,44 @@ declare_rule! { /// - DataView /// - Date /// - Error + /// - EvalError + /// - FinalizationRegistry /// - Float32Array /// - Float64Array /// - Function - /// - Int8Array /// - Int16Array /// - Int32Array + /// - Int8Array /// - Map - /// - WeakMap - /// - Set - /// - WeakSet + /// - Object /// - Promise + /// - Proxy + /// - RangeError + /// - ReferenceError /// - RegExp - /// - Uint8Array + /// - Set + /// - SharedArrayBuffer + /// - SyntaxError + /// - TypeError + /// - URIError /// - Uint16Array /// - Uint32Array + /// - Uint8Array /// - Uint8ClampedArray - /// - SharedArrayBuffer - /// - Proxy + /// - WeakMap /// - WeakRef - /// - FinalizationRegistry + /// - WeakSet /// /// Disallows the use of new for following builtins: /// - /// - String - /// - Number + /// - BigInt /// - Boolean - /// - /// These builtins are handled by [noInvalidBuiltin](https://biomejs.dev/linter/rules/no-invalid-new-builtin/) rule: - /// + /// - Number + /// - String /// - Symbol - /// - BigInt /// - /// > These should not use new as that would create object wrappers for the primitive values, which is not what you want. However, without new they can be useful for coercing a value to that type. + /// > These should not use `new` as that would create object wrappers for the primitive values, which is not what you want. + /// > However, without `new` they can be useful for coercing a value to that type. /// /// ## Examples /// @@ -92,18 +97,23 @@ declare_rule! { /// ]); /// ``` /// - pub UseConsistentNewBuiltin { - version: "next", - name: "useConsistentNewBuiltin", - sources: &[RuleSource::EslintUnicorn("new-for-builtins"), RuleSource::Eslint("no-new-wrappers")], + pub UseConsistentBuiltinInstatiation { + version: "1.7.2", + name: "useConsistentBuiltinInstatiation", + sources: &[ + RuleSource::EslintUnicorn("new-for-builtins"), + RuleSource::Eslint("no-new-wrappers"), + // TODO: Add this source once `noInvalidNewBuiltin` is deprecated + //RuleSource::Eslint("no-new-native-nonconstructor") + ], recommended: false, fix_kind: FixKind::Unsafe, } } -impl Rule for UseConsistentNewBuiltin { +impl Rule for UseConsistentBuiltinInstatiation { type Query = Semantic; - type State = UseConsistentNewBuiltinState; + type State = UseConsistentBuiltinInstatiationState; type Signals = Option; type Options = (); @@ -120,7 +130,7 @@ impl Rule for UseConsistentNewBuiltin { .is_ok() { return ctx.model().binding(&reference).is_none().then_some( - UseConsistentNewBuiltinState { + UseConsistentBuiltinInstatiationState { name: name_text.to_string(), creation_rule, }, @@ -185,6 +195,7 @@ impl Rule for UseConsistentNewBuiltin { /// Sorted array of builtins that require new keyword. const BUILTINS_REQUIRING_NEW: &[&str] = &[ + "AggregateError", "Array", "ArrayBuffer", "BigInt64Array", @@ -192,6 +203,7 @@ const BUILTINS_REQUIRING_NEW: &[&str] = &[ "DataView", "Date", "Error", + "EvalError", "FinalizationRegistry", "Float32Array", "Float64Array", @@ -203,9 +215,14 @@ const BUILTINS_REQUIRING_NEW: &[&str] = &[ "Object", "Promise", "Proxy", + "RangeError", + "ReferenceError", "RegExp", "Set", "SharedArrayBuffer", + "SyntaxError", + "TypeError", + "URIError", "Uint16Array", "Uint32Array", "Uint8Array", @@ -216,7 +233,7 @@ const BUILTINS_REQUIRING_NEW: &[&str] = &[ ]; /// Sorted array of builtins that should not use new keyword. -const BUILTINS_NOT_REQUIRING_NEW: &[&str] = &["Boolean", "Number", "String"]; +const BUILTINS_NOT_REQUIRING_NEW: &[&str] = &["BigInt", "Boolean", "Number", "String", "Symbol"]; enum BuiltinCreationRule { MustUseNew, @@ -232,7 +249,7 @@ impl BuiltinCreationRule { } } -pub struct UseConsistentNewBuiltinState { +pub struct UseConsistentBuiltinInstatiationState { name: String, creation_rule: BuiltinCreationRule, } diff --git a/crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs b/crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs index 24de16cce92f..9c7d8c59f8f7 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs @@ -38,7 +38,7 @@ declare_rule! { /// } /// ``` pub UseDefaultSwitchClause { - version: "next", + version: "1.7.2", name: "useDefaultSwitchClause", sources: &[RuleSource::Eslint("default-case")], recommended: false, diff --git a/crates/biome_js_analyze/src/options.rs b/crates/biome_js_analyze/src/options.rs index 59e36288f3eb..006d0c376156 100644 --- a/crates/biome_js_analyze/src/options.rs +++ b/crates/biome_js_analyze/src/options.rs @@ -260,7 +260,7 @@ pub type UseButtonType = pub type UseCollapsedElseIf = ::Options; pub type UseConsistentArrayType = < lint :: style :: use_consistent_array_type :: UseConsistentArrayType as biome_analyze :: Rule > :: Options ; -pub type UseConsistentNewBuiltin = < lint :: nursery :: use_consistent_new_builtin :: UseConsistentNewBuiltin as biome_analyze :: Rule > :: Options ; +pub type UseConsistentBuiltinInstatiation = < lint :: nursery :: use_consistent_builtin_instatiation :: UseConsistentBuiltinInstatiation as biome_analyze :: Rule > :: Options ; pub type UseConst = ::Options; pub type UseDefaultParameterLast = < lint :: style :: use_default_parameter_last :: UseDefaultParameterLast as biome_analyze :: Rule > :: Options ; pub type UseDefaultSwitchClause = < lint :: nursery :: use_default_switch_clause :: UseDefaultSwitchClause as biome_analyze :: Rule > :: Options ; diff --git a/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx b/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx deleted file mode 100644 index 2f0eff654fdf..000000000000 --- a/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import { Component } from 'react'; - -export class MyComponent extends Component { - render() { - return ; - } -} \ No newline at end of file diff --git a/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx.snap b/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx.snap deleted file mode 100644 index f7fd71ea5e2a..000000000000 --- a/crates/biome_js_analyze/tests/specs/correctness/noUndeclaredVariables/thisInJsx.jsx.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/biome_js_analyze/tests/spec_tests.rs -assertion_line: 83 -expression: thisInJsx.jsx ---- -# Input -```jsx -import { Component } from 'react'; - -export class MyComponent extends Component { - render() { - return ; - } -} -``` diff --git a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js similarity index 96% rename from crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js rename to crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js index 4e2ba875040a..d264e1b2d136 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js +++ b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js @@ -32,9 +32,11 @@ function foo() { return /** Start */ globalThis.Object({ foo: 'bar' }) /** End */ } -new String() -new Number() new Boolean() +new BigInt() +new Number() +new String() +new Symbol() new window.String(123) new globalThis.String() function foo() { diff --git a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js.snap similarity index 59% rename from crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js.snap rename to crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js.snap index f4dffe3ced4b..634832703a5f 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/invalid.js.snap @@ -38,9 +38,11 @@ function foo() { return /** Start */ globalThis.Object({ foo: 'bar' }) /** End */ } -new String() -new Number() new Boolean() +new BigInt() +new Number() +new String() +new Symbol() new window.String(123) new globalThis.String() function foo() { @@ -50,7 +52,7 @@ function foo() { # Diagnostics ``` -invalid.js:1:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:1:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Object() instead of Object(). @@ -67,7 +69,7 @@ invalid.js:1:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:2:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:2:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Array() instead of Array(). @@ -85,7 +87,7 @@ invalid.js:2:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:3:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:3:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new ArrayBuffer() instead of ArrayBuffer(). @@ -104,7 +106,7 @@ invalid.js:3:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:4:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:4:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new BigInt64Array() instead of BigInt64Array(). @@ -123,7 +125,7 @@ invalid.js:4:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:5:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:5:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new BigUint64Array() instead of BigUint64Array(). @@ -142,7 +144,7 @@ invalid.js:5:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:6:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:6:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new DataView() instead of DataView(). @@ -161,7 +163,7 @@ invalid.js:6:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:7:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:7:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Date() instead of Date(). @@ -180,7 +182,7 @@ invalid.js:7:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:8:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:8:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Error() instead of Error(). @@ -199,7 +201,7 @@ invalid.js:8:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:9:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:9:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Float32Array() instead of Float32Array(). @@ -218,7 +220,7 @@ invalid.js:9:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━ ``` ``` -invalid.js:10:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:10:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Float64Array() instead of Float64Array(). @@ -237,7 +239,7 @@ invalid.js:10:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:11:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:11:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Function() instead of Function(). @@ -256,7 +258,7 @@ invalid.js:11:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:12:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:12:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Int8Array() instead of Int8Array(). @@ -275,7 +277,7 @@ invalid.js:12:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:13:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:13:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Int16Array() instead of Int16Array(). @@ -294,7 +296,7 @@ invalid.js:13:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:14:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:14:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Int32Array() instead of Int32Array(). @@ -313,7 +315,7 @@ invalid.js:14:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:15:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:15:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Map() instead of Map(). @@ -332,7 +334,7 @@ invalid.js:15:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:16:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:16:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new WeakMap() instead of WeakMap(). @@ -351,7 +353,7 @@ invalid.js:16:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:17:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:17:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Set() instead of Set(). @@ -370,7 +372,7 @@ invalid.js:17:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:18:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:18:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new WeakSet() instead of WeakSet(). @@ -389,7 +391,7 @@ invalid.js:18:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:19:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:19:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Promise() instead of Promise(). @@ -408,7 +410,7 @@ invalid.js:19:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:20:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:20:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new RegExp() instead of RegExp(). @@ -427,7 +429,7 @@ invalid.js:20:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:21:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:21:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Uint8Array() instead of Uint8Array(). @@ -446,7 +448,7 @@ invalid.js:21:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:22:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:22:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Uint16Array() instead of Uint16Array(). @@ -465,7 +467,7 @@ invalid.js:22:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:23:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:23:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Uint32Array() instead of Uint32Array(). @@ -484,7 +486,7 @@ invalid.js:23:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:24:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:24:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Uint8ClampedArray() instead of Uint8ClampedArray(). @@ -503,7 +505,7 @@ invalid.js:24:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:25:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:25:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new SharedArrayBuffer() instead of SharedArrayBuffer(). @@ -522,7 +524,7 @@ invalid.js:25:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:26:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:26:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Proxy() instead of Proxy(). @@ -541,7 +543,7 @@ invalid.js:26:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:27:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:27:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new WeakRef() instead of WeakRef(). @@ -560,7 +562,7 @@ invalid.js:27:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:28:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:28:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new FinalizationRegistry() instead of FinalizationRegistry(). @@ -579,7 +581,7 @@ invalid.js:28:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:29:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:29:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Object() instead of Object(). @@ -598,7 +600,7 @@ invalid.js:29:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:30:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:30:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Object() instead of Object(). @@ -617,7 +619,7 @@ invalid.js:30:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:32:25 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:32:25 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use new Object() instead of Object(). @@ -636,113 +638,151 @@ invalid.js:32:25 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━ ``` ``` -invalid.js:35:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:35:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Use String() instead of new String(). + ! Use Boolean() instead of new Boolean(). 33 │ } 34 │ - > 35 │ new String() + > 35 │ new Boolean() + │ ^^^^^^^^^^^^^ + 36 │ new BigInt() + 37 │ new Number() + + i Unsafe fix: Remove new keyword. + + 35 │ new·Boolean() + │ ---- + +``` + +``` +invalid.js:36:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use BigInt() instead of new BigInt(). + + 35 │ new Boolean() + > 36 │ new BigInt() │ ^^^^^^^^^^^^ - 36 │ new Number() - 37 │ new Boolean() + 37 │ new Number() + 38 │ new String() i Unsafe fix: Remove new keyword. - 35 │ new·String() + 36 │ new·BigInt() │ ---- ``` ``` -invalid.js:36:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:37:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use Number() instead of new Number(). - 35 │ new String() - > 36 │ new Number() + 35 │ new Boolean() + 36 │ new BigInt() + > 37 │ new Number() │ ^^^^^^^^^^^^ - 37 │ new Boolean() - 38 │ new window.String(123) + 38 │ new String() + 39 │ new Symbol() i Unsafe fix: Remove new keyword. - 36 │ new·Number() + 37 │ new·Number() │ ---- ``` ``` -invalid.js:37:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:38:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Use Boolean() instead of new Boolean(). + ! Use String() instead of new String(). - 35 │ new String() - 36 │ new Number() - > 37 │ new Boolean() - │ ^^^^^^^^^^^^^ - 38 │ new window.String(123) - 39 │ new globalThis.String() + 36 │ new BigInt() + 37 │ new Number() + > 38 │ new String() + │ ^^^^^^^^^^^^ + 39 │ new Symbol() + 40 │ new window.String(123) i Unsafe fix: Remove new keyword. - 37 │ new·Boolean() - │ ---- + 38 │ new·String() + │ ---- + +``` + +``` +invalid.js:39:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Use Symbol() instead of new Symbol(). + + 37 │ new Number() + 38 │ new String() + > 39 │ new Symbol() + │ ^^^^^^^^^^^^ + 40 │ new window.String(123) + 41 │ new globalThis.String() + + i Unsafe fix: Remove new keyword. + + 39 │ new·Symbol() + │ ---- ``` ``` -invalid.js:38:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:40:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use String() instead of new String(). - 36 │ new Number() - 37 │ new Boolean() - > 38 │ new window.String(123) + 38 │ new String() + 39 │ new Symbol() + > 40 │ new window.String(123) │ ^^^^^^^^^^^^^^^^^^^^^^ - 39 │ new globalThis.String() - 40 │ function foo() { + 41 │ new globalThis.String() + 42 │ function foo() { i Unsafe fix: Remove new keyword. - 38 │ new·window.String(123) + 40 │ new·window.String(123) │ ---- ``` ``` -invalid.js:39:1 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:41:1 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use String() instead of new String(). - 37 │ new Boolean() - 38 │ new window.String(123) - > 39 │ new globalThis.String() + 39 │ new Symbol() + 40 │ new window.String(123) + > 41 │ new globalThis.String() │ ^^^^^^^^^^^^^^^^^^^^^^^ - 40 │ function foo() { - 41 │ return /** Start */ new globalThis.String("foo") /** End */ + 42 │ function foo() { + 43 │ return /** Start */ new globalThis.String("foo") /** End */ i Unsafe fix: Remove new keyword. - 39 │ new·globalThis.String() + 41 │ new·globalThis.String() │ ---- ``` ``` -invalid.js:41:25 lint/nursery/useConsistentNewBuiltin FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.js:43:25 lint/nursery/useConsistentBuiltinInstatiation FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Use String() instead of new String(). - 39 │ new globalThis.String() - 40 │ function foo() { - > 41 │ return /** Start */ new globalThis.String("foo") /** End */ + 41 │ new globalThis.String() + 42 │ function foo() { + > 43 │ return /** Start */ new globalThis.String("foo") /** End */ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 42 │ } + 44 │ } i Unsafe fix: Remove new keyword. - 41 │ ····return·/**·Start·*/·new·globalThis.String("foo")·/**·End·*/ + 43 │ ····return·/**·Start·*/·new·globalThis.String("foo")·/**·End·*/ │ ---- ``` diff --git a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js similarity index 97% rename from crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js rename to crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js index ee0db4caa817..99054f6e1e75 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js +++ b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js @@ -32,9 +32,11 @@ function foo() { return new globalThis.Object() } -String() -Number() Boolean() +BigInt() +Number() +String() +Symbol() window.String() globalThis.String(123) function foo() { diff --git a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js.snap similarity index 98% rename from crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js.snap rename to crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js.snap index c705032a3fc5..1c9042ea79b6 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/useConsistentNewBuiltin/valid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/useConsistentBuiltinInstatiation/valid.js.snap @@ -38,9 +38,11 @@ function foo() { return new globalThis.Object() } -String() -Number() Boolean() +BigInt() +Number() +String() +Symbol() window.String() globalThis.String(123) function foo() { diff --git a/crates/biome_js_parser/src/syntax/jsx/mod.rs b/crates/biome_js_parser/src/syntax/jsx/mod.rs index 2ac4b6b71d47..19ae4e6964cc 100644 --- a/crates/biome_js_parser/src/syntax/jsx/mod.rs +++ b/crates/biome_js_parser/src/syntax/jsx/mod.rs @@ -409,9 +409,7 @@ fn parse_jsx_expression_child(p: &mut JsParser) -> ParsedSyntax { fn parse_jsx_any_element_name(p: &mut JsParser) -> ParsedSyntax { let name = parse_jsx_name_or_namespace(p); name.map(|mut name| { - if name.kind(p) == JSX_NAME && name.text(p) == "this" { - name.change_kind(p, JS_THIS_EXPRESSION) - } else if name.kind(p) == JSX_NAME && (p.at(T![.]) || !is_intrinsic_element(name.text(p))) { + if name.kind(p) == JSX_NAME && (p.at(T![.]) || !is_intrinsic_element(name.text(p))) { name.change_kind(p, JSX_REFERENCE_IDENTIFIER) } else if name.kind(p) == JSX_NAMESPACE_NAME && p.at(T![.]) { let error = p.err_builder( @@ -436,7 +434,7 @@ fn parse_jsx_any_element_name(p: &mut JsParser) -> ParsedSyntax { /// Tests if this is an intrinsic element name. Intrinsic elements are such elements /// that are built in, for example HTML elements. This implementation uses React's semantic /// and assumes that anything starting with a lower case character is an intrinsic element, and -/// that custom components start with an upper case character. +/// that custom components start with an uper case character. /// /// Resources: [TypeScript's documentation on intrinsic elements](https://www.typescriptlang.org/docs/handbook/jsx.html#intrinsic-elements) fn is_intrinsic_element(element_name: &str) -> bool { diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index b02d3ed64249..6700d9a5fbe7 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -999,7 +999,7 @@ export interface Nursery { /** * Enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt. */ - useConsistentNewBuiltin?: RuleConfiguration_for_Null; + useConsistentBuiltinInstatiation?: RuleConfiguration_for_Null; /** * Require the default clause in switch statements. */ @@ -2005,7 +2005,7 @@ export type Category = | "lint/nursery/noUselessUndefinedInitialization" | "lint/nursery/noUnknownUnit" | "lint/nursery/useBiomeSuppressionComment" - | "lint/nursery/useConsistentNewBuiltin" + | "lint/nursery/useConsistentBuiltinInstatiation" | "lint/nursery/useGenericFontNames" | "lint/nursery/useDefaultSwitchClause" | "lint/nursery/useImportRestrictions" diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index fb7bc6b7b6b3..85ed6c6bc86a 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -1584,7 +1584,7 @@ { "type": "null" } ] }, - "useConsistentNewBuiltin": { + "useConsistentBuiltinInstatiation": { "description": "Enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, diff --git a/packages/@biomejs/biome/package.json b/packages/@biomejs/biome/package.json index 576ef6fc47b4..217a9c985e2c 100644 --- a/packages/@biomejs/biome/package.json +++ b/packages/@biomejs/biome/package.json @@ -1,6 +1,6 @@ { "name": "@biomejs/biome", - "version": "1.7.1", + "version": "1.7.2", "bin": "bin/biome", "scripts": { "postinstall": "node scripts/postinstall.js"