3 Star 1 Fork 4

VTJ.PRO/node_modules

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

eslint-plugin-promise

Enforce best practices for JavaScript promises.

travis-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

rule description recommended fixable
catch-or-return Enforces the use of catch() on un-returned promises.
no-return-wrap Avoid wrapping values in Promise.resolve or Promise.reject when not needed.
param-names Enforce consistent param names and ordering when creating new promises.
always-return Return inside each then() to create readable and reusable Promise chains.
no-native In an ES5 environment, make sure to create a Promise constructor before using.
no-nesting Avoid nested then() or catch() statements
no-promise-in-callback Avoid using promises inside of callbacks
no-callback-in-promise Avoid calling cb() inside of a then() (use nodeify instead)
avoid-new Avoid creating new promises outside of utility libs (use pify instead)
no-new-statics Avoid calling new on a Promise static method
no-return-in-finally Disallow return statements in finally()
valid-params Ensures the proper number of arguments are passed to Promise functions
prefer-await-to-then Prefer await to then() for reading Promise values
prefer-await-to-callbacks Prefer async/await to the callback pattern

Key

icon description
Reports as error in recommended configuration
Reports as warning in recommended configuration
ES2017 Async Await rules
Rule is fixable with eslint --fix

Maintainers

License

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/newgateway/node_modules.git
git@gitee.com:newgateway/node_modules.git
newgateway
node_modules
node_modules
master

搜索帮助