6.1.1 • Published 1 year ago

eslint-plugin-promise v6.1.1

Weekly downloads
2,406,559
License
ISC
Repository
github
Last release
1 year ago

eslint-plugin-promise

Enforce best practices for JavaScript promises.

CI npm version code style: prettier

Installation

You'll first need to install ESLint:

$ npm install eslint --save-dev

Next, install eslint-plugin-promise:

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

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

Usage

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

{
  "plugins": ["promise"]
}

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

{
  "rules": {
    "promise/always-return": "error",
    "promise/no-return-wrap": "error",
    "promise/param-names": "error",
    "promise/catch-or-return": "error",
    "promise/no-native": "off",
    "promise/no-nesting": "warn",
    "promise/no-promise-in-callback": "warn",
    "promise/no-callback-in-promise": "warn",
    "promise/avoid-new": "warn",
    "promise/no-new-statics": "error",
    "promise/no-return-in-finally": "warn",
    "promise/valid-params": "warn"
  }
}

or start with the recommended rule set:

{
  "extends": ["plugin:promise/recommended"]
}

Rules

ruledescriptionrecommendedfixable
catch-or-returnEnforces the use of catch() on un-returned promises.:bangbang:
no-return-wrapAvoid wrapping values in Promise.resolve or Promise.reject when not needed.:bangbang:
param-namesEnforce consistent param names and ordering when creating new promises.:bangbang:
always-returnReturn inside each then() to create readable and reusable Promise chains.:bangbang:
no-nativeIn an ES5 environment, make sure to create a Promise constructor before using.
no-nestingAvoid nested then() or catch() statements:warning:
no-promise-in-callbackAvoid using promises inside of callbacks:warning:
no-callback-in-promiseAvoid calling cb() inside of a then() (use nodeify instead):warning:
avoid-newAvoid creating new promises outside of utility libs (use pify instead)
no-new-staticsAvoid calling new on a Promise static method:bangbang::wrench:
no-return-in-finallyDisallow return statements in finally():warning:
valid-paramsEnsures the proper number of arguments are passed to Promise functions:warning:
prefer-await-to-thenPrefer await to then()/catch()/finally() for reading Promise values:seven:
prefer-await-to-callbacksPrefer async/await to the callback pattern:seven:
no-multiple-resolvedDisallow creating new promises with paths that resolve multiple times

Key

icondescription
:bangbang:Reports as error in recommended configuration
:warning:Reports as warning in recommended configuration
:seven:ES2017 Async Await rules
:wrench:Rule is fixable with eslint --fix

Maintainers

License

@yysmx/eslint-config@yysmx/eslint-config-basic@anjun-brasil/eslint-configwhzbcx_web_comswhzbcx_web_cxwhzbcx_web_cx3whzbcx_web_cxewhzbcx_web_cxgiswhzbcx_web_gwwhzbcx_web_sjzxwhzbcx_web_swdzwhzbcx_web_xjwhzbcx_web_yzwmc-eslintxcc-standard-eslint@bridge-tools/config@yoyuo/eslint-config@azul-tecnologia/eslint-config@lvyunlong/eslint-config@lvyunlong/eslint-config-basic@minozzzi/eslint-config@modern-js-app/eslint-config@jcamp/eslint-config-basic@jiqi/eslint-config@jiqi/eslint-config-basic@jiralite/eslint-config-neon@kaivanwong/eslint-config-base@qualopreco/eslint-config@rjqh/eslint-config-basic@rain-star/eslint-config-basic@polkadot/dev@cyenoch/eslint-config@fiuzagr/boot@asasinmode/eslint-config@knapsack-cloud/msk-design-system@knapsack/eslint-config-starter@obvcloud/eslint-config-preset-basic@denverzh/eslint-config@denverzh/eslint-config-baseeslint-config-bambieslint-config-metamoeslint-config-nectis@wongbejoonline/eslint-plugin-wbo@maiscrm/eslint-config-frontendnoodles-normes6-flowyreact-antd-scripts-newreact-native-brave@wheresalice/standard-adfreeeslint-config-contra@oka_technology/eslint-config@suozhao/eslint-vue-168ch168vueeslinteslint-vue-168@analogyxbi-ui/build-configvideocapturinghaodfplusnode-next-servermagnoabsass-sdfddabc-jdjdjjdmo-foundation-base@ffbutton/eslint-config-baseeslint-config-standard-vincent@outcome-co/eslint-config@mole/eslint-config-vueflowycharteslint-config-slickidvcyp-mdlinksyp-.mdlinksswiss-tourneysprobica15probica16eslint-config-quartztogether-lib@martyncherry/eslint-configmetamo-eslint-configmetamo-lint-config@mark42/deploy@straal/eslint-config-fp-startereslint-config-smarchetti@scalara/eslintconfigeslint-config-prettystandard-vueeslint-config-clicktimegusgard-eslint-configzjlab-clieslint-config-demingdemingeslint-config-kelexkelex-clislm_cdkkelex-plugin-lintkelex-plugin-apptemp2-test-scriptseslint-config-mti@iftek/standardcq-batch-templatedeming-linterbb-chat
6.1.0

2 years ago

6.1.1

1 year ago

6.0.1

2 years ago

5.2.0

2 years ago

6.0.0

2 years ago

5.1.1

2 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.3.1

3 years ago

4.3.0

3 years ago

4.2.1

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.8.0

6 years ago

3.7.0

6 years ago

3.6.0

7 years ago

3.5.0

7 years ago

3.4.2

7 years ago

3.4.1

7 years ago

3.4.0

7 years ago

3.4.0-0

7 years ago

3.3.2

7 years ago

3.3.1

7 years ago

3.3.0

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.8

8 years ago

1.0.0

8 years ago