UNPKG

3.99 kBMarkdownView Raw
1# @commitlint/config-conventional
2
3Lint your conventional commits
4
5Shareable `commitlint` config enforcing [conventional commits](https://conventionalcommits.org/).
6Use with [@commitlint/cli](https://npm.im/@commitlint/cli) and [@commitlint/prompt-cli](https://npm.im/@commitlint/prompt-cli).
7
8## Getting started
9
10```sh
11npm install --save-dev @commitlint/config-conventional @commitlint/cli
12echo "export default {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
13```
14
15## Rules
16
17### Problems
18
19The following rules are considered problems for `@commitlint/config-conventional` and will yield a non-zero exit code when not met.
20
21Consult [Rules reference](https://commitlint.js.org/reference/rules) for a list of available rules.
22
23#### type-enum
24
25- **condition**: `type` is found in value
26- **rule**: `always`
27- **level**: `error`
28- **value**
29
30 ```
31 [
32 'build',
33 'chore',
34 'ci',
35 'docs',
36 'feat',
37 'fix',
38 'perf',
39 'refactor',
40 'revert',
41 'style',
42 'test'
43 ];
44 ```
45
46```sh
47echo "foo: some message" # fails
48echo "fix: some message" # passes
49```
50
51#### type-case
52
53- **description**: `type` is in case `value`
54- **rule**: `always`
55- **level**: `error`
56- **value**
57 ```
58 'lowerCase'
59 ```
60
61```sh
62echo "FIX: some message" # fails
63echo "fix: some message" # passes
64```
65
66#### type-empty
67
68- **condition**: `type` is empty
69- **rule**: `never`
70- **level**: `error`
71
72```sh
73echo ": some message" # fails
74echo "fix: some message" # passes
75```
76
77#### subject-case
78
79- **condition**: `subject` is in one of the cases `['sentence-case', 'start-case', 'pascal-case', 'upper-case']`
80- **rule**: `never`
81- **level**: `error`
82
83```sh
84echo "fix(SCOPE): Some message" # fails
85echo "fix(SCOPE): Some Message" # fails
86echo "fix(SCOPE): SomeMessage" # fails
87echo "fix(SCOPE): SOMEMESSAGE" # fails
88echo "fix(scope): some message" # passes
89echo "fix(scope): some Message" # passes
90```
91
92#### subject-empty
93
94- **condition**: `subject` is empty
95- **rule**: `never`
96- **level**: `error`
97
98```sh
99echo "fix:" # fails
100echo "fix: some message" # passes
101```
102
103#### subject-full-stop
104
105- **condition**: `subject` ends with `value`
106- **rule**: `never`
107- **level**: `error`
108- **value**
109
110```
111'.'
112```
113
114```sh
115echo "fix: some message." # fails
116echo "fix: some message" # passes
117```
118
119#### header-max-length
120
121- **condition**: `header` has `value` or less characters
122- **rule**: `always`
123- **level**: `error`
124- **value**
125
126```
127100
128```
129
130```sh
131echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
132echo "fix: some message" # passes
133```
134
135#### footer-leading-blank
136
137- **condition**: `footer` should have a leading blank line
138- **rule**: `always`
139- **level**: `warning`
140
141```sh
142echo "fix: some message
143BREAKING CHANGE: It will be significant" # warning
144
145echo "fix: some message
146
147BREAKING CHANGE: It will be significant" # passes
148```
149
150#### footer-max-line-length
151
152- **condition**: `footer` each line has `value` or less characters
153- **rule**: `always`
154- **level**: `error`
155- **value**
156
157```
158100
159```
160
161```sh
162echo "fix: some message
163
164BREAKING CHANGE: footer with multiple lines
165has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails
166
167echo "fix: some message
168
169BREAKING CHANGE: footer with multiple lines
170but still no line is too long" # passes
171```
172
173#### body-leading-blank
174
175- **condition**: `body` should have a leading blank line
176- **rule**: `always`
177- **level**: `warning`
178
179```sh
180echo "fix: some message
181body" # warning
182
183echo "fix: some message
184
185body" # passes
186```
187
188#### body-max-line-length
189
190- **condition**: `body` each line has `value` or less characters
191- **rule**: `always`
192- **level**: `error`
193- **value**
194
195```
196100
197```
198
199```sh
200echo "fix: some message
201
202body with multiple lines
203has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails
204
205echo "fix: some message
206
207body with multiple lines
208but still no line is too long" # passes
209```