question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add commitlint for commit message linting

See original GitHub issue

The version of ESLint you are using. 7.0.0-alpha.3

The problem you want to solve. Easing the commit message formatting. Currently after committing and pushing it, In PR/push the commit messages gets checked and if there is an error it fails the CI.

Your take on the correct solution to problem. Eslint does have githooks setup for linting the stage files. We can use commitlint in order to lint the commit message in commit-msg git hook. commitlint does provides rules configuration in order to write rules as per our needs and lint on that basis.

Packages needs to add (all devDep)

  • @commitlint/cli
  • husky
  • @commitlint/config-conventional (optional if want to extend the base rules)`

Rules which I think will satisfy eslint’s format

  "commitlint": {
        "rules": {
            "header-max-length": [
                2,
                "always",
                72
            ],
            "scope-empty": [
                2,
                "always"
            ],
            "type-enum": [
                2,
                "always",
                [
                    "Fix",
                    "Update",
                    "New",
                    "Breaking",
                    "Docs",
                    "Build",
                    "Upgrade",
                    "Chore",
                    "Sponsors"
                ]
            ],
            "type-case": [
                2,
                "always",
                "start-case"
            ],
            "type-empty": [
                2,
                "never"
            ],
            "body-leading-blank": [
                1,
                "always"
            ]
        }
    },

Screen Shot for wrong commit message

image

Screenshot of correct commit message

image

Are you willing to submit a pull request to implement this change?

Yes

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Apr 3, 2020

I’m not a fan of front-loading anything but the most important things into the precommit check. It’s already a bit slow and I’m not sure this is important enough to take another hit.

That said, I don’t feel strongly and am happy to go along with consensus if the team wants to move forward.

1reaction
anikethsahacommented, Mar 30, 2020

I think it only lints the latest one of current branch. I will have to confirm that though

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Write Good Commit Messages with Commitlint
Commitlint is a simple tool that lints your commit messages and makes sure they follow a set of rules. It runs as a...
Read more >
How to Lint Commit Messages with Husky and CommitLint
CommitLint is a commit linting tool that will force us to write beautiful commits. How does it do this? CommitLint works with something...
Read more >
conventional-changelog/commitlint: Lint commit messages
lint - Lint a string against commitlint rules; load - Load shared commitlint configuration; read - Read commit messages from a specified range...
Read more >
commitlint - Lint commit messages
commitlint helps your team adhere to a commit convention. By supporting npm-installed configurations it makes sharing of commit conventions easy.
Read more >
How to lint Git commit messages - Husky - remarkablemark
This post goes over how to lint Git commit messages with commitlint and husky (see demo repository). husky; husky 4 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found