Skip to content

refactor(oxlint): extract shared isBooleanPrefixedPropName util#704

Open
aidenybai wants to merge 2 commits into
mainfrom
refactor/boolean-prefixed-prop-util
Open

refactor(oxlint): extract shared isBooleanPrefixedPropName util#704
aidenybai wants to merge 2 commits into
mainfrom
refactor/boolean-prefixed-prop-util

Conversation

@aidenybai
Copy link
Copy Markdown
Member

@aidenybai aidenybai commented Jun 6, 2026

Summary

  • Extracts the boolean-prop-name regex (^(?:is|has|should|can|show|hide|enable|disable|with)[A-Z]) out of no-many-boolean-props into a single-purpose util isBooleanPrefixedPropName (one util per file).
  • Reuses it in no-many-boolean-propsbehavior-preserving (the regex is byte-identical, no g-flag state).
  • Adds a focused unit test for the predicate.

Foundation for the stacked PR that adds prefer-explicit-variants, which reuses the same predicate instead of duplicating the pattern.

Test plan

  • new unit test is-boolean-prefixed-prop-name.test.ts
  • integration run-oxlint/architecture.test.tsno-many-boolean-props still fires (behavior unchanged)
  • typecheck / lint / format:check

Note

Low Risk
Maintainability-only lint additions at warn severity with broad false-positive guards; no-many-boolean-props behavior is unchanged via the extracted predicate.

Overview
Adds a new prefer-explicit-variants architecture rule (warn, app-only) that warns when a component uses two or more boolean-prefixed props, each as the test of a two-sided JSX ternary swapping whole subtrees—nudging split into explicit variant components. Heuristics deliberately skip single switches, null arms, non-JSX arms, nested render props, and a curated set of cross-cutting props (isLoading, isMobile, etc.).

Refactor: moves the boolean-prop name regex into shared isBooleanPrefixedPropName (with unit tests) and wires no-many-boolean-props through it unchanged. Adds isJsxElementOrFragment, BOOLEAN_PROP_VARIANT_BRANCH_THRESHOLD, registry wiring, and APP_ONLY_RULE_KEYS entry for the new rule.

Reviewed by Cursor Bugbot for commit d942131. Bugbot is set up for automated code reviews on this repo. Configure here.

Pull the boolean-prop-name regex out of no-many-boolean-props into a
single-purpose util so the upcoming prefer-explicit-variants rule can
reuse it instead of duplicating the pattern. Behavior-preserving; adds a
unit test for the predicate.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@704
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@704
npm i https://pkg.pr.new/react-doctor@704

commit: d942131

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

No React Doctor issues found. 🎉

Reviewed by React Doctor for commit d942131.

@aidenybai
Copy link
Copy Markdown
Member Author

/rde parity

@react-doctor-evals
Copy link
Copy Markdown

react-doctor-evals Bot commented Jun 6, 2026

❌ Parity failed — trace 358600bebb4da9ab1e50a4145dc36d15. Check server logs for that trace ID.

@aidenybai
Copy link
Copy Markdown
Member Author

/rde parity

@aidenybai
Copy link
Copy Markdown
Member Author

/rde parity

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant