logoESLint React
Rules

avoid-shorthand-boolean

Full Name in eslint-plugin-react-x

react-x/avoid-shorthand-boolean

Full Name in @eslint-react/eslint-plugin

@eslint-react/avoid-shorthand-boolean

Features

🔧

Description

Enforces explicit boolean values for boolean attributes.

Examples

Failing

const Input = <input type="checkbox" checked />;
//                                   ^^^^^^^
//                                   - Expected `checked={true}` instead of `checked`
const button = <button disabled />;
//                     ^^^^^^^^
//                     - Expected `disabled={true}` instead of `disabled`

Passing

const Input = <input type="checkbox" checked={true} />;
const button = <button disabled={true} />;

Implementation


See Also

On this page