Skip to content

Commit a1ddfcf

Browse files
authored
docs: add missing rules to documentation (#2428)
* docs: correct documentation for rules - missing docs for rules: - body-case - footer-empty - body-empty - add simple unit test for docs validation - update lowerCase to lower-case * test: improve unit test for rules
1 parent c548a32 commit a1ddfcf

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

@commitlint/rules/src/index.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
import fs from 'fs';
23
import globby from 'globby';
34
import rules from '.';
45

@@ -13,6 +14,19 @@ test('rules export functions', () => {
1314
expect(actual.every((rule) => typeof rule === 'function')).toBe(true);
1415
});
1516

17+
test('all rules are present in documentation', () => {
18+
const file = fs.readFileSync(
19+
path.join(__dirname, '../../../docs/reference-rules.md'),
20+
'utf-8'
21+
);
22+
const results = file
23+
.split(/(\n|\r)/)
24+
.filter((s) => s.startsWith('####') && !s.includes('`deprecated`'))
25+
.map((s) => s.replace('#### ', ''));
26+
27+
expect(Object.keys(rules)).toEqual(expect.arrayContaining(results));
28+
});
29+
1630
async function glob(pattern: string | string[]) {
1731
const files = await globby(pattern, {
1832
ignore: ['**/index.ts', '**/*.test.ts'],

docs/reference-rules.md

+38-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Rule configurations are either of type `array` residing on a key with the rule's
5757
- **condition**: `body` begins with blank line
5858
- **rule**: `always`
5959

60+
#### body-empty
61+
62+
- **condition**: `body` is empty
63+
- **rule**: `never`
64+
6065
#### body-max-length
6166

6267
- **condition**: `body` has `value` or less characters
@@ -87,11 +92,41 @@ Infinity
8792
0
8893
```
8994

95+
#### body-case
96+
97+
- **condition**: `header` is in case `value`
98+
- **rule**: `always`
99+
- **value**
100+
101+
```
102+
'lower-case'
103+
```
104+
105+
- **possible values**
106+
107+
```
108+
[
109+
'lower-case', // default
110+
'upper-case', // UPPERCASE
111+
'camel-case', // camelCase
112+
'kebab-case', // kebab-case
113+
'pascal-case', // PascalCase
114+
'sentence-case', // Sentence case
115+
'snake-case', // snake_case
116+
'start-case' // Start Case
117+
]
118+
```
119+
90120
#### footer-leading-blank
91121

92122
- **condition**: `footer` begins with blank line
93123
- **rule**: `always`
94124

125+
#### footer-empty
126+
127+
- **condition**: `footer` is empty
128+
- **rule**: `never`
129+
95130
#### footer-max-length
96131

97132
- **condition**: `footer` has `value` or less characters
@@ -129,7 +164,7 @@ Infinity
129164
- **value**
130165

131166
```
132-
'lowerCase'
167+
'lower-case'
133168
```
134169

135170
- **possible values**
@@ -198,7 +233,7 @@ Infinity
198233
- **value**
199234

200235
```
201-
'lowerCase'
236+
'lower-case'
202237
```
203238

204239
- **possible values**
@@ -248,7 +283,7 @@ Infinity
248283
- **value**
249284

250285
```
251-
'lowerCase'
286+
'lower-case'
252287
```
253288

254289
- **possible values**

0 commit comments

Comments
 (0)