Skip to content

Commit

Permalink
Merge pull request #347 from lo1tuma/deprecated-apis
Browse files Browse the repository at this point in the history
Stop using deprecated ESLint context methods
  • Loading branch information
lo1tuma committed Feb 16, 2024
2 parents f8e1e98 + e0ec495 commit 6d7a3e5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/rules/handle-done-callback.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-top-level-suites.js
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-empty-description.js
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-global-tests.js
Expand Up @@ -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.' });
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/prefer-arrow-callback.js
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/valid-suite-description.js
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/valid-test-description.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/util/ast.js
Expand Up @@ -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;
Expand Down

0 comments on commit 6d7a3e5

Please sign in to comment.