Skip to content

Commit

Permalink
[Tests] jsx-key: add some debugging info
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 10, 2022
1 parent 86f17d2 commit 0d1a62e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/jsx-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {
if (node.alternate) {
getReturnStatements(node.alternate, returnStatements);
}
} else if (node.body) {
} else if (Array.isArray(node.body)) {
node.body.forEach((item) => {
if (item.type === 'IfStatement') {
getReturnStatements(item, returnStatements);
Expand All @@ -105,6 +105,8 @@ module.exports = {
returnStatements.push(item);
}
});
} else if (node.body) {
throw new TypeError(`jsx-key: non-array truthy node.body found: ${JSON.stringify(node.body)}`);
}

return returnStatements;
Expand Down

0 comments on commit 0d1a62e

Please sign in to comment.