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

📝 Formatter needs two saves to settle #5035

Open
1 task done
dawsonbooth opened this issue Feb 4, 2025 · 2 comments
Open
1 task done

📝 Formatter needs two saves to settle #5035

dawsonbooth opened this issue Feb 4, 2025 · 2 comments
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@dawsonbooth
Copy link

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.13.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/4.6.0"

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

Formatter:
  Format with errors:           false
  Indent style:                 Space
  Indent width:                 2
  Line ending:                  Lf
  Line width:                   100
  Attribute position:           Auto
  Bracket spacing:              BracketSpacing(true)
  Ignore:                       ["public/", "*.code-snippets", "routeTree.gen.ts"]
  Include:                      []

JavaScript Formatter:
  Enabled:                      false
  JSX quote style:              Double
  Quote properties:             AsNeeded
  Trailing commas:              All
  Semicolons:                   AsNeeded
  Arrow parentheses:            AsNeeded
  Bracket spacing:              BracketSpacing(true)
  Bracket same line:            false
  Quote style:                  Single
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Attribute position:           Auto

JSON Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Trailing Commas:              unset

CSS Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Quote style:                  Double

GraphQL Formatter:
  Enabled:                      false
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Bracket spacing:              unset
  Quote style:                  unset

Workspace:
  Open Documents:               0

Configuration

{
"formatter": {
    "enabled": true,
    "useEditorconfig": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineEnding": "lf",
    "lineWidth": 100,
    "attributePosition": "auto",
    "bracketSpacing": true,
    "ignore": ["public/", "*.code-snippets", "routeTree.gen.ts"]
  },
"javascript": {
    "formatter": {
      "jsxQuoteStyle": "double",
      "quoteProperties": "asNeeded",
      "trailingCommas": "all",
      "semicolons": "asNeeded",
      "arrowParentheses": "asNeeded",
      "bracketSameLine": false,
      "quoteStyle": "single",
      "attributePosition": "auto",
      "bracketSpacing": true
    }
  }
}

Playground link

https://biomejs.dev/playground/?lineWidth=100&indentStyle=space&quoteStyle=single&semicolons=as-needed&arrowParentheses=as-needed&code=aQBtAHAAbwByAHQAIAB7ACAAegAgAH0AIABmAHIAbwBtACAAIgB6AG8AZAAiADsACgAKAGUAeABwAG8AcgB0ACAAYwBvAG4AcwB0ACAAZgBvAG8AIAA9ACAAegAKACAAIAAuAG8AYgBqAGUAYwB0ACgAewB9ACkACgAgACAALgBjAGEAdABjAGgAYQBsAGwAKAAKACAAIAAgACAAegAuAGEAcgByAGEAeQAoAHoALgBzAHQAcgBpAG4AZwAoACkAKQAuAHIAZQBmAGkAbgBlACgAKABpAHQAZQBtAHMAKQAgAD0APgAgAG4AZQB3ACAAUwBlAHQAKABpAHQAZQBtAHMAKQAuAHMAaQB6AGUAIAA9AD0APQAgAGkAdABlAG0AcwAuAGwAZQBuAGcAdABoACwAIAB7ACAAbQBlAHMAcwBhAGcAZQA6ACAAJwBBAHIAcgBhAHkAIABlAG4AdAByAGkAZQBzACAAbQB1AHMAdAAgAGIAZQAgAHUAbgBpAHEAdQBlACcAIAB9ACkALAAKACAAIAApAA%3D%3D

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@dawsonbooth dawsonbooth added the S-Needs triage Status: this issue needs to be triaged label Feb 4, 2025
@dyc3
Copy link
Contributor

dyc3 commented Feb 4, 2025

It looks like this is a bug with prettier too.

@dyc3 dyc3 added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Feb 4, 2025
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Feb 4, 2025
@dawsonbooth
Copy link
Author

For extra context that the playground doesn't show, this snippet:

import { z } from "zod";

export const foo = z
  .object({})
  .catchall(
    z.array(z.string()).refine((items) => new Set(items).size === items.length, { message: 'Array entries must be unique' }),
  )

formats to the following:

import { z } from 'zod'

export const foo = z
  .object({})
  .catchall(
    z
      .array(z.string())
      .refine(items => new Set(items).size === items.length, {
        message: 'Array entries must be unique',
      }),
  )

which formats to the following:

import { z } from 'zod'

export const foo = z.object({}).catchall(
  z.array(z.string()).refine(items => new Set(items).size === items.length, {
    message: 'Array entries must be unique',
  }),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

2 participants