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
avoid-shorthand-fragment
Enforces the use of explicit<Fragment>
or<React.Fragment>
components instead of the shorthand<>
or</>
syntax.prefer-shorthand-boolean
Enforces the use of shorthand syntax for boolean attributes.prefer-shorthand-fragment
Enforces the use of shorthand syntax for fragments.