Closed AustinMatherne closed 6 years ago
This feature is not implemented yet. There is a PR taking a stab at it: https://github.com/marionebl/commitlint/pull/76, where I added an outline how this could work:
// commitlint.config.js
module.exports = {
parserPreset: './parser-preset',
rules: {
'references-empty': [2, 'never'],
// extended use case, check if id is present
'references-enum': getIssueIds().then((ids) => [2, 'always', ids])
}
}
// parser-preset
module.exports = {
paserOpts: {
issuePrefixes: ['PRJ-', 'MFB-']
}
};
@AustinMatherne Would the feature match your use case?
@marionebl What is the value of ids
? Is it a RegEx, or an array of all possible IDs?
I'm matching against thousands of numerical IDs. Generating an array of them is easy enough, but seems less than ideal.
Thanks!
It is an string[]
, like the other *-enum
rules. My impression is you'd be catered by this anyways as for your example the *-enum
rule is not necessary:
references-empty
: [2, 'never']
, commits without issue id would fail as outlined in your examples'references-enum'
: [2, 'always', someArray]
you could fetch the actual list of available/allowed issue ids (say by fetch
ing them from JIRA) and check if the given ID is present. The pattern is established for the lerna
and patternplate
configs and works reasonably well: https://github.com/marionebl/commitlint/blob/master/%40commitlint/config-lerna-scopes/index.js#L6I'd like to keep parsing/regexp matching out of commitlint
. If the current conventional-commits-parser
capabilities are not enough to distinguish between valid and invalid references we can work on improving it.
In theory validating the ID against a real Jira story would be nice, but there's no way my team would accept an online requirement in order to make commits. Instead I'd have to create an array for every value between "0" and at least "99999".
@AustinMatherne I created a plugin and a config special for JIRA commit messages style commitlint-jira ;) I think this will be useful for you :)
Can commitlint validate numerical IDs?