Skip to content

πŸ“Ž Implement useImplicitBooleanΒ #5095

Description

@dyc3

Description

Add useImplicitBoolean, a rule that enforces using implicit booleans in JSX over explicit boolean props.

Valid

<Foo bar />
<Foo bar={false} />

Invalid

<Foo bar={true} />

Requested here: #3 (comment)

Source: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md

Note that we already have noImplicitBoolean, the opposite of this rule. Would it be worth it to combine them into one rule? The best time to do so would be before 2.0.

Activity

  1. added
    S-Needs discussion
    on Feb 11, 2025
  2. arendjr commented on Feb 12, 2025

    @arendjr
    Contributor

    useConsistentBooleanProps with values implicit and explicit?

    I don’t really like that noExplicitBoolean has no reference in its name that it’s for use with JSX; it sounds like something TypeScript-specific.

  3. ematipico commented on Mar 19, 2025

    @ematipico
    Member

    I removed the rule from v2. This can be shipped whenever we can, and it shouldn't stop us from releasing v2

  4. izakfilmalter commented on Aug 19, 2025

    @izakfilmalter

    Bit confused here, is there a rule that marks

    <Foo bar={true} />

    as invalid?

  5. siketyan commented on Aug 19, 2025

    @siketyan
    Member

    @izakfilmalter That is what this issue will achieve.

  6. vladimir-ivanov commented on Nov 16, 2025

    @vladimir-ivanov
    Contributor

    @arendjr @siketyan @dyc3 @ematipico
    can we do a rule like:

    "useConsistentBooleanProps": {
      "mode": "implicit"   // enforce <Foo bar />
    }
    // or:
    "useConsistentBooleanProps": {
      "mode": "explicit"   // enforce <Foo bar={true} />
    }

    Or do we want React specific (tsx, jsx only).

    And what happens with the existing one if we introduce a different rule please? mark as deprecated?

    I am a fan of implicit mode for react personally and happy to implement it once there is an agreement on the approach.

    Thank you

  7. ematipico commented on Nov 16, 2025

    @ematipico
    Member

    I think it's a good plan, and we already deprecated rules in favour of others.

    One thing that this new rule needs to do is to ignore cases like

    let disabled = false;
    <Foo disabled={disabled}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

S-Needs discussion

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions