Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(no-identical-titles): ignore .each template cases #788

Merged
merged 1 commit into from Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions 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';

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
@@ -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