From 1cfc491ddfaf106c260b771c7a5e5becf656aee1 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Sun, 8 Sep 2019 03:58:46 -0400 Subject: [PATCH] Add additional tests --- lib/rules/indent.js | 2 +- tests/lib/rules/indent.js | 68 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/lib/rules/indent.js b/lib/rules/indent.js index def169c33a9..a87e323c7d1 100644 --- a/lib/rules/indent.js +++ b/lib/rules/indent.js @@ -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); diff --git a/tests/lib/rules/indent.js b/tests/lib/rules/indent.js index ed2d2a0fc4f..082c784e77f 100644 --- a/tests/lib/rules/indent.js +++ b/tests/lib/rules/indent.js @@ -4983,6 +4983,15 @@ ruleTester.run("indent", rule, { // comment ;(async () => {})() `, + unIndent` + { + let foo + + // comment + + ;(async () => {})() + } + `, unIndent` const foo = 1 const bar = foo @@ -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 { @@ -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 @@ -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 {