Skip to content

fix: ! gives errors when using parserPreset in config #4100

@Joxtacy

Description

@Joxtacy

Steps to Reproduce

I have prepared a branch in my repo [here (branch commitlint-error-testing)](https://github.com/Joxtacy/automatic-release-notes-testing/tree/commitlint-error-testing) which has the broken config.

1. Have a config file with `parserPreset` config.

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

const Configuration: UserConfig = {

  extends: ['@commitlint/config-conventional'],
  parserPreset: 'conventional-changelog-atom',
  formatter: '@commitlint/format',
  rules: {
    'type-enum': [RuleConfigSeverity.Error, 'always', ['foo']], 
  },
  // ...
};

export default Configuration;

2. Create a commit with a commit message similar to `feat!: subject`

Current Behavior

When the linter runs with a commit message containing ! the linter spits out the following error

❯ git commit -m 'feat!: subject'
╭──────────────────────────────────────╮
│ 🥊 lefthook v1.7.2  hook: commit-msg │
╰──────────────────────────────────────╯
┃  lint commit message ❯

⧗   input: feat!: subject
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]
⚠   scope may not be empty [scope-empty]

✖   found 2 problems, 1 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
  ────────────────────────────────────
summary: (done in 0.70 seconds)
🥊  lint commit message

Expected Behavior

I expect the linter to pass with a message containing !, like feat!: subject.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Haven't looked into the codebase, so can't give a possible solution to this right now.

Context

I'm just trying to run the linter on a commit hook, and to have the ! be correctly parsed. 🙃

commitlint --version

@commitlint/cli@19.3.0

git --version

v2.45.2

node --version

v20.15.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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy