Skip to content

Commit

Permalink
avoid using invalid Array.some syntax
Browse files Browse the repository at this point in the history
This isn't available in earlier node versions
  • Loading branch information
Belco90 committed Mar 27, 2022
1 parent 6c6a49a commit 160134a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rules/jsx-no-leaked-zero.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ module.exports = {
return {
'JSXExpressionContainer > LogicalExpression[operator="&&"]'(node) {
const leftSide = node.left;
const VALID_LEFT_SIDE_EXPRESSIONS = ['UnaryExpression', 'BinaryExpression', 'CallExpression'];
const CAST_VALID_LEFT_SIDE_EXPRESSIONS = ['UnaryExpression', 'BinaryExpression', 'CallExpression'];
const isCastStrategyValid = areBothStrategiesValid || fixStrategy === CAST_STRATEGY;
const isCastValidLeftExpression = CAST_VALID_LEFT_SIDE_EXPRESSIONS.some(
(validExpression) => validExpression === leftSide.type
);

if (isCastStrategyValid && VALID_LEFT_SIDE_EXPRESSIONS.includes(leftSide.type)) {
if (isCastStrategyValid && isCastValidLeftExpression) {
return;
}

Expand Down

0 comments on commit 160134a

Please sign in to comment.