Package Exports
- commitlint-config-emoji-convention
- commitlint-config-emoji-convention/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (commitlint-config-emoji-convention) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
commitlint-config-emoji-convention
Shareable commitlint configuration that enforces conventional commits and adds emoji support. Use with commitlint.
Getting Started
npm install --save-dev @commitlint/cli commitlint-config-emoji-convention
echo "export default { extends: ['emoji-convention'] }" > commitlint.config.js
The official commitlint documentation recommends using Husky to validate commit messages.
npm install --save-dev husky
npx husky init
To automatically validate and format commit messages based on the prefix, follow these steps:
touch .husky/commit-msg
Add the following script:
msg=$(cat "$1")
# Remove Git comments (lines starting with #)
msg=$(echo "$msg" | grep -v "^#")
# Process emoji replacement
msg=$(echo "$msg" | sed -e "s/^init/🎉 init/")
msg=$(echo "$msg" | sed -e "s/^feat/✨ feat/")
msg=$(echo "$msg" | sed -e "s/^fix/🐛 fix/")
msg=$(echo "$msg" | sed -e "s/^docs/📚 docs/")
msg=$(echo "$msg" | sed -e "s/^style/💎 style/")
msg=$(echo "$msg" | sed -e "s/^refactor/📦 refactor/")
msg=$(echo "$msg" | sed -e "s/^perf/🚀 perf/")
msg=$(echo "$msg" | sed -e "s/^test/🚨 test/")
msg=$(echo "$msg" | sed -e "s/^build/🛠 build/")
msg=$(echo "$msg" | sed -e "s/^ci/⚙️ ci/")
msg=$(echo "$msg" | sed -e "s/^chore/♻️ chore/")
msg=$(echo "$msg" | sed -e "s/^revert/🗑 revert/")
echo "$msg" > "$1"
npx commitlint --edit $1
Format
<emoji> <type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Examples
✨ feat(blog): add comment section
🐛 fix: resolve null pointer exception
📚 docs(README): add contribution guidelines
- Add code of conduct
- Update PR template
Issue: #123
If the emoji is not inserted into the message, it is automatically added after the action. Example:
feat(UI): add modal component
In the end, the message will be formatted as:
✨ feat(UI): add modal component
Rules
Commit message rules follow the Conventional Commits specification.
Supported commit types:
- 🎉 init: Project initialization
- ✨ feat: A new feature
- 🐛 fix: A bug fix
- 📚 docs: Documentation only changes
- 💎 style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- 📦 refactor: A code change that neither fixes a bug nor adds a feature
- 🚀 perf: A code change that improves performance
- 🚨 test: Adding missing tests or correcting existing tests
- 🛠 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: Travis, Circle, BrowserStack, SauceLabs)
- ♻️ chore: Other changes that don't modify src or test files
- 🗑 revert: Reverts a previous commit
Credits
- The initial inspiration for this project was commitlint-config-git-commit-emoji, including the
parserPreset
configuration and README structure - Emoji list and rules sourced from @commitlint/config-conventional
- The
commit-msg
hook script was adapted from Hubert Olender's gist
License
MIT © João Vitor