From 5c2a078b78bcb544111031463beb6676810ee079 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 26 Sep 2021 08:49:30 +1300 Subject: [PATCH] fix(no-identical-title): always ignore `.each` titles --- src/rules/__tests__/no-identical-title.test.ts | 14 ++++++++++++-- src/rules/no-identical-title.ts | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/rules/__tests__/no-identical-title.test.ts b/src/rules/__tests__/no-identical-title.test.ts index 6285c376f..de5b03c4d 100644 --- a/src/rules/__tests__/no-identical-title.test.ts +++ b/src/rules/__tests__/no-identical-title.test.ts @@ -124,12 +124,12 @@ ruleTester.run('no-identical-title', rule, { dedent` describe.each\` description - ${'b'} + $\{'b'} \`('$description', () => {}); describe.each\` description - ${'a'} + $\{'a'} \`('$description', () => {}); `, dedent` @@ -141,6 +141,16 @@ ruleTester.run('no-identical-title', rule, { describe('nested', () => {}); }); `, + dedent` + describe.each\`\`('my title', value => {}); + describe.each\`\`('my title', value => {}); + describe.each([])('my title', value => {}); + describe.each([])('my title', value => {}); + `, + dedent` + describe.each([])('when the value is %s', value => {}); + describe.each([])('when the value is %s', value => {}); + `, ], invalid: [ { diff --git a/src/rules/no-identical-title.ts b/src/rules/no-identical-title.ts index f83afb5f2..6f905bb18 100644 --- a/src/rules/no-identical-title.ts +++ b/src/rules/no-identical-title.ts @@ -1,6 +1,6 @@ -import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; import { createRule, + getNodeName, getStringValue, isDescribeCall, isStringNode, @@ -46,7 +46,7 @@ export default createRule({ contexts.push(newDescribeContext()); } - if (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression) { + if (getNodeName(node.callee)?.endsWith('.each')) { return; }