diff --git a/lib/rules/no-unused-expressions.js b/lib/rules/no-unused-expressions.js index 860737d..d31a074 100644 --- a/lib/rules/no-unused-expressions.js +++ b/lib/rules/no-unused-expressions.js @@ -255,11 +255,15 @@ module.exports = { return null; } - + const sourceCode = context.sourceCode ?? context.getSourceCode(); return { ExpressionStatement: function(node) { var valid = !Checker.isDisallowed(node.expression) - || isDirective(node, context.getAncestors()) + || isDirective(node, + (sourceCode.getAncestors + ? sourceCode.getAncestors(node) + : context.getAncestors() + )) || isChaiExpectCall(node) || isChaiShouldCall(node); if (!valid) {