diff --git a/lib/rules/no-async-before.js b/lib/rules/no-async-before.js index 6b2012e6..aa428543 100644 --- a/lib/rules/no-async-before.js +++ b/lib/rules/no-async-before.js @@ -28,11 +28,14 @@ module.exports = { && node.arguments.length >= 2 && node.arguments[1].async === true } + const sourceCode = context.sourceCode ?? context.getSourceCode() return { Identifier (node) { if (node.name === 'cy' || node.name === 'Cypress') { - const ancestors = context.getAncestors() + const ancestors = sourceCode.getAncestors + ? sourceCode.getAncestors(node) + : context.getAncestors() const asyncTestBlocks = ancestors .filter((n) => n.type === 'CallExpression') .filter(isBeforeBlock) diff --git a/lib/rules/no-async-tests.js b/lib/rules/no-async-tests.js index 560ac2bf..5d1ca284 100644 --- a/lib/rules/no-async-tests.js +++ b/lib/rules/no-async-tests.js @@ -28,11 +28,14 @@ module.exports = { && node.arguments.length >= 2 && node.arguments[1].async === true } + const sourceCode = context.sourceCode ?? context.getSourceCode() return { Identifier (node) { if (node.name === 'cy' || node.name === 'Cypress') { - const ancestors = context.getAncestors() + const ancestors = sourceCode.getAncestors + ? sourceCode.getAncestors(node) + : context.getAncestors() const asyncTestBlocks = ancestors .filter((n) => n.type === 'CallExpression') .filter(isTestBlock) diff --git a/lib/rules/no-unnecessary-waiting.js b/lib/rules/no-unnecessary-waiting.js index 56bcc6c2..1c1132e0 100644 --- a/lib/rules/no-unnecessary-waiting.js +++ b/lib/rules/no-unnecessary-waiting.js @@ -15,10 +15,14 @@ module.exports = { }, }, create (context) { + const sourceCode = context.sourceCode ?? context.getSourceCode() + return { CallExpression (node) { if (isCallingCyWait(node)) { - const scope = context.getScope() + const scope = sourceCode.getScope + ? sourceCode.getScope(node) + : context.getScope() if (isIdentifierNumberConstArgument(node, scope) || isNumberArgument(node)) { context.report({ node, messageId: 'unexpected' })