Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pkelly-rh opened this issue Oct 12, 2021 · 10 comments
Closed
Labels
Component: ESLint Rules Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@pkelly-rh
Copy link

pkelly-rh commented Oct 12, 2021

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 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Oct 12, 2021
@pkelly-rh
Copy link
Author

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 eslint-plugin-react-hooks@next

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
Copy link

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

@eps1lon
Copy link
Collaborator

eps1lon commented Oct 13, 2021

Fixed in #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
Copy link

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

@Bessonov
Copy link

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

pnpm add -DW eslint-plugin-react-hooks@next

@geekftz
Copy link

geekftz commented Oct 28, 2021

try to install "eslint-plugin-react-hooks@next" can resolve the question.

@pkelly-rh
Copy link
Author

Running npm install eslint-plugin-react-hooks@next worked for me

@paul-mesnilgrente
Copy link

paul-mesnilgrente commented Nov 4, 2021

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

I'm going to move to eslint-plugin-react-hooks@next for now.

@a-tonchev
Copy link

Running npm install eslint-plugin-react-hooks@next worked for me

This works for me, thanks!

@Dangoo
Copy link

Dangoo commented Nov 10, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ESLint Rules Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

10 participants