Skip to content

πŸ’… noUselessReturn safe fix removes the only statement of an unbraced if, and drops the comment before a returnΒ #11898

Description

@AlbinoGeek

Environment information

Details
CLI:
  Version:                      2.5.14
  Color support:                false

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:                npm
  BIOME_LOG_FILE:                    unset
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  BIOME_BINARY:                      unset
  RUST_BACKTRACE:                    unset
  NO_COLOR:                     1
  TERM:                         xterm-256color
  JS_RUNTIME_VERSION:           v24.18.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         bun/1.4.0

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false
  HTML full support enabled:    unset

Linter:
  JavaScript enabled:           unset
  JSON enabled:                 unset
  CSS enabled:                  unset
  GraphQL enabled:              unset
  Recommended:                  unset
  Enabled rules:
    complexity/noUselessReturn

Workspace:
  Open Documents:               0

Rule name

noUselessReturn

Playground link

https://biomejs.dev/playground/?lintRules=noUselessReturn&language=js&fix=safeFixes#code=ZQB4AHAAbwByAHQAIABmAHUAbgBjAHQAaQBvAG4AIABmACgAcAAsACAAYQBiAG8AcgB0AGUAZAApACAAewAKACAAIABwAC4AYwBhAHQAYwBoACgAKAApACAAPQA%2BACAAewAKACAAIAAgACAAaQBmACAAKABhAGIAbwByAHQAZQBkACkAIAByAGUAdAB1AHIAbgA7AAoAIAAgAH0AKQA7AAoAfQAKAGUAeABwAG8AcgB0ACAAZgB1AG4AYwB0AGkAbwBuACAAaAAoAHgAKQAgAHsACgAgACAAdAByAHkAIAB7AAoAIAAgACAAIAB4ACgAKQA7AAoAIAAgAH0AIABjAGEAdABjAGgAIAB7AAoAIAAgACAAIAAvAC8AIABiAGUAcwB0ACAAZQBmAGYAbwByAHQAOgAgAG4AbwB0AGgAaQBuAGcAIAB0AG8AIABkAG8ACgAgACAAIAAgAHIAZQB0AHUAcgBuADsACgAgACAAfQAKAH0ACgA%3D

Expected result

  1. A return; that is the body of an unbraced if/else is either not reported or removed together with its if.
  2. Leading comments of the removed statement are kept.

Actual (safe fixes): if (aborted) return; becomes if (aborted) with no consequent, so the file no longer parses (SyntaxError: Unexpected token '}'); if (a) return; else return; breaks the same way. The // best effort comment above the other removed return; is deleted with it.

Reproduces in the playground on Biome main (9bbff0c) and in the 2.5.14 CLI.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Tool Use Disclaimer: Claude Code using Anthropic Opus 5.5 helped build the reproduction.

Activity

  1. added
    S-Needs triage
    A-Linter
    L-JavaScript
    on Sep 22, 2026
  2. added theissue type on Sep 22, 2026
  3. added
    S-Bug-confirmed
    and removed
    S-Needs triage
    on Sep 23, 2026
  4. added a commit that references this issue on Sep 23, 2026
    d46f5f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LinterL-JavaScriptS-Bug-confirmed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions