Skip to content

junosuarez/eslint-plugin-promiseparams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-promiseparams

Enforce standard parameter names for Promise constructors

js-standard-style travis-ci npm version

Deprecated: please use eslint-plugin-promise instead

Rule

promiseparams

Valid

new Promise(function (resolve) { ... })
new Promise(function (resolve, reject) { ... })

Invalid

// incorrect order:
new Promise(function (reject, resolve) { ... })
// non-standard parameter names:
new Promise(function (ok, fail) { ... })

Ensures that new Promise() is instantiated with the parameter names resolve, reject to avoid confusion with order such as reject, resolve. The Promise constructor uses the RevealingConstructor pattern. Using the same parameter names as the language specification makes code more uniform and easier to understand.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-promiseparams:

$ npm install eslint-plugin-promiseparams --save-dev

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

Usage

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

{
    "plugins": [
        "promiseparams"
    ]
}

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

{
    "rules": {
        "promiseparams/promiseparams": 2
    }
}

Etc

(c) MMXV jden jason@denizac.org - ISC license.

About

Enforce standard parameter names for Promise constructors

Resources

Stars

Watchers

Forks

Packages

No packages published