Enforce standard parameter names for Promise constructors
Deprecated: please use eslint-plugin-promise instead
new Promise(function (resolve) { ... })
new Promise(function (resolve, reject) { ... })
// 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.
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.
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
}
}
(c) MMXV jden jason@denizac.org - ISC license.