-
-
Notifications
You must be signed in to change notification settings - Fork 688
Description
Description
This task is related to #1573 , but it has slightly different requirements and use cases, although we could potentially solve both with the same solution.
Background
Monorepo (package manager workspaces) are very common in the web ecosystem, and they come in different flavours and expectations.
However, the common denominator is the following: a root configuration file, and each package in the monorepo extends the root configuration.
Flavours:
- one command at the root of the monorepo, then the CLI/LSP does the job of understanding which configuration file that is closer to the file is processing, and it applies the changes accordingly. This is very common for lint/format/testing tools.
- multiple commands, each command is defined inside a package of the monorepo. Then users usually use other tools to run these commands at once, e.g.
pnpm run --filter
,turborepo
, etc. This is very common for building tools such as bundlers, compilers, and doc generation.
The Biome case
Biome is a particular case here, because, even though it is a linter/formatter, in the future Biome will also transform/compile users's code, so it requires awareness of the manifest file and the dependency graph. Which means, while it makes sense to run biome check
at the root of the monorepo, what about a - future - biome compile
command?
We will have to untangle this. I am also happy to force users to set up Biome in one way in their monorepo.
CLI vs LSP = Workspace
The solution should lie in the Workspace. The Workspace
is what LSP and CLI both share, meaning that both of them hold an instance of it, and they use it to pull data when they need.
CLI
The CLI usually works from up to bottom, it scans and handles the files that are closest to the working directorey, and eventually handles the farthest files from the working directory. Although, this isn't always true, because for each directory AND file, we always span a thread, which means that eventually all jobs go their own way.
We would need to change the strategy of our CLI here, in way where we would need to read and resolve possible biome.json
files in each folder.
This could be potentially solved with a new workspace
configuration, that would allow Biome to resolve the packages before hand.
LSP
The LSP has a different problem to solve. Biome must apply the correct configuration for the opened file when jumping from one file to another.
Workspace
The reason why I think the solution lies in the Workspace
, is because both CLI and LSP have to do a very similar job: when handling a file, we should apply the configuration that belongs to that file. The Biome Workspace
would potentially store all those configurations, and then the CLI and LSP could:
- signal the
Workspace
to use the correct configuration, e.g.Workspace::swap_config
- or the
Workpace
could that by checking the path of the file/folder, and resolving automatically the configuration to use