From 22eae1d27f313d1482d2047bef9c0fb1138c113c Mon Sep 17 00:00:00 2001 From: James Clark Date: Sat, 29 Apr 2017 14:39:40 -0400 Subject: [PATCH 1/2] Don't report 'statements are not aligned' for empty statements See issue #2608 --- src/rules/alignRule.ts | 4 ++-- test/rules/align/statements/test.ts.lint | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rules/alignRule.ts b/src/rules/alignRule.ts index e08b6d82775..39433ae95e8 100644 --- a/src/rules/alignRule.ts +++ b/src/rules/alignRule.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { getNextToken, isBlockLike } from "tsutils"; +import { getNextToken, isBlockLike, isEmptyStatement } from "tsutils"; import * as ts from "typescript"; import * as Lint from "../index"; @@ -82,7 +82,7 @@ class AlignWalker extends Lint.AbstractWalker { public walk(sourceFile: ts.SourceFile) { const cb = (node: ts.Node): void => { if (this.options.statements && isBlockLike(node)) { - this.checkAlignment(node.statements, OPTION_STATEMENTS); + this.checkAlignment(node.statements.filter(s => !isEmptyStatement(s)), OPTION_STATEMENTS); } else { switch (node.kind) { case ts.SyntaxKind.NewExpression: diff --git a/test/rules/align/statements/test.ts.lint b/test/rules/align/statements/test.ts.lint index 473331dd715..412c6dfdd81 100644 --- a/test/rules/align/statements/test.ts.lint +++ b/test/rules/align/statements/test.ts.lint @@ -153,9 +153,7 @@ function shouldntCrash() { if (foo) { bar; }; - ~ [statements are not aligned] if (foo) { bar; } /* should not be removed */; - ~ [statements are not aligned] From 479c33b3598faaf25db34c61874b59fd5202dcb8 Mon Sep 17 00:00:00 2001 From: James Clark Date: Sat, 29 Apr 2017 15:04:13 -0400 Subject: [PATCH 2/2] Add parens to arrow function --- src/rules/alignRule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules/alignRule.ts b/src/rules/alignRule.ts index 39433ae95e8..78c62a01b5e 100644 --- a/src/rules/alignRule.ts +++ b/src/rules/alignRule.ts @@ -82,7 +82,7 @@ class AlignWalker extends Lint.AbstractWalker { public walk(sourceFile: ts.SourceFile) { const cb = (node: ts.Node): void => { if (this.options.statements && isBlockLike(node)) { - this.checkAlignment(node.statements.filter(s => !isEmptyStatement(s)), OPTION_STATEMENTS); + this.checkAlignment(node.statements.filter((s) => !isEmptyStatement(s)), OPTION_STATEMENTS); } else { switch (node.kind) { case ts.SyntaxKind.NewExpression: