1 | > Lint your commits, angular-style
|
2 |
|
3 | # @commitlint/config-angular
|
4 |
|
5 | Shareable `commitlint` config enforcing the [Angular commit convention](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).
|
6 | Use with [@commitlint/cli](../cli) and [@commitlint/prompt-cli](../prompt-cli).
|
7 |
|
8 | ## Getting started
|
9 |
|
10 | ```sh
|
11 | npm install --save-dev @commitlint/config-angular @commitlint/cli
|
12 | echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js
|
13 | ```
|
14 |
|
15 | ## Rules
|
16 |
|
17 | ### Problems
|
18 |
|
19 | The following rules are considered problems for `@commitlint/config-angular` and will yield a non-zero exit code when not met.
|
20 | Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/reference-rules) for a list of available rules.
|
21 |
|
22 | #### type-enum
|
23 |
|
24 | - **condition**: `type` is found in value
|
25 | - **rule**: `always`
|
26 | - **value**
|
27 |
|
28 | ```
|
29 | [
|
30 | 'build',
|
31 | 'ci',
|
32 | 'docs',
|
33 | 'feat',
|
34 | 'fix',
|
35 | 'perf',
|
36 | 'refactor',
|
37 | 'revert',
|
38 | 'style',
|
39 | 'test'
|
40 | ]
|
41 | ```
|
42 |
|
43 | ```sh
|
44 | echo "foo: some message" # fails
|
45 | echo "fix: some message" # passes
|
46 | ```
|
47 |
|
48 | #### type-case
|
49 |
|
50 | - **description**: `type` is in case `value`
|
51 | - **rule**: `always`
|
52 | - **value**
|
53 | ```
|
54 | 'lowerCase'
|
55 | ```
|
56 |
|
57 | ```sh
|
58 | echo "FIX: some message" # fails
|
59 | echo "fix: some message" # passes
|
60 | ```
|
61 |
|
62 | #### type-empty
|
63 |
|
64 | - **condition**: `type` is empty
|
65 | - **rule**: `never`
|
66 |
|
67 | ```sh
|
68 | echo ": some message" # fails
|
69 | echo "fix: some message" # passes
|
70 | ```
|
71 |
|
72 | #### scope-case
|
73 |
|
74 | - **condition**: `scope` is in case `value`
|
75 | - **rule**: `always`
|
76 |
|
77 | ```
|
78 | 'lowerCase'
|
79 | ```
|
80 |
|
81 | ```sh
|
82 | echo "fix(SCOPE): some message" # fails
|
83 | echo "fix(scope): some message" # passes
|
84 | ```
|
85 |
|
86 | #### subject-case
|
87 |
|
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 |
|
102 | - **condition**: `subject` is empty
|
103 | - **rule**: `never`
|
104 |
|
105 | ```sh
|
106 | echo "fix:" # fails
|
107 | echo "fix: some message" # passes
|
108 | ```
|
109 |
|
110 | #### subject-full-stop
|
111 |
|
112 | - **condition**: `subject` ends with `value`
|
113 | - **rule**: `never`
|
114 | - **value**
|
115 |
|
116 | ```
|
117 | '.'
|
118 | ```
|
119 |
|
120 | ```sh
|
121 | echo "fix: some message." # fails
|
122 | echo "fix: some message" # passes
|
123 | ```
|
124 |
|
125 | #### subject-exclamation-mark
|
126 |
|
127 | - **condition**: `subject` must not have a `!` before the `:` marker
|
128 | - **rule**: `never`
|
129 |
|
130 | The [angular commit
|
131 | convention](hhttps://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit)
|
132 | does not use a `!` to define a breaking change in the commit subject. If you
|
133 | want to use this feature please consider using the [conventional commit
|
134 | config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#commitlintconfig-conventional).
|
135 |
|
136 | #### header-max-length
|
137 |
|
138 | - **condition**: `header` has `value` or less characters
|
139 | - **rule**: `always`
|
140 | - **value**
|
141 |
|
142 | ```
|
143 | 72
|
144 | ```
|
145 |
|
146 | ```sh
|
147 | echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
|
148 | echo "fix: some message" # passes
|
149 | ```
|
150 |
|
151 | ### Warnings
|
152 |
|
153 | The following rules are considered warnings for `@commitlint/config-angular` and will print warning messages when not met.
|
154 |
|
155 | #### body-leading-blank
|
156 |
|
157 | - **condition**: Body begins with blank line
|
158 | - **rule**: `always`
|