facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
229.89k stars 47.07k forks source link

Bug: exhaustive-deps not working with eslint 9.12.0 #31162

Closed isneace closed 1 month ago

isneace commented 1 month ago

Here is a simplified version of my eslint.config.mjs: (There are a lot more rules, custom plugins, ignores, files specifications, etc. but for the sake of this bug, I think this will do)

import tseslint from 'typescript-eslint';
import reactHooks from 'eslint-plugin-react-hooks';
import { fixupPluginRules } from '@eslint/compat';

export default tseslint.config({
  plugins: {
    'react-hooks': fixupPluginRules(reactHooks),
  },
  rules: {
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'error',
});

Here are the versions that I am running:

yarn list eslint eslint-plugin-react-hooks typescript-eslint

yarn list v1.22.19
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ eslint-plugin-react-hooks@4.6.2
├─ eslint@9.12.0
└─ typescript-eslint@8.8.1
Done in 0.42s.

If I attempt to run yarn eslint without fixupPluginRules I get the following error:

Oops! Something went wrong! :(

ESLint: 9.12.0

TypeError: context.getSource is not a function
Occurred while linting FILE (this is a placeholder)
Rule: "react-hooks/exhaustive-deps"

When I run yarn lint with fixupPluginRules it works fine.

If found the solution to this here: https://eslint.org/docs/latest/use/troubleshooting/v9-rule-api-changes That eslint documentation explicitly states that if fixupPluginRules is required, I should open an issue on the plugin image

eps1lon commented 1 month ago

Fixed in https://github.com/facebook/react/pull/28773