Skip to content

Commit

Permalink
Adapt to ast array elements posibly being null
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Jul 5, 2024
1 parent be051c0 commit eb258fa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/eslint-plugin/src/rules/syntax-preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ const checkExpressionPreferringObject = (
) => {
switch (node.type) {
case AST_NODE_TYPES.ArrayExpression:
node.elements.forEach(element =>
checkExpressionPreferringObject(context, element)
)
node.elements.forEach(element => {
if (element) {
checkExpressionPreferringObject(context, element)
}
})
return
case AST_NODE_TYPES.TemplateLiteral:
context.report({
Expand Down Expand Up @@ -154,9 +156,11 @@ const checkExpressionPreferringString = (
) => {
switch (node.type) {
case 'ArrayExpression':
node.elements.forEach(element =>
checkExpressionPreferringString(context, element)
)
node.elements.forEach(element => {
if (element) {
checkExpressionPreferringString(context, element)
}
})
return
case 'ObjectExpression':
context.report({
Expand Down

0 comments on commit eb258fa

Please sign in to comment.