Skip to content

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

Closed

Description

@pkelly-rh

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

Activity

  1. added
    Status: Unconfirmed
    on Oct 12, 2021
  2. pkelly-rh commented on Oct 12, 2021

    @pkelly-rh
    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?

  3. mcrawshaw commented on Oct 12, 2021

    @mcrawshaw

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

  4. eps1lon commented on Oct 13, 2021

    @eps1lon
    Collaborator

    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.

  5. caribou-code commented on Oct 25, 2021

    @caribou-code

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

  6. Bessonov commented on Oct 27, 2021

    @Bessonov

    @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
  7. geekftz commented on Oct 28, 2021

    @geekftz

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

  8. pkelly-rh commented on Oct 28, 2021

    @pkelly-rh
    Author

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

  9. paul-mesnilgrente commented on Nov 4, 2021

    @paul-mesnilgrente

    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.

  10. a-tonchev commented on Nov 4, 2021

    @a-tonchev

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

    This works for me, thanks!

  11. Dangoo commented on Nov 10, 2021

    @Dangoo

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: ESLint RulesStatus: Unconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions