Skip to content

Commit

Permalink
fix(no-identical-titles): ignore .each template cases (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
idan-at authored Mar 9, 2021
1 parent 9725597 commit d27a6e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rules/__tests__/no-identical-title.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import dedent from 'dedent';
import resolveFrom from 'resolve-from';
import rule from '../no-identical-title';

Expand Down Expand Up @@ -113,6 +114,17 @@ ruleTester.run('no-identical-title', rule, {
'describe.content(`testing backticks with the same title`);',
'describe.content(`testing backticks with the same title`);',
].join('\n'),
dedent`
describe.each\`
description
${'b'}
\`("$description", () => {})
describe.each\`
description
${'a'}
\`("$description", () => {})
`,
],
invalid: [
{
Expand Down
5 changes: 5 additions & 0 deletions src/rules/no-identical-title.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';
import {
createRule,
getStringValue,
Expand Down Expand Up @@ -41,6 +42,10 @@ export default createRule({
CallExpression(node) {
const currentLayer = contexts[contexts.length - 1];

if (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression) {
return;
}

if (isDescribe(node)) {
contexts.push(newDescribeContext());
}
Expand Down

0 comments on commit d27a6e6

Please sign in to comment.