refactor(oxlint): extract shared isBooleanPrefixedPropName util#704
Open
aidenybai wants to merge 2 commits into
Open
refactor(oxlint): extract shared isBooleanPrefixedPropName util#704aidenybai wants to merge 2 commits into
aidenybai wants to merge 2 commits into
Conversation
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.
5 tasks
commit: |
Contributor
|
No React Doctor issues found. 🎉 Reviewed by React Doctor for commit |
Member
Author
|
/rde parity |
|
❌ Parity failed — trace |
Member
Author
|
/rde parity |
Member
Author
|
/rde parity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
^(?:is|has|should|can|show|hide|enable|disable|with)[A-Z]) out ofno-many-boolean-propsinto a single-purpose utilisBooleanPrefixedPropName(one util per file).no-many-boolean-props— behavior-preserving (the regex is byte-identical, nog-flag state).Foundation for the stacked PR that adds
prefer-explicit-variants, which reuses the same predicate instead of duplicating the pattern.Test plan
is-boolean-prefixed-prop-name.test.tsrun-oxlint/architecture.test.ts—no-many-boolean-propsstill fires (behavior unchanged)typecheck/lint/format:checkNote
Low Risk
Maintainability-only lint additions at warn severity with broad false-positive guards;
no-many-boolean-propsbehavior is unchanged via the extracted predicate.Overview
Adds a new
prefer-explicit-variantsarchitecture 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 wiresno-many-boolean-propsthrough it unchanged. AddsisJsxElementOrFragment,BOOLEAN_PROP_VARIANT_BRANCH_THRESHOLD, registry wiring, andAPP_ONLY_RULE_KEYSentry for the new rule.Reviewed by Cursor Bugbot for commit d942131. Bugbot is set up for automated code reviews on this repo. Configure here.