Bug: Rules with suggestions must set the `meta.hasSuggestions` property to `true`

10
closed
pkelly-rh
pkelly-rh
Posted 1 month ago

Bug: Rules with suggestions must set the `meta.hasSuggestions` property to `true` #22545

I'm basically running into an issue where eslint is asking me to set meta.hasSuggestions to true. When I use "react-hooks/exhaustive-deps": "error". Is there something I'm doing wrong or is this a dep version thing?

React version:

Steps To Reproduce

  1. Have my eslint config:
{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:react-hooks/recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 13,
    "sourceType": "module"
  },
  "plugins": ["react", "react-hooks", "@typescript-eslint"],
  "rules": {
    "react-hooks/exhaustive-deps": "error",
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

Here's my deps from package.json

{
"dependecies": {
    "eslint": "^8.0.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-react": "^7.26.1",
    "eslint-plugin-react-hooks": "^4.2.0",
}

If I try to remove the react-hook plugin and extension this happens: Definition for rule 'react-hooks/exhaustive-deps' was not found

Link to code example:

The current behavior

The expected behavior

pkelly-rh
pkelly-rh
Created 1 month ago

Straight from the horses mouth. This fixed it helped me fix it: https://lifesaver.codes/answer/eslint-feedback-for-exhaustive-deps-lint-rule

Install: npm install [email protected]

And changed the eslint config to:

{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 13,
    "sourceType": "module"
  },
  "plugins": ["react", "react-hooks", "@typescript-eslint"],
  "rules": {
    "react-hooks/exhaustive-deps": "error",
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

@gaearon why didn't this just work out of the box?

mcrawshaw
mcrawshaw
Created 1 month ago

There was just a major version release of eslint (with breaking changes), so a few dep packages are still catching up.

eps1lon
eps1lon
Created 1 month ago

Fixed in https://github.com/facebook/react/pull/22248 which hasn't been released yet.

Keeping this open for visibility. We've had similar reports before and open issues have better visibility.

caribou-code
caribou-code
Created 1 month ago

Is there a release date for this yet? Looks like the fix was merged on 6 Sept.

Bessonov
Bessonov
Created 1 month ago

@caribou-code yeah, it's pity, but you can get the next version with the fix through your package manager:

pnpm add -DW [email protected]
hackftz
hackftz
Created 1 month ago

try to install "[email protected]" can resolve the question.

pkelly-rh
pkelly-rh
Created 1 month ago

Running npm install [email protected] worked for me

paul-mesnilgrente
paul-mesnilgrente
Created 3 weeks ago

Looks like we're still waiting on a new release. Is there any ETA?

I'm going to move to [email protected] for now.

a-tonchev
a-tonchev
Created 3 weeks ago

Running npm install [email protected] worked for me

This works for me, thanks!

Dangoo
Dangoo
Created 2 weeks ago

Looks like v4.3 was just released some hours ago which should ship ESLint 8 support: https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/CHANGELOG.md#430

See as well #22248

Previous