-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lint/noUnusedImports): add ignoreReact option (#2306)
- Loading branch information
Showing
13 changed files
with
404 additions
and
14 deletions.
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
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
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
8 changes: 8 additions & 0 deletions
8
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/invalid-unused-react.jsx
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,8 @@ | ||
import X from "react" | ||
import * as X from "react" | ||
import { default as X } from "react" | ||
|
||
import React from "x" | ||
import * as React from "x" | ||
import { default as React } from "x" | ||
import React, { useEffect } from "x" |
199 changes: 199 additions & 0 deletions
199
...es/biome_js_analyze/tests/specs/correctness/noUnusedImports/invalid-unused-react.jsx.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,199 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalid-unused-react.jsx | ||
--- | ||
# Input | ||
```jsx | ||
import X from "react" | ||
import * as X from "react" | ||
import { default as X } from "react" | ||
|
||
import React from "x" | ||
import * as React from "x" | ||
import { default as React } from "x" | ||
import React, { useEffect } from "x" | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalid-unused-react.jsx:1:8 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
> 1 │ import X from "react" | ||
│ ^ | ||
2 │ import * as X from "react" | ||
3 │ import { default as X } from "react" | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
1 │ import·X·from·"react" | ||
│ --------------------- | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:2:13 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
1 │ import X from "react" | ||
> 2 │ import * as X from "react" | ||
│ ^ | ||
3 │ import { default as X } from "react" | ||
4 │ | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
1 1 │ import X from "react" | ||
2 │ - import·*·as·X·from·"react" | ||
3 2 │ import { default as X } from "react" | ||
4 3 │ | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:3:21 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
1 │ import X from "react" | ||
2 │ import * as X from "react" | ||
> 3 │ import { default as X } from "react" | ||
│ ^ | ||
4 │ | ||
5 │ import React from "x" | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
1 1 │ import X from "react" | ||
2 2 │ import * as X from "react" | ||
3 │ - import·{·default·as·X·}·from·"react" | ||
4 3 │ | ||
5 4 │ import React from "x" | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:5:8 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
3 │ import { default as X } from "react" | ||
4 │ | ||
> 5 │ import React from "x" | ||
│ ^^^^^ | ||
6 │ import * as React from "x" | ||
7 │ import { default as React } from "x" | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
2 2 │ import * as X from "react" | ||
3 3 │ import { default as X } from "react" | ||
4 │ - | ||
5 │ - import·React·from·"x" | ||
6 4 │ import * as React from "x" | ||
7 5 │ import { default as React } from "x" | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:6:13 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
5 │ import React from "x" | ||
> 6 │ import * as React from "x" | ||
│ ^^^^^ | ||
7 │ import { default as React } from "x" | ||
8 │ import React, { useEffect } from "x" | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
4 4 │ | ||
5 5 │ import React from "x" | ||
6 │ - import·*·as·React·from·"x" | ||
7 6 │ import { default as React } from "x" | ||
8 7 │ import React, { useEffect } from "x" | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:7:21 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
5 │ import React from "x" | ||
6 │ import * as React from "x" | ||
> 7 │ import { default as React } from "x" | ||
│ ^^^^^ | ||
8 │ import React, { useEffect } from "x" | ||
9 │ | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
5 5 │ import React from "x" | ||
6 6 │ import * as React from "x" | ||
7 │ - import·{·default·as·React·}·from·"x" | ||
8 7 │ import React, { useEffect } from "x" | ||
9 8 │ | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:8:8 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
6 │ import * as React from "x" | ||
7 │ import { default as React } from "x" | ||
> 8 │ import React, { useEffect } from "x" | ||
│ ^^^^^ | ||
9 │ | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
8 │ import·React,·{·useEffect·}·from·"x" | ||
│ ------- | ||
``` | ||
|
||
``` | ||
invalid-unused-react.jsx:8:17 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
6 │ import * as React from "x" | ||
7 │ import { default as React } from "x" | ||
> 8 │ import React, { useEffect } from "x" | ||
│ ^^^^^^^^^ | ||
9 │ | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
8 │ import·React,·{·useEffect·}·from·"x" | ||
│ --------------- | ||
``` |
14 changes: 14 additions & 0 deletions
14
...iome_js_analyze/tests/specs/correctness/noUnusedImports/invalid-unused-react.options.json
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,14 @@ | ||
{ | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noUnusedImports": { | ||
"level": "error", | ||
"options": { | ||
"ignoreReact": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/valid-unused-react.jsx
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,3 @@ | ||
import React from "react" | ||
import { default as React } from "react" | ||
import * as React from "react" |
Oops, something went wrong.