Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using deprecated ESLint context methods #347

Merged
merged 2 commits into from Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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