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

Commit

Permalink
allow conditional expressions (#4606)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrogowski authored and Josh Goldberg committed Mar 26, 2019
1 parent a493460 commit 92d188a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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.

0 comments on commit 92d188a

Please sign in to comment.