1 | # @commitlint/config-conventional
|
2 |
|
3 | Lint your conventional commits
|
4 |
|
5 | Shareable `commitlint` config enforcing [conventional commits](https://conventionalcommits.org/).
|
6 | Use 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
|
11 | npm install --save-dev @commitlint/config-conventional @commitlint/cli
|
12 | echo "export default {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
|
13 | ```
|
14 |
|
15 | ## Rules
|
16 |
|
17 | ### Problems
|
18 |
|
19 | The following rules are considered problems for `@commitlint/config-conventional` and will yield a non-zero exit code when not met.
|
20 |
|
21 | Consult [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
|
47 | echo "foo: some message" # fails
|
48 | echo "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
|
62 | echo "FIX: some message" # fails
|
63 | echo "fix: some message" # passes
|
64 | ```
|
65 |
|
66 | #### type-empty
|
67 |
|
68 | - **condition**: `type` is empty
|
69 | - **rule**: `never`
|
70 | - **level**: `error`
|
71 |
|
72 | ```sh
|
73 | echo ": some message" # fails
|
74 | echo "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
|
84 | echo "fix(SCOPE): Some message" # fails
|
85 | echo "fix(SCOPE): Some Message" # fails
|
86 | echo "fix(SCOPE): SomeMessage" # fails
|
87 | echo "fix(SCOPE): SOMEMESSAGE" # fails
|
88 | echo "fix(scope): some message" # passes
|
89 | echo "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
|
99 | echo "fix:" # fails
|
100 | echo "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
|
115 | echo "fix: some message." # fails
|
116 | echo "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 | ```
|
127 | 100
|
128 | ```
|
129 |
|
130 | ```sh
|
131 | echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
|
132 | echo "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
|
142 | echo "fix: some message
|
143 | BREAKING CHANGE: It will be significant" # warning
|
144 |
|
145 | echo "fix: some message
|
146 |
|
147 | BREAKING 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 | ```
|
158 | 100
|
159 | ```
|
160 |
|
161 | ```sh
|
162 | echo "fix: some message
|
163 |
|
164 | BREAKING CHANGE: footer with multiple lines
|
165 | has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails
|
166 |
|
167 | echo "fix: some message
|
168 |
|
169 | BREAKING CHANGE: footer with multiple lines
|
170 | but 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
|
180 | echo "fix: some message
|
181 | body" # warning
|
182 |
|
183 | echo "fix: some message
|
184 |
|
185 | body" # 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 | ```
|
196 | 100
|
197 | ```
|
198 |
|
199 | ```sh
|
200 | echo "fix: some message
|
201 |
|
202 | body with multiple lines
|
203 | has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails
|
204 |
|
205 | echo "fix: some message
|
206 |
|
207 | body with multiple lines
|
208 | but still no line is too long" # passes
|
209 | ```
|