Skip to content

CaseRuleConfig<V> does not support array/tuple values #2631

Closed
@ImADrafter

Description

@ImADrafter

When moving config files to typescript in order to take advantage of types, previous valid values does not match signature.

Reviewing types, there is a condition in wich UserConfig cannot use arrays for casing values. Is this correct ?

Expected Behavior

If Im not wrong, array values for casing rules should be allowed.

Current Behavior

import type { UserConfig } from '@commitlint/types';

const config: UserConfig = {
    extends: ['@commitlint/config-conventional'],
    rules: {
        'scope-case': [
            2,
            'always',
            ['lower-case', 'camel-case', 'pascal-case'], // ! Type 'string[]' is not assignable to type '"lowerCase"'.ts(2322)
        ],
    },
};

Affected packages

  • cli
  • core
  • types

Possible Solution

Types are complex, but signature for rule values should be something like 'lower-case' | 'camel-case' | ('lower-case' | 'camel-case')[]

Context

Your Environment

Executable Version
commitlint --version 12.1.4
git --version 2.27.0
node --version 14.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions