close

jsx-curly-brace-presence

Configuration

rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/jsx-curly-brace-presence': 'error',
    },
  },
]);

Rule Details

Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children.

By default, the rule warns about unnecessary curly braces in both JSX props and children. Prop values that are JSX elements are ignored by default.

Examples of incorrect code for this rule:

<App prop={'foo'} attr={"bar"}>{'Hello world'}</App>;

Examples of correct code for this rule:

<App prop="foo" attr="bar">Hello world</App>;

Examples of incorrect code for this rule with { "props": "always", "children": "always" }:

{ "react/jsx-curly-brace-presence": ["error", { "props": "always", "children": "always" }] }
<App>Hello world</App>;
<App prop='Hello world'>{'Hello world'}</App>;

Examples of incorrect code for this rule with { "props": "always", "children": "always", "propElementValues": "always" }:

{ "react/jsx-curly-brace-presence": ["error", { "props": "always", "children": "always", "propElementValues": "always" }] }
<App prop=<div /> />;

Examples of incorrect code for this rule with { "props": "never", "children": "never", "propElementValues": "never" }:

{ "react/jsx-curly-brace-presence": ["error", { "props": "never", "children": "never", "propElementValues": "never" }] }
<App prop={<div />} />;

Options

The rule accepts either an options object or a single string shorthand:

{ "react/jsx-curly-brace-presence": ["error", { "props": "never", "children": "never", "propElementValues": "ignore" }] }
{ "react/jsx-curly-brace-presence": ["error", "never"] }

Each of props, children, and propElementValues accepts:

  • "always" — enforce curly braces.
  • "never" — disallow unnecessary curly braces.
  • "ignore" — disable the check.

The string shorthand sets props and children to the given value; propElementValues stays at its default of "ignore".

Original Documentation