prefer-shorthand-boolean
Rule category
Style.
What it does
Enforces the use of shorthand syntax for boolean attributes.
Examples
This rule enforces the use of shorthand syntax for boolean attributes.
Failing
import React from "react";
function function Example(): React.JSX.Element
Example() {
return <JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button React.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
disabled={true} />;
// - Prefer using shorthand syntax for 'disabled' attribute.
}
Passing
import React from "react";
function function Example(): React.JSX.Element
Example() {
return <JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
button React.ButtonHTMLAttributes<HTMLButtonElement>.disabled?: boolean | undefined
disabled />;
}