Skip to content

Commit 3aa0ed7

Browse files
committed
start docs of new plugin features
1 parent b88a28d commit 3aa0ed7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/advancedPlugin.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
```json
2+
"CustomRequirement": [
3+
{
4+
rule: "custom",
5+
plugin: "My Plugin Name",
6+
name: "checkThing",
7+
otherStuff: "I like nachos"
8+
}
9+
]
10+
```
11+
12+
plugin
13+
```js
14+
const addOptionalRules = require('./helpers/addOptionalRules')
15+
16+
module.exports = (context) => {
17+
// Register this plugin
18+
context.addPlugin({
19+
name: 'My Plugin Name',
20+
description: 'I do amazing things',
21+
customChecks: {
22+
checkThing: async (rule, context) => {
23+
const successObject = {
24+
pass: true,
25+
message: 'Custom check succeeded!'
26+
}
27+
const failureObject = {
28+
pass: false,
29+
message: 'Custom check failed!'
30+
}
31+
32+
// Randomly succeed or fail
33+
return !!Math.floor(Math.random() * 2) ? successObject : failureObject
34+
}
35+
}
36+
})
37+
}
38+
```

0 commit comments

Comments
 (0)