-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve import namespace handling
- Loading branch information
Showing
12 changed files
with
339 additions
and
29 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
5 changes: 5 additions & 0 deletions
5
...ome_js_analyze/tests/specs/correctness/noUndeclaredVariables/invalidNamesapceReference.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,5 @@ | ||
import * as Ns1 from ""; | ||
export type T1 = Ns1; // This doesn't reference the import namespace `Ns1` | ||
|
||
import type * as Ns2 from ""; | ||
export type T2 = Ns2; // This doesn't reference the import namespace `Ns1` |
39 changes: 39 additions & 0 deletions
39
...s_analyze/tests/specs/correctness/noUndeclaredVariables/invalidNamesapceReference.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,39 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalidNamesapceReference.ts | ||
--- | ||
# Input | ||
```ts | ||
import * as Ns1 from ""; | ||
export type T1 = Ns1; // This doesn't reference the import namespace `Ns1` | ||
|
||
import type * as Ns2 from ""; | ||
export type T2 = Ns2; // This doesn't reference the import namespace `Ns1` | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalidNamesapceReference.ts:2:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The Ns1 variable is undeclared | ||
1 │ import * as Ns1 from ""; | ||
> 2 │ export type T1 = Ns1; // This doesn't reference the import namespace `Ns1` | ||
│ ^^^ | ||
3 │ | ||
4 │ import type * as Ns2 from ""; | ||
``` | ||
|
||
``` | ||
invalidNamesapceReference.ts:5:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The Ns2 variable is undeclared | ||
4 │ import type * as Ns2 from ""; | ||
> 5 │ export type T2 = Ns2; // This doesn't reference the import namespace `Ns1` | ||
│ ^^^ | ||
``` |
5 changes: 5 additions & 0 deletions
5
crates/biome_js_analyze/tests/specs/correctness/noUnusedImports/invalid-import-namespace.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,5 @@ | ||
import * as Ns1 from "" | ||
export type T1 = Ns1; | ||
|
||
import type * as Ns2 from "" | ||
export type T2 = Ns2; |
56 changes: 56 additions & 0 deletions
56
...biome_js_analyze/tests/specs/correctness/noUnusedImports/invalid-import-namespace.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,56 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalid-import-namespace.ts | ||
--- | ||
# Input | ||
```ts | ||
import * as Ns1 from "" | ||
export type T1 = Ns1; | ||
|
||
import type * as Ns2 from "" | ||
export type T2 = Ns2; | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalid-import-namespace.ts:1:13 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
> 1 │ import * as Ns1 from "" | ||
│ ^^^ | ||
2 │ export type T1 = Ns1; | ||
3 │ | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
1 │ import·*·as·Ns1·from·"" | ||
│ ----------------------- | ||
``` | ||
|
||
``` | ||
invalid-import-namespace.ts:4:18 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This import is unused. | ||
2 │ export type T1 = Ns1; | ||
3 │ | ||
> 4 │ import type * as Ns2 from "" | ||
│ ^^^ | ||
5 │ export type T2 = Ns2; | ||
i Unused imports might be the result of an incomplete refactoring. | ||
i Safe fix: Remove the unused import. | ||
1 1 │ import * as Ns1 from "" | ||
2 2 │ export type T1 = Ns1; | ||
3 │ - | ||
4 │ - import·type·*·as·Ns2·from·"" | ||
5 3 │ export type T2 = Ns2; | ||
``` |
2 changes: 2 additions & 0 deletions
2
...es/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validNamesapceExportType.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,2 @@ | ||
namespace Ns {} | ||
export type { Ns } |
9 changes: 9 additions & 0 deletions
9
...ome_js_analyze/tests/specs/correctness/noUnusedVariables/validNamesapceExportType.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,9 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: validNamesapceExportType.ts | ||
--- | ||
# Input | ||
```ts | ||
namespace Ns {} | ||
export type { Ns } | ||
``` |
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
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
Oops, something went wrong.