Nguyen Nhat Hao - Portfolio
Blog

My Blog

Commitlint Gitmoji - Commit code theo gitmoji

Mục lục

Setup Commintlint - Angular Conventional Commit has gitmoji

Install dependencies

npm i -D commitlint-config-gitmoji commitlint
# or
yarn add -D commitlint-config-gitmoji commitlint

Add commitlint config for Gitmoji (file .commitlintrc.cjs)

module.exports = { extends: ["gitmoji"] };

The Gitmoji Structure of commit styles is below

:gitmoji: type(scope?): subject
body?
footer?

You can see Gitmoji here

Type theo conventional commit

Một số type phổ biến được khuyên sử dụng bao gồm:

feat: thêm một tính năng mới.
fix: fix bug cho hệ thống, vá lỗi trong codebase.
refactor: sửa code nhưng không fix bug cũng không thêm feature hoặc đôi khi bug cũng được fix từ việc refactor.
docs: thêm/thay đổi document, file .md.
chore: những sửa đổi nhỏ nhặt không liên quan tới code. Nó không nên thay đổi bất kỳ tệp nào liên quan đến src, test, build hoặc docs.
style: những thay đổi không làm thay đổi ý nghĩa của code như thay đổi css/ui, format (lint, prettier) chẳng hạn.
perf: code cải tiến về mặt hiệu năng xử lý.
test: thêm/thay đổi file testcase, thực hiện test và pass 100%
build: thực hiện build project.
ci: thêm/thay đổi các file cấu hình ci/cd (.yml).
revert: thực hiện revert hay reset code commit với git

Các lệnh commit thông dụng

Thêm tính năng mới

echo ":sparkles: feat: new feature" | npx commitlint

Fix bug

echo ":bug: fix: fix a subject bug" | npx commitlint

Thực hiện hotfix bug

echo ":ambulance: fix: hotfix a subject bug" | npx commitlint

Thêm, thay đổi file cấu hình CI/CD

echo ":green_heart: ci: update file ci" | npx commitlint

Thực hiện sửa css/ui

echo ":hammer: refactor: refactor code" | npx commitlint

Thực hiện refactor code

echo ":recycle: refactor: refactor code" | npx commitlint

Thực hiện merge branch, pull request review

echo ":twisted_rightwards_arrows: feat: merge feat" | npx commitlint

Thực hiện thêm, thay đổi failing testcase

echo ":test_tube: test: update testcase" | npx commitlint

Thêm, thay đổi hay pass testcase

echo ":white_check_mark: test: testcase" | npx commitlint

Cập nhật file README.md, documentation

echo ":memo: docs: update README.md" | npx commitlint

Thêm/thay đổi ảnh trong folder assets (files, paths, routes, etc)

echo ":bento: chore: update file position" | npx commitlint

Thay đổi resources (files, paths, routes, etc)

echo ":truck: chore: update file position" | npx commitlint

Update file ignore (.gitignore, .dockerignore, etc)

echo ":see_no_evil: chore: update gitignore" | npx commitlint

Thực hiện thay đổi metadata (SEO)

echo ":mag: perf: update metadata" | npx commitlint

Xóa file code

echo ":fire: docs: update README.md" | npx commitlint

Cập nhật hiệu suất mã nguồn

echo ":zap: perf: update" | npx commitlint

Thay đổi file config

echo ":wrench: ci: add file config" | npx commitlint

Cập nhật package, dependency

echo ":package: chore: update version package" | npx commitlint
Copyright @nxhawk