Skip to content

Commit

Permalink
fix(lint/noUnusedImports): handle typeof of an imported type (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Oct 20, 2023
1 parent 7d9080c commit 2193230
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 63 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom
#### Bug fixes

- Fix [#548](https://github.com/biomejs/biome/issues/548) which made [noSelfAssign](https://biomejs.dev/linter/rules/no-self-assign) panic.

- Fix [#555](https://github.com/biomejs/biome/issues/555), by correctly map `globals` into the workspace.

- Fix [#557](https://github.com/biomejs/biome/issues/557) which made [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) report imported types used in `typeof` expression. Contributed by @Conaclos

## 1.3.0 (2022-10-19)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface I {}

export declare const x: typeof I;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: invalidtypeof.ts
---
# Input
```js
interface I {}

export declare const x: typeof I;

```

# Diagnostics
```
invalidtypeof.ts:1:11 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! This interface is unused.
> 1 │ interface I {}
│ ^
2 │
3 │ export declare const x: typeof I;
i Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// See https://github.com/biomejs/biome/issues/557
import type Type from "mod";
export const a: typeof Type = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: issue557.ts
---
# Input
```js
// See https://github.com/biomejs/biome/issues/557
import type Type from "mod";
export const a: typeof Type = {};
```


174 changes: 111 additions & 63 deletions crates/biome_js_semantic/src/events.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions website/src/content/docs/internals/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom
#### Bug fixes

- Fix [#548](https://github.com/biomejs/biome/issues/548) which made [noSelfAssign](https://biomejs.dev/linter/rules/no-self-assign) panic.

- Fix [#555](https://github.com/biomejs/biome/issues/555), by correctly map `globals` into the workspace.

- Fix [#557](https://github.com/biomejs/biome/issues/557) which made [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) report imported types used in `typeof` expression. Contributed by @Conaclos

## 1.3.0 (2022-10-19)

Expand Down

0 comments on commit 2193230

Please sign in to comment.