Skip to content

Commit

Permalink
release: v1.7.2 (#2651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Apr 30, 2024
1 parent d7c86f8 commit 2c70d3f
Show file tree
Hide file tree
Showing 22 changed files with 216 additions and 174 deletions.
41 changes: 20 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)).
Expand Down Expand Up @@ -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 <this.foo />;
}
}
```

Contributed by @printfn

- [noMisplacedAssertion](https://biomejs.dev/linter/rules/no-misplaced-assertion/) now allow these matchers

- `expect.any()`
Expand All @@ -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:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions crates/biome_configuration/src/linter/rules.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/biome_diagnostics_categories/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_js_analyze/src/lint/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare_rule! {
/// <Hello class="Doe" />
/// ```
pub NoReactSpecificProps {
version: "next",
version: "1.7.2",
name: "noReactSpecificProps",
sources: &[RuleSource::EslintSolid("no-react-specific-props")],
recommended: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare_rule! {
/// ```
///
pub UseArrayLiterals {
version: "next",
version: "1.7.2",
name: "useArrayLiterals",
sources: &[RuleSource::Eslint("no-array-constructor")],
recommended: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,57 @@ 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
/// - BigUint64Array
/// - 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
///
Expand Down Expand Up @@ -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<JsNewOrCallExpression>;
type State = UseConsistentNewBuiltinState;
type State = UseConsistentBuiltinInstatiationState;
type Signals = Option<Self::State>;
type Options = ();

Expand All @@ -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,
},
Expand Down Expand Up @@ -185,13 +195,15 @@ impl Rule for UseConsistentNewBuiltin {

/// Sorted array of builtins that require new keyword.
const BUILTINS_REQUIRING_NEW: &[&str] = &[
"AggregateError",
"Array",
"ArrayBuffer",
"BigInt64Array",
"BigUint64Array",
"DataView",
"Date",
"Error",
"EvalError",
"FinalizationRegistry",
"Float32Array",
"Float64Array",
Expand All @@ -203,9 +215,14 @@ const BUILTINS_REQUIRING_NEW: &[&str] = &[
"Object",
"Promise",
"Proxy",
"RangeError",
"ReferenceError",
"RegExp",
"Set",
"SharedArrayBuffer",
"SyntaxError",
"TypeError",
"URIError",
"Uint16Array",
"Uint32Array",
"Uint8Array",
Expand All @@ -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,
Expand All @@ -232,7 +249,7 @@ impl BuiltinCreationRule {
}
}

pub struct UseConsistentNewBuiltinState {
pub struct UseConsistentBuiltinInstatiationState {
name: String,
creation_rule: BuiltinCreationRule,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ declare_rule! {
/// }
/// ```
pub UseDefaultSwitchClause {
version: "next",
version: "1.7.2",
name: "useDefaultSwitchClause",
sources: &[RuleSource::Eslint("default-case")],
recommended: false,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub type UseButtonType =
pub type UseCollapsedElseIf =
<lint::style::use_collapsed_else_if::UseCollapsedElseIf as biome_analyze::Rule>::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 = <lint::style::use_const::UseConst as biome_analyze::Rule>::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 ;
Expand Down

This file was deleted.

Loading

0 comments on commit 2c70d3f

Please sign in to comment.