1 | > Lint your conventional commits
|
2 |
|
3 | # @commitlint/config-conventional
|
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 | | :warning: | |
|
9 | |:-------:|--|
|
10 | | **IMPORTANT** | This is a direct replacement for [@commitlint/config-angular](https://npm.im/@commitlint/config-angular) prior to version 4. `config-angular` diverged from the conventional commit convention as of version 5. See [#146](https://github.com/conventional-changelog/commitlint/issues/146) for details. |
|
11 |
|
12 | ## Getting started
|
13 |
|
14 | ```sh
|
15 | npm install --save-dev @commitlint/config-conventional @commitlint/cli
|
16 | echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
|
17 | ```
|
18 |
|
19 | ## Rules
|
20 | ### Problems
|
21 |
|
22 | The following rules are considered problems for `@commitlint/config-conventional` and will yield a non-zero exit code when not met.
|
23 |
|
24 | Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/reference-rules) for a list of available rules.
|
25 |
|
26 |
|
27 | #### type-enum
|
28 | * **condition**: `type` is found in value
|
29 | * **rule**: `always`
|
30 | * **value**
|
31 |
|
32 | ```js
|
33 | [
|
34 | 'build',
|
35 | 'ci',
|
36 | 'chore',
|
37 | 'docs',
|
38 | 'feat',
|
39 | 'fix',
|
40 | 'perf',
|
41 | 'refactor',
|
42 | 'revert',
|
43 | 'style',
|
44 | 'test'
|
45 | ]
|
46 | ```
|
47 |
|
48 | ```sh
|
49 | echo "foo: some message" # fails
|
50 | echo "fix: some message" # passes
|
51 | ```
|
52 |
|
53 | #### type-case
|
54 | * **description**: `type` is in case `value`
|
55 | * **rule**: `always`
|
56 | * **value**
|
57 | ```js
|
58 | 'lowerCase'
|
59 | ```
|
60 |
|
61 | ```sh
|
62 | echo "FIX: some message" # fails
|
63 | echo "fix: some message" # passes
|
64 | ```
|
65 |
|
66 | #### type-empty
|
67 | * **condition**: `type` is empty
|
68 | * **rule**: `never`
|
69 |
|
70 | ```sh
|
71 | echo ": some message" # fails
|
72 | echo "fix: some message" # passes
|
73 | ```
|
74 |
|
75 | #### scope-case
|
76 | * **condition**: `scope` is in case `value`
|
77 | * **rule**: `always`
|
78 | ```js
|
79 | 'lowerCase'
|
80 | ```
|
81 |
|
82 | ```sh
|
83 | echo "fix(SCOPE): some message" # fails
|
84 | echo "fix(scope): some message" # passes
|
85 | ```
|
86 |
|
87 | #### subject-case
|
88 | * **condition**: `subject` is in one of the cases `['sentence-case', 'start-case', 'pascal-case', 'upper-case']`
|
89 | * **rule**: `never`
|
90 |
|
91 | ```sh
|
92 | echo "fix(SCOPE): Some message" # fails
|
93 | echo "fix(SCOPE): Some Message" # fails
|
94 | echo "fix(SCOPE): SomeMessage" # fails
|
95 | echo "fix(SCOPE): SOMEMESSAGE" # fails
|
96 | echo "fix(scope): some message" # passes
|
97 | echo "fix(scope): some Message" # passes
|
98 | ```
|
99 |
|
100 | #### subject-empty
|
101 | * **condition**: `subject` is empty
|
102 | * **rule**: `never`
|
103 |
|
104 | ```sh
|
105 | echo "fix:" # fails
|
106 | echo "fix: some message" # passes
|
107 | ```
|
108 |
|
109 | #### subject-full-stop
|
110 | * **condition**: `subject` ends with `value`
|
111 | * **rule**: `never`
|
112 | * **value**
|
113 | ```js
|
114 | '.'
|
115 | ```
|
116 |
|
117 | ```sh
|
118 | echo "fix: some message." # fails
|
119 | echo "fix: some message" # passes
|
120 | ```
|
121 |
|
122 |
|
123 | #### header-max-length
|
124 | * **condition**: `header` has `value` or less characters
|
125 | * **rule**: `always`
|
126 | * **value**
|
127 | ```js
|
128 | 72
|
129 | ```
|
130 |
|
131 | ```sh
|
132 | echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
|
133 | echo "fix: some message" # passes
|
134 | ```
|