diff --git a/@commitlint/rules/src/index.test.ts b/@commitlint/rules/src/index.test.ts index 9cab4155fa..1eaf0010e3 100644 --- a/@commitlint/rules/src/index.test.ts +++ b/@commitlint/rules/src/index.test.ts @@ -1,4 +1,5 @@ import path from 'path'; +import fs from 'fs'; import globby from 'globby'; import rules from '.'; @@ -13,6 +14,19 @@ test('rules export functions', () => { expect(actual.every((rule) => typeof rule === 'function')).toBe(true); }); +test('all rules are present in documentation', () => { + const file = fs.readFileSync( + path.join(__dirname, '../../../docs/reference-rules.md'), + 'utf-8' + ); + const results = file + .split(/(\n|\r)/) + .filter((s) => s.startsWith('####') && !s.includes('`deprecated`')) + .map((s) => s.replace('#### ', '')); + + expect(Object.keys(rules)).toEqual(expect.arrayContaining(results)); +}); + async function glob(pattern: string | string[]) { const files = await globby(pattern, { ignore: ['**/index.ts', '**/*.test.ts'], diff --git a/docs/reference-rules.md b/docs/reference-rules.md index 06454f1e3c..e8c8bb0be1 100644 --- a/docs/reference-rules.md +++ b/docs/reference-rules.md @@ -57,6 +57,11 @@ Rule configurations are either of type `array` residing on a key with the rule's - **condition**: `body` begins with blank line - **rule**: `always` +#### body-empty + +- **condition**: `body` is empty +- **rule**: `never` + #### body-max-length - **condition**: `body` has `value` or less characters @@ -87,11 +92,41 @@ Infinity 0 ``` +#### body-case + +- **condition**: `header` is in case `value` +- **rule**: `always` +- **value** + +``` +'lower-case' +``` + +- **possible values** + +``` +[ + 'lower-case', // default + 'upper-case', // UPPERCASE + 'camel-case', // camelCase + 'kebab-case', // kebab-case + 'pascal-case', // PascalCase + 'sentence-case', // Sentence case + 'snake-case', // snake_case + 'start-case' // Start Case +] +``` + #### footer-leading-blank - **condition**: `footer` begins with blank line - **rule**: `always` +#### footer-empty + +- **condition**: `footer` is empty +- **rule**: `never` + #### footer-max-length - **condition**: `footer` has `value` or less characters @@ -129,7 +164,7 @@ Infinity - **value** ``` -'lowerCase' +'lower-case' ``` - **possible values** @@ -198,7 +233,7 @@ Infinity - **value** ``` -'lowerCase' +'lower-case' ``` - **possible values** @@ -248,7 +283,7 @@ Infinity - **value** ``` -'lowerCase' +'lower-case' ``` - **possible values**