diff --git a/src/rules/expect-expect.ts b/src/rules/expect-expect.ts index ca23584..9696f83 100644 --- a/src/rules/expect-expect.ts +++ b/src/rules/expect-expect.ts @@ -15,6 +15,7 @@ function isAssertionCall( export default { create(context) { + const sourceCode = context.sourceCode ?? context.getSourceCode(); const unchecked: ESTree.CallExpression[] = []; const additionalAssertFunctionNames = getAdditionalAssertFunctionNames(context); @@ -36,7 +37,11 @@ export default { if (isTestCall(node, ['fixme', 'only', 'skip'])) { unchecked.push(node); } else if (isAssertionCall(node, additionalAssertFunctionNames)) { - checkExpressions(context.sourceCode.getAncestors(node)); + const ancestors = sourceCode.getAncestors + ? sourceCode.getAncestors(node) + : context.getAncestors(); + + checkExpressions(ancestors); } }, 'Program:exit'() { diff --git a/src/rules/prefer-to-contain.ts b/src/rules/prefer-to-contain.ts index 93ef98f..53ceb8c 100644 --- a/src/rules/prefer-to-contain.ts +++ b/src/rules/prefer-to-contain.ts @@ -48,7 +48,7 @@ export default { context.report({ fix(fixer) { - const sourceCode = context.getSourceCode(); + const sourceCode = context.sourceCode ?? context.getSourceCode(); // We need to negate the expectation if the current expected // value is itself negated by the "not" modifier