Skip to content

Commit

Permalink
Update: semi-spacing should check do-while statements (#13358)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jun 13, 2020
1 parent cbd0d00 commit 7686d7f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rules/semi-spacing.js
Expand Up @@ -223,6 +223,7 @@ module.exports = {
BreakStatement: checkNode,
ContinueStatement: checkNode,
DebuggerStatement: checkNode,
DoWhileStatement: checkNode,
ReturnStatement: checkNode,
ThrowStatement: checkNode,
ImportDeclaration: checkNode,
Expand Down
49 changes: 48 additions & 1 deletion tests/lib/rules/semi-spacing.js
Expand Up @@ -55,7 +55,9 @@ ruleTester.run("semi-spacing", rule, {
"function foo(){return 2;}",
"for(var i = 0; i < results.length;) {}",
{ code: "function foo() { return 2; }", options: [{ after: false }] },
{ code: "for ( var i = 0;i < results.length; ) {}", options: [{ after: false }] }
{ code: "for ( var i = 0;i < results.length; ) {}", options: [{ after: false }] },

"do {} while (true); foo"
],
invalid: [
{
Expand Down Expand Up @@ -370,6 +372,51 @@ ruleTester.run("semi-spacing", rule, {
endColumn: 7
}
]
},
{
code: "do {} while (true) ;",
output: "do {} while (true);",
errors: [{
messageId: "unexpectedWhitespaceBefore",
type: "DoWhileStatement",
line: 1,
column: 19,
endLine: 1,
endColumn: 20
}]
},
{
code: "do {} while (true);foo",
output: "do {} while (true); foo",
errors: [{
messageId: "missingWhitespaceAfter",
type: "DoWhileStatement",
line: 1,
column: 19,
endLine: 1,
endColumn: 20
}]
},
{
code: "do {} while (true); foo",
output: "do {} while (true) ;foo",
options: [{ before: true, after: false }],
errors: [{
messageId: "missingWhitespaceBefore",
type: "DoWhileStatement",
line: 1,
column: 19,
endLine: 1,
endColumn: 20
},
{
messageId: "unexpectedWhitespaceAfter",
type: "DoWhileStatement",
line: 1,
column: 20,
endLine: 1,
endColumn: 22
}]
}
]
});

0 comments on commit 7686d7f

Please sign in to comment.