Skip to content

extended configurations do not concatenate scope-enum #528

Open
@theetrain

Description

@theetrain

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

  • cli
  • core
  • config-lerna-scopes
  • 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:

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 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 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions