-
-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(analyzer): suppression comment fails with inner comments in funct…
…ions
- Loading branch information
1 parent
81fdedb
commit cfe66c3
Showing
3 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/suppressionComments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// biome-ignore lint/complexity/useArrowFunction: work | ||
const foo0 = function (bar: string) { | ||
// biome-ignore lint/style/noParameterAssign: allow | ||
bar = "baz"; | ||
}; | ||
|
||
// biome-ignore lint/complexity/useArrowFunction: work | ||
const foo1 = function () { | ||
// biome-ignore lint/suspicious/noExplicitAny: work | ||
let bar: any; | ||
}; |
133 changes: 133 additions & 0 deletions
133
crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/suppressionComments.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: suppressionComments.ts | ||
snapshot_kind: text | ||
--- | ||
# Input | ||
```ts | ||
// biome-ignore lint/complexity/useArrowFunction: work | ||
const foo0 = function (bar: string) { | ||
// biome-ignore lint/style/noParameterAssign: allow | ||
bar = "baz"; | ||
}; | ||
|
||
// biome-ignore lint/complexity/useArrowFunction: work | ||
const foo1 = function () { | ||
// biome-ignore lint/suspicious/noExplicitAny: work | ||
let bar: any; | ||
}; | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
suppressionComments.ts:2:14 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This function expression can be turned into an arrow function. | ||
1 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
> 2 │ const foo0 = function (bar: string) { | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
> 3 │ // biome-ignore lint/style/noParameterAssign: allow | ||
> 4 │ bar = "baz"; | ||
> 5 │ }; | ||
│ ^ | ||
6 │ | ||
7 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
i Function expressions that don't use this can be turned into arrow functions. | ||
i Safe fix: Use an arrow function instead. | ||
1 1 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
2 │ - const·foo0·=·function·(bar:·string)·{ | ||
2 │ + const·foo0·=·(bar:·string)·=>·{ | ||
3 3 │ // biome-ignore lint/style/noParameterAssign: allow | ||
4 4 │ bar = "baz"; | ||
``` | ||
|
||
``` | ||
suppressionComments.ts:8:14 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This function expression can be turned into an arrow function. | ||
7 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
> 8 │ const foo1 = function () { | ||
│ ^^^^^^^^^^^^^ | ||
> 9 │ // biome-ignore lint/suspicious/noExplicitAny: work | ||
> 10 │ let bar: any; | ||
> 11 │ }; | ||
│ ^ | ||
i Function expressions that don't use this can be turned into arrow functions. | ||
i Safe fix: Use an arrow function instead. | ||
6 6 │ | ||
7 7 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
8 │ - const·foo1·=·function·()·{ | ||
8 │ + const·foo1·=·()·=>·{ | ||
9 9 │ // biome-ignore lint/suspicious/noExplicitAny: work | ||
10 10 │ let bar: any; | ||
``` | ||
|
||
``` | ||
suppressionComments.ts:1:1 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule. | ||
> 1 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
2 │ const foo0 = function (bar: string) { | ||
3 │ // biome-ignore lint/style/noParameterAssign: allow | ||
``` | ||
|
||
``` | ||
suppressionComments.ts:3:2 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule. | ||
1 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
2 │ const foo0 = function (bar: string) { | ||
> 3 │ // biome-ignore lint/style/noParameterAssign: allow | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
4 │ bar = "baz"; | ||
5 │ }; | ||
``` | ||
|
||
``` | ||
suppressionComments.ts:7:1 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule. | ||
5 │ }; | ||
6 │ | ||
> 7 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
8 │ const foo1 = function () { | ||
9 │ // biome-ignore lint/suspicious/noExplicitAny: work | ||
``` | ||
|
||
``` | ||
suppressionComments.ts:9:5 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule. | ||
7 │ // biome-ignore lint/complexity/useArrowFunction: work | ||
8 │ const foo1 = function () { | ||
> 9 │ // biome-ignore lint/suspicious/noExplicitAny: work | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
10 │ let bar: any; | ||
11 │ }; | ||
``` |