Skip to content

bryanrsmith/eslint-plugin-no-arrow-labels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-no-arrow-labels

An ESLint rule to disallow label statements inside arrow function bodies.

Helps avoid the common error of omitting parens when returning object literals from arrow functions using the concise syntax. E.g., params => { object: literal }

See MDN's notes on returning object literals from arrow functions

Note: You should probably just disallow labeled statements everywhere.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-no-arrow-labels:

$ npm install eslint-plugin-no-arrow-labels --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-no-arrow-labels globally.

Usage

Add no-arrow-labels to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "no-arrow-labels"
    ]
}

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

{
    "rules": {
        "no-arrow-labels": 2
    }
}

About

ESLint rule to disallow labels in arrow function bodies

Resources

Stars

Watchers

Forks

Packages

No packages published