conventional-changelog / conventional-changelog/commitlint
Local plugin definition not supported by non-JS file formats (JSON & YAML)
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
With the new config file formats, how to state the plugins section in JSON or YAML?
#699
In the example of this issue above, and when "transcoding" the file into JSON, the value of dolar-sign can be a string, not a function.
## Expected Behavior
_commitlint.config.json_ should *eval* the function string `hello-world-rule`
```
{
"rules": {
"hello-world-rule": [
2,
"always"
]
},
"plugins": [
{
"rules": {
"hello-world-rule": "({subject}) => [ subject.includes('hi'), `Your subject should contain hi`]"
}
}
]
}
```
## Current Behavior
Throws an error
```
somerepo/node_modules/@commitlint/cli/lib/cli.js:112
throw err;
^
RangeError: Found invalid rule names: hello-world-rule. Supported rule names are: body-case, body-empty, body-full-stop, 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, subject-exclamation-mark, trailer-exists, type-case, type-empty, type-enum, type-max-length, type-min-length, hello-world-rule
at Object.lint [as default] (somerepo/node_modules/@commitlint/lint/lib/lint.js:53:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Promise.all (index 0)
at async main (somerepo/node_modules/@commitlint/cli/lib/cli.js:205:21)
```
## Affected packages
- [ ] cli
- [ ] core
- [ ] prompt
- [ ] config-angular
## Possible Solution
*eval* the function string
## Context
Using a config file in a JSON or YAML format which defines a local plugin
## Your Environment
| Executable | Version |
| ---------------------: | :------ |
| `commitlint --version` | @commitlint/cli@13.1.0 |
| `git --version` | VERSION |
| `node --version` | v14.17.4 |
Contributor guide
Assessment
This issue has not been assessed yet.