useConsistentBooleanProps (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useConsistentBooleanProps - This rule has a safe fix.
- The default severity of this rule is information.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useConsistentBooleanProps": "error" } } }}Description
Section titled “Description”Require a consistent style for JSX props with the value true
In JSX, <Foo bar /> and <Foo bar={true} /> are equivalent.
If style.noImplicitBoolean is enabled, turn it off before using implicit mode.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<Foo bar />code-block.jsx:1:6 lint/nursery/useConsistentBooleanProps FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This JSX attribute omits the required explicit true value.
> 1 │ <Foo bar />
│ ^^^
2 │
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Add an explicit true value.
1 │ <Foo·bar={true}·/>
│ +++++++
<Foo bar={true} enabled={false} disabled={disabled} />Options
Section titled “Options”The default, explicit, requires ={true}. Use implicit to require the shorthand.
{ "linter": { "rules": { "nursery": { "useConsistentBooleanProps": { "level": "on", "options": { "mode": "implicit" } } } } }}<Foo bar={true} />code-block.jsx:1:6 lint/nursery/useConsistentBooleanProps FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This JSX attribute already implies true when written without a value.
> 1 │ <Foo bar={true} />
│ ^^^^^^^^^^
2 │
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove the explicit true value.
1 │ <Foo·bar={true}·/>
│ -------
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.