Skip to content

useConsistentBooleanProps (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentBooleanProps": "error"
}
}
}
}

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.

<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} />

The default, explicit, requires ={true}. Use implicit to require the shorthand.

biome.json
{
"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}·/>
│ -------