Skip to content

Commit

Permalink
fix(curly-rule): enforce braces for else clause
Browse files Browse the repository at this point in the history
  • Loading branch information
scr2em committed Apr 11, 2024
1 parent 19332d5 commit f5f9028
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .grit/patterns/js/curly.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ engine marzano(1.0)
language js
or {
`if($_) $body`,
if_statement(consequence = $body),
for_statement($body),
while_statement($body),
do_statement($body),
else_clause(else = $body) where {
$body <: ! if_statement()
}
} where {
$body <: not statement_block(),
$body => `{$body}`,
Expand All @@ -33,6 +36,23 @@ if (x > 0) {
doStuff();
}
```

##else
```js
if (x > 0)
doStuff();
else
console.log("e");
```
will become
```js
if (x > 0) {
doStuff();
} else {
console.log("e");
}
```

## for
```js
for (var i = 0; i < 10; i++)
Expand Down

0 comments on commit f5f9028

Please sign in to comment.