Commitlint: Replace array config value rather than override element(s)

Created on 3 Dec 2016  ·  3Comments  ·  Source: conventional-changelog/commitlint

At first, thank you for your great work. conventional-changelog-lint with "husky" (my preference) really helps to keep clear commit messages with no pains.

BTW, I noticed that user configuration value, if it is an Array value, overrides element(s) of the value of sharable configuration. I don't know it is designed but it seems to be nice if user value replaces sharable configuration value rather than overriding.

For example:

conventional-changelog-lint-config-extendee/index.js
(in sharable configuration package: conventional-changelog-lint-config-extendee)

'use strict';

module.exports = {
    rules: {
        'type-enum': [
            2,
            'always',
            [
                'extendee-type-1',
                'extendee-type-2'
            ]
        ]
    }
};

.conventional-changelog-lintrc (user config)

{
    "extends": [
        "extendee"
    ],
    "rules"  : {
        "type-enum": [
            2,
            "always",
            [
                "user-type"
            ]
        ]
    }
}

Steps

When I run conventional-changelog-lint,

echo "invalid message" | conventional-changelog-lint

It produces the following result.

⧗   input: invalid message
✖   type must be one of ["user-type", "extendee-type-2"] [type-enum]
✖   found 1 problems, 0 warnings

Expected result

✖   type must be one of ["user-type"] [type-enum]

The user config's ["user-type"] replaces sharable configuration's ['extendee-type-1', 'extendee-type-2'].

Actual result

✖   type must be one of ["user-type", "extendee-type-2"] [type-enum]

The user config's ["user-type"] overrides a part of sharable configuration's ['extendee-type-1', 'extendee-type-2'].

Environment

Node.js 7.x.x + conventional-changelog-lint 1.1.0

bug

All 3 comments

Hey there! Thank you for contributing this issue. I am on a long travel leg and can't analyse right now - probably soonest sometime next week.

Looks like faulty config merging logic, this is definitely a bug.

Fixed by #30 and released. Feel free to reopen if problem persists!

❯ npm show conventional-changelog-lint .version
1.1.9
Was this page helpful?
0 / 5 - 0 ratings