Skip to content

Commit cd7f07d

Browse files
committed
style: ignore body-max-line-length rule for deps commits
1 parent 26b07cb commit cd7f07d

File tree

4 files changed

+76
-8
lines changed

4 files changed

+76
-8
lines changed

.github/workflows/commitlint.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ jobs:
1010
fetch-depth: 0
1111
- run: sed -i -E "s/(docker:.+)/Dockerfile/" ./action.yml
1212
- run: echo -n '' > .dockerignore
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: '14'
16+
- run: npm install
1317
- uses: ./
1418
id: run_commitlint
19+
env:
20+
NODE_PATH: ${{ github.workspace }}/node_modules
1521
- name: Show results from JSON output
1622
if: ${{ always() }}
1723
run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }}
@@ -21,4 +27,10 @@ jobs:
2127
- uses: actions/checkout@v2
2228
with:
2329
fetch-depth: 0
30+
- uses: actions/setup-node@v2
31+
with:
32+
node-version: '14'
33+
- run: npm install
2434
- uses: ./
35+
env:
36+
NODE_PATH: ${{ github.workspace }}/node_modules

commitlint.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
const { maxLineLength } = require('@commitlint/ensure')
2+
3+
const bodyMaxLineLength = 100
4+
5+
const validateBodyMaxLengthIgnoringDeps = parsedCommit => {
6+
const { type, scope, body } = parsedCommit
7+
const isDepsCommit =
8+
type === 'chore' && (scope === 'deps' || scope === 'deps-dev')
9+
10+
return [
11+
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
12+
`body's lines must not be longer than ${bodyMaxLineLength}`,
13+
]
14+
}
15+
116
module.exports = {
217
extends: ['@commitlint/config-conventional'],
18+
plugins: ['commitlint-plugin-function-rules'],
19+
rules: {
20+
'body-max-line-length': [0],
21+
'function-rules/body-max-line-length': [
22+
2,
23+
'always',
24+
validateBodyMaxLengthIgnoringDeps,
25+
],
26+
},
327
}

package-lock.json

Lines changed: 38 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
},
3535
"devDependencies": {
3636
"@commitlint/cli": "^11.0.0",
37+
"@commitlint/ensure": "^11.0.0",
3738
"@commitlint/test": "^9.0.1",
3839
"@commitlint/test-environment": "^9.0.1",
40+
"commitlint-plugin-function-rules": "^1.1.20",
3941
"conventional-changelog-cli": "^2.1.0",
4042
"husky": "^3.1.0",
4143
"jest": "^24.9.0",

0 commit comments

Comments
 (0)