Skip to content

Commit 4d5fc0e

Browse files
fix(biome_js_analyze): fixed noInvalidUseBeforeDeclaration false positives (#6794)
1 parent 1a57b51 commit 4d5fc0e

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#6719](https://github.com/biomejs/biome/issues/6719): The `noInvalidUseBeforeDeclaration` rule covers additional use cases.
6+
7+
Examples:
8+
9+
```ts
10+
type Bar = {[BAR]: true;};
11+
const BAR = 'bar';
12+
```
13+
14+
```ts
15+
interface Bar {child: {grandChild: {[BAR]: typeof BAR; enumFoo: EnumFoo}}}
16+
const BAR = 'bar';
17+
enum EnumFoo {BAR = 'bar'}
18+
```

crates/biome_js_analyze/src/services/control_flow/visitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use biome_js_syntax::{
55
AnyJsFunction, JsConstructorClassMember, JsGetterClassMember, JsGetterObjectMember, JsLanguage,
66
JsMethodClassMember, JsMethodObjectMember, JsModule, JsScript, JsSetterClassMember,
77
JsSetterObjectMember, JsStaticInitializationBlockClassMember, TsModuleDeclaration,
8+
TsPropertySignatureTypeMember,
89
};
910
use biome_rowan::{AstNode, SyntaxError, SyntaxResult, declare_node_union};
1011

@@ -171,6 +172,7 @@ declare_node_union! {
171172
| JsSetterClassMember
172173
| JsStaticInitializationBlockClassMember
173174
| TsModuleDeclaration
175+
| TsPropertySignatureTypeMember
174176
}
175177

176178
impl biome_analyze::NodeVisitor<ControlFlowVisitor> for FunctionVisitor {

crates/biome_js_analyze/tests/specs/correctness/noInvalidUseBeforeDeclaration/valid.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ namespace N {
1515
}
1616

1717
type X = typeof X; const X = 0;
18+
19+
type Bar = {[BAR]: true;};
20+
const BAR = 'bar';
21+
22+
interface NestedBar {child: {grandChild: {[FOO]: typeof FOO; enumFoo: EnumFoo}}}
23+
const FOO = 'foo';
24+
enum EnumFoo {BAR = 'bar'}
25+
26+

crates/biome_js_analyze/tests/specs/correctness/noInvalidUseBeforeDeclaration/valid.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: crates/biome_js_analyze/tests/spec_tests.rs
3+
assertion_line: 135
34
expression: valid.ts
45
---
56
# Input
@@ -22,4 +23,13 @@ namespace N {
2223
2324
type X = typeof X; const X = 0;
2425
26+
type Bar = {[BAR]: true;};
27+
const BAR = 'bar';
28+
29+
interface NestedBar {child: {grandChild: {[FOO]: typeof FOO; enumFoo: EnumFoo}}}
30+
const FOO = 'foo';
31+
enum EnumFoo {BAR = 'bar'}
32+
33+
34+
2535
```

0 commit comments

Comments
 (0)