commitlint icon indicating copy to clipboard operation
commitlint copied to clipboard

`negated` rule API

Open abitrolly opened this issue 1 year ago • 3 comments

I am trying add the new rule to fix https://github.com/conventional-changelog/commitlint/issues/3810 and I find the lines around negated puzzling. For example, https://github.com/conventional-changelog/commitlint/blob/3ee4c2884ffd0783e605e0ab57c37523a3709b3c/%40commitlint/rules/src/body-case.ts#L5

Why each rule has to calculate this negated property? Why it can not just receive the negated as a bool param? Where this negated is realistically used?

abitrolly avatar Jan 04 '24 00:01 abitrolly

Sorry, can't really answer this question

escapedcat avatar Jan 04 '24 09:01 escapedcat

If you can't answer, then I have no chance to understand it too. :D

abitrolly avatar Jan 04 '24 10:01 abitrolly

IMO, if the when param always has values 'always' or 'never' in commitlint's codebase, then, yes, we should refactor to make it a bool. Maybe we should check git-blame to see who coded this in the first place and ask her/him why did he choose a string? Maybe she/he was envisioning more things besides 'always', 'never', ...? (I wonder how a 'sometimes' could work.)

knocte avatar Feb 13 '24 04:02 knocte