Skip to content

useConsistentCurlyBraces suggests invalid JSX #8011

@GeneZharov

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:                       Loaded successfully
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false

Linter:
  JavaScript enabled:           unset
  JSON enabled:                 unset
  CSS enabled:                  unset
  GraphQL enabled:              unset
  Recommended:                  false
  Enabled rules:
    style/useConsistentCurlyBraces

Workspace:
  Open Documents:               0

Rule name

lint/style/useConsistentCurlyBraces

Playground link

https://biomejs.dev/playground/?lintRules=useConsistentCurlyBraces&analyzerFixMode=safeAndUnsafeFixes&code=ZQB4AHAAbwByAHQAIABjAG8AbgBzAHQAIABDAG8AbQBwAG8AbgBlAG4AdAAgAD0AIAAoACkAIAA9AD4AIAAoAAoAIAAgADwAZABpAHYAPgAKACAAIAAgACAAewAiAHMAdABhAHIAdAAgAHsAewAiAH0ACgAgACAAIAAgADwAcwBwAGEAbgA%2BAFQARQBYAFQAPAAvAHMAcABhAG4APgAKACAAIAAgACAAewAiAH0AfQAgAGUAbgBkACIAfQAKACAAIAA8AC8AZABpAHYAPgAKACkAOwA%3D&ruleDomains.project=recommended

Expected result

Image

As a result of biome lint --write --unsafe I get invalid JSX:

Image

I understand that it was "unsafe" but I did not expect to get invalid JSX as a result.

I would expect Biome to keep characters that need escaping as JS expressions (in curly brackets):

export const Comp = () => (
  <div>
-    {"start {{"}
+    start {"{{"}
    <span>TEXT</span>
-    {"}} end"}
+    {"}}"} end
  </div>
);

Or do not highlight such strings as issues at all (to me it is still less destructive than the current behavior).

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid buggood first issueGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions