-
-
Notifications
You must be signed in to change notification settings - Fork 32
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.requireConfigFile
Ignored When Opening Single File in VSCode
#390
Comments
In single-file mode, there won't be a biome.json in your workspace because there is no workspace by definition. Would you expect the extension to check for a configuration file in the file's parent folder? |
Yes, I would expect Biome to behave the same whether a file is open in a workspace or in single file mode. I think most users who enable |
@nhedger i think we can move this issue in the main repo. Biome LSP already accepts this configuration from the client, so Biome LSP should behave consistently, as long as the client sends this settings when reading the client configuration |
@ematipico Actually, the extension checks itself for the presence of the configuration file as well. It won't even start an LSP session if the @LucasOe I'm not sure this is the behavior we want. Opening a single file that is part of an actual project feels like an edge case. However, wanting to occasionally lint and format individual files could be desirable. Following Happy to discuss this more |
I choose to enable In addition to open-source projects, I frequently edit configuration files that don’t adhere to Prettier or Biome styles. For instance:
Could you elaborate on this? From my understanding, this issue applies to any single file, regardless if it's part of a project or not.
Alternatively, users can create a Maybe a potential solution could be adding a "Biome: Force Formatting" command to the command palette. That way, people could force formatting for single files, even if This brings me to a related question. If a single file is opened, will it respect the |
Here single file means that VS Code has been opened with in single-file mode (as opposed to workspace mode). When you open a single file this way, VS Code has no concept of workspace folder. What I mean by edge case, is that I don't see why I would ever open just that single file, if it's already part of a workspace. Let's take this repository as an example. I would always open the whole repository in VS Code, but I would never open say package.json in single-file mode, because it makes little sense (to me). However, if I was doing so work on an arbitrary JSON file I just downloaded, and it belongs to no repository, I may open it in single-file mode to format it, for example.
The idea is to have direct access to Biome's formatting and lining capabilities. Following the example in the previous paragraph, I wouldn't want to create biome.json file every time I want to open a single file in VS Code.
This is the expected behavior indeed. When you open a file in single-file mode, the Biome extension will create a so-called project whose root folder is the parent folder of that single file, and Biome will use the configuration it finds in the root folder. |
If that's the behavior you want, can't you just set Personally, I wouldn't want any arbitrary JSON file to be formatted on save, that's why I enable the
I still don't fully understand how this is relevant to this problem. If I open the This issue only applies to single files that aren't part of a project that uses Biome. Files in projects using Prettier, or various configuration files, for example. I think it would be nice to hear what other users think. Maybe a small poll on the Discord could be helpful? |
Related issue for Prettier, although it unfortunately doesn't have much discussion: prettier/prettier-vscode#693 |
VS Code version
1.94.1
Extension version
2024.10.40751 (pre-release)
Biome version
1.9.3
Operating system
Description
When
biome.requireConfigFile
is set totrue
, it is expected that Biome (linter/formatter) should only be activated if a valid configuration file is present. However, this behavior is inconsistent when opening a single file in VSCode. Biome appears to be enabled automatically, even if no configuration file is present, contrary to the setting. This issue does not occur when opening a directory, where Biome correctly respects thebiome.requireConfigFile
setting.I only tested this issue on the pre-release version of the Biome Extension.
Steps to reproduce
"biome.requireConfigFile": true
in your VSCode settings.Expected behavior
Biome should not be activated when opening a single file if no configuration file is present, respecting the
"biome.requireConfigFile": true
setting.Does this issue occur when using the CLI directly?
Not sure / Not applicable
Link to a minimal reproduction
No response
Logs
No response
The text was updated successfully, but these errors were encountered: