diff --git a/.github/configs/commitlint.config.js b/.github/configs/commitlint.config.js new file mode 100644 index 0000000..2c3951d --- /dev/null +++ b/.github/configs/commitlint.config.js @@ -0,0 +1,27 @@ +const { maxLineLength } = require('@commitlint/ensure') + +const bodyMaxLineLength = 100 + +const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => { + const { type, scope, body } = parsedCommit + const isDepsCommit = + type === 'chore' && scope === 'release' + + return [ + isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength), + `body's lines must not be longer than ${bodyMaxLineLength}`, + ] +} + +module.exports = { + extends: ['@commitlint/config-conventional'], + plugins: ['commitlint-plugin-function-rules'], + rules: { + 'body-max-line-length': [0], + 'function-rules/body-max-line-length': [ + 2, + 'always', + validateBodyMaxLengthIgnoringDeps, + ], + }, +} diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index 412f98b..6b20bac 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -7,7 +7,7 @@ on: pull_request: workflow_call: -jobs: +jobs: commitlint: runs-on: ubuntu-latest steps: @@ -15,3 +15,5 @@ jobs: with: fetch-depth: 0 - uses: wagoid/commitlint-github-action@v5 + with: + configFile: .github/configs/commitlint.config.js