Skip to content

"scope" and "type" rules fail when those fields are empty #256

@cengels

Description

@cengels

Describe the bug

  1. I defined a custom configuration file (see below) that ignores an empty type, but fails when a type other than "chore" is supplied.
  2. I ran commitlint --from HEAD~1 --to HEAD~1 on a commit that only had a description, no type or scope.
  3. Validation failed with the message: type is not allowed. Only ["cli"] are allowed

The same also happens with the scope and scope-empty rules.

Curiously, the same also still happens if you explicitly set options: [""] to say that the only valid types/scopes are an empty string.

Config

rules:
  type:
    level: error
    options: ["chore"]
  type-empty:
    level: ignore

Error message

N/A

Expected behavior

The type-empty and scope-empty rules already validate an empty type or scope, so the type and scope rules shouldn't do this again. From what I can see, this problem currently makes it impossible to define the ruleset that supplying a type/scope should generally be optional, but that if it is supplied, only certain types/scopes are accepted.

Version

# Run the following command
$ commitlint --version
commitlint-rs 0.1.6

Additional context

As an additional wish, I would like for it to be valid to define options in the type/scope rules as an empty array. That way it would be possible to, for instance, set up a repository in which supplying a scope is never allowed (only a type + description, for instance).

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions