Skip to content

linter: react/exhaustive-deps false negative #9788

@vemoo

Description

@vemoo

What version of Oxlint are you using?

0.15.15

What command did you run?

oxlint ./src

What does your .oxlintrc.json config file look like?

{
    "$schema": "./node_modules/oxlint/configuration_schema.json",
    "rules": {
        "react/exhaustive-deps": "warn",
        "no-unused-vars": "off"
    },
    "env": {
        "builtin": true,
        "browser": true
    },
    "ignorePatterns": ["dist/**", "out/**", "node_modules/**"]
}

What happened?

For this code:

import { useCallback, useEffect } from "react";

function Component({ foo }) {
    const log = useCallback(() => {
        console.log(foo);
    }, [foo]);
    useEffect(() => {
        log();
    }, []);
}

no warning is emitted.

Both react-hooks/exhaustive-deps from eslint-plugin-react-hooks and lint/correctness/useExhaustiveDependencies from biome emit a warning:

react-hooks/exhaustive-deps:

/home/berni/Documents/src/test/linters/src/index.js
  9:8  warning  React Hook useEffect has a missing dependency: 'log'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

✖ 1 problem (0 errors, 1 warning)

lint/correctness/useExhaustiveDependencies:

./src/index.js:7:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ This hook does not specify all of its dependencies: log
  
    5 │         console.log(foo);
    6 │     }, [foo]);
  > 7 │     useEffect(() => {
      │     ^^^^^^^^^
    8 │         log();
    9 │     }, []);
  
  ℹ This dependency is not specified in the hook dependency list.
  
     6 │     }, [foo]);
     7 │     useEffect(() => {
   > 8 │         log();
       │         ^^^
     9 │     }, []);
    10 │ }
  
  ℹ Either include it or remove the dependency array
  

Checked 1 file in 1396µs. No fixes applied.
Found 1 error.
lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Some errors were emitted while running checks.

Metadata

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions