← BLOG

@commitlint/config-conventional と @commitlint/config-angular を比べてみた

2020-08-04


くっそマニアックな話で申し訳ないのですが、気になっていたので調べてみます。


前提

そもそも commitlint とは

npm パッケージのことです。

これを導入すると conventional commit format という仕様に合わせて commit を行うことが強制されます。

複数人でバージョン管理ツールを使用して開発を行うのなら、コミットメッセージにルールが欲しくなるのは当然の流れだよなーと。

commitlint に設定を追加することで、初めてルールが適用される?というイメージです。

@commitlint/config-conventional とは

commitlint の公式が推している設定っぽいです。

ちなみに、元となっている仕様は @commitlint/config-angular と同様に、Angular のコミットメッセージのルールです。

自分は普段この設定しか使いません。

@commitlint/config-angular とは

たまに耳にする設定です。

おそらく Angular 公式のリポジトリにおけるコミットメッセージのルールを commilint に落とし込んだ設定だと思われます。

ただ、Angular の公式リポジトリに commitlint は導入されていないっぽいです。

本題

Conventional Commits によると、以下の要素で成り立っているみたいです。

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

type-enum

config-conventionalconfig-angular意味
build✓✓Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ci✓✓Changes to our CI configuration files and scripts (example scopes: Circle, BrowserStack, SauceLabs)
chore✓-maintain
docs✓✓Documentation only changes
feat✓✓A new feature
fix✓✓A bug fix
perf✓✓A code change that improves performance
refactor✓✓A code change that neither fixes a bug nor adds a feature
revert✓✓the commit reverts a previous commit
style✓✓Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
test✓✓Adding missing tests or correcting existing tests

type-enum 以外

config-conventionalconfig-angular備考
type-case✓✓
type-empty✓✓
scope-case✓✓
subject-case✓✓
subject-empty✓✓
subject-full-stop✓✓
header-max-length✓✓
footer-leading-blank✓warning
footer-max-line-length✓
body-leading-blank✓✓warning
body-max-line-length✓

こうやって見比べてみると @commitlint/config-conventional が @commitlint/config-angular の改良版というのがわかりますね。

これからも @commitlint/config-conventional を使っていけば良さそうです。

日本の現場では異常なほどコミットが軽視されていますが、コミットをルールのもとに行うことを意識すれば、いざというときに助けてくれるんじゃないかなーと思います。

← BLOG