Skip to content

Commit 5dc132f

Browse files
authored
docs: show config example in ts and js #2232 (#2424)
* docs: show config example in ts and js #2232 * docs: import config type from types #2232
1 parent a1ddfcf commit 5dc132f

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

docs/reference-configuration.md

+32-14
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,57 @@ The file is expected
88
- export a configuration object
99
- adhere to the schema outlined below
1010

11-
```ts
12-
type Config = {
11+
## Configuration object example
12+
13+
### JavaScript
14+
15+
```js
16+
const Configuration = {
1317
/*
14-
* Resolveable ids to commitlint configurations to extend
18+
* Resolve and load @commitlint/config-conventional from node_modules.
19+
* Referenced packages must be installed
1520
*/
16-
extends?: string[];
21+
extends: ['@commitlint/config-conventional'],
1722
/*
18-
* Resolveable id to conventional-changelog parser preset to import and use
23+
* Resolve and load conventional-changelog-atom from node_modules.
24+
* Referenced packages must be installed
1925
*/
20-
parserPreset?: string;
26+
parserPreset: 'conventional-changelog-atom',
2127
/*
22-
* Resolveable id to package, from node_modules, which formats the output.
28+
* Resolve and load @commitlint/format from node_modules.
29+
* Referenced package must be installed
2330
*/
24-
formatter: string;
31+
formatter: '@commitlint/format',
2532
/*
26-
* Rules to check against
33+
* Any rules defined here will override rules from @commitlint/config-conventional
2734
*/
28-
rules?: {[name: string]: Rule};
35+
rules: {
36+
'type-enum': [2, 'always', ['foo']],
37+
},
2938
/*
3039
* Functions that return true if commitlint should ignore the given message.
3140
*/
32-
ignores?: ((message: string) => boolean)[];
41+
ignores: [(commit) => commit === ''],
3342
/*
3443
* Whether commitlint uses the default ignore rules.
3544
*/
36-
defaultIgnores?: boolean;
45+
defaultIgnores: true,
3746
/*
3847
* Custom URL to show upon failure
3948
*/
40-
helpUrl?: string;
49+
helpUrl:
50+
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
4151
};
4252

43-
const Configuration: Config = {
53+
module.exports = Configuration;
54+
```
55+
56+
### TypeScript
57+
58+
```ts
59+
import type {UserConfig} from '@commitlint/types';
60+
61+
const Configuration: UserConfig = {
4462
/*
4563
* Resolve and load @commitlint/config-conventional from node_modules.
4664
* Referenced packages must be installed

0 commit comments

Comments
 (0)