Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/oxc_linter/src/rules/react/exhaustive_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ fn dependency_array_not_array_literal_diagnostic(hook_name: &str, span: Span) ->
.with_error_code_scope(SCOPE)
}

fn literal_in_dependency_array_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("The literal is not a valid dependency because it never changes.")
fn duplicate_dependency_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("This dependency is specified more than once in the dependency array.")
.with_label(span)
.with_help("Remove the literal from the array.")
.with_help("Remove the duplicate dependency from the array.")
.with_error_code_scope(SCOPE)
}

Expand Down Expand Up @@ -545,7 +545,7 @@ impl Rule for ExhaustiveDeps {
for item in declared_dependencies_iter {
let span = item.span;
if !declared_dependencies.insert(item) {
ctx.diagnostic(literal_in_dependency_array_diagnostic(span));
ctx.diagnostic(duplicate_dependency_diagnostic(span));
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_linter/src/snapshots/react_exhaustive_deps.snap
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ source: crates/oxc_linter/src/tester.rs
╰────
help: Either include it or remove the dependency array.

⚠ eslint-plugin-react-hooks(exhaustive-deps): The literal is not a valid dependency because it never changes.
⚠ eslint-plugin-react-hooks(exhaustive-deps): This dependency is specified more than once in the dependency array.
╭─[exhaustive_deps.tsx:6:22]
5 │ console.log(local);
6 │ }, [local, local]);
· ─────
7 │ }
╰────
help: Remove the literal from the array.
help: Remove the duplicate dependency from the array.

⚠ eslint-plugin-react-hooks(exhaustive-deps): React hook useEffect depends on `local`, which changes every render
╭─[exhaustive_deps.tsx:2:17]
Expand Down Expand Up @@ -877,14 +877,14 @@ source: crates/oxc_linter/src/tester.rs
╰────
help: Either include it or remove the dependency array.

⚠ eslint-plugin-react-hooks(exhaustive-deps): The literal is not a valid dependency because it never changes.
⚠ eslint-plugin-react-hooks(exhaustive-deps): This dependency is specified more than once in the dependency array.
╭─[exhaustive_deps.tsx:5:22]
4 │ console.log(local);
5 │ }, [local, local]);
· ─────
6 │ }
╰────
help: Remove the literal from the array.
help: Remove the duplicate dependency from the array.

⚠ eslint-plugin-react-hooks(exhaustive-deps): React hook useEffect depends on `local`, which changes every render
╭─[exhaustive_deps.tsx:5:15]
Expand Down
Loading