Skip to content
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

💅 useOptionalChain unsafe fix incorrectly discards conditions in logical and chains #1656

Closed
1 task done
bryanrsmith opened this issue Jan 24, 2024 · 0 comments · Fixed by #1685
Closed
1 task done
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@bryanrsmith
Copy link

Environment information

CLI:
  Version:                      1.5.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.5.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/9.8.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Rule name

useOptionalChain

Playground link

https://biomejs.dev/playground/?code=dABhAGcAcwAgACYAJgAgAHQAYQBnAHMALgBpAG4AYwBsAHUAZABlAHMAKAAnAGEAJwApACAAJgAmACAAdABhAGcAcwAuAGkAbgBjAGwAdQBkAGUAcwAoACcAYgAnACkA

Expected result

The unsafe fix currently applies:

- tags·&&·tags.includes('a')·&&·tags.includes('b')
+ tags?.includes('b')

The expected result is:

- tags·&&·tags.includes('a')·&&·tags.includes('b')
+ tags?.includes('a') && tags.includes('b')

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@vasucp1207 vasucp1207 added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
2 participants