biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
206 stars 25 forks source link

🐛 Unable to save auto-formatting in VSCode #255

Closed wangyi12358 closed 2 months ago

wangyi12358 commented 3 months ago

VS Code version

1.90.1

Extension version

2.3.0

Biome version

1.8.3

Operating system

Description

When I press Command + S to save in VSCode, it does not format the file.

biome.json

{
  "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "files": {
    "ignore": ["lib", "node_modules"]
  },
  "linter": {
    "enabled": true,
    "ignore": ["lib", "node_modules"],
    "include": ["packages/**"],
    "rules": {
      "style": {
        "noNonNullAssertion": "off"
      },
      "suspicious": {
        "noExplicitAny": "off",
        "noConfusingVoidType": "off"
      },
      "complexity": {
        "noStaticOnlyClass": "off"
      },
      "recommended": true
    }
  },
  "formatter": {
    "enabled": true,
    "attributePosition": "auto",
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 80,
    "ignore": ["lib", "node_modules"],
    "lineEnding": "lf"
  },
  "javascript": {
    "formatter": {
      "arrowParentheses": "always",
      "bracketSameLine": false,
      "bracketSpacing": true,
      "quoteStyle": "single",
      "jsxQuoteStyle": "single",
      "quoteProperties": "asNeeded",
      "semicolons": "always",
      "trailingCommas": "all"
    },
    "parser": {
      "unsafeParameterDecoratorsEnabled": true
    }
  }
}

.vscode/settings.json

{
  "editor.defaultFormatter": "biomejs.biome",
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "editor.codeActionsOnSave": {
    "quickfix.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
}

Steps to reproduce

  1. Command + S

Expected behavior

Format after saving

Does this issue occur when using the CLI directly?

No

Logs

Biome binary found at /Users/wangyi/vibe/nestjs-modules-repo/node_modules/.pnpm/@biomejs+cli-darwin-arm64@1.8.3/node_modules/@biomejs/cli-darwin-arm64/biome
Copying binary to temporary folder: file:///Users/wangyi/Library/Application%20Support/Code/User/workspaceStorage/111b475946637b58629d8b74394893e5/biomejs.biome/biome
Executing Biome from: /Users/wangyi/Library/Application Support/Code/User/workspaceStorage/111b475946637b58629d8b74394893e5/biomejs.biome/biome
[cli-stdout] data 66
[cli] exit 0
Connecting to "/Users/wangyi/Library/Caches/dev.biomejs.biome/biome-socket-1.8.3" ...
[Info  - 16:11:39] Server initialized with PID: 29379
ematipico commented 3 months ago

Is the configuration file placed in the root of your repository?

wangyi12358 commented 3 months ago

Is the configuration file placed in the root of your repository?

Yes biome.json is placed in the root directory of my project

ematipico commented 3 months ago

We'll need a reproduction at this point, would you mind creating one?

wangyi12358 commented 3 months ago

We'll need a reproduction at this point, would you mind creating one?

https://github.com/vibe-teams/nestjs-modules, pnpm Installation dependence.

unvalley commented 2 months ago

@wangyi12358 Did you set "editor.formatOnSave": true in settings.json? I confirmed that we can format code (on save) in the reproduction repo.

{
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome",
    "editor.formatOnSave": true
  }
  ...
}
wangyi12358 commented 2 months ago

@wangyi12358 Did you set "editor.formatOnSave": true in settings.json? I confirmed that we can format code (on save) in the reproduction repo.

{
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome",
    "editor.formatOnSave": true
  }
  ...
}

It should be due to missing this configuration. Thank you.