Skip to content

Commit c7400c1

Browse files
committed
Fix: prefer-output-null crashes, when a test case is not object.
1 parent 93bd142 commit c7400c1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/rules/prefer-output-null.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ module.exports = {
4040
* @returns {Node} found node; if not found, return null;
4141
*/
4242
function getTestInfo (key) {
43-
const res = test.properties.filter(item => item.key.name === key);
44-
return res.length ? res[res.length - 1] : null;
43+
if (test.type === 'ObjectExpression') {
44+
const res = test.properties.filter(item => item.key.name === key);
45+
return res.length ? res[res.length - 1] : null;
46+
}
47+
return key === 'code' ? test : null;
4548
}
4649

4750
const code = getTestInfo('code');

0 commit comments

Comments
 (0)