1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/eslint-plugin-promise/rules/no-nesting.js

30 lines
634 B
JavaScript
Raw Permalink Normal View History

2023-12-18 13:12:25 +08:00
/**
* Rule: no-nesting
* Avoid nesting your promises.
*/
'use strict'
const getDocsUrl = require('./lib/get-docs-url')
const hasPromiseCallback = require('./lib/has-promise-callback')
const isInsidePromise = require('./lib/is-inside-promise')
module.exports = {
meta: {
2024-01-16 21:26:16 +08:00
type: 'suggestion',
2023-12-18 13:12:25 +08:00
docs: {
2024-01-16 21:26:16 +08:00
url: getDocsUrl('no-nesting'),
},
2023-12-18 13:12:25 +08:00
},
create(context) {
return {
CallExpression(node) {
if (!hasPromiseCallback(node)) return
if (context.getAncestors().some(isInsidePromise)) {
context.report({ node, message: 'Avoid nesting promises.' })
}
2024-01-16 21:26:16 +08:00
},
2023-12-18 13:12:25 +08:00
}
2024-01-16 21:26:16 +08:00
},
2023-12-18 13:12:25 +08:00
}