Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Don't report 'statements are not aligned' for empty statements #2653

Merged
merged 2 commits into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/rules/alignRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -82,7 +82,7 @@ class AlignWalker extends Lint.AbstractWalker<Options> {
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:
Expand Down
2 changes: 0 additions & 2 deletions test/rules/align/statements/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ function shouldntCrash() {
if (foo) {
bar;
};
~ [statements are not aligned]

if (foo) {
bar;
} /* should not be removed */;
~ [statements are not aligned]