You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our plugin implementation is based off of [eslint's plugin implementation](https://github.com/eslint/eslint/blob/5018378131fd5190bbccca902c0cf4276ee1581a/lib/config/plugins.js);
4
+
Each plugin is an npm module with a name in the format of `commitlint-plugin-<plugin-name>`, such as `commitlint-plugin-jquery`. You can also use scoped packages in the format of `@<scope>/commitlint-plugin-<plugin-name>` such as `@jquery/commitlint-plugin-jquery`.
5
+
6
+
### Rules in Plugins
7
+
8
+
Plugins can expose additional rules for use in commitlint. To do so, the plugin must export a `rules` object containing a key-value mapping of rule ID to rule. The rule ID does not have to follow any naming convention (so it can just be `dollar-sign`, for instance).
9
+
10
+
```js
11
+
module.exports= {
12
+
rules: {
13
+
"dollar-sign":function(parsed, when, value) {
14
+
// rule implementation ...
15
+
}
16
+
}
17
+
};
18
+
```
19
+
20
+
To use the rule in commitlint, you would use the unprefixed plugin name, followed by a slash, followed by the rule name. So if this plugin were named `commitlint-plugin-myplugin`, then in your configuration you'd refer to the rule by the name `myplugin/dollar-sign`. Example: `"rules": {"myplugin/dollar-sign": 2}`.
21
+
22
+
### Peer Dependency
23
+
24
+
To make clear that the plugin requires commitlint to work correctly you have to declare commitlint as a `peerDependency` in your `package.json`.
25
+
The plugin support was introduced in commitlint version `7.6.0`. Ensure the `peerDependency` points to @commitlint`7.6.0` or later.
26
+
27
+
```json
28
+
{
29
+
"peerDependencies": {
30
+
"@commitlint/lint": ">=7.6.0"
31
+
}
32
+
}
33
+
```
34
+
35
+
## Share Plugins
36
+
37
+
In order to make your plugin available to the community you have to publish it on npm.
38
+
39
+
Recommended keywords:
40
+
41
+
*`commitlint`
42
+
*`commitlintplugin`
43
+
44
+
Add these keywords into your `package.json` file to make it easy for others to find.
0 commit comments