Code Monkey home page Code Monkey logo

biome-vscode's Introduction

Visual Studio Code extension for Biome

The Visual Studio Code extension for Biome brings first-party support for Biome to VS Code and similar editors such as VSCodium. By integrating with Biome's language server, the extension provides the following features, among others:

  • πŸ’Ύ Format on save
  • πŸ’‘ Inline suggestions with quick fixes
  • 🚧 Refactoring

Installation

The Visual Studio Code extension for Biome is available from the following sources.

Getting Started

This section describes how to get started with the Biome VS Code extension.

Setting as the default formatter

To set the VS Code extension for Biome as the default formatter, follow the steps below.

  1. Open the Command Palette: ⌘/Ctrl+⇧+P
  2. Select Format Document With…
  3. Select Configure Default Formatter…
  4. Select Biome

This will ensure that VS Code uses Biome to format all supported files, instead of other formatters that you may have installed.

Setting as the default formatter for specific languages

If you'd rather not set Biome as the default formatter for all languages, you can set it as the default formatter for specific languages only. The following steps describe how to do this.

  1. Open the Command Palette
  2. Select Preferences: Open User Settings (JSON)

Set the editor.defaultFormatter to biomejs.biome for the desired language. For example, to set Biome as the default formatter for JavaScript files, add the following to your editor's options.

"[javascript]": {
	"editor.defaultFormatter": "biomejs.biome"
}

Choosing a biome binary

To resolve the location of the biome binary, the extension will look into the following places, in order:

  1. The project's local dependencies (node_modules)
  2. The path specified in the biome.lspBin configuration option of the extension
  3. The extension's globalStorage location

If none of these locations has a biome binary, the extension will prompt you to download a binary compatible with your operating system and architecture and store it in the globalStorage.

Note

We recommend adding Biome to your project's devDependencies so that both the extension and your NPM scripts use the same version of Biome.

npm install -D @biomejs/biome

Usage

Formatting documents

On-demand formatting

To format a document on-demand, follow the steps below.

  1. Open the Command Palette: ⌘/Ctrl+⇧+P
  2. Select Format Document

You can also format a selection of text by following the steps below.

  1. Select the text you want to format
  2. Open the Command Palette: ⌘/Ctrl+⇧+P
  3. Select Format Selection

Formatting on save

This supports formatting on save out of the box. You should enable format on save in your editor's settings and make sure that the Biome extension is set as the default formatter for your documents/languages.

Autofix on save

This extension supports VS Code's Code Actions On Save setting. To enable autofix on save, add the following to your editor configuration.

{
  "editor.codeActionsOnSave": {
	"quickfix.biome": "explicit"
  }
}

Sorting imports (experimental)

Biome has an experimental Organize Imports feature that allows you to sort imports automatically. This feature can be run manually or automatically on save.

On-demand sorting

To sort imports on-demand, follow the steps below.

  1. Open the Command Palette: ⌘/Ctrl+⇧+P
  2. Select Organize Imports

Sorting on save

To automatically sort imports on save, add the following to your editor configuration.

{
  "editor.codeActionsOnSave": {
	"source.organizeImports.biome": "explicit"
  }
}

Extension Settings

biome.lspBin

The biome.lspBin option overrides the Biome binary used by the extension. The workspace folder is used as the base path if the path is relative.

biome.rename

Enables Biome to handle renames in the workspace (experimental).

biome-vscode's People

Contributors

95th avatar arendjr avatar bhbs avatar chieforz avatar conaclos avatar cpojer avatar ddanielsantos avatar denbezrukov avatar dependabot[bot] avatar edvardchen avatar ematipico avatar iwanabethatguy avatar jk-gan avatar kaioduarte avatar ktfth avatar leops avatar lucasweng avatar magic-akari avatar malix-off avatar michareiser avatar mrkldshv avatar mzbac avatar nhedger avatar nikeee avatar nissy-dev avatar noftaly avatar notmd avatar unvalley avatar xunilrj avatar yassere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

biome-vscode's Issues

πŸ›

VS Code version

1.87.2

Extension version

2.2.2

Biome version

1.6.3

Operating system

  • Windows
  • macOS
  • Linux

Description

vscode is not reporting all biome errors at once. It feels like Biome isn't running in the background, but when I first open a file with errors in it, then vscode knows about the "error".

image
Here it says 7, but in reality when I run biome in CLI I have around 100. I've waited a very long time in case biome is still figuring out all errors.

Steps to reproduce

N/A

Expected behavior

I expect to see all errors in the tab "Errors".

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

No response

πŸ› error access vscode extensions

Environment information

biome rage return :

Rage discovered this running server using an incompatible version of Biome.

Server:
  Version:                      1.1.2

yarn v3 on a monorepo.

What happened?

update vscode extension got an error:

Biome client: couldn't create connection to server.

/node_modules/.bin/biome: Permission denied

Discord asked me to run this command and it fixed the issue:

chmod +x ./node_modules/.bin/biome

been asked to reference this issue: rome/tools#3800

Expected result

update the vscode extension and it works

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Biome interferes Astro.config Files

I have noticed when biome is enabled/disabled it interferes the
astro-build.astro-vscode extension if you uninstall it doesn't.

  • Biome-extension: v2.1.1
  • Astro-extension: v2.6.2
  • VSCode: v1.85.2
  • OS Information: MacOS Sonoma Version 14.2

πŸ› VS Code Format on Save Ignores Biome.json Directives

Extension version

2.1.2

Biome version

1.5.3

Operating system

  • Windows
  • macOS
  • Linux

Description

The formatOnSave functionality within Visual Studio Code should adhere to the include and ignore directives as defined in the biome.json configuration file. For instance, consider the following configuration settings:

{
  "files": {
    "include": ["functions/*.js", "types.ts"],
    "ignore": ["schemas/*.json"]
  }
}

This configuration specifies that formatOnSave should only apply to JavaScript files in the functions directory and the TypeScript file types.ts, while explicitly excluding JSON files in the schemas directory.

Steps to reproduce

Navigate to any file that should be ignored, make a change to it, and then save the file. You'll notice that it gets formatted despite being listed as ignored.

Expected behavior

Upon saving, files specified under the ignore directive in biome.json are expected to remain unaltered by the formatOnSave feature, preserving their original formatting without applying any auto-formatting rules.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

No response

πŸ› VS Code extension can't run in vscode dev container

Environment information

We use devcontainer for development, and want to replace eslint with biome.

What happened?

  1. Try to install biome extension
  2. Display error message: The 'biomejs.biome' extension is not available in Visual Studio Code for Alpine Linux 64 bit.

Expected result

It works in dev container.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

VS Code Dev Container error: Extension can't find Biome if node_moduels isn't in the root of the workspace

My workspace has a directory structure like this:

project/
β”œβ”€β”€ javascript/
β”‚   β”œβ”€β”€ node_modules/
β”‚   └── package.json
└── python/

@biomejs/biome is in the devDependencies in the package.json and it is installed on the file system. i can use the module when running something like pnpm exec biome format .. However, when I launch a Visual Studio Code Development Container, I get the following error and auto format on save does not work.

Screenshot 2024-02-02 at 10 01 44 AM

This problem does not happen with other Visual Studio extensions like Prettier and ESLint.

Is there anything I can do on my side or do I need to wait for the improved detection mentioned in #74?

πŸ› Biome Not Linting NestJs Repositories

VS Code version

1.87

Extension version

2.2.1

Biome version

1.5.3

Operating system

  • Windows
  • macOS
  • Linux

Description

Attached is the screenshot of the NestJs controller and what Biome is complaining about

image

biome.json settings as below

 "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingComma": "none"
    },
    "parser": {
      "unsafeParameterDecoratorsEnabled": true
    }
  } 

Steps to reproduce

  1. Open any Nestjs default project
  2. Add biome.json and dependency
  3. Add @param under a @get or @post call

Editor starts complaining

Expected behavior

VSCode extension is not respecting the rules that CLI is respecting

Does this issue occur when using the CLI directly?

No

Logs

No response

πŸ› Autofix on save breaks imports

VS Code version

1.87.2

Extension version

2.2.2

Biome version

1.6.3

Operating system

  • Windows
  • macOS
  • Linux

Description

When noUnusedImports is enabled, autofix on save breaks the imports.

Steps to reproduce

Full reduced test case: https://github.com/OliverJAsh/biome-vscode-quickfix-import-issue. Contents inlined below.

Given:

biome.json:

{
    "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
    "linter": {
      "enabled": true,
      "rules": {
        "correctness": {
          "noUnusedImports": "warn"
        }
      }
    }
  }
  

.vscode/settings.json:

{
    "editor.codeActionsOnSave": {
      "quickfix.biome": "explicit"
    }
  }
  

index.ts:

import { A } from 'a';
import { B } from 'b';
import { C } from 'c';

// edit this comment and save the file

When I save index.ts and the autofix runs, I end up with broken imports:

import { B } from 'b';
import { 

Expected behavior

Imports are not broken.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

No response

πŸ› Possibility to use different Biome configurations in VSCode?

VS Code version

1.87.2

Extension version

2.2.2

Biome version

1.6.1

Operating system

  • Windows
  • macOS
  • Linux

Description

Hello friends. I am testing Biome in a monorepo project in Typescript and running Biome through the CLI works correctly, as I can pass the "--config-path" parameter to point out which config file I want to use.

However, the VSCode extension explains that it looks for biome.js in the root of the project. Is it possible to show Lint errors or format the code using a custom config path?

Steps to reproduce

  1. Create a new project with multiple applications.
  2. Add a Biome configuration for one of these projects.
  3. Open a file of one project (where we added the Biome config).

Expected behavior

Should show Lint errors associated with the Biome configuration for an especific project.

Does this issue occur when using the CLI directly?

No

Logs

No response

πŸ› `biome __print_socket` Permission denied error

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:           "v18.19.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.5.0"

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

Workspace:
  Open Documents:               0

What happened?

I updated VS Code to v1.87.1. At the same time I also clicked the popup to install biome globally (so this could be related to either of these actions, or a combination of both).

Now, when launching VS Code, an error popup saying "Biome: Restarting client failed" appears.

Full output tab below:

[Error - 11:53:44 PM] Restarting client failed
Error: Command "/Users/nrajlich/Library/Application Support/Code/User/workspaceStorage/de9bf791456e2ad24d56aca8e5b73508/biomejs.biome/biome __print_socket" exited with code 1
Output:
internalError/io ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Γ— Errors occurred while executing I/O operations.
    
    Caused by:
      Permission denied (os error 13)
  


	at getSocket (/Users/nrajlich/.vscode/extensions/biomejs.biome-2.2.2/out/main.js:36605:11)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async createMessageTransports (/Users/nrajlich/.vscode/extensions/biomejs.biome-2.2.2/out/main.js:36619:16)
	at async LanguageClient2.createConnection (/Users/nrajlich/.vscode/extensions/biomejs.biome-2.2.2/out/main.js:15598:28)
	at async LanguageClient2.start (/Users/nrajlich/.vscode/extensions/biomejs.biome-2.2.2/out/main.js:15174:30)
	at async activate (/Users/nrajlich/.vscode/extensions/biomejs.biome-2.2.2/out/main.js:36368:3)
	at async u.n (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:140:6255)
	at async u.m (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:140:6218)
	at async u.l (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:140:5675)

Expected result

Biome extension should initialize properly

Code of Conduct

  • I agree to follow Biome's Code of Conduct

πŸ› Can't use VSCode extension (node not found)

Environment information

CLI:
  Version:                      1.2.2
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.15.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.6.10"

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 can run it from the CLI just fine, but the extension throws this error:

Configuration file required, looking for one.
Config file found at /home/hyoretsu/@Projects/maple-simulator/biome.json, enabling Biome extension
Using Biome from /home/hyoretsu/@Projects/maple-simulator/node_modules/.bin/biome
[cli] exit 127
[cli-stderr] data 92
[cli-stderr] end
[cli-stdout] end
[Error - 12:33:39 PM] Biome client: couldn't create connection to server.
Error: Command "/home/hyoretsu/@Projects/maple-simulator/node_modules/.bin/biome __print_socket" exited with code 127
Output:
/home/hyoretsu/@Projects/maple-simulator/node_modules/.bin/biome: 16: exec: node: not found

    at getSocket (/home/hyoretsu/.vscode-server/extensions/biomejs.biome-1.4.2-linux-x64/out/main.js:19600:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at createMessageTransports (/home/hyoretsu/.vscode-server/extensions/biomejs.biome-1.4.2-linux-x64/out/main.js:19615:16)
    at LanguageClient2.createConnection (/home/hyoretsu/.vscode-server/extensions/biomejs.biome-1.4.2-linux-x64/out/main.js:15576:28)
    at LanguageClient2.start (/home/hyoretsu/.vscode-server/extensions/biomejs.biome-1.4.2-linux-x64/out/main.js:15152:30)
    at activate (/home/hyoretsu/.vscode-server/extensions/biomejs.biome-1.4.2-linux-x64/out/main.js:19421:3)
    at p.n (/home/hyoretsu/.vscode-server/bin/6c3e3dba23e8fadc360aed75ce363ba185c49794/out/vs/workbench/api/node/extensionHostProcess.js:103:6206)
    at p.m (/home/hyoretsu/.vscode-server/bin/6c3e3dba23e8fadc360aed75ce363ba185c49794/out/vs/workbench/api/node/extensionHostProcess.js:103:6169)
    at p.l (/home/hyoretsu/.vscode-server/bin/6c3e3dba23e8fadc360aed75ce363ba185c49794/out/vs/workbench/api/node/extensionHostProcess.js:103:5626)
[cli-stdout] close
[cli] close 127
[cli-stderr] close

Expected result

It should work just fine.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Extension fails to activate when there are no workspace folders open

If you open VS Code without any workspace folders (for example click File -> Close Folder) and then do anything that triggers the Biome extension to be activated (for example open a .ts file), the extension fails to activate with:

Activating extension 'biomejs.biome' failed: import_vscode6.workspace.workspaceFolders is not iterable.

Possibly caused by this code not handling undefined?

for (const workspaceFolder of workspace.workspaceFolders) {

πŸ› Biome applies unsafe fixes inside liveshares

It seems that biome applies unsafe fixes when working in virtual workspaces, at least when working inside liveshares.

Here is a reproducible example. https://github.com/gustaferiksson/biome-unsafe

If I start a liveshare in that repo and share it with myself (in a new vscode window), and save index.ts, biome will apply the unsafe fixes.

My vscode settings has the following related to biome

  "editor.formatOnSave": true,
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "editor.codeActionsOnSave": {
    "quickfix.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
  "biome.lspBin": "./node_modules/@biomejs/biome/bin/biome",

Here is the Output from the Biome Trace that applies the unsafe fixes

[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (24)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (24)' in 2ms.
Result: []


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (25)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "source.organizeImports.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (25)' in 2ms.
Result: []


[Trace - 10:55:20 AM] Sending request 'textDocument/formatting - (26)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/formatting - (26)' in 1ms.
Result: [
    {
        "newText": "// const unused = `hello`\n\nconst unused = `hellothereklajsdjk`\n",
        "range": {
            "end": {
                "character": 0,
                "line": 4
            },
            "start": {
                "character": 0,
                "line": 0
            }
        }
    }
]


[Trace - 10:55:20 AM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    }
}


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (27)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (27)' in 3ms.
Result: [
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 35,
                        "line": 2
                    },
                    "start": {
                        "character": 15,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 16,
                                "line": 2
                            },
                            "start": {
                                "character": 15,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 35,
                                "line": 2
                            },
                            "start": {
                                "character": 34,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.style.noUnusedTemplateLiteral",
        "title": "Replace with string literal"
    },
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 35,
                        "line": 2
                    },
                    "start": {
                        "character": 15,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 2
                            },
                            "start": {
                                "character": 0,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 2
                            },
                            "start": {
                                "character": 5,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.style.noUnusedTemplateLiteral",
        "title": "Suppress rule lint/style/noUnusedTemplateLiteral"
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 12,
                        "line": 2
                    },
                    "start": {
                        "character": 6,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "_unused",
                        "range": {
                            "end": {
                                "character": 12,
                                "line": 2
                            },
                            "start": {
                                "character": 6,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.correctness.noUnusedVariables",
        "title": "If this is intentional, prepend unused with an underscore."
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 12,
                        "line": 2
                    },
                    "start": {
                        "character": 6,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/correctness/noUnusedVariables: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 2
                            },
                            "start": {
                                "character": 0,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 2
                            },
                            "start": {
                                "character": 5,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.correctness.noUnusedVariables",
        "title": "Suppress rule lint/correctness/noUnusedVariables"
    }
]


[Trace - 10:55:20 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
        "version": 14
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 34
                },
                "end": {
                    "line": 2,
                    "character": 35
                }
            },
            "rangeLength": 1,
            "text": "\""
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 15
                },
                "end": {
                    "line": 2,
                    "character": 16
                }
            },
            "rangeLength": 1,
            "text": "\""
        }
    ]
}


[Trace - 10:55:20 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [
        {
            "code": "lint/correctness/noUnusedVariables",
            "codeDescription": {
                "href": "https://biomejs.dev/linter/rules/no-unused-variables"
            },
            "message": "This variable is unused.",
            "range": {
                "end": {
                    "character": 12,
                    "line": 2
                },
                "start": {
                    "character": 6,
                    "line": 2
                }
            },
            "severity": 1,
            "source": "biome"
        }
    ],
    "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
    "version": 14
}


[Trace - 10:55:20 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
        "version": 15
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 6
                },
                "end": {
                    "line": 2,
                    "character": 6
                }
            },
            "rangeLength": 0,
            "text": "_"
        }
    ]
}


[Trace - 10:55:20 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [],
    "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
    "version": 15
}


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (28)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (28)' in 1ms.
Result: []

enable biome extension to "monitor or alike" the workspace

"PROBLEMS" Tab only show the problems of the files that are opened.
Since biomejs is blazing fast it could monitor or check at opening the workspace.

with typescript I can accomplish adding this to JSON settings:

"typescript.tsserver.experimental.enableProjectDiagnostics": true

image

Extension does not start the server in offline environment

I installed the latest extension version (2.0.0) in an offline environment via vsix. The installation went fine, but the server doesn't start. Biome's status in status bar is stuck on initializing.

In biome extension's output I see it's using the local biome from node_modules

...but in Extension Host output there's an fetch error from the following stack trace (sorry, unable to provide the actual stack trace)

activate -> statusBar.setUsingBundledBiome -> checkForUpdates -> getVersions

I'd guess there's too eager update checking going on without proper error handling.

πŸ› VSCode extension can't find biome in subfolder

Environment information

Not related.

What happened?

Biome is installed via npm in a subfolder inside my project. The extension can't find it, instead it downloads a bundled version of Biome.

Expected result

The extension should scan for all package.json files in my project and use the already installed version of Biome.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Add `configPath` option

This option will allow the extension to resolve the configuration from a different path, as opposed to the default configuration resolution.

This option will pass --config-path to the CLI, so it will behave the same.

πŸ› Extension doesn't reload when installed Biome version changes

VS Code version

1.87.2

Extension version

2.2.2

Biome version

1.6.1

Operating system

  • Windows
  • macOS
  • Linux

Description

TL;DR: We could make Biome-VSCode's version reloading more reliable (to build upon #91) by using the VS Code file system watcher to monitor changes in node_modules/@biomejs/biome. The current createFileSystemWatcher doesn't support looking at user excluded folders (e.g. node_modules/**/*) even though its documentation implies it can, but a proposed API change (microsoft/vscode#169724) would allow us to do this.


When the installed version of Biome changes, the VS Code extension doesn't reload the Biome version. In #91, the
extension started listening for changes to any lockfile to determine when to reload. While that solves part of the problem, it does not account for a common workflow: one person updates the Biome version, checks in the updated version and lockfile, and another person pulls those changes.

Specifically, using arbitrary version numbers and Bun to help illustrate the issue, if we:

  1. Have a package.json locked to biome version 1.5.3, bun install, touch bun.lockb, the biome-vscode extension will load Biome version 1.5.3
  2. In an untracked folder, make a commit where biome is bumped to 1.6.1, run bun install, include the commit of the lockfile being updated
  3. Pull that commit. The lockfile will be updated, the biome-vscode extension will attempt a reload but nothing will change because locally we're still running 1.5.3
  4. Run bun/yarn/npm install. The biome version will be updated to 1.6.1, but since the lockfile won't change (it was already pulled in), the extension won't reload it.

I believe this issue would also be present the first time cloning a repo, since only monitoring the lockfile for changes would result in us triggering a reload before Biome's installed.


The ideal fix for this (IMO) is to add a watcher on the node_modules/@biomejs folder to look to detect when the version changes (for example, node_modules/@biomejs/biome/package.json. In #91, we specifically avoided doing that because the node_modules folder is excluded from VS Code:

biome-vscode/src/main.ts

Lines 185 to 186 in a8da209

// Best way to determine package updates. Will work for npm, yarn, pnpm and bun. (Might work for more files also).
// It is not possible to listen node_modules, because it is usually gitignored.

Digging into that, I noticed that the documentation of the createFileSystemWatcher heavily implies that it's possible to create a non-recursive watcher in a user excluded folder: https://github.com/microsoft/vscode/blob/1.87.2/src/vscode-dts/vscode.d.ts#L13182-L13186. This comment also implies it should be possible.

Unfortunately, I could not figure out any way to get VS Code to watch this excluded folder. Here's a patch that I thought would work based on the documentation:

diff --git a/src/main.ts b/src/main.ts
index 7d512a0..cd2a6f9 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -184,27 +184,34 @@ export async function activate(context: ExtensionContext) {
 	if (workspace.workspaceFolders?.[0]) {
 		// Best way to determine package updates. Will work for npm, yarn, pnpm and bun. (Might work for more files also).
-  		// It is not possible to listen node_modules, because it is usually gitignored.
-		const watcher = workspace.createFileSystemWatcher(
+		const lockfileWatcher = workspace.createFileSystemWatcher(
 			new RelativePattern(workspace.workspaceFolders[0], "*lock*"),
 		);
+		const biomeVersionWatcher = workspace.createFileSystemWatcher(
+			new RelativePattern(workspace.workspaceFolders[0], 'node_modules/@biomejs/biome/package.json'),
+		);
+
+		async function reloadBiomeExecutable() {
+			try {
+				outputChannel.appendLine("Reloading biome executable.");
+				if (client.isRunning()) {
+					await client.stop();
+				}
+				await reloadClient();
+				if (client.isRunning()) {
+					await client.restart();
+				} else {
+					await client.start();
+				}
+			} catch (error) {
+				outputChannel.appendLine(`Reloading client failed: ${error}`);
+			}
+		}
+		// When the lockfile OR the installed biome version changes, reload the biome executable.
 		context.subscriptions.push(
-			watcher.onDidChange(async () => {
-				try {
-					// When the lockfile changes, reload the biome executable.
-					outputChannel.appendLine("Reloading biome executable.");
-					if (client.isRunning()) {
-						await client.stop();
-					}
-					await reloadClient();
-					if (client.isRunning()) {
-						await client.restart();
-					} else {
-						await client.start();
-					}
-				} catch (error) {
-					outputChannel.appendLine(`Reloading client failed: ${error}`);
-				}
-			}),
+			lockfileWatcher.onDidChange(reloadBiomeExecutable),
+			biomeVersionWatcher.onDidChange(reloadBiomeExecutable),
+			biomeVersionWatcher.onDidCreate(reloadBiomeExecutable),
 		);
 	}
 

There is a new proposed API for createFileSystemWatcher that solves this problem by accepting an excludes option to be passed:

const biomeVersionWatcher = workspace.createFileSystemWatcher(
	new RelativePattern(workspace.workspaceFolders[0], 'node_modules/@biomejs/biome/package.json'),
	{ excludes: [] },
);

However, since it's a proposed API, it only works in development with code . --enable-proposed-api biomejs.biome and adding "enabledApiProposals": ["createFileSystemWatcher"] to the package.json.

I would recommend waiting until the proposed API gets merged and using this patch to have better version swapping support.

Steps to reproduce

See above.

Expected behavior

See above.

Does this issue occur when using the CLI directly?

No

Logs

No response

Compatibility issue with yarn pnp

Hi,

we use yarn pnp in our project and the extension complains it cannot find the @biomejs/biome package

Could not find Biome in your dependencies. Either add the @biomejs/biome package to your dependencies, or download the Biome binary.

but @biomejs/biome is in the dev dependencies

"devDependencies": {
    "@biomejs/biome": "1.4.1"
}

how can i make this combo work?
thanks

πŸ› Missing information in the contributing section

Extension version

main

Biome version

main

Operating system

  • Windows
  • macOS
  • Linux

Description

The current CONTRIBUTING.md document doesn't explain how a contributor can bundle the VSCode extension, and it doesn't explain how to launch VSCode with the bundled extension.

Steps to reproduce

  1. Open the document CONTRIBUTING.md
  2. Check the Development header
  3. It mentions a watch mode for debugging, but it's unclear how it works. I pressed in F5, but it didn't do anything

Expected behavior

I would expect more information for people who aren't accustomed to the developments of the project

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

No response

The VSCode extension fails to work when the Github API rate limit is reached.

I encountered the API rate limit, resulting in the malfunctioning of the VSCode extension. I found this error:

`releases.filter` is not a function

I examined the log and discovered that the return from the getVersions function is not an array when retrieving from https://api.github.com/repos/biomejs/biome/releases?per_page=100.

{
  "message": "API rate limit exceeded for[IP.IP.IP.IP]. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
  "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

BTW. Thanks for creating biome. It helps me a lot!

Remove the `requireConfiguration` option

We discussed this internally, and we agreed that this option must go.

Biome can resolve its configuration perfectly fine, and if it doesn't, it uses the default behaviour.

The reason why we added this configuration was because "people don't want to see diagnostics if they aren't in a biome project". While this is true, this hides how powerful Biome is. People can still disable the extension if they need.

We want users to download the extension and start using it straightaway because that's what Biome is. Good defaults and configuration are not needed. This is the message we want to send.

Request textDocument/codeAction failed.

It looks like we should be able to limit the extensions to work only in workspace

[Error - 19:26:08] Request textDocument/codeAction failed.
  Message: Size of /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts is 1.2 MiB which exceeds configured maximum of 1.0 MiB for this project. The file size limit exists to prevent us inadvertently slowing down and loading large files that we shouldn't.
  Code: -32603 
image

Use the new logo

Soon we will update the website with the new logo, although we can start migrating the rest of the tools to use the new logo.

Browse biomejs/resources and choose the icon that fits best!

Extension 'Biome' is configured as formatter but it cannot format 'JavaScript'-Files

When i click configure, no biome is in the list.

I created a fresh new example project:

Installed Biome v2.0.0 in VSCode.

Added settings.json

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

/example.code.workspace

{
  "folders": [
    {
      "path": "biome-test"
    }
  ]
}

/biome-test/package.json

{
  "name": "biome-test",
  "version": "1.0.0",
  "main": "index.js",
  "devDependencies": {
    "@biomejs/biome": "^1.4.1"
  }
}

/biome-test/biome.json (from biome-hompeage

{
  "$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
  "organizeImports": {
    "enabled": false
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  }
}

/biome-test/index.js

console.log("Hello World!") // without semicolon so `biome check index.js` errors in cli

Restart everything, vscode has no biome.

In command line i can execute:

cd biome-test
./node_modules/.bin/biome check index.js

It shows Checked 1 file(s) in 1031Β΅s Found 2 error(s)

Adding /biome/test/biome.json

  "javascript": {
    "formatter": {
      "semicolons": "asNeeded"
    }
  }

Re-run and it shows Checked 1 file(s) in 932Β΅s

So biome cli works and uses biome.json.

But not in VSCode. Tried nightly too, the same, no biome detected.

VSCode 1.84.2
Biome v2.0.0
Node v18.19.0
Linux Mint 21.2 (Ubuntu jammy)

Let me know, if i can provide more informations.

Allow custom `biome.json` route

I would like to be able to load a biome.json that isn't on the root of the workspace (instead in ./config as it is shared by multiple projects within the same repo)

Enable VSCode for `vue`, `svelte` and `astro` files

Descriptions

This issue has more background: biomejs/biome#1719

Technical changes

From Discord

For the upcoming partial support of vue, svelte and astro we have to change the VSCode extension. At the moment the extension activates when specific file langauges are opened, but that won't work for astro files
This means that we have to trigger extension in a more generic way, and "disable" it dynamically by checking the extension file that is currently about to open

The extension does not check that the binary exists when defined explicitly with `biome.lspBin`

The extension does not check that the binary exists when defined explicitly with biome.lspBin.

biome-vscode/src/main.ts

Lines 346 to 354 in cd6ef47

const config = workspace.getConfiguration();
const explicitPath = config.get("biome.lspBin");
if (typeof explicitPath === "string" && explicitPath !== "") {
return {
bundled: false,
workspaceDependency: false,
command: await getWorkspaceRelativePath(explicitPath),
};
}

Biome is not fully allowing typescript as a format on install.

I've noticed in your biome vscode extension it didn't support typescript.

I reloaded an it was there. maybe there's some weird bug going on when you install it?

Solutions I have found.

Force a reload on first install using preinstall and "preInstallMessage" in package.json

Help?

But I am to help out on this issue of concern if needed I know typescript, javascript and rust, So I can help you if needed.

πŸ› `biome.json` ignored when multiple folders open in a VS code session

VS Code version

1.87

Extension version

2.2.2

Biome version

1.6.1

Operating system

  • Windows
  • macOS
  • Linux

Description

So I found a nasty bug where my biome.json is ignored when I have two projects open in a single VS code session.

But, the bug only happens if the project that uses Biome is the 2nd workspace.

This works fine, biome.json is found

typescript-project
  - biome.json
python-project

This does not. My "tabs as spaces" configuration is ignored.

python-project
typescript-project
  - biome.json

I assume the bug is the VS code extension assumes one folder or always picks the first one.

Steps to reproduce

  1. Create a new VS code workspace
  2. Add a folder and select a project that does not have a biome.json at its root
  3. Add a folder that has a biome.json
  4. Configure format on save
  5. Go into a typescript file in the 2nd folder, edit and save. Spaces will be replaced with Tabs

Here's my biome.json:

{
  "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "linter": {
    "enabled": false,
    "rules": {
      "recommended": true,
      "suspicious": {
        "noExplicitAny": "off"
      }
    }
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 80,
    "lineEnding": "lf",
    "ignore": []
  },
  "javascript": {
    "formatter": {
      "indentWidth": 2,
      "indentStyle": "space"
    }
  },
  "json": {
    "formatter": {
      "indentWidth": 2,
      "indentStyle": "space"
    }
  }
}

Expected behavior

The Biome extension should be aware of multiple workspaces and use the settings specific to each project.

Does this issue occur when using the CLI directly?

No

Logs

No response

πŸ› biome.lspBin didn't work after update to latest extension

VS Code version

1.87.0

Extension version

2.2.1

Biome version

1.5.3

Operating system

  • Windows
  • macOS
  • Linux

Description

I use settings biome.lspBin to find my biome,however, it doesn't work after today I update this extension.And I rollback to v2.1.2, it still works.

"biome.lspBin": "./common/autoinstallers/rush-format/node_modules/@biomejs/biome/bin/biome",

Maybe you should well test before publish.I'm tired of finding new bugs...
I will keep use old versions.

Steps to reproduce

Use the same settings and will fail in the latest extension.

Expected behavior

work as before.

Does this issue occur when using the CLI directly?

No

Logs

No response

πŸ“Ž Yarn PnP support

Summary

This task tracks the implementation of Yarn PnP support for resolving the biome binary from a project's dependencies.

Yarn PnP uses a different strategy for installing dependencies that does not involve a node_modules folder, which is what we've been relying on with other package managers.

Ideally, we shouldn't have to rely on executing an external command to find the path to the binary, but it is unclear if that's even possible.

Reference

Contributing

If you'd like to contribute and implement this, please make it known in the comments so we can assign you to the task.

Format on save uses incorrect `biome.json` configuration in workspace

With the following:

Untitled Workspace
    folder1/
        src/
            index.ts
        biome.json
    folder2/
        src/
            index.ts
        biome.json

folder1/biome.json

{
	"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
	"formatter": {
		"indentSize": 2
	},
	"javascript": {
		"formatter": {
			"semicolons": "asNeeded"
		}
	}
}

folder2/biome.json

{
	"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
	"formatter": {
		"indentSize": 2
	},
	"javascript": {
		"formatter": {
			"semicolons": "always"
		}
	}
}

If I edit folder2/src/index.ts and save, it uses folder1's biome.json configuration, removing the semicolon.


I'm not sure if this is the same issue as #32, although I thought this applied to a single folder within a workspace? I typically have multiple different projects open in a single workspace like this, and should abide by the project's settings. Prettier works like this fwiw, and I never had an issue with it

Missing Biome warning should be optional

I work with several projects and some of them do not (yet!) use Biome. Currently the extension shows this warning every time a project without Biome is loaded:

Could not find Biome in your dependencies. Either add the @biomejs/biome package to your dependencies, or download the Biome binary.

I propose that a biome.warnIfDependencyMissing setting be added that allows disabling this warning, and a "Don't remind me again" option be added to the warning that sets this setting to false.

I'd be happy to work on this if it's something others want πŸ‘Œ

✨ Consider adding husky for better development experience

This is a feature request.

I think it would be a good idea to add husky to the project.
The pre-commit hook could then be used to format/lint automatically before committing.

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx biome format . --write
npx biome lint . --apply

This would prevent the biome ci from failing due to minor mistakes.
It can possibly also be combined with lint-staged to only run on staged files.

If this is something that the team would like implemented, please let me know and I'll gladly set up a pull request with it.

πŸ› No highlighting in vs code workspaces

Environment information

not needed

What happened?

Open a workspace in vs code (for eg. an application that runs in combination with an other combination)
Highlighting does not work

Open the files without workspaces - highlighting works.

Expected result

That highlighting is working

Code of Conduct

  • I agree to follow Biome's Code of Conduct

πŸ› Format on save doesn't work if "editor.formatOnSaveMode" is set to "modifications"

Extension version

2.1.2

Biome version

1.5.3

Operating system

  • Windows
  • macOS
  • Linux

Description

I'm not sure if it's indeed a bug or just a design decision, or maybe some incompatibility, but if you add "editor.formatOnSaveMode": "modifications" to your vscode settings, formatting on save stops working completely.

No suspect errors or warnings, I spent quite some time until I figure out that this option was breaking the extension. It would be good if we can add some info to the docs

764e5121-7526-46e9-bd80-efda59bb9b9e.mp4

Steps to reproduce

  1. Create a .vscode/settings.json file
{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports.biome": "explicit",
    "quickfix.biome": "explicit"
  },
  "editor.defaultFormatter": "biomejs.biome",
  "editor.formatOnSaveMode": "modifications"
}
  1. Try to format any file

Expected behavior

I expect the file to be formatted accordingly

Does this issue occur when using the CLI directly?

No

Logs

[Trace - 2:09:30 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx",
        "version": 3
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 12,
                    "character": 0
                },
                "end": {
                    "line": 12,
                    "character": 0
                }
            },
            "rangeLength": 0,
            "text": "\n"
        }
    ]
}


[Trace - 2:09:30 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [],
    "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx",
    "version": 3
}


[Trace - 2:09:30 AM] Sending request 'textDocument/codeAction - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 23,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "source.fixAll.eslint"
        ],
        "triggerKind": 2
    }
}


[Trace - 2:09:30 AM] Received response 'textDocument/codeAction - (4)' in 2ms.
Result: []


[Trace - 2:09:30 AM] Sending request 'textDocument/codeAction - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 23,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "source.organizeImports.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 2:09:30 AM] Received response 'textDocument/codeAction - (5)' in 2ms.
Result: []


[Trace - 2:09:30 AM] Sending request 'textDocument/codeAction - (6)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 23,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 2:09:30 AM] Received response 'textDocument/codeAction - (6)' in 2ms.
Result: []


[Trace - 2:09:30 AM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/luizfelicio/projects/personal/my-life/src/index.tsx"
    }
}

Unable to format unsaved json files

In VSCode if you create a new file, without saving, with JSON content and try to format the document biome is unable to:

image

Saving the file to disk works and it can format it.

πŸ› Cannot format TypeScript in VS Code

Environment information

I don't have a "biome" binary installed. I just installed the VS Code extension.

What happened?

I installed the VS Code extension and followed the instructions in its README to configure the default formatter for TypeScript files. I'm used to this procedure so I know how to do so.

Also tried running the command "Format Document" with Biome as the default formatter for TypeScript, and I'm met with this dialog:

image

Same with JavaScript files:

image

Prettier works fine... 🀷

Expected result

I expect it to be able to format TypeScript, since that's what it says in the README.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

πŸ› Error during extension activation

Extension version

2.1.2

Biome version

1.5.3

Operating system

  • Windows
  • macOS
  • Linux

Description

The extension hasn't been working for me since a long time. I used to use Biome (nightly) to workaround it, but after using pre-releases instead, I cannot workaround it now, and I cannot install the nightly extension anymore.

Screenshot 2024-02-25 at 3 38 47β€―PM Screenshot 2024-02-25 at 3 39 03β€―PM

I tried to rm -rf all of these files and install again but it's still the same:

~/Library/Caches/dev.biomejs.biome/
~/Library/Application Support/Code/CachedExtensionVSIXs/biomejs.biome-2.1.2
~/Library/Application Support/Code/CachedExtensionVSIXs/biomejs.biome-2024.2.180911
~/Library/Application Support/Code/User/globalStorage/biomejs.biome-nightly/
~/Library/Application Support/Code/User/globalStorage/github.vscode-pull-request-github/mentionableUsers/biomejs/"mentionableUsers/biomejs/
~/Library/Application Support/Code/User/workspaceStorage/a7f8779e138249a08dd303e379921e5e/biomejs.biome-nightly/"biome-nightly/"biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/2494cbf7408af6f0400cb09200025efa/biomejs.biome-nightly/"biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/617ba0f85fec7d3086f01c3300008aef/biomejs.biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/0b14f3415f97a11c2e48f788969955f4/biomejs.biome-nightly/"biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/cc166bb585e1c6a68ded8ce260fbe199/biomejs.biome-nightly/"biome-nightly/"biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/6ffd687be8fbefe0983f7b6226aa07c9/biomejs.biome-nightly/"biome-nightly/
~/Library/Application Support/Code/User/workspaceStorage/50e3b92dd3b6ca6f1a10b4f1ff951a56/biomejs.biome-nightly/

Steps to reproduce

  1. Install the extension

Expected behavior

To work

Does this issue occur when using the CLI directly?

No

Logs

N/A

πŸ› EPERM: operation not permitted node_modules\@biomejs\cli-win32-x64\biome.exe

Environment information

CLI:
  Version:                      1.3.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v18.18.2"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.0.0"

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 am getting an unexpected error when trying to install current/new packages using yarn. The problem happens when running the vs code extension while doing this. I suspect that this might because the VSCode extension depends on the installed version of biome in node_modules.

The error is as follows:

error An unexpected error occurred: "EPERM: operation not permitted, unlink '[...]\\node_modules\\@biomejs\\cli-win32-x64\\biome.exe'".

Workaround:

  • Close VSCode
  • Open Powershell or other cmd
  • Install packages using the new cmd

Expected result

It should not throw an error when trying to install the packages.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

File size limit popup opens multiple times when moving through a big file.

When looking at large files, this error message will pop up in the Biome output window every time you move through the file by arrows, mouse or any other action:

[Error - 12:54:55 AM] Request textDocument/codeAction failed.
  Message: Size of packages\apps\api\public\swagger\swagger-ui-bundle.js is 1.3 MiB which exceeds configured maximum of 1.0 MiB for this project. The file size limit exists to prevent us inadvertently slowing down and loading large files that we shouldn't.
  Code: -32603 

Similarly, a popup will appear for every move or action taken in the file:

image

Is it possible to make this popup only appear once, or once per unique file?
The popup does not close unless manually closed, it takes away focus and is generally annoying.
Sometimes you need to poke around in your build files or other packages, and this quickly gets tiresome.

I think the size limit is there for a reason, and that's a good thing. Instead of going around this to "fix" my problem, I would like to be annoyed only once by this popup.

Biome does not find biome executable despite setting lspBin (NixOS)

I use nixos and I cannot use the binary provided by the npm package. I install https://search.nixos.org/packages?channel=23.11&show=biome&from=0&size=50&sort=relevance&type=packages&query=biome, making it accessible in my $PATH:

$ which biome
/nix/store/rgg2nkfch4n4v4nsnpaq8jxh77xjrnca-biome-1.4.0/bin/biome

However, when I set "biome" as the lspBin, the extension fails to detect it, even though it's available in my VSCode environment. Using "/nix/store/rgg2nkfch4n4v4nsnpaq8jxh77xjrnca-biome-1.4.0/bin/biome" as lspBin resolves the issue, but it's not a sustainable solution due to the volatile nature of the hash in the Nix store. I propose that when lspBin is set to "biome" and biome isn't found in the local directory, it should automatically check in the $PATH as a fallback option.

πŸ“Ž Publish nightlies as pre-releases instead of separate extension

Summary

The stable and nightly versions of Biome are currently published as two separate extensions.

  • biomejs.biome (stable)
  • biomejs.biome-nightly (nightly)

One of the goals of publishing a nightly release of the extension is to allow early adopters to test new features and help us catch issues before they land in a stable release. In order to reduce friction, switching from the stable release to the nightly and vice-versa should be as straightforward as possible.

When I originally petitioned to split both releases into separate extensions, my hope was to avoid dealing with the fact that the VS Marketplace does not support SemVer. To cope with that limitation, extensions that publish pre-releases usually have a system in place that consists of publishing stable releases with an even-numbered minor version and pre-releases with an odd-numbered minor version.

  • 2.0.0 (stable)
  • 2.1.0 (pre-release)
  • 2.2.0 (stable)

This has the effect of producing non-linear versions within a channel (2.0.0 -> 2.2.0), which is something I'm admittedly not a fan of. That being said, and having discussed it among ourselves and with community members, we feel that the benefits of having a single extension with two release channels outweigh the cons.

  • Easier to switch between stable and nightly
  • Users need to maintain only one set of settings
  • Easier upgrade path
  • No more conflicts between both versions

Upgrade paths

  • Users who subscribe to the stable release channel expect to be upgraded to the next stable version, not the next pre-release version.
  • Users who subscribe to the pre-release channel expect to be upgraded to the next pre-release version, but won't mind being upgraded to the next stable release if there isn't yet a pre-release version available.

Version numbers

To prevent confusion, the version number of the latest stable release should always be higher than the latest pre-release, even if this means that we end up with gaps.

For example, if we publish a pre-release (2.1.0), and some days later we publish another pre-release (2.3.0), the next stable release should not be 2.2.0, but 2.4.0.

To do

  • Stop packaging nightly
  • Stop publishing nightly
  • Mark pre-releases with vsce
  • Refactor code meant to prevent conflicts with nightly
  • Use CI to ensure the version pattern matches the corresponding channel
  • Use CI to ensure stable version numbers are always higher than the version of the latest pre-release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.