dprint / dprint

Pluggable and configurable code formatting platform written in Rust.

Home Page:https://dprint.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible to have `dprint` `biome` point to `biome.json` for configuration?

o-az opened this issue · comments

commented

I installed the biome plugin and see that in the config I set a subset of the biome configuration. I'm wondering if I can have biome in dprint just use the biome.json config file I already have?

It's not possible because dprint's CLI runs Biome sandboxed in a Wasm runtime. It's not able to reach out and ask what's at a certain path. This has the security benefit, but also the performance benefit that plugin config only needs to be loaded from one file (dprint.json) instead of many different files. The downside is obviously that config needs to be duplicated in some cases if desired.

This problem is somewhat similar to a problem in #552 –– the plugin needs access to a project file (in that case of #552, the tailwindcss config file is needed). @dsherret thoughts on allowing users to explicitly allow read access to specific files? These file contents could be automatically added to plugin context.

{
  "read": ["biome.json", "tailwind.config.ts"],
  // rest of dprint config...
}

It would be a lot of work to give plugins read access to the file system and it would slow things down a lot. Plus, the plugins in dprint ideally should work in Web browsers. If anything, there should maybe be some ability to be able to specify a subset to include from another JSON file in the config. So for example, the shared config in tailwind.config.ts could be extracted out to a statically analyzable JSON file, then used in both tailwind.config.ts and dprint.json. I opened #821.