Skip to content

linter: eslint-plugin-react-hooks not working with underscored function #14475

@skovhus

Description

@skovhus

What version of Oxlint are you using?

1.22.0

What command did you run?

No response

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

{
  "rules": {
    "react-hooks/rules-of-hooks": "warn"
  }
}

What happened?

False positive for eslint-plugin-react-hooks when prefixing component function with _

This is marked as invalid, but fairly comment to preview a mobx wrapped component with _

import { observer } from "mobx-react-lite";

export const CommentLikeActivityEntry = observer(function _CommentLikeActivityEntry({
  const reduceMotion = useReducedMotion() ?? false;
  return null;
});

As a workaround this works:

import { observer } from "mobx-react-lite";

export const CommentLikeActivityEntry = observer(function CommentLikeActivityEntry_({
  const reduceMotion = useReducedMotion() ?? false;
  return null;
});

React Hook "useReducedMotion" is called in function "_CommentLikeActivityEntry" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".oxc[eslint-plugin-react-hooks(rules-of-hooks)](https://oxc.rs/docs/guide/usage/linter/rules/react/rules-of-hooks.html)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions