From d27a6e6e013c518a47b9f219edeb5e63d7a974f9 Mon Sep 17 00:00:00 2001 From: Idan Attias Date: Tue, 9 Mar 2021 10:43:59 +0200 Subject: [PATCH] fix(no-identical-titles): ignore .each template cases (#788) --- src/rules/__tests__/no-identical-title.test.ts | 12 ++++++++++++ src/rules/no-identical-title.ts | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/rules/__tests__/no-identical-title.test.ts b/src/rules/__tests__/no-identical-title.test.ts index 913cbe5e2..3b2ec2ff3 100644 --- a/src/rules/__tests__/no-identical-title.test.ts +++ b/src/rules/__tests__/no-identical-title.test.ts @@ -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'; @@ -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: [ { diff --git a/src/rules/no-identical-title.ts b/src/rules/no-identical-title.ts index 374219408..6f1f69bf0 100644 --- a/src/rules/no-identical-title.ts +++ b/src/rules/no-identical-title.ts @@ -1,3 +1,4 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; import { createRule, getStringValue, @@ -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()); }