Skip to content

Extends array not merging as expected #2163

Closed
@adambullmer

Description

@adambullmer

Expected Behavior

When using multiple extends configs, I expect the last config to override any previously specified setting from the previous config(s).

Current Behavior

Some settings (in my case the parserPreset) are being overwritten by the last config option, while others are not (a rule).
Given a config like in the example below, I expect the enum-types rule to override the one specified in @commitlint/config-conventional.
When reversing the extends array, which solves the rule merging, I expect the parserPreset override to be the one from semantic-commit-emoji

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Refactor config extends loading and merging? Looking at transpiled code, in resolve-extends, your reducer is transpiled as reduceRight which seems backwards from what was originally authored in source.

Steps to Reproduce (for bugs)

Knowing that types is a type added by semantic-commit-emoji and absent in conventional-changelog, you can reproduce the issue and get an invalid type with: git commit -m "types: Foo"

commitlint.config.js ```js module.exports = { extends: ["@commitlint/config-conventional", "semantic-commit-emoji"], }; ```

Context

Using community defined presets/plugins, I cannot use compatible rules and parsers necessary to run.

Your Environment

Executable Version
commitlint --version 9.1.2
git --version 2.21.0
node --version 14.13.1
yarn --version 1.22.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions