Skip to content

Commit

Permalink
Merge pull request #202 from imjordanxd/issue/change-callback-err-naming
Browse files Browse the repository at this point in the history
included check for string literal 'error'
  • Loading branch information
xjamundx committed Feb 10, 2021
2 parents ac57a5f + ee0a8d4 commit ca0f877
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/prefer-await-to-callbacks.js
Expand Up @@ -51,6 +51,14 @@ ruleTester.run('prefer-await-to-callbacks', rule, {
{
code: 'callback()',
errors: [{ message }]
},
{
code: 'heart(error => {})',
errors: [{ message }]
},
{
code: 'heart(function(error) {})',
errors: [{ message }]
}
]
})
6 changes: 5 additions & 1 deletion rules/prefer-await-to-callbacks.js
Expand Up @@ -50,7 +50,11 @@ module.exports = {
) {
return
}
if (arg.params && arg.params[0] && arg.params[0].name === 'err') {
if (
arg.params &&
arg.params[0] &&
(arg.params[0].name === 'err' || arg.params[0].name === 'error')
) {
if (!isInsideYieldOrAwait()) {
context.report({ node: arg, messageId: 'error' })
}
Expand Down

0 comments on commit ca0f877

Please sign in to comment.