We are trying to share a company-wide config so that we can easily have a standard linter with just one line in package.json. We want to use a plugin that adds a rule that otherwise doesn't exist.
The configuration looks like this:
const types = require('conventional-commit-types').types;
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: ['subject'],
rules: {
'scope-empty': [2, 'always'],
'type-enum': [2, 'always', Object.keys(types)],
'subject-case': [0, 'always'],
'subject-regexp': [2, 'always', /^DAZ-\d+\s.*/],
},
};
The plugin is commitlint-plugin-subject and we use it to enforce that we can put a JIRA-issue at the beginning of a subject line. Like fix: DAZ-123 Remove bugs.
I expect the commit fix: DAZ-123 Remove bugs to pass, and the rule 'subject-regexper' to be recognized.
When I extend the configuration and run a commit like fix: DAZ-123 Remove bugs I get the following error:
❯ git commit -m "fix: DAZ-123 Remove bugs"
husky > commit-msg (node v13.9.0)
/Users/julius.celik/Coding/temp/commitlint-test/node_modules/@commitlint/cli/lib/cli.js:124
throw err;
^
RangeError: Found invalid rule names: subject-regexp. Supported rule names are: body-case, body-empty, body-leading-blank, body-max-length, body-max-line-length, body-min-length, footer-empty, footer-leading-blank, footer-max-length, footer-max-line-length, footer-min-length, header-case, header-full-stop, header-max-length, header-min-length, references-empty, scope-case, scope-empty, scope-enum, scope-max-length, scope-min-length, signed-off-by, subject-case, subject-empty, subject-full-stop, subject-max-length, subject-min-length, type-case, type-empty, type-enum, type-max-length, type-min-length
at Object.<anonymous> (/Users/julius.celik/Coding/temp/commitlint-test/node_modules/@commitlint/lint/lib/index.js:76:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
husky > commit-msg hook failed (add --no-verify to bypass)
I am not sure but I think it is a core-issue.
I am not sure. We really want a fix for this so If you point me in the right direction I could look into submitting a PR tomorrow.
npm init -y && git initnpm i -D husky @commitlint/clinpm install @digitalroute/commitlint-config -Decho "module.exports = {extends: ['@digitalroute/commitlint-config']};" > commitlint.config.js"husky": { "hooks": {"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}}git commit -m "fix: DAZ-123 Remove bugs"If you do npm install @digitalroute/commitlint-config -D you get the following config:
const types = require('conventional-commit-types').types;
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: ['subject'],
rules: {
'scope-empty': [2, 'always'],
'type-enum': [2, 'always', Object.keys(types)],
'subject-case': [0, 'always'],
'subject-regexp': [2, 'always', /^DAZ-\d+\s.*/],
},
};
You can modify it in node_modules if necessary. If you comment out subject_regexp: ... and plugins: ['subject'], It should work to do a commit.
We want to run a regex on the subject line. The goal is to enforce that all our issues start with 'DAZ-\d+'
| Executable | Version |
| ---------------------: | :------ |
| @commitlint/cli --version | 8.3.5 |
| git --version | git version 2.17.2 (Apple Git-113) |
| node --version | v13.9.0 |
Hey @juliuscc, thanks for the issue! Not sure when we have time to look into this or point at directions. You could ask in the chat: https://devtoolscommunity.herokuapp.com
Just a status update. We got higher priority tasks so I have not looked too much at this. I will most likely start looking at this by the end of this week or next week. Before I do so I just want a confirmation: Is committing supposed to work as I expected it to?
Maybe @byCedric finds some time to give you a hint for this, when he's back. Might be better to wait for his feedback before you dig into this.