feat(no-single-promise-in-promise-methods): add no-single-promise-in-promise-methods rule - #1524
Open
bartlomieju wants to merge 1 commit into
Open
bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
…-promise-methods` rule
Member
Author
|
Verdict: LGTM — correct and carefully handled. Recommend merge after the RECOMMENDED sign-off you flagged + rebase. Not auto-merging (new rule). Faithful, thorough port. I traced the tricky cases: Correctness — verified
Minor / non-blocking
Perf: trivial (per Housekeeping: No code changes requested — the edge-case handling (elision, spread, TS wrappers, optional/computed, allSettled) is exactly right. Just the tagging decision + rebase. |
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.
This ports the oxlint
unicorn/no-single-promise-in-promise-methodsrule todeno_lint as a native Rust rule.
The rule flags calls to
Promise.all([x]),Promise.any([x]), andPromise.race([x])where the sole argument is an array literal containingexactly one element and that element is neither a spread nor an elision. Wrapping
a single value in such a call is pointless: the value can be used directly, or
Promise.resolve(...)can be used instead. The argument array is unwrappedthrough parentheses and TypeScript type-modifying expressions (
as,satisfies,as const, non-null assertions, type assertions, instantiationexpressions) before inspection, and optional-chaining/computed forms such as
Promise?.race([x]),Promise.race?.([x]), andPromise["race"]([x])are notmatched.
Promise.allSettled([x])is intentionally not flagged, matching theoxc reference.
Unlike oxc, which ships a conditional fixer, this implementation is
diagnostic-only (no autofix), consistent with the rest of deno_lint. The
diagnostic message and help text, and the complete pass/fail fixture sets, are
ported from the oxc reference:
https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs
Tagged RECOMMENDED (on by default) — flagging for maintainer sign-off.