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

Fix #4556 - False positive: No void expression #4606

Merged
merged 1 commit into from
Mar 26, 2019
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: 4 additions & 0 deletions src/rules/noVoidExpressionRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ function walk(ctx: Lint.WalkContext<Options>, checker: ts.TypeChecker): void {
// Something like "x && console.log(x)".
case ts.SyntaxKind.BinaryExpression:
return isParentAllowedVoid(node.parent);

// Something like "!!cond ? console.log(true) : console.log(false)"
case ts.SyntaxKind.ConditionalExpression:
return true;
default:
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions test/rules/no-void-expression/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ declare function doIt(): void;
declare function doAsync(): Promise<void>;
declare function print(strs: TemplateStringsArray): void;

!!data ? console.info(message, data) : console.info(message);

[0]: Expression has type `void`. Put it on its own line as a statement.