DocumentationRulesprefer-shorthand-boolean

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 Example() {
  return <button disabled={true} />;
  //             ^^^^^^^^^^^^^^^
  //             - Use shorthand boolean attribute 'disabled'.
}

Passing

import React from "react";
 
function Example() {
  return <button disabled />;
}