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

🐛 Biome doesn't handle unterminated JSX strings #2410

Closed
1 task done
Jiangultimo opened this issue Apr 11, 2024 · 2 comments · Fixed by #2649
Closed
1 task done

🐛 Biome doesn't handle unterminated JSX strings #2410

Jiangultimo opened this issue Apr 11, 2024 · 2 comments · Fixed by #2649
Assignees
Labels
A-Parser Area: parser L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@Jiangultimo
Copy link

Environment information

CLI:
  Version:                      1.6.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.9.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

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

Workspace:
  Open Documents:               0

What happened?

I have a react component:

import Image from 'next/image'

const Robot = () => {
  return (
    <div>
      <Image
        width={36}
        height={32}
        src="/assets/icon/robot.svg'
        alt="This is a robot"
      />
    </div>
  )
}

export default Robot

The quote style rules:

// ... other configs
 "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "jsxQuoteStyle": "double",
      "semicolons": "asNeeded",
      "indentStyle": "space"
    }
  },

An error occurred when I run npx @biomejs/biome check ./src/components/Robot/index.tsx

./src/components/Robot/index.tsx:10:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ unterminated string literal
  
     8 │         height={32}
     9 │         src="/assets/icon/robot.svg'
  > 10 │         alt="This is a robot"
       │                             ^
    11 │       />
    12 │     </div>
  

  
     8 │         height={32}
     9 │         src="/assets/icon/robot.svg'
  > 10 │         alt="This is a robot"
       │                             ^
    11 │       />
    12 │     </div>
  
  ℹ line breaks here
  
     8 │         height={32}
     9 │         src="/assets/icon/robot.svg'
  > 10 │         alt="This is a robot"> 11 │       />
Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: /Users/runner/work/biome/biome/crates/biome_text_size/src/range.rs:50:9
Thread Name: biome::console
Message: assertion failed: start <= end

Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: crates/biome_cli/src/execute/traverse.rs:207:24
Thread Name: main
Message: called `Result::unwrap()` on an `Err` value: Any { .. }

Expected result

It should not throw an error.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Sec-ant
Copy link
Member

Sec-ant commented Apr 11, 2024

I think this one is similar to #2357, although that is related to the json lexer and this one is related to the js (JSX) lexer. But they share the similar causes (unbalanced string quotes) and source of error (biome_text_size -> range)

We should handle unterminated string literals more carefully.

@Sec-ant Sec-ant added L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug A-Parser Area: parser labels Apr 15, 2024
@Sec-ant
Copy link
Member

Sec-ant commented Apr 15, 2024

Here is a minimized code to reproduce this issue:

const f = () => (
  <div
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa="a'
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb="b"
  />
);

@ematipico ematipico added the S-Help-wanted Status: you're familiar with the code base and want to help the project label Apr 19, 2024
@ematipico ematipico changed the title 🐛 Biome encountered an unexpected error 🐛 Biome doesn't handle unterminated JSX strings Apr 19, 2024
@Conaclos Conaclos self-assigned this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants