Skip to content

Conversation

dex4er
Copy link
Contributor

@dex4er dex4er commented Jun 19, 2025

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.

@dex4er dex4er changed the title biome: run from parent biome: run from parent to fix silently broken plugin Jun 19, 2025
@TylerJang27
Copy link
Collaborator

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.

@dex4er
Copy link
Contributor Author

dex4er commented Jun 25, 2025

Yes, it was noticed in this PR: freelensapp/freelens#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.

@dex4er
Copy link
Contributor Author

dex4er commented Jun 29, 2025

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.

@dex4er
Copy link
Contributor Author

dex4er commented Jul 12, 2025

The problem is related to biomejs/biome#6662 which was not really fixed yet and decribed in biomejs/biome#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.

@dex4er
Copy link
Contributor Author

dex4er commented Aug 19, 2025

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.

@TylerJang27
Copy link
Collaborator

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:

  1. 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 run and run_from that you've set in your current config
  2. 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
  3. 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

@dex4er dex4er marked this pull request as draft August 20, 2025 17:30
@dex4er
Copy link
Contributor Author

dex4er commented Aug 20, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants