eslint-plugin-react-hooks-eleme

1.0.3 • Public • Published

eslint-plugin-react-hooks-eleme

eslint-plugin-react-hooks-eleme

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-react-hooks-eleme:

$ npm install eslint-plugin-react-hooks-eleme --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-react-hooks-eleme globally.

Usage

Add react-hooks-eleme to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "react-hooks-eleme"
    ]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    // ...
    // Hooks Rules
    "react-hooks-eleme/rules-of-hooks": "error",
    "react-hooks-eleme/exhaustive-deps": "warn",
    // 1.Hook: [useStateuseReducer] > useMemo > useRef > Hook > useCallback >  useEffect
    "react-hooks-eleme/call-order-of-hooks": "error",
    // 2.HookuseCallback
    "react-hooks-eleme/functions-declared": "error",
    // 3.HookuseMemo
    "react-hooks-eleme/variables-or-constants-declared": "error",
    // 4.useEffect
    "react-hooks-eleme/useeffect-circular-reference": "error",
    // 5.
    "react-hooks-eleme/update-state-directly": "error",
    // 6.useState const [stateName, setStateName] = useState()
    // 7.useReducer const [state, stateDispatch] = useReducer(stateReducer, stateInitialVal, stateInit)
    // 8.useRef
    // 9.useMemo
    "react-hooks-eleme/declaration-of-usestate": "error",
    "react-hooks-eleme/declaration-of-usereducer": "error",
    "react-hooks-eleme/declaration-of-useref": "error",
    "react-hooks-eleme/declaration-of-usememo": "error",
  }
}

Supported Rules

  • Fill in provided rules here

Package Sidebar

Install

npm i eslint-plugin-react-hooks-eleme

Weekly Downloads

10

Version

1.0.3

License

ISC

Unpacked Size

99 kB

Total Files

14

Last publish

Collaborators

  • yanjun0501