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
🔍
🔧
What it does
Enforces the use of explicit boolean values for boolean attributes.
A safe auto-fix is available for this rule.
Examples
Failing
import React from "react";
function MyComponent() {
return <button disabled />;
// ^^^^^^^^
// - Avoid using shorthand syntax for 'disabled' attribute.
}
Passing
import React from "react";
function MyComponent() {
return <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.