biome: run from parent to fix silently broken plugin
It addresses problems:
-
run_from: ${parent}
Now plugin breaks with the error:
direct_configs:
- biome.jsonc
exit_status: exited
exit_code: 1
stdout: (none)
stderr: |
/Users/dex4er/Sources/freelens/freelens/biome.jsonc configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Found a nested root configuration, but there's already a root configuration.
i The other configuration was found in /private/var/folders/k5/wyp40c2n6kzfqm5_gzry576c0000gn/T/trunk-501/MbkdUy/GW6i9I.
i Use the migration command from the root of the project to update the configuration.
$ biome migrate --write
configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Biome exited because the configuration resulted in errors. Please fix them.
With this setting biome correctly detects errors.
-
files: html
HTML file types are supported by Biome from 2.0 when enabled in configuration.
Hi! Thanks for the PR! Do you have a repro for this issue? I suspect ${root_or_parent_with_any_config} might be a better setting if the issue is not finding the proper biome.jsonc file to run from.
Yes, it was noticed in this PR: https://github.com/freelensapp/freelens/pull/874 You can get this commit after merge then remove settings from the .trunk.yaml and see the result: biome plugin silently ignores errors after you'll run trunk check --all -v.
If you say ${root_or_parent_with_any_config} is better then I'll switch to this option.
So it must be just ${parent} otherwise I get
× Found a nested root configuration, but there's already a root configuration.
i The other configuration was found in /private/var/folders/k5/wyp40c2n6kzfqm5_gzry576c0000gn/T/trunk-501/cMNcwD/7iasVC.
i Use the migration command from the root of the project to update the configuration.
$ biome migrate --write
configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Biome exited because the configuration resulted in errors. Please fix them.
The problem is related to https://github.com/biomejs/biome/pull/6662 which was not really fixed yet and decribed in https://github.com/biomejs/biome/issues/6509
Biome sees the copy of working tree in sandbox as duplicated then refuses to work.
My workaround is to use explicit --config-path option. Unfortunately, we must use explicit config file name, then it is just hardcoded to biome.jsonc as I can be just a single file in this option.
I disabled cache as a first reason of the problem that it was for long time undetected. Biome is so fast that caching is not important.
FYI: I had a lot of troubles with using Biome and Trunk together. In the end my configuration now is: https://github.com/freelensapp/freelens/blob/a4d0d192398878caee3c73d9721f60071fdf9121/.trunk/trunk.yaml#L22
lint:
definitions:
# See https://github.com/trunk-io/plugins/pull/1063
- name: biome
files:
- astro
- css
- graphql
- html
- javascript
- json
- typescript
commands:
- output: regex
success_codes:
- 0
- 1
batch: true
cache_results: false
name: lint
parse_regex: ^::(?P<severity>.*) title=(?P<code>[^,]+),file=(?P<path>[^,]+),line=(?P<line>[^,]+),endLine=[^,]+,col=(?P<col>[^,]+),endColumn=[^:]+::(?P<message>.*)
read_output_from: stdout
run: biome check --config-path=${workspace}/biome.jsonc --reporter=github ${target}
run_from: ${root_or_parent_with(biome.jsonc)}
- output: regex
success_codes:
- 0
batch: true
cache_results: false
formatter: true
name: fmt
parse_regex: ^::(?P<severity>.*) title=(?P<code>[^,]+),file=(?P<path>[^,]+),line=(?P<line>[^,]+),endLine=[^,]+,col=(?P<col>[^,]+),endColumn=[^:]+::(?P<message>.*)
read_output_from: stdout
run: biome format --config-path=${workspace}/biome.jsonc --reporter=github --write ${target}
run_from: ${root_or_parent_with(biome.jsonc)}
run_timeout: 1m
so it is now just ${root_or_parent_with(biome.jsonc)}.
And the main problem is that if biome uses vcs: {useIgnoreFile: true} option AND the .gitignore file contains tmp path then Biome does not work with Trunk Check!
Actually this is the same with yamlfmt tool: tmp cannot be in .gitignore.
Thanks for the follow-up. I'm reticent to accept this PR as-is, as it will break older versions of biome, and we try to preserve a reasonable level of backwards compatibility. However, I recognize that the multiple config file flow is a standard Biome idiom. Of the following alternatives, which do you think would work best for you:
- Provide essentially 2 different biome linter configurations in Trunk, one for <2.0.0 and one for >=2.0.0. For the newer versions, we would only support the one config file name by default, and would use the
runandrun_fromthat you've set in your current config - The minimal change would be updating the README.md for biome (and Trunk docs) to include these overrides for users who have multiple config files
- Some third middle ground? Although I don't believe there is a way we can support both nested and non-nested flows with flexibility given the biome issues you linked
I converted this PR back to a draft.
So: I think it is some limitation in Trunk that I miss some variable with the configuration file name. Now I must to use:
run: biome format --config-path=${workspace}/biome.jsonc --reporter=github --write ${target}
run_from: ${root_or_parent_with(biome.jsonc)}
and it will work only for 1 configuration file biome.jsonc. Biome can work also with biome.json and I would prefer to have some autodetection what file exists and I would like to use it in the command with some variable like --config-path=${config} or something else.
If it is not possible to detect more configuration files, then I prefer .jsonc of course, as it allows me to use comments.
My configuration, which I use almost every day, really works well in VS Code in real-time. I could prepare it as a proper PR if you allow me.