Skip to content

Commit

Permalink
(#168) no-identical-title: Do not report identical titles when using …
Browse files Browse the repository at this point in the history
…macros
  • Loading branch information
jfmengels committed Feb 9, 2017
1 parent c2235d8 commit dd5765b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rules/no-identical-title.js
Expand Up @@ -2,6 +2,7 @@
const espurify = require('espurify');
const visitIf = require('enhance-visitors').visitIf;
const deepStrictEqual = require('deep-strict-equal');
const util = require('../util');
const createAvaRule = require('../create-ava-rule');

const purify = node => node && espurify(node);
Expand Down Expand Up @@ -37,6 +38,11 @@ const create = context => {
return;
}

// Don't flag what look to be macros
if (args.length > 2 && !util.isFunctionExpression(args[1])) {
return;
}

if (isTitleUsed(usedTitleNodes, titleNode)) {
context.report({
node,
Expand Down
19 changes: 19 additions & 0 deletions test/no-identical-title.js
Expand Up @@ -32,6 +32,25 @@ ruleTester.run('no-identical-title', rule, {
// multiple anonymous tests covered by the if-multiple rule
header + 'test(t => {}); test(t => {});',
header + 'test(t => {}); test.cb(t => {});',
// macros
` ${header}
const macro = (t, value) => { t.true(value); };
test(macro, true);
test(macro, false);
`,
` ${header}
const macro = (t, value) => { t.true(value); };
test('should work', macro, true);
test('should fail', macro, false);
`,
` ${header}
const macro = (t, value) => { t.true(value); };
test('same title', macro, true);
test('same title', macro, false);
`,
// shouldn't be triggered since it's not a test file
'test(t => {}); test(t => {});',
'test("a", t => {}); test("a", t => {});'
Expand Down

0 comments on commit dd5765b

Please sign in to comment.