Rules
prefer-shorthand-boolean
Full Name in eslint-plugin-react-x
react-x/prefer-shorthand-boolean
Full Name in @eslint-react/eslint-plugin
@eslint-react/prefer-shorthand-boolean
Features
🔧
Description
Enforces shorthand syntax for boolean attributes.
Examples
Failing
import React from "react";
function MyComponent() {
return <button disabled={true} />;
// ^^^^^^^^^^^^^^^
// - Use shorthand boolean attribute 'disabled'.
}
Passing
import React from "react";
function MyComponent() {
return <button disabled />;
}
Implementation
See Also
avoid-shorthand-boolean
Enforces the use of explicit boolean values for boolean attributes.avoid-shorthand-fragment
Enforces the use of explicit<Fragment>
or<React.Fragment>
components instead of the shorthand<>
or</>
syntax.prefer-shorthand-fragment
Enforces the use of shorthand syntax for fragments.