Enforce best practices for JavaScript promises.
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.
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", "promise/no-multiple-resolved": "error" } }
or start with the recommended rule set:
eslint.config.js
:
import pluginPromise from 'eslint-plugin-promise' export default [ // ... pluginPromise.configs['flat/recommended'], ]
.eslintrc.*
:
{ "extends": ["plugin:promise/recommended"] }
💼 Configurations enabled in.
⚠️ Configurations set to warn in.
🚫 Configurations disabled in.
✅ Set in the flat/recommended
configuration.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4