Skip to content

feat(no-topromise): suggest an exact replacement for toPromise() #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

JasonWeinzierl
Copy link
Owner

@JasonWeinzierl JasonWeinzierl commented Apr 16, 2025

This adds the "most correct" suggestion to no-topromise for replacing toPromise().

The old toPromise() would resolve to undefined, while the new lastValueFrom rejects with EmptyError. So if a user followed the old top suggestion and replaced toPromise with lastValueFrom, they might be surprised to find EmptyError now thrown instead. This wouldn't be a problem for someone using the strict config, which includes no-ignored-default-value, but users of the recommended config wouldn't get that lint notification.

Resolves #168

Copy link

LCOV of commit 4f2ecf5 during .github/workflows/ci.yml #477

Summary coverage rate:
  lines......: 96.7% (4333 of 4479 lines)
  functions..: 96.1% (270 of 281 functions)
  branches...: no data found

Files changed coverage rate:
                                         |Lines       |Functions  |Branches    
  Filename                               |Rate     Num|Rate    Num|Rate     Num
  =============================================================================
  src/rules/no-topromise.ts              | 4.0%    100| 0.0%     4|    -      0

@JasonWeinzierl JasonWeinzierl merged commit 940ee0c into main Apr 16, 2025
3 checks passed
@JasonWeinzierl JasonWeinzierl deleted the better-no-topromise-suggest branch April 16, 2025 20:27
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.

lastValueFrom suggestion for no-topromise may produce unexpected code
1 participant