-
-
Notifications
You must be signed in to change notification settings - Fork 726
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.6.0
What command did you run?
No response
What does your .oxlintrc.json config file look like?
What happened?
input with a false positive and a true positive:
import { useEffect, useState } from "react";
export function Test() {
const [state, setState] = useState();
useEffect(() => {
console.log("state", state); // false positive
});
useEffect(() => {
setState(1); // true positive
});
}oxlint output - false positive then true positive:
⚠ eslint-plugin-react-hooks(exhaustive-deps): React Hook useEffect contains a call to setState. Without a list of dependencies, this can lead to an infinite chain of updates.
╭─[test.js:6:3]
5 │
6 │ useEffect(() => {
· ─────────
7 │ console.log("state", state);
╰────
help: Consider adding an empty list of dependencies to make it clear which values are intended to be stable.
⚠ eslint-plugin-react-hooks(exhaustive-deps): React Hook useEffect contains a call to setState. Without a list of dependencies, this can lead to an infinite chain of updates.
╭─[test.js:10:3]
9 │
10 │ useEffect(() => {
· ─────────
11 │ setState(1);
╰────
help: Consider adding an empty list of dependencies to make it clear which values are intended to be stable.
Found 2 warnings and 0 errors.
Finished in 5ms on 2 files using 16 threads.
equivalent eslint (v9.30.1) with eslint.config.js:
import reactHooks from 'eslint-plugin-react-hooks';
export default [
reactHooks.configs['recommended-latest'],
];output - only true positive:
D:\scratch\oxlint-repro\test.js
10:3 warning React Hook useEffect contains a call to 'setState'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [] as a second argument to the useEffect Hook react-hooks/exhaustive-deps
✖ 1 problem (0 errors, 1 warning)
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
{ "plugins": ["react-hooks"] }