Skip to content

Commit

Permalink
Update documentation (#127)
Browse files Browse the repository at this point in the history
Added extending multiple plugins
Added creating plugin
  • Loading branch information
brayovsky authored Feb 6, 2024
1 parent db3139b commit 1b2767b
Showing 1 changed file with 58 additions and 15 deletions.
73 changes: 58 additions & 15 deletions packages/docs/src/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ Boll is configured by way of the `.boll.config.js` file in the root of a given p
Each boll configuration must load rules to be run across the repository. It may either
extend an existing configuration or fabricate a new configuration.

## Extending an existing configuration

To extend an configuration, first make sure rules are loaded, then export an object with
an `extends` key.

```js
"use strict";
const { bootstrapRecommendedConfiguration } = require('@boll/recommended');
bootstrapRecommendedConfiguration();
module.exports = {
extends: "boll:recommended"
};
```

## Creating a new configuration

A configuration is a list of `RuleSet` objects. Each `RuleSet` must define a `fileLocator`
Expand All @@ -42,4 +28,61 @@ module.exports = {
};
```

`@boll/core` provides several `fileLocator` implementations (see [FileGlob](../api/core/interfaces/fileglob)) out of the box.
`@boll/core` provides several `fileLocator` implementations (see [FileGlob](../api/core/interfaces/fileglob)) out of the box.


[Learn how to create rules](custom-rule)

## Extending an existing configuration

To extend an configuration, install the plugin and export an object with
an `extends` key.

```js
"use strict";

module.exports = {
extends: "boll:recommended"
};
```

You may also extend from multiple plugins.
```js
"use strict";

module.exports = {
extends: ["boll:recommended","plugin:check-readme"]
};
```

## Creating a plugin
A plugin is a configuration that can be extended from to provide additional rules. To create a plugin,
create a module which exports a `bootstrap` function. The plugin's configuration name also has to begin with the prefix `plugin:`.

```js
"use strict";
const { addRule, WorkspacesGlob, ConfigRegistryInstance } = require("@boll/core");
// a custom created rule to check readme file
const { ensureReadMe } = require("./rules/readme");

const readMeConfig = {
name: "plugin:check-readme",
ruleSets: [
{
fileLocator: new WorkspacesGlob(),
checks: {
file: [{ rule: "ensureReadMe" }]
}
}
]
};

function bootstrap() {
addRule(ensureReadme);
ConfigRegistryInstance.register(readMeConfig);
}

module.exports = {
bootstrap
};
```

0 comments on commit 1b2767b

Please sign in to comment.