Skip to content

Commit

Permalink
Add semi colon to non-block expression
Browse files Browse the repository at this point in the history
  • Loading branch information
zaicevas committed Mar 22, 2022
1 parent 6b0ed64 commit 93b6637
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rules/no-array-for-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ function getFixFunction(callExpression, functionInfo, context) {
const indentedForOfClosingBracket = isSingleLine ? '}' : `${indentString('}', 1, {indent: '\t'})}`;
const isMultilineBlock = callback.body.type === 'BlockStatement' && !isSingleLine;

if (callback.body.type !== 'BlockStatement' && isSingleLine) {
yield fixer.insertTextAfter(callback.body, ';')
}

if (!isMultilineBlock) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/no-array-for-each.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ test({
`,
output: outdent`
if (foo) {
for (const element of foo) console.log(element)
for (const element of foo) console.log(element);
}
`,
errors: 1,
Expand All @@ -498,7 +498,7 @@ test({
`,
output: outdent`
if (foo) {
for (const element of foo) console.log(element)
for (const element of foo) console.log(element);
}
`,
errors: 1,
Expand Down

0 comments on commit 93b6637

Please sign in to comment.