`parserPreset` in `.commitlintc.json` is ignored
Steps to Reproduce
- Create
.commitlintrc.jsonwith the following contents
{
"extends": ["@commitlint/config-conventional"],
"parserPreset:": {
"parserOpts": {
"issuePrefixes": ["PREFIX-"]
}
},
"rules": {
"references-empty": [2, "never"]
}
}
- Run
echo "feat: some feature (PREFIX-123)" | npx commitlintand observe how an error for empty references is thrown. - Run
npx commitlint --print-configand observe howparserPreset.parserOpts.issuePrefixesis[ '#' ].
With a commitlint.config.js this does not happen.
Current Behavior
see above.
Expected Behavior
It should correctly pick up parserPreset from the JSON configuration.
Affected packages
- [X] cli
- [X] core
- [ ] prompt
- [ ] config-angular
Possible Solution
No response
Context
No response
commitlint --version
@commitlint/[email protected]
git --version
2.45.2
node --version
v20.13.1
and observe how an error for empty references is thrown.
Please copy+paste that error.
Uhm, sure:
â§— input: feat: some feature (PREFIX-123)
✖ references may not be empty [references-empty]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
If you want a repro, see this repo.
Uhm, can you check if this works?:
feat: some feature (#PREFIX-123)
Update: Hm, no. Should work as you described it I guess :(
I have created a sharable config and need to overwrite the parser options.
I found a workaround to overwrite the @commitlint/config-conventional parserOpts presets without losing them.
index.js
import { resolveFrom } from '@commitlint/load';
// Resolve and import the conventional config
const conventionalConfigPath = resolveFrom('@commitlint/config-conventional', process.cwd());
const conventionalConfig = (await import(conventionalConfigPath)).default;
// Resolve and import the conventional parser options
const conventionalParserOptsPath = resolveFrom('conventional-changelog-conventionalcommits', process.cwd());
const conventionalParserOptsModule = await import(conventionalParserOptsPath);
const conventionalParserOpts = (await conventionalParserOptsModule.default()).parser;
export default {
...conventionalConfig,
parserPreset: {
parserOpts: {
...conventionalParserOpts,
issuePrefixes: ['TNO-'],
},
},
};