Skip to content

Commit 4586bdc

Browse files
SaberreSimenB
authored andcommitted
fix(valid-describe): allow concise body arrow function (#106)
1 parent 8213ada commit 4586bdc

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Diff for: rules/__tests__/valid-describe.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ ruleTester.run('valid-describe', rule, {
3434
})
3535
})
3636
`,
37+
`
38+
describe('foo', () =>
39+
test('bar', () => {})
40+
)
41+
`,
3742
],
3843
invalid: [
3944
{

Diff for: rules/valid-describe.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ module.exports = {
7676
loc: paramsLocation(callbackFunction.params),
7777
});
7878
}
79-
callbackFunction.body.body.forEach(node => {
80-
if (node.type === 'ReturnStatement') {
81-
context.report({
82-
message: 'Unexpected return statement in describe callback',
83-
node,
84-
});
85-
}
86-
});
79+
if (callbackFunction.body.type === 'BlockStatement') {
80+
callbackFunction.body.body.forEach(node => {
81+
if (node.type === 'ReturnStatement') {
82+
context.report({
83+
message: 'Unexpected return statement in describe callback',
84+
node,
85+
});
86+
}
87+
});
88+
}
8789
}
8890
},
8991
};

0 commit comments

Comments
 (0)