commitlint icon indicating copy to clipboard operation
commitlint copied to clipboard

Allow gitmojis

Open rubensa opened this issue 2 years ago • 2 comments

Allow using gitmojis in the commit message description.

Looks like they are detected as part of the scope.

For example, the following commit message generated in VSCode using Conventional Commits extension:

chore: :hammer: Add commitlint as git commit-msg hook

Also add **Conventional Commits** VSCode extension

gives:

commitlint

→ input: "chore: :hammer: Add co..."

Errors:
  ❌ parser: scope must be followed by ': '

Total 1 errors, 0 warnings, 0 other severities

rubensa avatar Nov 24 '23 11:11 rubensa

This looks like the parser picks the last : instead of the first one, to separate type(scope) from the rest of the header.

gumbo2k avatar Jul 15 '24 19:07 gumbo2k

Found it! The bug is not in commitlint itself, but in conventionalcommit/parser

And it is slightly different than I thought. The parser doesn't work with regex but uses a lexer instead.

When the parser reads a header like type(scope): description and moves from type(scope) to description it uses a greedy take(": ") to read the delimiter. This take will read any number (and order) of and : into the current token. and then the parser compares the result to : . This fails when the description starts with a : as the take will have read : : already. I've fixed it in my fork and I'll open a PR.

gumbo2k avatar Jul 15 '24 23:07 gumbo2k