eslint-plugin-mocha
Advanced tools
Comparing version 10.0.1 to 10.0.2
@@ -17,2 +17,18 @@ 'use strict'; | ||
function isTemplateString(node) { | ||
return [ 'TaggedTemplateExpression', 'TemplateLiteral' ].includes(node && node.type); | ||
} | ||
function isIdentifier(node) { | ||
return node && node.type === 'Identifier'; | ||
} | ||
function isStaticallyAnalyzableDescription(node, extractedText) { | ||
if (extractedText === null) { | ||
return !(isTemplateString(node) || isIdentifier(node)); | ||
} | ||
return true; | ||
} | ||
module.exports = { | ||
@@ -55,11 +71,7 @@ meta: { | ||
function isTemplateString(node) { | ||
return [ 'TaggedTemplateExpression', 'TemplateLiteral' ].includes(node && node.type); | ||
} | ||
function checkDescription(mochaCallExpression) { | ||
function isNonEmptyDescription(mochaCallExpression) { | ||
const description = mochaCallExpression.arguments[0]; | ||
const text = getStringIfConstant(description); | ||
const text = getStringIfConstant(description, context.getScope()); | ||
if (isTemplateString(description) && text === null) { | ||
if (!isStaticallyAnalyzableDescription(description, text)) { | ||
return true; | ||
@@ -74,3 +86,3 @@ } | ||
if (isTest(node)) { | ||
if (!checkDescription(node)) { | ||
if (!isNonEmptyDescription(node)) { | ||
context.report({ | ||
@@ -77,0 +89,0 @@ node, |
{ | ||
"name": "eslint-plugin-mocha", | ||
"version": "10.0.1", | ||
"version": "10.0.2", | ||
"description": "Eslint rules for mocha.", | ||
@@ -5,0 +5,0 @@ "engines": { |
83962
2123