Skip to content

Commit 04c8d15

Browse files
committed
fixed newline errors + snap tests
1 parent 4ab8a86 commit 04c8d15

18 files changed

+275
-49
lines changed

crates/biome_cli/tests/snapshots/main_cases_rules_via_dependencies/enables_react_rules_via_dependencies.snap

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Component2() {
2525
console.log(local);
2626
}, [local, local]);
2727
}
28-
28+
2929
```
3030

3131
# Termination Message
@@ -34,7 +34,7 @@ function Component2() {
3434
lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3535
3636
× Some errors were emitted while running checks.
37-
37+
3838
3939
4040
```
@@ -45,104 +45,108 @@ lint ━━━━━━━━━━━━━━━━━━━━━━━━━
4545
test.jsx:4:10 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4646
4747
! This function Component2 is unused.
48-
48+
4949
2 │ import { useCallback } from "react";
50-
3 │
50+
3 │
5151
> 4 │ function Component2() {
5252
^^^^^^^^^^
5353
5const [local,SetLocal] = useState(0);
5454
6const handle = useCallback(() => {
55-
55+
5656
i Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
57-
57+
5858
i Unsafe fix: If this is intentional, prepend Component2 with an underscore.
59-
59+
6060
2 2import { useCallback } from "react";
61-
3 3
61+
3 3
6262
4- function·Component2()·{
6363
4+ function·_Component2()·{
6464
5 5const [local,SetLocal] = useState(0);
6565
6 6const handle = useCallback(() => {
66-
66+
6767
6868
```
6969
7070
```block
7171
test.jsx:5:18 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
7272
7373
! This variable SetLocal is unused.
74-
74+
7575
4function Component2() {
7676
> 5const [local,SetLocal] = useState(0);
7777
^^^^^^^^
7878
6const handle = useCallback(() => {
7979
7console.log(local);
80-
80+
8181
i Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
82-
82+
8383
i Unsafe fix: If this is intentional, prepend SetLocal with an underscore.
84-
85-
3 3
84+
85+
3 3
8686
4 4function Component2() {
8787
5- ····const·[local,SetLocal]·=·useState(0);
8888
5+ ····const·[local,_SetLocal]·=·useState(0);
8989
6 6const handle = useCallback(() => {
9090
7 7console.log(local);
91-
91+
9292
9393
```
9494
9595
```block
9696
test.jsx:6:11 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
9797
9898
! This variable handle is unused.
99-
99+
100100
4function Component2() {
101101
5const [local,SetLocal] = useState(0);
102102
> 6const handle = useCallback(() => {
103103
^^^^^^
104104
7console.log(local);
105105
8 │ }, [local, local]);
106-
106+
107107
i Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
108-
108+
109109
i Unsafe fix: If this is intentional, prepend handle with an underscore.
110-
110+
111111
4 4function Component2() {
112112
5 5const [local,SetLocal] = useState(0);
113113
6- ····const·handle·=·useCallback(()·=>·{
114114
6 │ + ····const·_handle·=·useCallback(()·=>·{
115115
7 7console.log(local);
116116
8 8 │ }, [local, local]);
117-
117+
118118
119119
```
120120
121121
```block
122122
test.jsx:6:20 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
123123
124-
× This hook specifies more dependencies than necessary: local
125-
124+
× This hook specifies more dependencies than necessary: local.
125+
126126
4function Component2() {
127127
5const [local,SetLocal] = useState(0);
128128
> 6const handle = useCallback(() => {
129129
^^^^^^^^^^^
130130
7console.log(local);
131131
8 │ }, [local, local]);
132-
132+
133133
i This dependency can be removed from the list.
134-
134+
135135
6const handle = useCallback(() => {
136136
7console.log(local);
137137
> 8 │ }, [local, local]);
138138
^^^^^
139139
9 │ }
140-
10
141-
140+
10
141+
142+
i React relies on hook dependencies to determine when to re-compute Effects.
143+
Specifying more dependencies than required can lead to unnecessary re-rendering
144+
and degraded performance.
145+
142146
i Unsafe fix: Remove the extra dependencies from the list.
143-
147+
144148
8 │ ····},·[locallocal]);
145-
-------
149+
-------
146150
147151
```
148152

crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ declare_lint_rule! {
338338
/// ```jsx,use_options
339339
/// function Foo() {
340340
/// let stateVar = 1;
341-
/// // not used but still OK due to disabled rule
341+
/// // not used but still OK
342342
/// useEffect(() => {}, [stateVar]);
343343
/// }
344344
/// ```
@@ -1008,7 +1008,7 @@ impl Rule for UseExhaustiveDependencies {
10081008
"This hook "<Emphasis>"does not specify"</Emphasis>" its dependency on "<Emphasis>{capture_text.as_ref()}</Emphasis>"."
10091009
},
10101010
).note(markup! {
1011-
"\nReact relies on hook dependencies to determine when to re-compute Effects."
1011+
"React relies on hook dependencies to determine when to re-compute Effects."
10121012
"\nFailing to specify dependencies can result in Effects "<Emphasis>"not updating correctly"</Emphasis>" when state changes."
10131013
"\nThese \"stale closures\" are a common source of surprising bugs."
10141014
},
@@ -1046,9 +1046,9 @@ impl Rule for UseExhaustiveDependencies {
10461046
},
10471047
)
10481048
.note(markup! {
1049-
"\nReact relies on hook dependencies to determine when to re-compute Effects."
1049+
"React relies on hook dependencies to determine when to re-compute Effects."
10501050
"\nSpecifying more dependencies than required can lead to "<Emphasis>"unnecessary re-rendering"</Emphasis>
1051-
" and "<Emphasis>"degraded performance"</Emphasis>"."
1051+
"\nand "<Emphasis>"degraded performance"</Emphasis>"."
10521052
},
10531053
);
10541054

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ checkHooksImportedFromReact.js:3:9 lint/correctness/useExhaustiveDependencies F
4949
5 │ }, []);
5050
6
5151
52+
i React relies on hook dependencies to determine when to re-compute Effects.
53+
Failing to specify dependencies can result in Effects not updating correctly when state changes.
54+
These "stale closures" are a common source of surprising bugs.
55+
5256
i Either include it or remove the dependency array.
5357
5458
i Unsafe fix: Add the missing dependency to the list.

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ customHook.js:5:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━
4545
7 │ }, []);
4646
8
4747
48+
i React relies on hook dependencies to determine when to re-compute Effects.
49+
Failing to specify dependencies can result in Effects not updating correctly when state changes.
50+
These "stale closures" are a common source of surprising bugs.
51+
4852
i Either include it or remove the dependency array.
4953
5054
i Unsafe fix: Add the missing dependency to the list.
@@ -74,6 +78,10 @@ customHook.js:9:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━
7478
11}, []);
7579
12 │
7680
81+
i React relies on hook dependencies to determine when to re-compute Effects.
82+
Failing to specify dependencies can result in Effects not updating correctly when state changes.
83+
These "stale closures" are a common source of surprising bugs.
84+
7785
i Either include it or remove the dependency array.
7886
7987
i Unsafe fix: Add the missing dependency to the list.

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/duplicateDependencies.js.snap

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Component2() {
2424
```
2525
duplicateDependencies.js:4:20 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━━━━
2626
27-
× This hook specifies more dependencies than necessary: a
27+
× This hook specifies more dependencies than necessary: a.
2828
2929
3 │ function Component1({ a }) {
3030
> 4const handle = useCallback(() => {
@@ -41,6 +41,10 @@ duplicateDependencies.js:4:20 lint/correctness/useExhaustiveDependencies FIXABL
4141
7}
4242
8 │
4343
44+
i React relies on hook dependencies to determine when to re-compute Effects.
45+
Specifying more dependencies than required can lead to unnecessary re-rendering
46+
and degraded performance.
47+
4448
i Unsafe fix: Remove the extra dependencies from the list.
4549
4650
6 │ ····},·[a,·a]);
@@ -51,7 +55,7 @@ duplicateDependencies.js:4:20 lint/correctness/useExhaustiveDependencies FIXABL
5155
```
5256
duplicateDependencies.js:11:20 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━━━
5357
54-
× This hook specifies more dependencies than necessary: local
58+
× This hook specifies more dependencies than necessary: local.
5559
5660
9 │ function Component2() {
5761
10const [local,SetLocal] = useState(0);
@@ -68,6 +72,10 @@ duplicateDependencies.js:11:20 lint/correctness/useExhaustiveDependencies FIXAB
6872
^^^^^
6973
14}
7074
75+
i React relies on hook dependencies to determine when to re-compute Effects.
76+
Specifying more dependencies than required can lead to unnecessary re-rendering
77+
and degraded performance.
78+
7179
i Unsafe fix: Remove the extra dependencies from the list.
7280
7381
13 │ ····},·[local,·local]);

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function MyComponent3() {
5050
```
5151
extraDependenciesInvalid.js:5:3 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━━
5252
53-
× This hook specifies more dependencies than necessary: a
53+
× This hook specifies more dependencies than necessary: a.
5454
5555
3 │ function MyComponent() {
5656
4let a = 1;
@@ -68,6 +68,10 @@ extraDependenciesInvalid.js:5:3 lint/correctness/useExhaustiveDependencies FIXA
6868
6}
6969
7 │
7070
71+
i React relies on hook dependencies to determine when to re-compute Effects.
72+
Specifying more dependencies than required can lead to unnecessary re-rendering
73+
and degraded performance.
74+
7175
i Unsafe fix: Remove the extra dependencies from the list.
7276
7377
5 │ ··useEffect(()·=>·{},·[a]);
@@ -78,7 +82,7 @@ extraDependenciesInvalid.js:5:3 lint/correctness/useExhaustiveDependencies FIXA
7882
```
7983
extraDependenciesInvalid.js:12:3 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━
8084
81-
× This hook specifies more dependencies than necessary: a, b
85+
× This hook specifies more dependencies than necessary: a, b.
8286
8387
10 │ function MyComponent2() {
8488
11let a = 1, b = 1;
@@ -105,6 +109,10 @@ extraDependenciesInvalid.js:12:3 lint/correctness/useExhaustiveDependencies FIX
105109
13}
106110
14 │
107111
112+
i React relies on hook dependencies to determine when to re-compute Effects.
113+
Specifying more dependencies than required can lead to unnecessary re-rendering
114+
and degraded performance.
115+
108116
i Unsafe fix: Remove the extra dependencies from the list.
109117
110118
12 │ ··useEffect(()·=>·{},·[a,·b]);
@@ -115,7 +123,7 @@ extraDependenciesInvalid.js:12:3 lint/correctness/useExhaustiveDependencies FIX
115123
```
116124
extraDependenciesInvalid.js:19:3 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━
117125
118-
× This hook specifies more dependencies than necessary: a
126+
× This hook specifies more dependencies than necessary: a.
119127
120128
17 │ function MyComponent2() {
121129
18const a = 1;
@@ -133,6 +141,10 @@ extraDependenciesInvalid.js:19:3 lint/correctness/useExhaustiveDependencies FIX
133141
20}
134142
21 │
135143
144+
i React relies on hook dependencies to determine when to re-compute Effects.
145+
Specifying more dependencies than required can lead to unnecessary re-rendering
146+
and degraded performance.
147+
136148
i Unsafe fix: Remove the extra dependencies from the list.
137149
138150
19 │ ··useEffect(()·=>·{},·[a]);
@@ -143,7 +155,7 @@ extraDependenciesInvalid.js:19:3 lint/correctness/useExhaustiveDependencies FIX
143155
```
144156
extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━
145157
146-
× This hook specifies a dependency more specific that its captures: someObj.id
158+
× This hook specifies a dependency more specific than its captures: someObj.id
147159
148160
26 │ function MyComponent1() {
149161
27let someObj = getObj();
@@ -194,6 +206,10 @@ extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies FIX
194206
30 │ }, [someObj.id]);
195207
31}
196208
209+
i React relies on hook dependencies to determine when to re-compute Effects.
210+
Failing to specify dependencies can result in Effects not updating correctly when state changes.
211+
These "stale closures" are a common source of surprising bugs.
212+
197213
i Unsafe fix: Add the missing dependency to the list.
198214
199215
30 │ ··},·[someObj.id,·someObj]);
@@ -204,7 +220,7 @@ extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies FIX
204220
```
205221
extraDependenciesInvalid.js:36:3 lint/correctness/useExhaustiveDependencies FIXABLE ━━━━━━━━━━━━━━
206222
207-
× This hook specifies more dependencies than necessary: outer
223+
× This hook specifies more dependencies than necessary: outer.
208224
209225
34 │ // Dependencies from outer scope should not be valid
210226
35 │ function MyComponent3() {
@@ -222,6 +238,10 @@ extraDependenciesInvalid.js:36:3 lint/correctness/useExhaustiveDependencies FIX
222238
39}
223239
40 │
224240
241+
i React relies on hook dependencies to determine when to re-compute Effects.
242+
Specifying more dependencies than required can lead to unnecessary re-rendering
243+
and degraded performance.
244+
225245
i Unsafe fix: Remove the extra dependencies from the list.
226246
227247
38 │ ··},·[outer]);

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ ignoredDependencies.js:8:5 lint/correctness/useExhaustiveDependencies FIXABLE
4949
10}, []);
5050
11 │ }
5151
52+
i React relies on hook dependencies to determine when to re-compute Effects.
53+
Failing to specify dependencies can result in Effects not updating correctly when state changes.
54+
These "stale closures" are a common source of surprising bugs.
55+
5256
i Either include it or remove the dependency array.
5357
5458
i Unsafe fix: Add the missing dependency to the list.

0 commit comments

Comments
 (0)