Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Sep 8, 2019
1 parent 4f32d17 commit 1cfc491
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/indent.js
Expand Up @@ -1594,7 +1594,7 @@ module.exports = {

// If the line after a comment begins with a semicolon, validate the indentation against the previous line.
if (
tokenBefore && tokenAfter && tokenAfter.type === "Punctuator" && tokenAfter.value === ";"
tokenBefore && tokenAfter && astUtils.isSemicolonToken(tokenAfter)
) {
const firstTokenOfPrevLine = tokenInfo.firstTokensByLineNumber.get(tokenBefore.loc.start.line);

Expand Down
68 changes: 68 additions & 0 deletions tests/lib/rules/indent.js
Expand Up @@ -4983,6 +4983,15 @@ ruleTester.run("indent", rule, {
// comment
;(async () => {})()
`,
unIndent`
{
let foo
// comment
;(async () => {})()
}
`,
unIndent`
const foo = 1
const bar = foo
Expand Down Expand Up @@ -5020,6 +5029,17 @@ ruleTester.run("indent", rule, {
/* comment */
;[1, 2, 3].forEach(() => {})
`,
unIndent`
{
const foo = 1
const bar = foo
/* comment */
;[1, 2, 3].forEach(() => {})
}
`,

// import expressions
{
Expand Down Expand Up @@ -9730,6 +9750,29 @@ ruleTester.run("indent", rule, {
`,
errors: expectedErrors([1, 0, 4, "Line"])
},
{
code: unIndent`
{
let foo
// comment
;(async () => {})()
}
`,
output: unIndent`
{
let foo
// comment
;(async () => {})()
}
`,
errors: expectedErrors([4, 4, 8, "Line"])
},
{
code: unIndent`
const foo = 1
Expand Down Expand Up @@ -9788,6 +9831,31 @@ ruleTester.run("indent", rule, {
`,
errors: expectedErrors([1, 0, 4, "Block"])
},
{
code: unIndent`
{
const foo = 1
const bar = foo
/* comment */
;[1, 2, 3].forEach(() => {})
}
`,
output: unIndent`
{
const foo = 1
const bar = foo
/* comment */
;[1, 2, 3].forEach(() => {})
}
`,
errors: expectedErrors([5, 4, 8, "Block"])
},

// import expressions
{
Expand Down

0 comments on commit 1cfc491

Please sign in to comment.