Skip to content

Wrong @commitlint/types definitions for rules #4357

Open
@gperdomor

Description

@gperdomor

Steps to Reproduce

1. Install commitlint and @commitlint/config-nx-scopes
2. Create TS commitlint custom config:

import { utils } from '@commitlint/config-nx-scopes';
import type { UserConfig } from '@commitlint/types';
import { RuleConfigSeverity } from '@commitlint/types';

const Configuration: UserConfig = {
  extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes'],
  //   parserPreset: "conventional-changelog-atom",
  //   formatter: "@commitlint/format",
  rules: {
    'scope-enum': async (ctx) => [
      RuleConfigSeverity.Error,
      'always',
      ['repo', 'deps', 'release', ...(await utils.getProjects(ctx))],
    ],
  },
};

export default Configuration;

Current Behavior

TS fails because Rule definition not accept functions with arguments...

Expected Behavior

Types should accept function with arguments to pass the context...

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Update QualifiedRuleConfig type to include ctx parameter

Context

No response

commitlint --version

19.8.0

git --version

2.49.0

node --version

22.14.0

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