Skip to content

useExplicitLengthCheck ruins multi-line conditions that have single-line comments #7984

Closed

Description

@GeneZharov

Environment information

CLI:
  Version:                      2.3.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         screen-256color
  JS_RUNTIME_VERSION:           v22.20.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Not set
  Path:                         unset

Workspace:
  Open Documents:               0

Rule name

lint/style/useExplicitLengthCheck

Playground link

https://biomejs.dev/playground/?lintRules=useExplicitLengthCheck&analyzerFixMode=safeAndUnsafeFixes&code=ZgB1AG4AYwB0AGkAbwBuACAAdQBzAGUAUQB1AGUAcgB5AEEAcwBzAGkAcwB0AGEAbgB0ACgAKQAgAHsACgAgACAAaQBmACAAKAAKACAAIAAgACAAIQBzAGgAbwB3AFQAaABpAG4AawBpAG4AZwAgACYAJgAgAC8ALwAgAHcAaABpAGwAZQAgAGkAdAAnAHMAIAB0AGgAaQBuAGsAaQBuAGcAIAB0AGgAZQByAGUAIABpAHMAIABoAG8AcABlACAAdABvACAAZwBlAHQAIABzAHUAZwBnAGUAcwB0AGkAbwBuAHMACgAgACAAIAAgACEAYwBvAG0AbQBlAG4AdABzAD8ALgBsAGUAbgBnAHQAaAAKACAAIAApACAAewAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgAKQA7AAoAIAAgAH0ACgB9AAoA

Expected result

Minimal JS to reproduce the issue:

function useQueryAssistant() {
  if (
    !showThinking && // while it's thinking there is hope to get suggestions
    !comments?.length
  ) {
    console.log();
  }
}

If you apply unsafe writes:

yarn exec biome lint ./test.ts --only=lint/style/useExplicitLengthCheck --write --unsafe

It will break the multi-line condition by joining it with a single-line comment:

function useQueryAssistant() {
  if (
    !showThinking && // while it's thinking there is hope to get suggestionscomments?.length === 0
  ) {
    console.log();
  }
}

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

  1. added theissue type on Nov 4, 2025
  2. changed the title [-]useExplicitLengthCheck ruins multiline conditions with single-line comments[/-] [+]useExplicitLengthCheck ruins multi-line conditions that have single-line comments[/+] on Nov 4, 2025
  3. GeneZharov commented on Nov 4, 2025

    @GeneZharov
    Author

    Actually the same issue happens with the useSimplifiedLogicExpression rule:

    if (
    -  !showRequestSizeWarning ||
    -  !query.metrics // context was too large to count tokens
    +  !(showRequestSizeWarning &&query.metrics // context was too large to count tokens) // context was too large to count tokens
    ) {/* ... */}
  4. dyc3 commented on Nov 4, 2025

    @dyc3
    Contributor

    I'm not seeing this behavior for either of those rules in the playground.

  5. GeneZharov commented on Nov 4, 2025

    @GeneZharov
    Author

    I'm not seeing this behavior for either of those rules in the playground.

    See the suggested unsafe fix in the console tab.
    And Biome actually applies this change when I run the following command:

    biome lint ./test.ts --only=lint/style/useExplicitLengthCheck --write --unsafe
    
    Image
  6. github-actions commented on Nov 4, 2025

    @github-actions
    Contributor

    Hello @GeneZharov, please provide a minimal reproduction. You can use one of the following options:

    • Provide a link to our playground, if it's applicable.
    • Provide a link to GitHub repository. To easily create a reproduction, you can use our interactive CLI via npm create @biomejs/biome-reproduction

    Issues marked with S-Needs repro will be closed if they have no activity within 3 days.

  7. added
    L-JavaScriptLanguage: JavaScript and super languages
    S-Bug-confirmedStatus: report has been confirmed as a valid bug
    and removed
    S-Needs reproStatus: needs a reproduction
    on Nov 4, 2025
  8. self-assigned this
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions