diff --git a/.github/commitlint.config.js b/.github/commitlint.config.js deleted file mode 100644 index 252a9ad7..00000000 --- a/.github/commitlint.config.js +++ /dev/null @@ -1,15 +0,0 @@ -const Configuration = { - /* - * Resolve and load @commitlint/config-conventional from node_modules. - * Referenced packages must be installed - */ - extends: ['@commitlint/config-conventional'], - /* - * Any rules defined here will override rules from @commitlint/config-conventional - */ - rules: { - 'body-max-line-length': [1, 'always', 80], - }, -}; - -module.exports = Configuration; diff --git a/.github/commitlint.config.mjs b/.github/commitlint.config.mjs new file mode 100644 index 00000000..51b1c339 --- /dev/null +++ b/.github/commitlint.config.mjs @@ -0,0 +1,29 @@ +/* Taken from: https://github.com/wagoid/commitlint-github-action/blob/7f0a61df502599e1f1f50880aaa7ec1e2c0592f2/commitlint.config.mjs */ +/* eslint-disable import/no-extraneous-dependencies */ +import { maxLineLength } from '@commitlint/ensure' + +const bodyMaxLineLength = 100 + +const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => { + const { type, scope, body } = parsedCommit + const isDepsCommit = + type === 'chore' && (scope === 'deps' || scope === 'deps-dev') + + return [ + isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength), + `body's lines must not be longer than ${bodyMaxLineLength}`, + ] +} + +export default { + 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/lint.yaml b/.github/workflows/lint.yaml index cc5746a1..d29e7f6e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -28,7 +28,7 @@ jobs: fetch-depth: 0 - uses: wagoid/commitlint-github-action@3c75220e8d20774b68eea48e869a706ff7249b54 # v6.0.0 with: - configFile: .github/commitlint.config.js + configFile: .github/commitlint.config.mjs lint-actions: permissions: contents: read