logoESLint React
Rules

jsx-shorthand-boolean

Full Name in @eslint-react/eslint-plugin

@eslint-react/jsx-shorthand-boolean

Full Name in eslint-plugin-react-x

react-x/jsx-shorthand-boolean

Features

🔧 ⚙️

Description

Enforces the use of shorthand syntax for boolean attributes.

Rule Options

This rule has a single integer option with the following values:

  • 1 (Default): Always use shorthand syntax for boolean attributes.
  • -1: Never use shorthand syntax for boolean attributes.

Examples

Failing

import React from "react";

function MyComponent() {
  return <button disabled={true} />;
  //             ^^^^^^^^^^^^^^^
  //             - Omit the `=true` for boolean attributes.
}

Passing

import React from "react";

function MyComponent() {
  return <button disabled />;
}

Implementation


See Also

On this page