Skip to content

sentence-case should not ensure that other letters are lowercase #211

@joaogranado

Description

@joaogranado

The sentence-case does not allow to other words than the first one to be capitalized, since in ensure-case it checks if other letters are in lower-case format. This is not correct, since sentence-case only requires the first word to be capitalised as well proper nouns and other words. For variable names, classes, etc it makes sense to include mixed case characters, while requiring the first letter to be capitalised.

Expected Behavior

The following should be valid:

Update Foo.sayBar method

Current Behavior

With the example above it throws a validation error:

input: Update Foo.sayBar method
subject must not be sentence-case [subject-case]
found 1 problems, 0 warnings

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

I can make a PR, but I'll leave this open to discussion. I think that according to the grammar rule the only validation should be about checking if the first letter is capitalised:

// ...
case 'sentencecase':
  return ensureCase(raw.charAt(0), 'upper-case');
// ...

Steps to Reproduce (for bugs)

  1. Add the rule: 'subject-case': [2, 'always', 'sentence-case']
  2. Create a commit message with the subject: Add Foo
Executable Version
commitlint --version 5.1.1
git --version 2.14.3
node --version 8.9.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions