Skip to content

Commit

Permalink
fix(lint/useExhaustiveDependencies): do not panic on TS import equal (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Jan 18, 2024
1 parent badc93f commit 44ebe0c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

Contributed by @Conaclos

- [useExhaustiveDependencies](https://biomejs.dev/linter/use-exhaustive-dependencies) no longer made Biome errors in code TypeScript import equal declarations ([#1194](https://github.com/biomejs/biome/issues/1194)). Contributed by @Conaclos

### Parser


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,15 @@ fn capture_needs_to_be_in_the_dependency_list(
| AnyJsBindingDeclaration::TsDeclareFunctionExportDefaultDeclaration(_)
| AnyJsBindingDeclaration::JsCatchDeclaration(_) => Some(capture),

// Ignore TypeScript `import <id> =`
AnyJsBindingDeclaration::TsImportEqualsDeclaration(_) => None,

// This should be unreachable because of the test if the capture is imported
AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsBogusNamedImportSpecifier(_)
| AnyJsBindingDeclaration::JsDefaultImportSpecifier(_)
| AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_)
| AnyJsBindingDeclaration::TsImportEqualsDeclaration(_) => {
| AnyJsBindingDeclaration::JsNamespaceImportSpecifier(_) => {
unreachable!()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useMemo } from 'react';

enum Foo {
A = 1,
}

import Foo2 = Foo;

const useBad = () => {
useMemo(() => {
2 === Foo2.A;
}, []);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: issue1194.ts
---
# Input
```ts
import { useMemo } from 'react';

enum Foo {
A = 1,
}

import Foo2 = Foo;

const useBad = () => {
useMemo(() => {
2 === Foo2.A;
}, []);
};
```


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 @@ -63,6 +63,8 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom

Contributed by @Conaclos

- [useExhaustiveDependencies](https://biomejs.dev/linter/use-exhaustive-dependencies) no longer made Biome errors in code TypeScript import equal declarations ([#1194](https://github.com/biomejs/biome/issues/1194)). Contributed by @Conaclos

### Parser


Expand Down

0 comments on commit 44ebe0c

Please sign in to comment.