jsx-curly-newline
Configuration
Enforce consistent linebreaks inside the curly braces of JSX expression containers ({ ... } in attribute values and children).
Rule Details
For each JSX expression container the rule checks two positions: right after the opening { and right before the closing }. Whether a newline is required at those positions is controlled by the option, chosen by whether the contained expression spans a single line or multiple lines.
The rule only manages the linebreaks themselves; it does not adjust indentation (that is the job of an indentation rule).
Options
This rule accepts either a string or an object.
-
"consistent"(default) — the closing brace's linebreak must match the opening brace's: if there is a newline after{, there must be one before}, and vice versa. -
"never"— no linebreaks are allowed after{or before}. -
An object
{ "singleline": ..., "multiline": ... }, where each property is one of:"consistent"(default for each property) — match the opening brace, as above."require"— a newline is required after{and before}."forbid"— newlines after{and before}are not allowed.
singlelineapplies when the expression is on a single line;multilineapplies when it spans multiple lines.
Examples of incorrect code for this rule with the default "consistent" option:
Examples of correct code for this rule with the default "consistent" option:
Examples of incorrect code for this rule with the "never" option:
Examples of correct code for this rule with the "never" option:
Examples of incorrect code for this rule with the { "singleline": "consistent", "multiline": "require" } option:
Examples of correct code for this rule with the { "singleline": "consistent", "multiline": "require" } option: