commitlint-rs icon indicating copy to clipboard operation
commitlint-rs copied to clipboard

`scope-format` does not support missing scopes

Open FelixZY opened this issue 10 months ago • 0 comments

Describe the bug

I want to allow commit messages that do not include a scope. However, the scope-format rule fails on such messages.

Config

rules:
  scope:
    level: ignore
    optional: true
    options: []
  scope-format:
    level: error
    format: ^.*$

Error message

$ commitlint --edit test.msg
found no scope

Expected behavior

scope-format should pass if there is no scope present, regardless of format (i.e. ^.+$ should still pass for an empty scope).

Checking for the presence of a scope should be done via the scope rule.

Examples:

# allowed if `scope` is optional (even if `scope-format` is `^.+$`)
feat: lorem ipsum dolor sit amet

# allowed
feat(scope): lorem ipsum dolor sit amet

# allowed if `scope-format` is `^.*$` (but not if `scope-format` is `^.+$`!)
feat(): lorem ipsum dolor sit amet

Version

$ commitlint -V
commitlint-rs 0.2.2

FelixZY avatar Feb 08 '25 00:02 FelixZY