Sha256: a4619077d9f08d3da5504a32b99f10bdff6358c16e112036a5dfcd37e167cb39

Contents?: true

Size: 631 Bytes

Versions: 44

Compression:

Stored size: 631 Bytes

Contents

'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

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
decidim-0.26.8 packages/eslint-config/node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-18.0.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.21.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.20.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.19.1 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.19.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.18.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.17.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.16.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.15.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.14.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.13.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.12.2 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.12.1 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.12.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.11.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.10.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.9.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.8.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js
govuk_publishing_components-17.7.0 node_modules/eslint-plugin-promise/rules/lib/is-inside-callback.js