Skip to content

fix(no-useless-undefined): Support functions with allowed undefined return types and mixed returns #2621

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nsotiroglou96
Copy link

This update refines the no-useless-undefined rule to better handle cases where returning undefined is valid, specifically:

  1. The rule now inspects the enclosing function’s return type annotation and skips reporting when that type includes undefined (e.g. Promise<number | undefined>).
  2. It also introduces an allowMixedReturns option so that functions with mixed return values (some branches returning a value, others undefined) aren’t flagged unnecessarily.

@github-actions github-actions bot changed the title fix(no-useless-undefined): Support functions with allowed undefined return types and mixed returns fix(no-useless-undefined): Support functions with allowed undefined return types and mixed returns Apr 3, 2025
@sindresorhus
Copy link
Owner

Please make sure npm test passes locally.

You need to add tests.

@sindresorhus
Copy link
Owner

Bump :)

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.

2 participants