Skip to content

Sentence-case is not work properly #3517

Open
@tugaydmrl

Description

@tugaydmrl

Expected Behavior

module.exports = {
  extends: ["@commitlint/config-conventional"],
  rules: {
    "subject-case": [2, "always", "sentence-case"],
    "type-enum": [
      2,
      "always",
      ["ADD", "FEAT", "FIX", "REFACTOR", "REMOVE", "TEST", "UPDATE"],
    ],
    "type-case": [2, "always", "upper-case"],
  },
};

I have commitlint.config.js like this. According the rules, my subject sentence should start with capitalized word, other words should be all lowercase.

Current Behavior

But when i try to commit with message like "FEAT: Test Commit", it accepts. It should throw an error because this sentence is not compable with sentence-case.

Affected packages

  • cli
    core
    prompt
    config-angular

Steps to Reproduce

1. First step
Add this rule to your configuration: "subject-case": [2, "always", "sentence-case"]
2. Second step
Make a commit that doesn't follow the rule.

commitlint --version

@commitlint/{cli,config-conventional}^17.4.2,

git --version

v2.30

node --version

v16.5.1

Activity

escapedcat

escapedcat commented on Feb 1, 2023

@escapedcat
Member

Isn't sentence case for the subject correct in this way? Subject is "Test Commit" and that's sentence case?
https://commitlint.js.org/#/reference-rules?id=subject-case

tugaydmrl

tugaydmrl commented on Feb 1, 2023

@tugaydmrl
Author

Actually, my expectation from the sentence-case was that it only starts the first word of the sentence with a capital letter and forces all the letters of the remaining words to be lowercase. I think we understood the sentence-case differently.

In my opinion, "Test Commit" should wrong and "Test commit" is true form of the sentence-case. I have seen similar situations in my research on the internet.

If sentence-case works fine, what value should I use to make it do what I want?

Thanks for your interest

escapedcat

escapedcat commented on Feb 1, 2023

@escapedcat
Member

Got it! Thanks

In my opinion, "Test Commit" should wrong and "Test commit" is true form of the sentence-case. I have seen similar situations in my research on the internet.

I guess you got a point there 👍
Also the docs say "// Sentence case".
Unfortunately we do not have test for this case, but we do for the others...

Switching the label back to "bug"

knocte

knocte commented on Feb 3, 2023

@knocte
Contributor

In my opinion, "Test Commit" should wrong and "Test commit" is true form of the sentence-case

Wouldn't that ban the use of names in the commit title? Like, let's say, King Kong, or whatever. I wouldn't find this interpretation of sentence-case to be very useful, there would be false negatives all the time.

escapedcat

escapedcat commented on Feb 3, 2023

@escapedcat
Member

True, good point. Looking at the current implementation it looks like it does what it's supposed to do. Maybe the docs should be more clear about this.
Wondering why there's no test for it.

I'm tempted to close this, what do you think @tugaydmrl . It will be hard to get this right. If the expectation is "correct English sentence" I doubt it's possible currently.

tugaydmrl

tugaydmrl commented on Feb 4, 2023

@tugaydmrl
Author

I agree with you. Forcing only the first letter of the first word to be capitalized and the others to be lowercase also seems not appropriate for the sentence-case. For example, if New York is included in the sentence, this will also cause a problem. The approach to only capitalize the first letter of the first word is the best approach we have. We can close issue 👍 .

Thanks for your feedbacks guys.

knocte

knocte commented on Feb 5, 2023

@knocte
Contributor

So, is sentence-case Supposed To Be Like This? If so, I would rather rename it to title-case, to avoid further confusions.

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @knocte@escapedcat@tugaydmrl

        Issue actions

          Sentence-case is not work properly · Issue #3517 · conventional-changelog/commitlint