diff --git a/__tests__/no-callback-in-promise.js b/__tests__/no-callback-in-promise.js index 8dcbf916..eb59c9f8 100644 --- a/__tests__/no-callback-in-promise.js +++ b/__tests__/no-callback-in-promise.js @@ -34,6 +34,18 @@ ruleTester.run('no-callback-in-promise', rule, { code: 'a.then(() => next())', options: [{ exceptions: ['next'] }], }, + { + code: 'a.then(() => next()).catch((err) => next(err))', + options: [{ exceptions: ['next'] }], + }, + { + code: 'a.then(next)', + options: [{ exceptions: ['next'] }], + }, + { + code: 'a.then(next).catch(next)', + options: [{ exceptions: ['next'] }], + }, ], invalid: [ diff --git a/rules/no-callback-in-promise.js b/rules/no-callback-in-promise.js index 429621cf..cd86c472 100644 --- a/rules/no-callback-in-promise.js +++ b/rules/no-callback-in-promise.js @@ -11,6 +11,8 @@ const hasPromiseCallback = require('./lib/has-promise-callback') const isInsidePromise = require('./lib/is-inside-promise') const isCallback = require('./lib/is-callback') +const CB_BLACKLIST = ['callback', 'cb', 'next', 'done'] + module.exports = { meta: { type: 'suggestion', @@ -48,12 +50,7 @@ module.exports = { if (hasPromiseCallback(node)) { const name = node.arguments && node.arguments[0] && node.arguments[0].name - if ( - name === 'callback' || - name === 'cb' || - name === 'next' || - name === 'done' - ) { + if (!exceptions.includes(name) && CB_BLACKLIST.includes(name)) { context.report({ node: node.arguments[0], messageId: 'callback',