diff --git a/.changeset/deep-women-retire.md b/.changeset/deep-women-retire.md new file mode 100644 index 000000000000..24d4ce12c5af --- /dev/null +++ b/.changeset/deep-women-retire.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fixed [#7813](https://github.com/biomejs/biome/issues/7813): improved the diagnostic of the rule [`useExhaustiveDependencies`](https://biomejs.dev/linter/rules/use-exhaustive-dependencies/). The diagnostic now shows the name of the variable to add to the dependency array. diff --git a/crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs b/crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs index d0f0024fd5fa..710b8d81e948 100644 --- a/crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs +++ b/crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs @@ -1627,11 +1627,12 @@ impl Rule for UseExhaustiveDependencies { let message = match state { Fix::AddDependency { - captures: (_, captures), + captures, dependencies_array, .. } => { - let new_elements = captures.first().into_iter().filter_map(|node| { + let (capture_text, captures_range) = captures; + let new_elements = captures_range.first().into_iter().filter_map(|node| { if let Some(jsx_ref) = JsxReferenceIdentifier::cast_ref(node) { return Some(AnyJsArrayElement::AnyJsExpression( make::js_identifier_expression(make::js_reference_identifier( @@ -1662,7 +1663,7 @@ impl Rule for UseExhaustiveDependencies { recreate_array(dependencies_array, elements), ); - markup! { "Add the missing dependency to the list." } + markup! { "Add the missing dependency "{capture_text.as_ref()}" to the list." } } Fix::RemoveDependency { dependencies, diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.ts.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.ts.snap index 9cfe023a0608..e719be276f25 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.ts.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.ts.snap @@ -111,7 +111,7 @@ customHook.ts:14:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 16 │ ····},·[a]); │ + @@ -200,7 +200,7 @@ customHook.ts:46:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 46 │ ····useEvenMoreEffect([],·["foo",·a],·()·=>·{ │ +++ @@ -232,7 +232,7 @@ customHook.ts:46:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency b to the list. 46 │ ····useEvenMoreEffect([],·["foo",·b],·()·=>·{ │ +++ @@ -348,7 +348,7 @@ customHook.ts:61:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 61 │ ····doSomething([a],·"apple",·()·=>·{ │ + @@ -382,7 +382,7 @@ customHook.ts:61:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency b to the list. 61 │ ····doSomething([b],·"apple",·()·=>·{ │ + @@ -414,7 +414,7 @@ customHook.ts:64:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 64 │ ····doSomething(["a·b",·a],·[a],·()·=>·{ │ +++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap index ab1f62b40113..7ff955da4d22 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap @@ -210,7 +210,7 @@ extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies FIX Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency someObj to the list. 30 │ ··},·[someObj.id,·someObj]); │ +++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap index b91f30850f16..b9781faba99b 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap @@ -55,7 +55,7 @@ ignoredDependencies.js:8:5 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 10 │ ····},·[a]); │ + diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snap index 30dcf64afcca..5bb19045a299 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snap @@ -61,7 +61,7 @@ issue1931.js:9:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency calc to the list. 13 │ ····},·[calc]); │ ++++ @@ -95,7 +95,7 @@ issue1931.js:21:19 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency calc to the list. 25 │ ····},·[calc]); │ ++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3080.ts.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3080.ts.snap index 2432578eb92e..9359409272cb 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3080.ts.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3080.ts.snap @@ -52,7 +52,7 @@ issue3080.ts:5:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency bar to the list. 8 │ ····},·[bar]); │ +++ @@ -86,7 +86,7 @@ issue3080.ts:5:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency foo to the list. 8 │ ····},·[foo]); │ +++ @@ -119,7 +119,7 @@ issue3080.ts:16:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency bar to the list. 16 │ ····useEffect(myEffect,·[bar]); │ +++ @@ -151,7 +151,7 @@ issue3080.ts:16:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency foo to the list. 16 │ ····useEffect(myEffect,·[foo]); │ +++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3512.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3512.js.snap index 9278bfd25660..15b4a8055e93 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3512.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue3512.js.snap @@ -108,7 +108,7 @@ issue3512.js:18:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency y to the list. 20 │ ····},·[x,·y]); │ +++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue5914.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue5914.js.snap index e77768c6d4eb..831dff0f20bf 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue5914.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue5914.js.snap @@ -63,7 +63,7 @@ issue5914.js:14:16 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency varA to the list. 14 │ ········varB·=·useMemo(()·=>·varA,·[varA]) │ ++++ @@ -97,7 +97,7 @@ issue5914.js:26:18 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency varA to the list. 26 │ ····const·varB·=·useMemo(()·=>·varA,·[varA]); │ ++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snap index b97496717182..07520cc5e486 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snap @@ -51,7 +51,7 @@ issue6278.js:4:8 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency myFn to the list. 7 │ → },·[myFn]); │ ++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snap index 59c72a712470..4bc6ac92b6d3 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snap @@ -42,7 +42,7 @@ issue6893.js:5:8 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency firstId to the list. 7 │ → },·[firstId]) │ +++++++ @@ -75,7 +75,7 @@ issue6893.js:5:8 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency secondId to the list. 7 │ → },·[secondId]) │ ++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue7982.ts.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue7982.ts.snap index 2fc4789882cc..68140d2f1ac5 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue7982.ts.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue7982.ts.snap @@ -57,7 +57,7 @@ issue7982.ts:8:26 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency count to the list. 10 │ ····},·[count]); │ +++++ @@ -90,7 +90,7 @@ issue7982.ts:13:27 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency count to the list. 17 │ ········[count], │ +++++ @@ -123,7 +123,7 @@ issue7982.ts:20:35 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency count to the list. 22 │ ····},·[count])·as·Function; │ +++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8427.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8427.js.snap index bbe963bca53e..06e42fd9f9de 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8427.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8427.js.snap @@ -67,7 +67,7 @@ issue8427.js:6:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency fe to the list. 8 │ ····},·[id,·fe]); │ ++++ @@ -99,7 +99,7 @@ issue8427.js:13:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ Failing to specify dependencies can result in Effects not updating correctly when state changes. These "stale closures" are a common source of surprising bugs. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency fetchEntity to the list. 15 │ ····},·[id,·fetchEntity]) │ +++++++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts.snap index 875abd260b61..d6fa3d62ec76 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts.snap @@ -55,7 +55,7 @@ issue8802.ts:17:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency props.value to the list. 19 │ ····},·[props.value]); │ +++++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8883.tsx.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8883.tsx.snap index 0dd447099537..adb5339bdda8 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8883.tsx.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8883.tsx.snap @@ -54,7 +54,7 @@ issue8883.tsx:18:5 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency msg to the list. 18 │ ····useEffect(()·=>·console.log(msg),·[msg]);·//·should·trigger·useExhaustiveDependencies │ +++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8907Reassigned.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8907Reassigned.js.snap index 1d342912da3c..60f2fbc85da9 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8907Reassigned.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8907Reassigned.js.snap @@ -55,7 +55,7 @@ issue8907Reassigned.js:8:3 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency setA to the list. 10 │ ··},·[setA]); │ ++++ @@ -88,7 +88,7 @@ issue8907Reassigned.js:18:3 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency b.current to the list. 20 │ ··},·[b.current]); │ +++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/jsxDependencies.jsx.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/jsxDependencies.jsx.snap index 47130a9689ac..fd2e3bbda6fe 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/jsxDependencies.jsx.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/jsxDependencies.jsx.snap @@ -62,7 +62,7 @@ jsxDependencies.jsx:8:22 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency Sub to the list. 8 │ ··const·renderItem·=·useCallback(()·=>·,·[Sub·]) │ ++++ @@ -94,7 +94,7 @@ jsxDependencies.jsx:28:22 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency LocalSub to the list. 28 │ ····const·memoized·=·useCallback(()·=>·,·[LocalSub·]); │ +++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snap index d5a685715bbb..6adf652420c1 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snap @@ -227,7 +227,7 @@ missingDependenciesInvalid.jsx:19:5 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 21 │ ····},·[a]); │ + @@ -261,7 +261,7 @@ missingDependenciesInvalid.jsx:19:5 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency b to the list. 21 │ ····},·[b]); │ + @@ -295,7 +295,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency deferredValue to the list. 48 │ ··},·[deferredValue]); │ +++++++++++++ @@ -329,7 +329,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency memoizedCallback to the list. 48 │ ··},·[memoizedCallback]); │ ++++++++++++++++ @@ -363,7 +363,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency state to the list. 48 │ ··},·[state]); │ +++++ @@ -397,7 +397,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency name to the list. 48 │ ··},·[name]); │ ++++ @@ -431,7 +431,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency isPending to the list. 48 │ ··},·[isPending]); │ +++++++++ @@ -464,7 +464,7 @@ missingDependenciesInvalid.jsx:34:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency memoizedValue to the list. 48 │ ··},·[memoizedValue]); │ +++++++++++++ @@ -498,7 +498,7 @@ missingDependenciesInvalid.jsx:55:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 55 │ ··useEffect(()·=>·console.log(a),·[a]); │ + @@ -532,7 +532,7 @@ missingDependenciesInvalid.jsx:56:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 56 │ ··useCallback(()·=>·console.log(a),·[a]); │ + @@ -566,7 +566,7 @@ missingDependenciesInvalid.jsx:57:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 57 │ ··useMemo(()·=>·console.log(a),·[a]); │ + @@ -600,7 +600,7 @@ missingDependenciesInvalid.jsx:58:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 58 │ ··useImperativeHandle(ref,·()·=>·console.log(a),·[a]); │ + @@ -634,7 +634,7 @@ missingDependenciesInvalid.jsx:59:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 59 │ ··useLayoutEffect(()·=>·console.log(a),·[a]); │ + @@ -668,7 +668,7 @@ missingDependenciesInvalid.jsx:60:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 60 │ ··useInsertionEffect(()·=>·console.log(a),·[a]); │ + @@ -702,7 +702,7 @@ missingDependenciesInvalid.jsx:67:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 69 │ ··},·[a]); │ + @@ -745,7 +745,7 @@ missingDependenciesInvalid.jsx:76:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 79 │ ··},·[a]); │ + @@ -779,7 +779,7 @@ missingDependenciesInvalid.jsx:86:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency someObj.name to the list. 88 │ ··},·[someObj.name]); │ ++++++++++++ @@ -812,7 +812,7 @@ missingDependenciesInvalid.jsx:92:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 94 │ ··},·[a]); │ + @@ -845,7 +845,7 @@ missingDependenciesInvalid.jsx:98:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 100 │ ··},·[a]); │ + @@ -879,7 +879,7 @@ missingDependenciesInvalid.jsx:106:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 108 │ ··},·[a]); │ + @@ -913,7 +913,7 @@ missingDependenciesInvalid.jsx:113:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 115 │ ··},·[a]); │ + @@ -947,7 +947,7 @@ missingDependenciesInvalid.jsx:121:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 123 │ ··},·[a]); │ + @@ -981,7 +981,7 @@ missingDependenciesInvalid.jsx:128:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 130 │ ··},·[a]); │ + @@ -1015,7 +1015,7 @@ missingDependenciesInvalid.jsx:136:9 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 138 │ ··},·[a]); │ + @@ -1049,7 +1049,7 @@ missingDependenciesInvalid.jsx:144:2 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency ref.current to the list. 146 │ → },·[ref.current]); │ +++++++++++ @@ -1083,7 +1083,7 @@ missingDependenciesInvalid.jsx:155:2 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency ref.current to the list. 157 │ → },·[ref.current]); │ +++++++++++ @@ -1116,7 +1116,7 @@ missingDependenciesInvalid.jsx:168:3 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency func to the list. 170 │ ··},·[func]) │ ++++ @@ -1149,7 +1149,7 @@ missingDependenciesInvalid.jsx:176:2 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 178 │ → },·[a]); │ + @@ -1182,7 +1182,7 @@ missingDependenciesInvalid.jsx:185:2 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency a to the list. 187 │ → },·[a]); │ + @@ -1215,7 +1215,7 @@ missingDependenciesInvalid.jsx:185:2 lint/correctness/useExhaustiveDependencies i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency b to the list. 187 │ → },·[b]); │ + diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snap index cb30073ed7a7..3fa9a603243a 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snap @@ -45,7 +45,7 @@ preactHooks.js:6:23 lint/correctness/useExhaustiveDependencies FIXABLE ━━ i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency value to the list. 8 │ ····},·[value]); │ +++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snap index 071d61521f50..c6df399a60b5 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snap @@ -42,7 +42,7 @@ stableResultInvalid.js:6:22 lint/correctness/useExhaustiveDependencies FIXABLE i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency dispatch to the list. 6 │ ····const·doAction·=·useCallback(()·=>·dispatch(someAction()),·[dispatch]); │ ++++++++ diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snap index e9db6b08f834..ab832b974808 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snap @@ -57,7 +57,7 @@ stableResultInvalidKeysIndices.js:6:22 lint/correctness/useExhaustiveDependencie i Either include it or remove the dependency array. - i Unsafe fix: Add the missing dependency to the list. + i Unsafe fix: Add the missing dependency dispatch to the list. 6 │ ····const·doAction·=·useCallback(()·=>·dispatch(someAction()),·[dispatch]); │ ++++++++