eslint-plugin-promise
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
eslint | 8.57.0 | 2.9 MB | MIT | prod peer |
The eslint-plugin-promise
is a powerful JavaScript tool that enforces best practices for JavaScript promises. By analyzing your code, it helps ensure adherence to guidelines that enhance code readability, reliability, and maintainability. Crucially for JavaScript developers utilizing promises, this reduces errors and makes efficient use of JavaScript's asynchronous capabilities.
To utilize eslint-plugin-promise
in your project, follow these simple steps.
$ npm install eslint --save-dev
eslint-plugin-promise
:$ npm install eslint-plugin-promise --save-dev
Remember that if ESLint is installed globally, you'll also need to install eslint-plugin-promise
globally.
Next, add promise
to the plugins section of your .eslintrc.json
configuration file:
{
"plugins": ["promise"]
}
Now, you can configure the rules you want to use under the rules section, or start with the recommended rule set:
{
"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"
}
}
Alternatively, start with the recommended rule set:
{
"extends": ["plugin:promise/recommended"]
}
Detailed documentation for eslint-plugin-promise
, including comprehensive descriptions of all rules and how to use them, is available in the plugin's GitHub repository. Refer to this resource to maximise your use of this tool and better enforce JavaScript promises best practices in your projects.