curly
Configuration
Rule Details
This rule enforces consistent use of curly braces around blocks that follow
if, else, for, for...in, for...of, while, and do...while
statements. By default it requires braces everywhere, but it can also be
configured to forbid them where they are unnecessary.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
The rule accepts a primary string option and an optional secondary
"consistent" modifier: ["error", "multi", "consistent"].
"all" (default)
Requires braces around every block.
"multi"
Forbids braces around blocks that contain a single statement, and requires them when the block contains two or more statements.
Examples of incorrect code for "multi":
Examples of correct code for "multi":
"multi-line"
Allows brace-less single-line statements, but requires braces once a statement spans multiple lines.
Examples of correct code for "multi-line":
"multi-or-nest"
Forces brace-less syntax for a single-line statement, and requires braces for a multi-line statement or a statement that contains a nested block.
Examples of correct code for "multi-or-nest":
"consistent"
Used together with "multi", "multi-line", or "multi-or-nest", this option
forces all branches of an if/else if/else chain to agree: either all have
braces or none do.
Examples of correct code for ["multi", "consistent"]: