conventional-changelog / conventional-changelog/commitlint
extended configurations do not concatenate `scope-enum`
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
Thank you for maintaining commitlint.
When extending multiple configurations, whether local or package-based, the `scope-enum` option does not concatenate the `scope-enum` options from every extended configuration. **I am unsure if this is intentional behaviour of commitlint.**
## Expected Behavior
When using the `extends` configuration option, the `scope-enum` sub option concatenates or merges all imported configs.
## Current Behavior
When using the `extends` configuration option, the `scope-enum` sub option does not concatenate and only the left-most array item in the `extends` value has their `scope-enum` sub option resolved.
## Affected packages
* [x] cli
* [x] core
* [x] config-lerna-scopes
* [x] resolve-extends
## Possible Solution
Depending on the intent of commitlint, the answer lies somewhere in `resolve-extends`. I'd be happy to contribute in any case.
## Steps to Reproduce (for bugs)
Here is a minimal example using only local configs: https://repl.it/@EnricoSacchetti/Commitlint-Extends-concatenation
To reproduce:
1. Open link above
2. Click 'run' at the top
3. Observe the output of 'Base config' that shows values from base.js
4. Observe the output of 'Extended config' that shows values from custom.js, but not base.js
Sample output:
```sh
base.js {"rules":{"scope-enum":[2,"always",["chore","test"]]}}
base config {"extends":["./base.js"]}
Resolved base config: [ 2, 'always', [ 'chore', 'test' ] ]
custom.js {"rules":{"scope-enum":[2,"always",["package-one","package-two"]]}}
extended config {"extends":["./custom.js","./base.js"]}
Resolved extended config: [ 2, 'always', [ 'package-one', 'package-two' ] ]
```
## Context
I am a maintainer of the [telus/tds-core](https://github.com/telus/tds-core) repository that uses lerna, and `@commitlint/config-lerna-scopes`. My goal is to set up custom scopes as well as the scopes gathered by `config-lerna-scopes`, but concatenation has become an issue.
As a workaround, I [concatenated my scopes manually](https://github.com/telus/tds-core/blob/057d4e8be05cddc562a5b73e4e2bb90dd3eaf8f8/commitlint.config.js) by using the `@commitlint/config-lerna-scopes` package API, but this is a brittle solution since it is not meant to be used this way. Importing scopes using `@commitlint/config-lerna-scopes@7.0.0` is synchronous, and `@commitlint/config-lerna-scopes@7.2.1` is asynchronous. I want to make proper use of `extends` or `@commitlint/load`.
If this non-concatenation behaviour of `extends` is a bug, then resolving the bug and using `extends` for conatenating options may be the best solution.
## Your Environment
| Executable | Version |
| ---: | :--- |
| `commitlint --version` | 7.2.1 |
| `git --version` | 2.19.2 |
| `node --version` | 8.11.3 |
Contributor guide
Assessment
This issue has not been assessed yet.