Skip to content

fix(no-misused-promises): don't report comma expressions as conditionals - #1254

Merged
camc314 merged 3 commits into
oxc-project:mainfrom
geniusmonir:gm/fix/no-misused-promises-comma
Oct 2, 2026
Merged

camc314 merged 3 commits into
oxc-project:mainfrom
geniusmonir:gm/fix/no-misused-promises-comma

Conversation

@geniusmonir

Copy link
Copy Markdown
Contributor

Fixes #1252

The KindBinaryExpression listener passed every binary expression to checkConditional. A comma expression is a BinaryExpression in the TypeScript AST, so (a, promise) was reported as a boolean conditional even when it was only returned or assigned. In typescript-eslint the same code is a SequenceExpression, which its LogicalExpression listener never sees.

The listener now calls checkConditional only for &&, || and ??. A comma expression that really is a condition (an if or ?: test, a ! operand, a logical operand) is still reported through those paths, and now once instead of twice.

Tests

  • Valid: the three cases from the issue (arrow function return, callback return, variable initializer).
  • Invalid: a comma expression as a ?: condition and as a || operand, one diagnostic each. typescript-eslint 8.71.0 reports one diagnostic at the same range for both.

Before the fix, the three valid cases each get a conditional report and the two invalid cases report 2 errors instead of 1. After the fix, go test ./internal/rules/no_misused_promises/ and the e2e suite pass, and gofmt and golangci-lint run on the rule package are clean. With this build, oxlint 1.86.0 reports nothing on the issue's reproduction, and its output for the conditional cases matches typescript-eslint.

AI disclosure: fix and tests written with an AI coding assistant (Claude Code). The test results above are from real runs.

@camc314 camc314 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@camc314
camc314 merged commit f69fe73 into oxc-project:main Oct 2, 2026
8 checks passed
@camc314 camc314 self-assigned this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no-misused-promises: comma expression ending in a Promise is reported as a boolean conditional

2 participants