conventional-commits / parser

reference implementation of conventionalcommits.org spec
ISC License
43 stars 7 forks source link

Simplify parsing by preventing `!` in Tyoe? #40

Open epage opened 2 years ago

epage commented 2 years ago

Currently, the grammar only prevents the sequence !:. So someone could have a type like He!!o.

::= +

Personally, I would find this confusing to see but it also would greatly simplify this grammar rule to only be looking at characters rather than sequence of characters.

WillGibson commented 4 months ago

Using ! in the type to indicate a breaking change is part of the Conventional Commit standard...

https://www.conventionalcommits.org/en/v1.0.0/?ref=blog.formacao.dev#commit-message-with--to-draw-attention-to-breaking-change

Why would we want to prevent it?

epage commented 4 months ago

My suggestion is to make this change

- ::= <any UTF8-octets except newline or parens or ":" or "!:" or whitespace>+
+ ::= <any UTF8-octets except newline or parens or ":" or "!" or whitespace>+

The idea being that a message like:

He!!o: some message

is both odd (harder to parse by computer and human) and inconsistent in what it allows as you can't then do

He!!: some message

without there being a semantic change

WillGibson commented 4 months ago

As I understand it, indicating a breaking change is meant to be a single ! after the type, e.g. feat!: some commit message.

I ended up here by mistake though, the package I am needing to fiddle with is actually https://www.npmjs.com/package/conventional-commits-parser.