Publish packages
When several projects use the same plugins or the same configuration, you can publish them once as an npm package and install it everywhere. Your package lists the plugin rules, rule presets, and configurations it exports in a manifest named biome-manifest.json or biome-manifest.jsonc, and Biome loads them from node_modules/.
Manifests require Biome v2.6 or later. To share a configuration with projects that use an earlier version, see Support Biome versions before v2.6.
Publish plugin rules
Section titled “Publish plugin rules”-
Create
biome-manifest.jsonat the root of your package. Set the requiredversionfield, and map the name of each rule to its file inplugins.rules:biome-manifest.json {"version": 1,"plugins": {"rules": [{ "useCompanyLogger": "./rules/useCompanyLogger.grit" }]}}A rule file can be a GritQL plugin or a JavaScript plugin.
-
In
package.json, add the manifest and the rule files tofiles, and map thebiomeentry ofexportsto the manifest:package.json {"name": "@org/biome-plugins","version": "1.0.0","files": ["biome-manifest.json","rules"],"exports": {"biome": "./biome-manifest.json"}} -
Publish the package, and install it in the project that uses the rules. Then enable a rule by adding
<PACKAGE_NAME>/<RULE_NAME>toplugins:biome.json {"plugins": ["@org/biome-plugins/useCompanyLogger"]}
Group rules into presets
Section titled “Group rules into presets”A preset enables several rules at once. Declare presets in plugins.presets, each with the names of the rules it enables. This manifest defines a recommended and a strict preset:
{ "version": 1, "plugins": { "rules": [ { "useCompanyLogger": "./rules/useCompanyLogger.grit" }, { "noLegacyLibrary": "./rules/noLegacyLibrary.ts" } ], "presets": { "recommended": ["useCompanyLogger"], "strict": ["useCompanyLogger", "noLegacyLibrary"] } }}To enable a preset, add <PACKAGE_NAME>/presets/<PRESET_NAME> to plugins:
{ "plugins": ["@org/biome-plugins/presets/recommended"]}Re-export rules from another package
Section titled “Re-export rules from another package”Your package can also export rules and presets that come from one of its dependencies. Projects then enable them through your package name, so their configuration and suppression comments keep working if you replace the underlying rule later.
In plugins.rules, an object maps a name to a file in your package, and a string re-exports a rule or a preset from a dependency. This manifest re-exports the noExternalLinks rule and the minimal preset of a hypothetical biome-ux-plugins package, and adds noExternalLinks to its own recommended preset:
{ "version": 1, "plugins": { "rules": [ "biome-ux-plugins/noExternalLinks", "biome-ux-plugins/presets/minimal", { "useCompanyLogger": "./rules/useCompanyLogger.grit" }, { "noLegacyLibrary": "./rules/noLegacyLibrary.ts" } ], "presets": { "recommended": [ "useCompanyLogger", "biome-ux-plugins/noExternalLinks" ], "strict": ["useCompanyLogger", "noLegacyLibrary"] } }}The rules of biome-ux-plugins are now available under @org/biome-plugins. This configuration enables the recommended preset, and useAnimationFallback, a rule from the re-exported minimal preset:
{ "plugins": [ "@org/biome-plugins/presets/recommended", "@org/biome-plugins/useAnimationFallback" ]}Publish configurations
Section titled “Publish configurations”-
Create
biome-manifest.jsonat the root of your package. Set the requiredversionfield, and map the name of each configuration to its file inconfigs:biome-manifest.json {"version": 1,"configs": [{ "recommended": "./configs/recommended.json" },{ "strict": "./configs/strict.json" }]} -
In
package.json, add the manifest and the configuration files tofiles, and map thebiomeentry ofexportsto the manifest:package.json {"name": "@org/biome-configs","version": "1.0.0","files": ["biome-manifest.json","configs"],"exports": {"biome": "./biome-manifest.json"}} -
Publish the package, and install it in the project that uses the configuration. Then extend a configuration by adding
<PACKAGE_NAME>/configs/<CONFIG_NAME>toextends:biome.json {"extends": ["@org/biome-configs/configs/strict"]}
Re-export configurations from another package
Section titled “Re-export configurations from another package”Like rules, configurations can come from a dependency. Projects then extend them through your package name, so their configuration keeps working if you replace the underlying configuration later.
To re-export a configuration, add its path as a string to configs. This manifest re-exports the nuxt and astro configurations of the hypothetical biome-ux-plugins package:
{ "version": 1, "configs": [ "biome-ux-plugins/configs/nuxt", "biome-ux-plugins/configs/astro", { "recommended": "./configs/recommended.json" }, { "strict": "./configs/strict.json" } ]}To extend the nuxt configuration, add @org/biome-configs/configs/nuxt to extends:
{ "extends": ["@org/biome-configs/configs/nuxt"]}Help people find your package
Section titled “Help people find your package”Add the biome-plugin keyword to package.json, so that people can find your package when they search npm:
{ "name": "@org/biome-configs", "version": "1.0.0", "keywords": ["biome-plugin"]}Support Biome versions before v2.6
Section titled “Support Biome versions before v2.6”Biome versions before v2.6 do not read manifests, but they can extend a configuration that a package exports directly. Use this method only if your package must support those versions.
-
In
package.json, map a./biomeentry ofexportsto the configuration file. This example exports@org/shared-configs/biome:package.json {"name": "@org/shared-configs","type": "module","exports": {"./biome": "./biome.json"}} -
Install
@org/shared-configsin the project that uses the configuration, and add@org/shared-configs/biometoextends:biome.json {"extends": ["@org/shared-configs/biome"]}
Biome resolves @org/shared-configs from the working directory. For CLI commands, this is the directory where you run the command, usually the one that contains package.json. For the language server, it is the project root.
© 2023-present Biome developers and contributors.