ok... today we'll go install commitlint

juanestban

Juan Esteban Perdomo

Posted on March 15, 2023

ok... today we'll go install commitlint

nice... already we can start this section correctly and fixing somes fails or bugs that I found with the previous post

we'll install the commitlint package like dev dependecy

npm install commitlint -D
Enter fullscreen mode Exit fullscreen mode

after that create file config called commitlint.config.js and export some config, if you don't know any of this library, this is the documentation, try to read, isn't to hard understand

the file commitlint.config.js will have the next config:

module.exports = {
  rules: {
    'header-max-length': () => Promise.resolve([0, 'always', 120]),
    'body-max-length': () => Promise.resolve([0, 'always', 120]),
  },
};
Enter fullscreen mode Exit fullscreen mode

then if you make a commit you will have follow the rules:

  • max body 120 characters
  • header max: 120

one more thing for finish this...

you need add the next script for create into folder .husky file bash called commit-msg for execute after the pre-commit

npx husky add .husky/commit-msg "npx --no -- commitlint --edit $1"
# OR
yarn husky add .husky/commit-msg "yarn commitlint --edit $1"
Enter fullscreen mode Exit fullscreen mode

result file .husky/commit-msg

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit $1
Enter fullscreen mode Exit fullscreen mode

try look the file into .husky/commit-msg and be sure that the final argument "$1" because in sometimes this part not be added

okay... now just try to do the next commit:

git add . && git commit -m "chore(commitlint): install and config done"
Enter fullscreen mode Exit fullscreen mode

if you don't follow some of this rules, you'll can't do the commit


previous post, implement linter to project
next theme for the next post: thinking about that >.<

github profile

github repo: I'm still working on that >.< srry

💖 💪 🙅 🚩
juanestban
Juan Esteban Perdomo

Posted on March 15, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ok... today we'll go install commitlint
reactnative ok... today we'll go install commitlint

March 15, 2023