Skip to content

A eslint rule for React, to encourage the use of functional setState when accessing this.state and this props inside a setState call.

Notifications You must be signed in to change notification settings

BE-Webdesign/eslint-plugin-react-functional-set-state

Repository files navigation

eslint-plugin-react-functional-set-state

Lint Rule for React to use functional setState and prevent the use of accessing this.state and this.props inside of setState calls.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-react-functional-set-state:

$ npm install eslint-plugin-react-functional-set-state --save-dev

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

Usage

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

{
    "plugins": [
        "react-functional-set-state"
    ]
}

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

{
    "rules": {
        "react-functional-set-state/no-this-state-props": 2
    }
}

Supported Rules

  • no-this-state-props

About

A eslint rule for React, to encourage the use of functional setState when accessing this.state and this props inside a setState call.

Resources

Stars

Watchers

Forks

Packages

No packages published