Skip to content

Conversation

@hiteshshetty-dev
Copy link
Contributor

What changed / motivation ?

ESLint rule was incorrectly flagging valid style properties when values were assigned conditionally using ternary operators (? :) or logical operators (||, ??, &&).

Enhanced the validation logic to properly traverse and validate both branches of conditional expressions:

  • Ternary expressions: Validates both consequent and alternate branches
  • Logical expressions: Validates both left and right operands for ||, ??, and && operators

Please let me know if I’ve missed any scenarios or if you’d suggest further refactoring. I’m happy to incorporate feedback.

Linked PR/Issues

Fixes: #1259

Additional Context

Before:
Screenshot 2025-10-04 at 6 13 46 PM

After:
Screenshot 2025-10-04 at 6 15 54 PM

Pre-flight checklist

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 4, 2025
@hiteshshetty-dev hiteshshetty-dev changed the title feat(eslint-plugin): enhance validation for ternary and logical expressions in style properties [eslint-plugin] enhance validation for ternary and logical expressions in style properties Oct 10, 2025
@mellyeliu
Copy link
Member

Thanks for putting this up! Will get to this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[eslint-plugin] valid-styles mistakenly reports ternary conditions (with all valid values) as invalid

2 participants