Skip to content

ESLint rule which encourages returns instead of assignment where possible.

License

Notifications You must be signed in to change notification settings

deadbeef404/eslint-plugin-return-early-dont-assign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-return-early-dont-assign

Avoid assignment when you could just return.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-return-early-dont-assign:

$ npm install eslint-plugin-return-early-dont-assign --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-return-early-dont-assign globally.

Usage

Add return-early-dont-assign to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "return-early-dont-assign"
    ]
}

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

{
    "rules": {
        "return-early-dont-assign/return-early-dont-assign": 2
    }
}

Supported Rules

  • return-early-dont-assign

Check docs for synopsis.

Special shoutout

This is my first ESLint plugin/rule and the following links helped make it happen:

About

ESLint rule which encourages returns instead of assignment where possible.

Resources

License

Stars

Watchers

Forks

Packages

No packages published