eslint-plugin-mocha
Advanced tools
Comparing version 10.4.2 to 10.4.3
@@ -26,4 +26,6 @@ 'use strict'; | ||
}, | ||
// eslint-disable-next-line max-statements | ||
create(context) { | ||
const astUtils = createAstUtils(context.settings); | ||
const { sourceCode = {} } = context; | ||
const [ { ignoreSkipped = false } = {} ] = context.options; | ||
@@ -53,3 +55,6 @@ const modifiersToCheck = ignoreSkipped ? [ 'only' ] : [ 'only', 'skip' ]; | ||
function checkAsyncMochaFunction(functionExpression) { | ||
const scope = context.sourceCode.getScope(functionExpression); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(functionExpression) : | ||
context.getScope(); | ||
const callback = functionExpression.params[0]; | ||
@@ -56,0 +61,0 @@ const callbackName = callback.name; |
@@ -37,2 +37,3 @@ 'use strict'; | ||
create(context) { | ||
const { sourceCode = {} } = context; | ||
const astUtils = createAstUtils(context.settings); | ||
@@ -52,3 +53,5 @@ const topLevelDescribes = []; | ||
if (astUtils.isDescribe(node)) { | ||
const scope = context.sourceCode.getScope(node); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(node) : | ||
context.getScope(); | ||
@@ -55,0 +58,0 @@ if (isTopLevelScope(scope)) { |
@@ -69,2 +69,3 @@ 'use strict'; | ||
const options = context.options[0]; | ||
const { sourceCode = {} } = context; | ||
@@ -77,2 +78,3 @@ const { testNames, message } = objectOptions(options); | ||
// eslint-disable-next-line complexity | ||
function isNonEmptyDescription(mochaCallExpression) { | ||
@@ -85,7 +87,8 @@ const description = mochaCallExpression.arguments[0]; | ||
const text = getStringIfConstant( | ||
description, | ||
context.sourceCode.getScope(mochaCallExpression) | ||
); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(mochaCallExpression) : | ||
context.getScope(); | ||
const text = getStringIfConstant(description, scope); | ||
if (!isStaticallyAnalyzableDescription(description, text)) { | ||
@@ -92,0 +95,0 @@ return true; |
@@ -16,2 +16,3 @@ 'use strict'; | ||
const astUtils = createAstUtils(context.settings); | ||
const { sourceCode = {} } = context; | ||
@@ -25,3 +26,5 @@ function isGlobalScope(scope) { | ||
const callee = node.callee; | ||
const scope = context.sourceCode.getScope(node); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(node) : | ||
context.getScope(); | ||
@@ -28,0 +31,0 @@ if (astUtils.isTestCase(node) && isGlobalScope(scope)) { |
@@ -152,2 +152,3 @@ 'use strict'; | ||
const sourceCode = context.getSourceCode(); | ||
const { sourceCode: sourceCodeFromContext = {} } = context; | ||
const isTestCase = astUtils.buildIsTestCaseAnswerer(); | ||
@@ -290,3 +291,5 @@ const isDescribe = astUtils.buildIsDescribeAnswerer(); | ||
// Skip recursive functions. | ||
const nameVar = context.sourceCode.getDeclaredVariables(node)[0]; | ||
const nameVar = typeof sourceCodeFromContext.getDeclaredVariables !== 'undefined' ? | ||
sourceCodeFromContext.getDeclaredVariables(node)[0] : | ||
context.getDeclaredVariables(node)[0]; | ||
@@ -298,3 +301,6 @@ if (isFunctionName(nameVar) && nameVar.references.length > 0) { | ||
// Skip if it's using arguments. | ||
const variable = getVariableOfArguments(context.sourceCode.getScope(node)); | ||
const scope = typeof sourceCodeFromContext.getScope !== 'undefined' ? | ||
sourceCodeFromContext.getScope(node) : | ||
context.getScope(); | ||
const variable = getVariableOfArguments(scope); | ||
@@ -301,0 +307,0 @@ if (variable && variable.references.length > 0) { |
@@ -74,2 +74,3 @@ 'use strict'; | ||
const options = context.options[0]; | ||
const { sourceCode = {} } = context; | ||
@@ -87,7 +88,8 @@ const { pattern, suiteNames, message } = typeof options === 'object' ? | ||
const descriptionArgument = args[0]; | ||
const description = getStringIfConstant( | ||
descriptionArgument, | ||
context.sourceCode.getScope(mochaCallExpression) | ||
); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(mochaCallExpression) : | ||
context.getScope(); | ||
const description = getStringIfConstant(descriptionArgument, scope); | ||
if (description) { | ||
@@ -94,0 +96,0 @@ return pattern.test(description); |
@@ -73,2 +73,3 @@ 'use strict'; | ||
const options = context.options[0]; | ||
const { sourceCode = {} } = context; | ||
@@ -86,7 +87,8 @@ const { pattern, testNames, message } = typeof options === 'object' ? | ||
const testDescriptionArgument = args[0]; | ||
const description = getStringIfConstant( | ||
testDescriptionArgument, | ||
context.sourceCode.getScope(mochaCallExpression) | ||
); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(mochaCallExpression) : | ||
context.getScope(); | ||
const description = getStringIfConstant(testDescriptionArgument, scope); | ||
if (description) { | ||
@@ -93,0 +95,0 @@ return pattern.test(description); |
@@ -136,4 +136,7 @@ 'use strict'; | ||
return (node, context) => { | ||
const { sourceCode = {} } = context; | ||
if (isMochaFunctionCall(node)) { | ||
const scope = context.sourceCode.getScope(node); | ||
const scope = typeof sourceCode.getScope !== 'undefined' ? | ||
sourceCode.getScope(node) : | ||
context.getScope(); | ||
@@ -140,0 +143,0 @@ if (!isCallToShadowedReference(node, scope)) { |
{ | ||
"name": "eslint-plugin-mocha", | ||
"version": "10.4.2", | ||
"version": "10.4.3", | ||
"description": "Eslint rules for mocha.", | ||
@@ -37,3 +37,3 @@ "engines": { | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.29.0", | ||
"eslint": "8.39.0", | ||
"eslint-doc-generator": "^1.0.2", | ||
@@ -80,3 +80,3 @@ "eslint-plugin-eslint-plugin": "^5.0.6", | ||
"functions": 100, | ||
"branches": 100, | ||
"branches": 96, | ||
"exclude": [ | ||
@@ -83,0 +83,0 @@ ".ncurc.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95730
2273