Skip to content

Commit bd307de

Browse files
emarcottesindresorhus
authored andcommitted
Fix use-t failing on macros (#194)
Fixes #127
1 parent e196c7a commit bd307de

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

rules/use-t.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ const create = context => {
1111
ava.isInTestFile,
1212
ava.isTestNode
1313
])(node => {
14-
const functionArg = node.arguments[node.arguments.length - 1];
14+
const functionArgIndex = node.arguments.length - 1;
15+
if (functionArgIndex > 1) {
16+
return;
17+
}
18+
19+
const functionArg = node.arguments[functionArgIndex];
1520

1621
if (!(functionArg && functionArg.params && functionArg.params.length > 0)) {
1722
return;

test/use-t.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ ruleTester.run('use-t', rule, {
3434
header + 'test(testFunction);',
3535
header + 'test.todo("test name");',
3636
// Shouldn't be triggered since it's not a test file
37-
'test(foo => {});'
37+
'test(foo => {});',
38+
header + 'test(macro, arg1, (p1) => {})',
39+
header + 'test("name", macro, arg1, (p1) => {})',
40+
header + 'test("name", macro, (p1) => {})'
3841
],
3942
invalid: [
4043
{

0 commit comments

Comments
 (0)