Skip to content

🐛 When using React hook prefix, exhaustive deps breaks #578

@crutchcorn

Description

@crutchcorn

Environment information

↳  pnpm biome rage
CLI:
  Version:                      1.3.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v18.16.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.9.2"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

While the following works as-expected:

import {useState, useEffect} from "react";

const Comp = () => {
  const [count, setCount] = useState(0)

  useEffect(() => {
    setCount(v => v+1);
  }, [])
  
  return null;
}

Aliasing React like so:

import * as React from "react";

const Comp = () => {
  const [count, setCount] = React.useState(0)

  React.useEffect(() => {
    setCount(v => v+1);
  }, [])
  
  return null;
}

Forces the following error to be thrown:

This hook do not specify all of its dependencies.

Playground link

Expected result

No errors to be thrown in the code sample listed above

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LinterArea: linterS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions