close

jsx-curly-newline

Unreleased

Configuration

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

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

Enforce consistent line breaks immediately inside curly braces in JSX attributes and expressions.

Rule Details

This rule checks both braces of every JSX expression container. It can require, forbid, or keep consistent the newline directly after { and directly before }. Comments are preserved: a diagnostic adjacent to a comment may not be autofixable.

Examples of incorrect code with the default "consistent" option:

<div>{ foo
}</div>

<div>{
  foo }</div>

Examples of correct code:

<div>{ foo }</div>

<div>{
  foo
}</div>

Rule Options

The default is "consistent", an alias for:

{ "singleline": "consistent", "multiline": "consistent" }

"never" is an alias for { "singleline": "forbid", "multiline": "forbid" }. Alternatively, use an object with independently configured singleline and multiline values: "consistent", "require", or "forbid".

{ "react/jsx-curly-newline": ["error", { "singleline": "require", "multiline": "forbid" }] }

With "require", both immediate brace boundaries must have newlines. With "forbid", neither boundary may have one. With "consistent", the right boundary follows the existing state of the left boundary.

Original Documentation