Skip to content

Commit 952b95e

Browse files
committed
refactor: minor improvements
1 parent bf93b7d commit 952b95e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ export default createRule<[], MessageID>({
191191
return match<typeof node, O.Option<ReportDescriptor<MessageID>>>(node)
192192
.when(isJSX, O.none)
193193
.with({ type: NodeType.LogicalExpression, operator: "&&" }, ({ left, right }) => {
194+
const isLeftUnaryNot = isMatching({ type: NodeType.UnaryExpression, operator: "!" }, left);
195+
if (isLeftUnaryNot) return checkExpression(right);
194196
const initialScope = context.sourceCode.getScope(left);
195197
const isLeftNan = isMatching({ type: NodeType.Identifier, name: "NaN" }, left)
196198
|| getStaticValue(left, initialScope)?.value === "NaN";
@@ -201,8 +203,6 @@ export default createRule<[], MessageID>({
201203
node: left,
202204
});
203205
}
204-
const isLeftUnaryNot = isMatching({ type: NodeType.UnaryExpression, operator: "!" }, left);
205-
if (isLeftUnaryNot) return checkExpression(right);
206206
const leftType = getConstrainedTypeAtLocation(services, left);
207207
const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
208208
const isLeftValid = Array

0 commit comments

Comments
 (0)