Skip to content

Commit abcb81e

Browse files
authoredNov 29, 2022
Fix: false positives with arrow functions in no-hooks-from-ancestor-modules rule (#275)
1 parent 98572d5 commit abcb81e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎lib/rules/no-hooks-from-ancestor-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
function getCallbackArg(args) {
6464
// Callback can be either args[1] or args[2]
6565
// https://api.qunitjs.com/QUnit/module/
66-
return args.slice(1, 3).find(arg => arg.type === "FunctionExpression");
66+
return args.slice(1, 3).find(arg => ["FunctionExpression", "ArrowFunctionExpression"].includes(arg.type));
6767
}
6868

6969
function getHooksIdentifierFromParams(params) {

‎tests/lib/rules/no-hooks-from-ancestor-modules.js

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ ruleTester.run("no-hooks-from-ancestor-modules", rule, {
4545
QUnit.module("module", function(hooks) { hooks.beforeEach(function() {}); });
4646
`,
4747
`
48+
QUnit.module("module", (hooks) => { hooks.beforeEach(() => {}); });
49+
`,
50+
`
51+
QUnit.module("module", (hooks) => { QUnit.module("module", (hooks) => { hooks.beforeEach(() => {}); }) });
52+
`,
53+
`
4854
QUnit.module("module", function(hooks) { hooks.afterEach(function() {}); });
4955
`,
5056
`

0 commit comments

Comments
 (0)
Please sign in to comment.