Skip to content

Commit f70612d

Browse files
committed
fix(no-test-callback): check argument is an identifier
1 parent e7e092a commit f70612d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/rules/__tests__/no-test-callback.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ ruleTester.run('no-test-callback', rule, {
1818
'test("something", someArg)',
1919
],
2020
invalid: [
21+
{
22+
code: 'test("something", (...args) => {args[0]();})',
23+
errors: [
24+
{
25+
messageId: 'illegalTestCallback',
26+
line: 1,
27+
column: 20,
28+
},
29+
],
30+
},
2131
{
2232
code: 'test("something", done => {done();})',
2333
errors: [{ messageId: 'illegalTestCallback', line: 1, column: 19 }],

src/rules/no-test-callback.ts

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export default createRule({
3434

3535
const [argument] = callback.params;
3636

37+
if (argument.type !== AST_NODE_TYPES.Identifier) {
38+
context.report({
39+
node: argument,
40+
messageId: 'illegalTestCallback',
41+
});
42+
43+
return;
44+
}
45+
3746
if (callback.async) {
3847
context.report({
3948
node: argument,

0 commit comments

Comments
 (0)