DEV Community

Martin Krause
Martin Krause

Posted on β€’ Edited on

5 1

How to use commitlint with yorkie & vue-cli@3.x

TLDR: "commit-msg": "commitlint -e -V" instead of "commitlint -E HUSKY_GIT_PARAMS"

During the last year, I became extremely fond of [commitlint](https://commitlint.js.org) and the related ecosystem. The ability to enforce a specific commit message format is the cornerstone of my automated releases. Yes, in a perfect world, there would be no need for linters etc. But mistakes happen, especially during crunchtime. A modern front-end development workflow should automate as much chores as possible to relieve the developer form those micro-tasks.

When you followed the commitlint guide, your package.json implements the git-hook with this lines:

"husky": {
  "hooks": {
    "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
  }
}
Enter fullscreen mode Exit fullscreen mode

Let's break it down. As soon as a you create a new commit message, the commit-msg git-hook calls the commitlint executable. The -E flag takes husky's own environment variable HUSKY_GIT_PARAMS and passes it to the executable. HUSKY_GIT_PARAMS contains the commit message you just created.

A few weeks ago, I used vue-cli for a small PWA. While browsing through the setup guide, I stumbled across this line:

@vue/cli-service also installs yorkie, (....) yorkie is a fork of husky and is not compatible with the latter.

I wanted to keep my workflow, so I needed to find a way to pass the latest git commit message to the commitlint executable without the proprietary HUSKY_GIT_PARAMS.

Luckily, commitlint cli has another flag, which is exactly what I needed:

--edit, -e read last commit message from the specified file or fallbacks to ./.git/COMMIT_EDITMSG

So, to use yorkie with commitlint, I replaced the "husky"-property with the following "gitHooks"-property at the package.json:

"gitHooks": {
  "commit-msg": "commitlint -e -V ",
}
Enter fullscreen mode Exit fullscreen mode

Follow me on Twitter: @martinkr and consider to buy me a coffee

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo πŸ“Šβœ¨

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series πŸ“Ί

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series

πŸ‘‹ Kindness is contagious

If this article connected with you, consider tapping ❀️ or leaving a brief comment to share your thoughts!

Okay