Skip to content

Commit

Permalink
fix: js curly rule doesn't work without else clause (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
scr2em authored Apr 11, 2024
1 parent 19332d5 commit 427d0c7
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 427d0c7

Please sign in to comment.