feat(linter): implement no-promise-executor-return rule#16779
Merged
camc314 merged 6 commits intooxc-project:mainfrom Dec 12, 2025
Merged
feat(linter): implement no-promise-executor-return rule#16779camc314 merged 6 commits intooxc-project:mainfrom
no-promise-executor-return rule#16779camc314 merged 6 commits intooxc-project:mainfrom
Conversation
camc314
reviewed
Dec 12, 2025
crates/oxc_linter/src/rules/eslint/no_promise_executor_return.rs
Outdated
Show resolved
Hide resolved
camc314
reviewed
Dec 12, 2025
51ca947 to
211ff89
Compare
CodSpeed Performance ReportMerging #16779 will not alter performanceComparing Summary
Footnotes
|
871054b to
0d5900c
Compare
c47b640 to
5d03612
Compare
5d03612 to
045fa6b
Compare
Disallow returning values from Promise executor functions. The return value of the Promise executor is ignored and returning a value is likely a mistake. The rule detects: - Implicit returns from arrow function expression bodies - Explicit return statements with values - Returns inside control flow (if, switch, loops, try-catch, etc.) Configuration: - `allowVoid`: Allow `return void expr` pattern (default: false) Closes #25083
045fa6b to
70f9e88
Compare
camc314
reviewed
Dec 12, 2025
crates/oxc_linter/src/rules/eslint/no_promise_executor_return.rs
Outdated
Show resolved
Hide resolved
camc314
approved these changes
Dec 12, 2025
graphite-app bot
pushed a commit
that referenced
this pull request
Jan 12, 2026
…17901) The original implementation of the rule did not port most of the tests. I'm not sure that it's worth retaining the previous tests, so I just replaced them entirely for now. Almost all the tests pass, thankfully, but a few fail and needed to be commented out. We should probably fix them. Rule was added in #16779.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements ESLint's
no-promise-executor-returnrule which disallows returning values from Promise executor functions.The return value of a Promise executor is ignored, so returning a value is likely a mistake. This rule detects:
new Promise(r => r(1)))return 1,return resolve(1))Configuration
allowVoid(default:false): Whentrue, allowsreturn void exprpattern (both explicit and implicit returns)Design Notes
This rule only checks executors passed directly as arrow/function expressions. It does not track references like
new Promise(executor)whereexecutoris defined elsewhere — this is an intentional design choice consistent with ESLint's implementation.Test Plan
cargo test -p oxc_linter no_promise_executor_returnpassescargo clippy -p oxc_linterpassesCloses #7790