diff --git a/lib/rules/handle-done-callback.js b/lib/rules/handle-done-callback.js index dc324cb..6c0c8db 100644 --- a/lib/rules/handle-done-callback.js +++ b/lib/rules/handle-done-callback.js @@ -49,7 +49,7 @@ module.exports = { } function checkAsyncMochaFunction(functionExpression) { - const scope = context.getScope(); + const scope = context.sourceCode.getScope(functionExpression); const callback = functionExpression.params[0]; const callbackName = callback.name; const callbackVariable = findParamInScope(callbackName, scope); diff --git a/lib/rules/max-top-level-suites.js b/lib/rules/max-top-level-suites.js index fd37751..9319a02 100644 --- a/lib/rules/max-top-level-suites.js +++ b/lib/rules/max-top-level-suites.js @@ -48,7 +48,7 @@ module.exports = { return { CallExpression(node) { if (astUtils.isDescribe(node)) { - const scope = context.getScope(); + const scope = context.sourceCode.getScope(node); if (isTopLevelScope(scope)) { topLevelDescribes.push(node); diff --git a/lib/rules/no-empty-description.js b/lib/rules/no-empty-description.js index 50b2aad..4cb1162 100644 --- a/lib/rules/no-empty-description.js +++ b/lib/rules/no-empty-description.js @@ -80,7 +80,10 @@ module.exports = { return false; } - const text = getStringIfConstant(description, context.getScope()); + const text = getStringIfConstant( + description, + context.sourceCode.getScope(mochaCallExpression) + ); if (!isStaticallyAnalyzableDescription(description, text)) { return true; diff --git a/lib/rules/no-global-tests.js b/lib/rules/no-global-tests.js index 7364823..83e0c54 100644 --- a/lib/rules/no-global-tests.js +++ b/lib/rules/no-global-tests.js @@ -21,7 +21,7 @@ module.exports = { return { CallExpression(node) { const callee = node.callee; - const scope = context.getScope(); + const scope = context.sourceCode.getScope(node); if (astUtils.isTestCase(node) && isGlobalScope(scope)) { context.report({ node: callee, message: 'Unexpected global mocha test.' }); diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index 958b059..575c24e 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -286,14 +286,14 @@ module.exports = { } // Skip recursive functions. - const nameVar = context.getDeclaredVariables(node)[0]; + const nameVar = context.sourceCode.getDeclaredVariables(node)[0]; if (isFunctionName(nameVar) && nameVar.references.length > 0) { return; } // Skip if it's using arguments. - const variable = getVariableOfArguments(context.getScope()); + const variable = getVariableOfArguments(context.sourceCode.getScope(node)); if (variable && variable.references.length > 0) { return; diff --git a/lib/rules/valid-suite-description.js b/lib/rules/valid-suite-description.js index 958c3d4..dce14d9 100644 --- a/lib/rules/valid-suite-description.js +++ b/lib/rules/valid-suite-description.js @@ -83,7 +83,10 @@ module.exports = { function hasValidSuiteDescription(mochaCallExpression) { const args = mochaCallExpression.arguments; const descriptionArgument = args[0]; - const description = getStringIfConstant(descriptionArgument, context.getScope()); + const description = getStringIfConstant( + descriptionArgument, + context.sourceCode.getScope(mochaCallExpression) + ); if (description) { return pattern.test(description); diff --git a/lib/rules/valid-test-description.js b/lib/rules/valid-test-description.js index f71603e..b1c5ad1 100644 --- a/lib/rules/valid-test-description.js +++ b/lib/rules/valid-test-description.js @@ -82,7 +82,10 @@ module.exports = { function hasValidTestDescription(mochaCallExpression) { const args = mochaCallExpression.arguments; const testDescriptionArgument = args[0]; - const description = getStringIfConstant(testDescriptionArgument, context.getScope()); + const description = getStringIfConstant( + testDescriptionArgument, + context.sourceCode.getScope(mochaCallExpression) + ); if (description) { return pattern.test(description); diff --git a/lib/util/ast.js b/lib/util/ast.js index fecc57a..97c13a8 100644 --- a/lib/util/ast.js +++ b/lib/util/ast.js @@ -134,7 +134,7 @@ function createAstUtils(settings) { return (node, context) => { if (isMochaFunctionCall(node)) { - const scope = context.getScope(); + const scope = context.sourceCode.getScope(node); if (!isCallToShadowedReference(node, scope)) { return true;