Skip to content

Commit 7fc1855

Browse files
committed
feat: [@onr/commitlint-config] add new package
1 parent 9a8ae12 commit 7fc1855

File tree

7 files changed

+397
-78
lines changed

7 files changed

+397
-78
lines changed

commitlint.config.js

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
11
module.exports = {
2-
parserPreset: 'conventional-changelog-conventionalcommits',
3-
rules: {
4-
'body-leading-blank': [1, 'always'],
5-
'body-max-line-length': [2, 'always', 100],
6-
'footer-leading-blank': [1, 'always'],
7-
'footer-max-line-length': [2, 'always', 100],
8-
'header-max-length': [2, 'always', 100],
9-
'scope-case': [2, 'always', 'lower-case'],
10-
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
11-
'subject-empty': [2, 'never'],
12-
'subject-full-stop': [2, 'never', '.'],
13-
'type-case': [2, 'always', 'lower-case'],
14-
'type-empty': [2, 'never'],
15-
'type-enum': [
16-
2,
17-
'always',
18-
[
19-
'assets',
20-
'build',
21-
'chore',
22-
'ci',
23-
'docs',
24-
'feat',
25-
'fix',
26-
'hotfix',
27-
'perf',
28-
'refactor',
29-
'revert',
30-
'style',
31-
'test',
32-
],
33-
],
34-
},
2+
extends: ['@onr/commitlint-config'],
353
};
Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
11
module.exports = {
2-
parserPreset: 'conventional-changelog-conventionalcommits',
3-
rules: {
4-
'body-leading-blank': [1, 'always'],
5-
'body-max-line-length': [2, 'always', 100],
6-
'footer-leading-blank': [1, 'always'],
7-
'footer-max-line-length': [2, 'always', 100],
8-
'header-max-length': [2, 'always', 100],
9-
'scope-case': [2, 'always', 'lower-case'],
10-
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
11-
'subject-empty': [2, 'never'],
12-
'subject-full-stop': [2, 'never', '.'],
13-
'type-case': [2, 'always', 'lower-case'],
14-
'type-empty': [2, 'never'],
15-
'type-enum': [
16-
2,
17-
'always',
18-
[
19-
'assets',
20-
'build',
21-
'chore',
22-
'ci',
23-
'docs',
24-
'feat',
25-
'fix',
26-
'hotfix',
27-
'perf',
28-
'refactor',
29-
'revert',
30-
'style',
31-
'test',
32-
],
33-
],
34-
},
2+
extends: ['@onr/commitlint-config'],
353
};

examples/next-starter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@commitlint/cli": "^11.0.0",
36-
"@commitlint/config-conventional": "^11.0.0",
36+
"@onr/commitlint-config": "^1.0.0",
3737
"husky": "^5.0.0",
3838
"lerna": "^3.22.1",
3939
"lint-staged": "^10.2.11"
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
> Lint your conventional commits
2+
3+
# @onr/commitlint-config
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 @onr/commitlint-config @commitlint/cli
12+
echo "module.exports = {extends: ['@onr/commitlint-config']};" > commitlint.config.js
13+
```
14+
15+
## Rules
16+
17+
### Problems
18+
19+
The following rules are considered problems for `@onr/commitlint-config` and will yield a non-zero exit code when not met.
20+
21+
Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/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+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
parserPreset: 'conventional-changelog-conventionalcommits',
3+
rules: {
4+
'body-leading-blank': [1, 'always'],
5+
'body-max-line-length': [2, 'always', 100],
6+
'footer-leading-blank': [1, 'always'],
7+
'footer-max-line-length': [2, 'always', 100],
8+
'header-max-length': [2, 'always', 100],
9+
'scope-case': [2, 'always', 'lower-case'],
10+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
11+
'subject-empty': [2, 'never'],
12+
'subject-full-stop': [2, 'never', '.'],
13+
'type-case': [2, 'always', 'lower-case'],
14+
'type-empty': [2, 'never'],
15+
'type-enum': [
16+
2,
17+
'always',
18+
[
19+
'assets',
20+
'build',
21+
'chore',
22+
'ci',
23+
'docs',
24+
'feat',
25+
'fix',
26+
'hotfix',
27+
'perf',
28+
'refactor',
29+
'revert',
30+
'style',
31+
'test',
32+
'devops',
33+
],
34+
],
35+
},
36+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@onr/commitlint-config",
3+
"version": "1.0.0",
4+
"license": "Apache-2.0",
5+
"description": "Shareable commitlint config enforcing conventional commits",
6+
"files": [
7+
"index.js"
8+
],
9+
"scripts": {
10+
"deps": "dep-check",
11+
"pkg": "pkg-check"
12+
},
13+
"publishConfig": {
14+
"access": "public"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/OnrampLab/onr-react-ui.git",
19+
"directory": "@onr/commitlint-config"
20+
},
21+
"keywords": [
22+
"conventional-changelog",
23+
"commitlint",
24+
"commitlint-config",
25+
"angular"
26+
],
27+
"engines": {
28+
"node": ">=v14"
29+
},
30+
"devDependencies": {
31+
"@commitlint/lint": "^17.3.0"
32+
},
33+
"dependencies": {
34+
"conventional-changelog-conventionalcommits": "^5.0.0"
35+
}
36+
}

0 commit comments

Comments
 (0)