ags
This commit is contained in:
parent
eddf7cecb8
commit
aea798d119
16631 changed files with 1480363 additions and 257 deletions
20
home/ags/node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
generated
vendored
Normal file
20
home/ags/node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
'use strict'
|
||||
|
||||
const isInsidePromise = require('./is-inside-promise')
|
||||
|
||||
function isInsideCallback(node) {
|
||||
const isCallExpression =
|
||||
node.type === 'FunctionExpression' ||
|
||||
node.type === 'ArrowFunctionExpression' ||
|
||||
node.type === 'FunctionDeclaration' // this may be controversial
|
||||
|
||||
// it's totally fine to use promises inside promises
|
||||
if (isInsidePromise(node)) return
|
||||
|
||||
const name = node.params && node.params[0] && node.params[0].name
|
||||
const firstArgIsError = name === 'err' || name === 'error'
|
||||
const isInACallback = isCallExpression && firstArgIsError
|
||||
return isInACallback
|
||||
}
|
||||
|
||||
module.exports = isInsideCallback
|
||||
Loading…
Add table
Add a link
Reference in a new issue