Skip to content

Commit

Permalink
fix(no-identical-title): always consider .each titles unique (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Sep 29, 2021
1 parent bcc8176 commit a41a40e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/rules/__tests__/no-identical-title.test.ts
Expand Up @@ -124,12 +124,12 @@ ruleTester.run('no-identical-title', rule, {
dedent`
describe.each\`
description
${'b'}
$\{'b'}
\`('$description', () => {});
describe.each\`
description
${'a'}
$\{'a'}
\`('$description', () => {});
`,
dedent`
Expand All @@ -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: [
{
Expand Down
4 changes: 2 additions & 2 deletions 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,
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a41a40e

Please sign in to comment.