From f53812b3e70c8bb71fb98e758a9204f029c52bca Mon Sep 17 00:00:00 2001 From: Ze-Zheng Wu Date: Fri, 29 Mar 2024 21:02:43 +0800 Subject: [PATCH] chore: codegen --- crates/biome_rowan/src/ast/mod.rs | 2 +- .../linter/rules/no-duplicate-object-keys.md | 12 +++---- .../rules/no-extra-non-null-assertion.md | 4 +-- .../docs/linter/rules/no-focused-tests.md | 12 +++---- .../docs/linter/rules/no-inferrable-types.md | 34 +++++++++++++------ .../linter/rules/no-redundant-use-strict.md | 17 ++++------ .../docs/linter/rules/no-skipped-tests.md | 12 +++---- .../linter/rules/no-switch-declarations.md | 27 +++++++-------- .../docs/linter/rules/no-this-in-static.md | 8 ++--- .../docs/linter/rules/no-unused-imports.md | 10 +++--- .../linter/rules/no-useless-switch-case.md | 11 +++--- .../linter/rules/no-useless-this-alias.md | 5 ++- .../linter/rules/use-as-const-assertion.md | 4 +-- .../content/docs/linter/rules/use-is-array.md | 2 +- .../linter/rules/use-single-case-statement.md | 3 +- 15 files changed, 77 insertions(+), 86 deletions(-) diff --git a/crates/biome_rowan/src/ast/mod.rs b/crates/biome_rowan/src/ast/mod.rs index b938efb6f6e6..ff7c1d9d26b8 100644 --- a/crates/biome_rowan/src/ast/mod.rs +++ b/crates/biome_rowan/src/ast/mod.rs @@ -733,7 +733,7 @@ impl> DoubleEndedIterator let node = match self.slots.next_back() { None => panic!("Malformed separated list, expected a node but found none"), - Some(SyntaxSlot::Empty{..}) => Err(SyntaxError::MissingRequiredChild), + Some(SyntaxSlot::Empty{ .. }) => Err(SyntaxError::MissingRequiredChild), Some(SyntaxSlot::Token(token)) => panic!("Malformed list, node expected but found token {:?} instead. You must add missing markers for missing elements.", token), Some(SyntaxSlot::Node(node)) => { Ok(N::unwrap_cast(node)) diff --git a/website/src/content/docs/linter/rules/no-duplicate-object-keys.md b/website/src/content/docs/linter/rules/no-duplicate-object-keys.md index e36791cdc3b2..3af25d8c9cf4 100644 --- a/website/src/content/docs/linter/rules/no-duplicate-object-keys.md +++ b/website/src/content/docs/linter/rules/no-duplicate-object-keys.md @@ -49,11 +49,9 @@ const obj = { Unsafe fix: Remove this property value named a 1 1 const obj = { - 2 - ···a:·1, - 3 - ···a:·2, - 2+ ···a:·2, + 2 - ···a:·1, + 3 2 a: 2, 4 3 } - 5 4 @@ -88,11 +86,9 @@ const obj = { Unsafe fix: Remove this setter named a 1 1 const obj = { - 2 - ···set·a(v)·{}, - 3 - ···a:·2, - 2+ ···a:·2, + 2 - ···set·a(v)·{}, + 3 2 a: 2, 4 3 } - 5 4 diff --git a/website/src/content/docs/linter/rules/no-extra-non-null-assertion.md b/website/src/content/docs/linter/rules/no-extra-non-null-assertion.md index 528268043dc5..b85aa6cbdc8f 100644 --- a/website/src/content/docs/linter/rules/no-extra-non-null-assertion.md +++ b/website/src/content/docs/linter/rules/no-extra-non-null-assertion.md @@ -33,8 +33,8 @@ const bar = foo!!.bar; Safe fix: Remove extra non-null assertion. - 1 │ const·bar·=·foo!!.bar; - - + 1 │ const·bar·=·foo!!.bar; + - ```ts diff --git a/website/src/content/docs/linter/rules/no-focused-tests.md b/website/src/content/docs/linter/rules/no-focused-tests.md index 2dc2bc57d3ec..d088a9682fb3 100644 --- a/website/src/content/docs/linter/rules/no-focused-tests.md +++ b/website/src/content/docs/linter/rules/no-focused-tests.md @@ -38,10 +38,8 @@ describe.only("foo", () => {}); Unsafe fix: Remove focus from test. - 1 - describe.only("foo",·()·=>·{}); - 1+ describe("foo",·()·=>·{}); - 2 2 - + 1 │ describe.only("foo",·()·=>·{}); + ----- ```jsx @@ -62,10 +60,8 @@ test.only("foo", () => {}); Unsafe fix: Remove focus from test. - 1 - test.only("foo",·()·=>·{}); - 1+ test("foo",·()·=>·{}); - 2 2 - + 1 │ test.only("foo",·()·=>·{}); + ----- ### Valid diff --git a/website/src/content/docs/linter/rules/no-inferrable-types.md b/website/src/content/docs/linter/rules/no-inferrable-types.md index 2b783c08a557..d436e5702736 100644 --- a/website/src/content/docs/linter/rules/no-inferrable-types.md +++ b/website/src/content/docs/linter/rules/no-inferrable-types.md @@ -38,8 +38,10 @@ const variable: 1 = 1; Safe fix: Remove the type annotation. - 1 │ const·variable:·1·=·1; - --- + 1 - const·variable:·1·=·1; + 1+ const·variable·=·1; + 2 2 + ```ts @@ -56,8 +58,10 @@ let variable: number = 1; Safe fix: Remove the type annotation. - 1 │ let·variable:·number·=·1; - -------- + 1 - let·variable:·number·=·1; + 1+ let·variable·=·1; + 2 2 + ```ts @@ -78,8 +82,12 @@ class SomeClass { Safe fix: Remove the type annotation. - 2 │ ··readonly·field:·1·=·1; - --- + 1 1 class SomeClass { + 2 - ··readonly·field:·1·=·1; + 2+ ··readonly·field·=·1; + 3 3 } + 4 4 + ```ts @@ -100,8 +108,12 @@ class SomeClass { Safe fix: Remove the type annotation. - 2 │ ··field:·number·=·1; - -------- + 1 1 class SomeClass { + 2 - ··field:·number·=·1; + 2+ ··field·=·1; + 3 3 } + 4 4 + ```ts @@ -118,8 +130,10 @@ function f(param: number = 1): void {} Safe fix: Remove the type annotation. - 1 │ function·f(param:·number·=·1):·void·{} - -------- + 1 - function·f(param:·number·=·1):·void·{} + 1+ function·f(param·=·1):·void·{} + 2 2 + ### Valid diff --git a/website/src/content/docs/linter/rules/no-redundant-use-strict.md b/website/src/content/docs/linter/rules/no-redundant-use-strict.md index 0f442a3155b3..01a8578bd861 100644 --- a/website/src/content/docs/linter/rules/no-redundant-use-strict.md +++ b/website/src/content/docs/linter/rules/no-redundant-use-strict.md @@ -43,9 +43,8 @@ function foo() { 1 1 "use strict"; 2 2 function foo() { - 3 - ·"use·strict"; - 4 - } - 3+ ·} + 3 - ·"use·strict"; + 4 3 } 5 4 @@ -155,11 +154,9 @@ class C1 { 1 1 class C1 { 2 2 test() { - 3 - "use·strict"; - 4 - } - 3+ } + 3 - "use·strict"; + 4 3 } 5 4 } - 6 5 @@ -198,11 +195,9 @@ const C2 = class { 1 1 const C2 = class { 2 2 test() { - 3 - "use·strict"; - 4 - } - 3+ } + 3 - "use·strict"; + 4 3 } 5 4 }; - 6 5 diff --git a/website/src/content/docs/linter/rules/no-skipped-tests.md b/website/src/content/docs/linter/rules/no-skipped-tests.md index 593f495f32c0..16da0041f03f 100644 --- a/website/src/content/docs/linter/rules/no-skipped-tests.md +++ b/website/src/content/docs/linter/rules/no-skipped-tests.md @@ -36,10 +36,8 @@ describe.skip("test", () => {}); Unsafe fix: Enable the test. - 1 - describe.skip("test",·()·=>·{}); - 1+ describe("test",·()·=>·{}); - 2 2 - + 1 │ describe.skip("test",·()·=>·{}); + ----- ```jsx @@ -60,10 +58,8 @@ test.skip("test", () => {}); Unsafe fix: Enable the test. - 1 - test.skip("test",·()·=>·{}); - 1+ test("test",·()·=>·{}); - 2 2 - + 1 │ test.skip("test",·()·=>·{}); + ----- ## Valid diff --git a/website/src/content/docs/linter/rules/no-switch-declarations.md b/website/src/content/docs/linter/rules/no-switch-declarations.md index 9f94a20ed8f4..93e1eb5a068a 100644 --- a/website/src/content/docs/linter/rules/no-switch-declarations.md +++ b/website/src/content/docs/linter/rules/no-switch-declarations.md @@ -61,12 +61,11 @@ switch (foo) { 2 - ····case·0: 2+ ····case·0:·{ 3 3 const x = 1; - 4 4 break; - 5 - ····case·2: - 5+ ····} - 6+ ····case·2: + 4 - ········break; + 4+ ········break; + 5+ ····} + 5 6 case 2: 6 7 x; // `x` can be used while it is not initialized - 7 8 break; @@ -110,12 +109,11 @@ switch (foo) { 2 - ····case·0: 2+ ····case·0:·{ 3 3 function f() {} - 4 4 break; - 5 - ····case·2: - 5+ ····} - 6+ ····case·2: + 4 - ········break; + 4+ ········break; + 5+ ····} + 5 6 case 2: 6 7 f(); // `f` can be called here - 7 8 break; @@ -159,12 +157,11 @@ switch (foo) { 2 - ····case·0: 2+ ····case·0:·{ 3 3 class A {} - 4 4 break; - 5 - ····default: - 5+ ····} - 6+ ····default: + 4 - ········break; + 4+ ········break; + 5+ ····} + 5 6 default: 6 7 new A(); // `A` can be instantiated here - 7 8 break; diff --git a/website/src/content/docs/linter/rules/no-this-in-static.md b/website/src/content/docs/linter/rules/no-this-in-static.md index de63b4e1f8f2..d3a33847bf06 100644 --- a/website/src/content/docs/linter/rules/no-this-in-static.md +++ b/website/src/content/docs/linter/rules/no-this-in-static.md @@ -53,8 +53,8 @@ misunderstandings and bugs that can arise from the unique behavior of `this` and 3 3 4 4 static foo() { - 5 - ········this.CONSTANT; - 5+ ········A.CONSTANT; + 5 - ········this.CONSTANT; + 5+ ········A.CONSTANT; 6 6 } 7 7 } @@ -85,8 +85,8 @@ misunderstandings and bugs that can arise from the unique behavior of `this` and 1 1 class B extends A { 2 2 static bar() { - 3 - ········super.CONSTANT; - 3+ ········A.CONSTANT; + 3 - ········super.CONSTANT; + 3+ ········A.CONSTANT; 4 4 } 5 5 } diff --git a/website/src/content/docs/linter/rules/no-unused-imports.md b/website/src/content/docs/linter/rules/no-unused-imports.md index 798dacdc6a5d..f3dda0dbbc35 100644 --- a/website/src/content/docs/linter/rules/no-unused-imports.md +++ b/website/src/content/docs/linter/rules/no-unused-imports.md @@ -30,9 +30,8 @@ import A from 'mod'; Safe fix: Remove the unused import. - 1 - import·A·from·'mod'; - 2 - - + 1 │ import·A·from·'mod'; + -------------------- ```jsx @@ -51,9 +50,8 @@ import * as A from 'mod'; Safe fix: Remove the unused import. - 1 - import·*·as·A·from·'mod'; - 2 - - + 1 │ import·*·as·A·from·'mod'; + ------------------------- ```ts diff --git a/website/src/content/docs/linter/rules/no-useless-switch-case.md b/website/src/content/docs/linter/rules/no-useless-switch-case.md index da905e160a9f..57e89a9c4194 100644 --- a/website/src/content/docs/linter/rules/no-useless-switch-case.md +++ b/website/src/content/docs/linter/rules/no-useless-switch-case.md @@ -55,11 +55,9 @@ switch (foo) { Unsafe fix: Remove the useless case. 1 1 switch (foo) { - 2 - ····case·0: - 3 - ····default: - 2+ ····default: + 2 - ····case·0: + 3 2 default: 4 3 break; - 5 4 case 1: @@ -97,8 +95,9 @@ switch (foo) { Unsafe fix: Remove the useless case. 1 1 switch (foo) { - 2 2 default: - 3 - ····case·0: + 2 - ····default: + 3 - ····case·0: + 2+ ····default: 4 3 break; 5 4 case 1: diff --git a/website/src/content/docs/linter/rules/no-useless-this-alias.md b/website/src/content/docs/linter/rules/no-useless-this-alias.md index 0d3a61e26313..30be067aab6e 100644 --- a/website/src/content/docs/linter/rules/no-useless-this-alias.md +++ b/website/src/content/docs/linter/rules/no-useless-this-alias.md @@ -47,10 +47,9 @@ class A { 1 1 class A { 2 2 method() { - 3 - ········const·self·=·this; - 4 - ········return·()·=>·{ + 3 - ········const·self·=·this; + 4 3 return () => { 5 - ············return·self; - 3+ ········return·()·=>·{ 4+ ············return·this; 6 5 } 7 6 } diff --git a/website/src/content/docs/linter/rules/use-as-const-assertion.md b/website/src/content/docs/linter/rules/use-as-const-assertion.md index af7298408333..dbb16cf8e097 100644 --- a/website/src/content/docs/linter/rules/use-as-const-assertion.md +++ b/website/src/content/docs/linter/rules/use-as-const-assertion.md @@ -40,8 +40,8 @@ let bar: 2 = 2; Safe fix: Replace with as const. - 1 - let·bar:·2·=·2; - 1+ let·bar·=·2·as·const; + 1 - let·bar:·2·=·2; + 1+ let·bar·=·2·as·const; 2 2 diff --git a/website/src/content/docs/linter/rules/use-is-array.md b/website/src/content/docs/linter/rules/use-is-array.md index 30ab7b4280e0..cb3dc27f782d 100644 --- a/website/src/content/docs/linter/rules/use-is-array.md +++ b/website/src/content/docs/linter/rules/use-is-array.md @@ -43,7 +43,7 @@ if (xs instanceof Array) {} 1 1 const xs = []; 2 - if·(xs·instanceof·Array)·{} - 2+ if·(Array.isArray(xs))·{} + 2+ if·(Array.isArray(xs))·{} 3 3 diff --git a/website/src/content/docs/linter/rules/use-single-case-statement.md b/website/src/content/docs/linter/rules/use-single-case-statement.md index 24e4ce70d340..ebca83c2352d 100644 --- a/website/src/content/docs/linter/rules/use-single-case-statement.md +++ b/website/src/content/docs/linter/rules/use-single-case-statement.md @@ -39,7 +39,8 @@ switch (foo) { 3 - ····case·false: 3+ ····case·false:·{ 4 4 let foo = ''; - 5 5 foo; + 5 - ········foo; + 5+ ········foo; 6+ ····} 6 7 } 7 8