Skip to content

Commit f5f9028

Browse files
committed
fix(curly-rule): enforce braces for else clause
1 parent 19332d5 commit f5f9028

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.grit/patterns/js/curly.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ engine marzano(1.0)
1010
language js
1111
1212
or {
13-
`if($_) $body`,
13+
if_statement(consequence = $body),
1414
for_statement($body),
1515
while_statement($body),
1616
do_statement($body),
17+
else_clause(else = $body) where {
18+
$body <: ! if_statement()
19+
}
1720
} where {
1821
$body <: not statement_block(),
1922
$body => `{$body}`,
@@ -33,6 +36,23 @@ if (x > 0) {
3336
doStuff();
3437
}
3538
```
39+
40+
##else
41+
```js
42+
if (x > 0)
43+
doStuff();
44+
else
45+
console.log("e");
46+
```
47+
will become
48+
```js
49+
if (x > 0) {
50+
doStuff();
51+
} else {
52+
console.log("e");
53+
}
54+
```
55+
3656
## for
3757
```js
3858
for (var i = 0; i < 10; i++)

0 commit comments

Comments
 (0)