Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .changeset/package-grit-plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
"@biomejs/biome": minor
---

Added support for distributing named Grit rules, rule presets, and configurations through `biome-manifest.json` or `biome-manifest.jsonc`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would say something like "in packages that have a manifest"


The field `plugins` is used to export named Grit plugins, and `configs` is used to export named configurations.
Package entries must select a named export: `package/rule`, `package/presets/preset`, or `package/configs/config`. Bare package entries aren't supported.
Rules consumed from another package are exposed under the consuming package's name, while package authors continue to reference them by their source package inside the manifest.
Configurations consumed from another package are also exposed under the consuming package's name.

```json5
{
"$schema": "./node_modules/@biomejs/biome/manifest_schema.json",
"version": 1,
"plugins": {
"rules": [
"@org/shared-rules/noDeprecatedApi",
"@org/strict-rules/presets/recommended",
{ "useCompanyLogger": "./rules/useCompanyLogger.grit" }
],
"presets": {
"recommended": [
"useCompanyLogger",
"@org/shared-rules/noDeprecatedApi"
]
}
},
"configs": [
"@org/shared-configs/configs/recommended",
{ "base": "./configs/base.json" }
]
}
```
Comment thread
dyc3 marked this conversation as resolved.

The package must publish the manifest and every referenced file, for example, through the `files` field in `package.json`.
Plugin authors can expose their manifest through the `biome` condition with `./biome-manifest.json` as its value.

```json5
// package.json
{
"name": "@org/biome-plugin",
"exports": {
"biome": "./biome-manifest.json",
"default": "./index.js"
},
"files": ["biome-manifest.json", "rules", "configs"]
}
```

And then, you can load the rules in your `biome.json`:

```json
{
"plugins": [
"@org/biome-plugin/useCompanyLogger",
"@org/biome-plugin/presets/recommended"
]
}
```

For more information on how to create a plugin to distribute via npm, check the relative [guide](https://biomejs.dev/guides/publish-packages/).
Comment thread
ematipico marked this conversation as resolved.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ biome_json_value = { path = "./crates/biome_json_value", version = "
biome_line_index = { path = "./crates/biome_line_index", version = "0.1.0" }
biome_lsp = { path = "./crates/biome_lsp" }
biome_lsp_converters = { path = "./crates/biome_lsp_converters", version = "0.1.0" }
biome_manifest = { path = "./crates/biome_manifest", version = "0.0.1" }
biome_markdown_factory = { path = "./crates/biome_markdown_factory", version = "0.0.1" }
biome_markdown_formatter = { path = "./crates/biome_markdown_formatter", version = "0.0.1" }
biome_markdown_parser = { path = "./crates/biome_markdown_parser", version = "0.0.1" }
Expand Down
6 changes: 4 additions & 2 deletions crates/biome_cli/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ where
if let Some(channel) = channel {
let response = match (response.result, response.error) {
(Some(result), None) => Ok(result),
(None, Some(err)) => Err(TransportError::RPCError(err.message)),
(None, Some(err)) => match err.data.and_then(|data| from_str(data.get()).ok()) {
Some(diagnostic) => Err(TransportError::RemoteDiagnostic(Box::new(diagnostic))),
None => Err(TransportError::RPCError(err.message)),
},

// Both result and error will be None if the request
// returns a null-ish result, in this case create a
Expand Down Expand Up @@ -443,7 +446,6 @@ struct JsonRpcError {
#[expect(dead_code)]
code: i64,
message: String,
#[expect(dead_code)]
data: Option<Box<RawValue>>,
}

Expand Down
Loading
Loading