eslint-plugin-jest
Advanced tools
Comparing version 22.3.0 to 22.3.1
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "22.3.0", | ||
"version": "22.3.1", | ||
"description": "Eslint rules for Jest", | ||
@@ -38,3 +38,3 @@ "repository": "jest-community/eslint-plugin-jest", | ||
"eslint": "^5.1.0", | ||
"eslint-config-prettier": "^3.0.1", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-eslint-plugin": "^2.0.0", | ||
@@ -41,0 +41,0 @@ "eslint-plugin-node": "^8.0.0", |
@@ -15,2 +15,4 @@ 'use strict'; | ||
].join('\n'), | ||
['describe();describe();'].join('\n'), | ||
['it();it();'].join('\n'), | ||
[ | ||
@@ -85,2 +87,13 @@ 'describe("describe1", function() {', | ||
].join('\n'), | ||
{ | ||
code: [ | ||
'describe("describe", () => {', | ||
' it(`testing ${someVar} with the same title`, () => {});', | ||
' it(`testing ${someVar} with the same title`, () => {});', | ||
'});', | ||
].join('\n'), | ||
env: { | ||
es6: true, | ||
}, | ||
}, | ||
], | ||
@@ -217,3 +230,22 @@ | ||
}, | ||
{ | ||
code: [ | ||
'describe("describe", () => {', | ||
' it(`testing backticks with the same title`, () => {});', | ||
' it(`testing backticks with the same title`, () => {});', | ||
'});', | ||
].join('\n'), | ||
env: { | ||
es6: true, | ||
}, | ||
errors: [ | ||
{ | ||
message: | ||
'Test title is used multiple times in the same describe block.', | ||
column: 5, | ||
line: 3, | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
'use strict'; | ||
const { getDocsUrl, isDescribe, isTestCase } = require('./util'); | ||
const { | ||
getDocsUrl, | ||
isDescribe, | ||
isTestCase, | ||
isString, | ||
hasExpressions, | ||
} = require('./util'); | ||
@@ -37,4 +43,11 @@ const newDescribeContext = () => ({ | ||
const isFirstArgLiteral = node => | ||
node.arguments && node.arguments[0] && node.arguments[0].type === 'Literal'; | ||
const isFirstArgValid = arg => { | ||
if (!arg || !isString(arg)) { | ||
return false; | ||
} | ||
if (arg.type === 'TemplateLiteral' && hasExpressions(arg)) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
@@ -55,6 +68,6 @@ module.exports = { | ||
} | ||
if (!isFirstArgLiteral(node)) { | ||
const [firstArgument] = node.arguments; | ||
if (!isFirstArgValid(firstArgument)) { | ||
return; | ||
} | ||
const title = node.arguments[0].value; | ||
@@ -61,0 +74,0 @@ handleTestCaseTitles(context, currentLayer.testTitles, node, title); |
@@ -137,2 +137,4 @@ 'use strict'; | ||
const hasExpressions = node => node.expressions && node.expressions.length > 0; | ||
/** | ||
@@ -216,2 +218,3 @@ * Generates the URL to documentation for the given rule name. It uses the | ||
isString, | ||
hasExpressions, | ||
getDocsUrl, | ||
@@ -218,0 +221,0 @@ scopeHasLocalReference, |
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
203520
5857