diff --git a/lib/rules/await-async-query.js b/lib/rules/await-async-query.js index ad676087..11e10b85 100644 --- a/lib/rules/await-async-query.js +++ b/lib/rules/await-async-query.js @@ -39,10 +39,11 @@ module.exports = { const variableDeclaratorParent = node.parent.parent; const references = - variableDeclaratorParent.type === 'VariableDeclarator' && - context - .getDeclaredVariables(variableDeclaratorParent)[0] - .references.slice(1); + (variableDeclaratorParent.type === 'VariableDeclarator' && + context + .getDeclaredVariables(variableDeclaratorParent)[0] + .references.slice(1)) || + []; if ( references && diff --git a/tests/lib/rules/await-async-query.js b/tests/lib/rules/await-async-query.js index 2c3ba98e..f4032413 100644 --- a/tests/lib/rules/await-async-query.js +++ b/tests/lib/rules/await-async-query.js @@ -149,5 +149,17 @@ ruleTester.run('await-async-query', rule, { }, ], })), + ...ASYNC_QUERIES_COMBINATIONS.map(query => ({ + code: `async () => { + expect(${query}('foo')).toBeInTheDocument() + } + `, + errors: [ + { + line: 2, + message: `\`${query}\` must have \`await\` operator`, + }, + ], + })), ], });