promise/no-nesting
eslint-plugin-promise
No autofixRecommended
eslint.config.js
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/no-nesting": "error",
},
},
];myPromise.then((val) => doSomething(val).then(doSomethingElse))
myPromise.then((val) => doSomething(val).catch(errors))
myPromise.catch((err) => doSomething(err).then(doSomethingElse))
myPromise.catch((err) => doSomething(err).catch(errors))myPromise.then(doSomething).then(doSomethingElse).catch(errors)Examples from the ESLint documentation.
promise/no-nesting
eslint-plugin-promise
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/no-nesting": "error",
},
},
];promise/no-nesting
promise plugin · style
{
"plugins": [
"promise"
],
"rules": {
"promise/no-nesting": "error"
}
}suspicious/noNestedPromises
suspicious · since 2.3.15
{
"linter": {
"rules": {
"suspicious": {
"noNestedPromises": "error"
}
}
}
}Require returning inside each then() to create readable and reusable Promise chains.
Enforce the use of catch() on un-returned promises.
Disallow calling cb() inside of a then() (use [util.callbackify][] instead).
Disallow calling new on a Promise static method.
Disallow using promises inside of callbacks.
Enforces the proper number of arguments are passed to Promise functions.