eslint-plugin-react-hooks
ESLint rules for React Hooks
Last updated 15 days ago by gaearon .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install eslint-plugin-react-hooks 
SYNC missed versions from official npm registry.

eslint-plugin-react-hooks

This ESLint plugin enforces the Rules of Hooks.

It is a part of the Hooks API for React.

Installation

Note: If you're using Create React App, please use react-scripts >= 3 instead of adding it directly.

Assuming you already have ESLint installed, run:

# npm
npm install eslint-plugin-react-hooks --save-dev

# yarn
yarn add eslint-plugin-react-hooks --dev

Then extend the recommended eslint config:

{
  "extends": [
    // ...
    "plugin:react-hooks/recommended"
  ]
}

Custom Configuration

If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:

{
  "plugins": [
    // ...
    "react-hooks"
  ],
  "rules": {
    // ...
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn"
  }
}

Advanced Configuration

exhaustive-deps can be configured to validate dependencies of custom Hooks with the additionalHooks option. This option accepts a regex to match the names of custom Hooks that have dependencies.

{
  "rules": {
    // ...
    "react-hooks/exhaustive-deps": ["warn", {
      "additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
    }]
  }
}

We suggest to use this option very sparingly, if at all. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.

Valid and Invalid Examples

Please refer to the Rules of Hooks documentation and the Hooks FAQ to learn more about this rule.

License

MIT

Current Tags

  • 0.0.0-experimental-94c0244ba                                ...           experimental (2 months ago)
  • 4.1.2                                ...           latest (15 days ago)
  • 4.2.0-rc.2                                ...           next (5 days ago)
  • 0.0.0-4e6999103                                ...           untagged (a month ago)

128 Versions

  • 4.2.0-rc.2                                ...           5 days ago
  • 0.0.0-3834174dd                                ...           5 days ago
  • 4.1.2                                ...           15 days ago
  • 4.1.1                                ...           16 days ago
  • 0.0.0-4e6999103                                ...           a month ago
  • 4.1.0                                ...           a month ago
  • 4.1.0-rc.0                                ...           2 months ago
  • 0.0.0-experimental-94c0244ba                                ...           2 months ago
  • 0.0.0-94c0244ba                                ...           2 months ago
  • 0.0.0-experimental-f77c7b9d7                                ...           2 months ago
  • 0.0.0-f77c7b9d7                                ...           2 months ago
  • 0.0.0-experimental-3d0895557                                ...           2 months ago
  • 0.0.0-3d0895557                                ...           2 months ago
  • 0.0.0-experimental-ede917064                                ...           2 months ago
  • 0.0.0-experimental-4c8c98ab9                                ...           2 months ago
  • 4.0.8                                ...           2 months ago
  • 4.0.7                                ...           3 months ago
  • 4.0.6                                ...           3 months ago
  • 4.0.5                                ...           3 months ago
  • 0.0.0-experimental-7f28234f8                                ...           3 months ago
  • 0.0.0-7f28234f8                                ...           3 months ago
  • 4.0.4                                ...           4 months ago
  • 4.0.3                                ...           4 months ago
  • 4.0.2                                ...           4 months ago
  • 4.0.1                                ...           4 months ago
  • 0.0.0-experimental-33c3af284                                ...           5 months ago
  • 0.0.0-33c3af284                                ...           5 months ago
  • 4.0.0                                ...           5 months ago
  • 0.0.0-experimental-e5d06e34b                                ...           6 months ago
  • 0.0.0-experimental-d7382b6c4                                ...           6 months ago
  • 0.0.0-d7382b6c4                                ...           6 months ago
  • 3.0.0                                ...           6 months ago
  • 2.5.1                                ...           6 months ago
  • 0.0.0-da834083c                                ...           6 months ago
  • 0.0.0-experimental-aae83a4b9                                ...           6 months ago
  • 0.0.0-experimental-8b155d261                                ...           6 months ago
  • 0.0.0-235a6c4af                                ...           7 months ago
  • 0.0.0-experimental-235a6c4af                                ...           7 months ago
  • 0.0.0-experimental-355970aa4                                ...           7 months ago
  • 2.5.0                                ...           7 months ago
  • 0.0.0-experimental-d28bd2994                                ...           7 months ago
  • 0.0.0-d28bd2994                                ...           7 months ago
  • 0.0.0-experimental-8d7535e54                                ...           7 months ago
  • 0.0.0-8d7535e54                                ...           7 months ago
  • 0.0.0-5de5b6150                                ...           7 months ago
  • 0.0.0-experimental-5de5b6150                                ...           7 months ago
  • 0.0.0-ea6ed3dbb                                ...           7 months ago
  • 0.0.0-experimental-ea6ed3dbb                                ...           7 months ago
  • 2.4.0                                ...           7 months ago
  • 2.4.0-alpha.0                                ...           7 months ago
  • 0.0.0-experimental-241c4467e                                ...           8 months ago
  • 0.0.0-241c4467e                                ...           8 months ago
  • 0.0.0-experimental-57333ca33                                ...           8 months ago
  • 0.0.0-57333ca33                                ...           8 months ago
  • 0.0.0-experimental-f42431abe                                ...           9 months ago
  • 0.0.0-f42431abe                                ...           9 months ago
  • 0.0.0-experimental-2c169a568                                ...           10 months ago
  • 0.0.0-experimental-3f3fe0874                                ...           10 months ago
  • 0.0.0-experimental-0e6839614                                ...           10 months ago
  • 2.3.0                                ...           10 months ago
  • 0.0.0-experimental-b53ea6ca0                                ...           10 months ago
  • 0.0.0-b53ea6ca0                                ...           10 months ago
  • 0.0.0-38dd17ab9                                ...           a year ago
  • 0.0.0-experimental-38dd17ab9                                ...           a year ago
  • 0.0.0-f6b8d31a7                                ...           a year ago
  • 0.0.0-experimental-f6b8d31a7                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 0.0.0-experimental-5faf377df                                ...           a year ago
  • 0.0.0-5faf377df                                ...           a year ago
  • 0.0.0-experimental-1022ee0ec                                ...           a year ago
  • 0.0.0-1022ee0ec                                ...           a year ago
  • 0.0.0-experimental-7082d5a2d                                ...           a year ago
  • 0.0.0-7082d5a2d                                ...           a year ago
  • 0.0.0-experimental-d7feeb25a                                ...           a year ago
  • 0.0.0-experimental-d364d8555                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 0.0.0-4ab6305f6                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 0.0.0-d346d9208                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 0.0.0-3694a3b5e                                ...           a year ago
  • 0.0.0-b4b8a349a                                ...           a year ago
  • 0.0.0-45b6443c9                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0 [deprecated]           ...           a year ago
  • 0.0.0-8d5403877                                ...           a year ago
  • 1.7.0                                ...           a year ago
  • 1.7.0-rc.0                                ...           a year ago
  • 0.0.0-a1dbb852c                                ...           a year ago
  • 0.0.0-375616788                                ...           a year ago
  • 0.0.0-db3ae32b8                                ...           a year ago
  • 0.0.0-bbd21066e                                ...           a year ago
  • 0.0.0-b4178af81                                ...           a year ago
  • 0.0.0-424099da6                                ...           a year ago
  • 0.0.0-9f395904c                                ...           a year ago
  • 1.6.1                                ...           a year ago
  • 0.0.0-fa1e8df11                                ...           a year ago
  • 0.0.0-50b50c26f                                ...           a year ago
  • 0.0.0-6da04b5d8                                ...           a year ago
  • 0.0.0-fb28e9048                                ...           a year ago
  • 0.0.0-4221565e1                                ...           a year ago
  • 0.0.0-9ebe1768a                                ...           a year ago
  • 0.0.0-a9eff329c                                ...           a year ago
  • 1.7.0-alpha.0                                ...           a year ago
  • 0.0.0-c35e37aab                                ...           a year ago
  • 1.6.0                                ...           2 years ago
  • 0.0.0-679402a66                                ...           2 years ago
  • 1.5.1                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.5.0-beta.1                                ...           2 years ago
  • 1.5.0-beta.0                                ...           2 years ago
  • 1.5.0-alpha.0                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 0.0.0-29b7b775f                                ...           2 years ago
  • 0.0.0-b668168d4                                ...           2 years ago
  • 1.1.0-rc.0                                ...           2 years ago
  • 1.1.0-alpha.1                                ...           2 years ago
  • 1.1.0-alpha.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 0.0.0-dfabb77a9                                ...           2 years ago
  • 0.0.0-0e4135e8c                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 0.0.0-11565a207                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Downloads
Today 75
This Week 48,820
This Month 195,953
Last Day 2,783
Last Week 52,749
Last Month 218,605
Dependencies (0)
None
Dev Dependencies (3)
Dependents (3551)

Copyright 2014 - 2017 © taobao.org |