Skip to content

Error message if colon is missed is highly misleading #3045

Open
@RosieBaish

Description

@RosieBaish

If you type a commit message but forget the colon after the type you get the error messages [subject-empty] and [type-empty] which are highly misleading.
It might be obvious to an expert user, but to a casual user it really wasn't.

Expected Behavior

echo "test(foo)

bar" | npx --no-install commitlint -V
⧗ input: test(foo)

bar
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
W warning - missing colon after scope [missing-colon]

✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Current Behavior

echo "test(foo)

bar" | npx --no-install commitlint -V
⧗ input: test(foo)

bar
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]

✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

An additional warning message for any commit which matches the following

  • Missing one or both of subject and type
  • First non-whitespace character of second word is not ':' or '('
  • If first non-whitespace character of second word is '(' then first non-whitespace character after matching ')' is not ':'

Steps to Reproduce (for bugs)

rvb@rosie-laptop:~/standby$ echo "test(foo)

bar" | npx --no-install commitlint -V
⧗ input: test(foo)

bar
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]

✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

$ echo "test(foo) bar

desc" | npx --no-install commitlint -V
⧗ input: test(foo) bar

desc
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]

✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

$ echo "test(foo): bar

desc" | npx --no-install commitlint -V
⧗ input: test(foo): bar
✔ found 0 problems, 0 warnings

Your Environment

npx --no-install commitlint -v
@commitlint/cli@13.1.0

$ uname -a
Linux <removed> 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

Executable Version
commitlint --version @commitlint/cli@13.1.0
git --version git version 2.25.1
node --version git version 2.25.1

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