/commitlint-config-gitmoji

Shareable commitlint config enforcing the gitmoji commit convention

Primary LanguageJavaScriptMIT LicenseMIT

@ballcat/commit-config-gitmoji

English | δΈ­ζ–‡

Shareable commitlint config enforcing gitmoji.
Use with @commitlint/cli and @commitlint/prompt-cli.

Getting started

install commitlint and commit-config-gitmoji

# For Windows:
npm install --save-dev @ballcat/commitlint-config-gitmoji @commitlint/cli

# Configure commitlint to use conventional config
echo "module.exports = {extends: ['./node_modules/@ballcat/commitlint-config-gitmoji']}" > commitlint.config.js

To lint commits before they are created you can use Husky's commit-msg hook:

install husky v8

npx husky-init && npm install       # npm
npx husky-init && yarn              # Yarn 1
yarn dlx husky-init --yarn2 && yarn # Yarn 2+
pnpm dlx husky-init && pnpm install # pnpm

add hook

npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'

Commit Message Format

<type> [scope] <subject>

[body]

[footer]
  • type(required): An emoji from the list.
  • scope(optional): A string wrapped in parentheses that adds contextual information for the scope of the change.
  • subject(required): A brief explanation of the change.
  • body(required): Detailed description of the change.
  • footer(required): Links and operation issues or PR, eg.Closes #392

Rules

Problems

The following rules are considered problems for @ballcat/commit-config-gitmoji and will yield a non-zero exit code when not met.

Consult docs/rules for a list of available rules.

type-enum

  • condition: type is found in value
  • rule: always
  • level: error
  • value: emoji code list, see gitmoji list
echo ":no: some message" # fails
echo ":bug: some message" # passes

type-case

  • description: type is in case value
  • rule: always
  • level: error
  • value
    'lowerCase'
    
echo ":BUG: some message" # fails
echo ":bug: some message" # passes

type-empty

  • condition: type is empty
  • rule: never
  • level: error
echo "some message" # fails
echo ":bug: some message" # passes

subject-case

  • condition: subject is in one of the cases ['sentence-case', 'start-case', 'pascal-case', 'upper-case']
  • rule: always
  • level: error
echo ":bug: Some message" # fails
echo ":bug: Some Message" # fails
echo ":bug: SomeMessage" # fails
echo ":bug: SOMEMESSAGE" # fails
echo ":bug: some message" # passes
echo ":bug: some Message" # passes

subject-empty

  • condition: subject is empty
  • rule: never
  • level: error
echo ":bug:" # fails
echo ":bug: some message" # passes

subject-full-stop

  • condition: subject ends with value
  • rule: never
  • level: error
  • value
'.'
echo ":bug: some message." # fails
echo ":bug: some message" # passes

header-max-length

  • condition: header has value or less characters
  • rule: always
  • level: error
  • value
72
echo ":bug: some message that is way too long and breaks the line max-length by several characters" # fails
echo ":bug: some message" # passes

footer-leading-blank

  • condition: footer should have a leading blank line
  • rule: always
  • level: error
echo ":bug: some message
BREAKING CHANGE: It will be significant" # error

echo ":bug: some message

BREAKING CHANGE: It will be significant" # passes

body-leading-blank

  • condition: body should have a leading blank line
  • rule: always
  • level: error
echo ":bug: some message
body" # error

echo ":bug: some message

body" # passes

Gitmoji List

see gitmojis.json or gitmoji.dev

Emoji Emoji code Description
🎨 :art: Improve structure / format of the code.
⚑️ :zap: Improve performance.
πŸ”₯ :fire: Remove code or files.
πŸ› :bug: Fix a bug.
πŸš‘ :ambulance: Critical hotfix.
✨ :sparkles: Introduce new features.
πŸ“ :memo: Add or update documentation.
πŸš€ :rocket: Deploy stuff.
πŸ’„ :lipstick: Add or update the UI and style files.
πŸŽ‰ :tada: Begin a project.
βœ… :white_check_mark: Add, update, or pass tests.
πŸ”’ :lock: Fix security issues.
πŸ” :closed_lock_with_key: Add or update secrets.
πŸ”– :bookmark: Release / Version tags.
🚨 :rotating_light: Fix compiler / linter warnings.
🚧 :construction: Work in progress.
πŸ’š :green_heart: Fix CI Build.
⬇️ :arrow_down: Downgrade dependencies.
⬆️ :arrow_up: Upgrade dependencies.
πŸ“Œ :pushpin: Pin dependencies to specific versions.
πŸ‘· :construction_worker: Add or update CI build system.
πŸ“ˆ :chart_with_upwards_trend: Add or update analytics or track code.
♻️ :recycle: Refactor code.
βž• :heavy_plus_sign: Add a dependency.
βž– :heavy_minus_sign: Remove a dependency.
πŸ”§ :wrench: Add or update configuration files.
πŸ”¨ :hammer: Add or update development scripts.
🌐 :globe_with_meridians: Internationalization and localization.
✏️ :pencil2: Fix typos.
πŸ’© :poop: Write bad code that needs to be improved.
βͺ️ :rewind: Revert changes.
πŸ”€ :twisted_rightwards_arrows: Merge branches.
πŸ“¦οΈ :package: Add or update compiled files or packages.
πŸ‘½οΈ :alien: Update code due to external API changes.
🚚 :truck: Move or rename resources (e.g.: files, paths, routes).
πŸ“„ :page_facing_up: Add or update license.
πŸ’₯ :boom: Introduce breaking changes.
🍱 :bento: Add or update assets.
♿️ :wheelchair: Improve accessibility.
πŸ’‘ :bulb: Add or update comments in source code.
🍻 :beers: Write code drunkenly.
πŸ’¬ :speech_balloon: Add or update text and literals.
πŸ—ƒοΈ :card_file_box: Perform database related changes.
πŸ”Š :loud_sound: Add or update logs.
πŸ”‡ :mute: Remove logs.
πŸ‘₯ :busts_in_silhouette: Add or update contributor(s).
🚸 :children_crossing: Improve user experience / usability.
πŸ—οΈ :building_construction: Make architectural changes.
πŸ“± :iphone: Work on responsive design.
🀑 :clown_face: Mock things.
πŸ₯š :egg: Add or update an easter egg.
πŸ™ˆ :see_no_evil: Add or update a .gitignore file.
πŸ“Έ :camera_flash: Add or update snapshots.
βš—οΈ :alembic: Perform experiments.
πŸ”οΈ :mag: Improve SEO.
🏷️ :label: Add or update types.
🌱 :seedling: Add or update seed files.
🚩 :triangular_flag_on_post: Add, update, or remove feature flags.
πŸ₯… :goal_net: Catch errors.
πŸ’« :dizzy: Add or update animations and transitions.
πŸ—‘οΈ :wastebasket: Deprecate code that needs to be cleaned up.
πŸ›‚ :passport_control: Work on code related to authorization, roles and permissions.
🩹 :adhesive_bandage: Simple fix for a non-critical issue.
🧐 :monocle_face: Data exploration/inspection.
⚰️ :coffin: Remove dead code.
πŸ§ͺ :test_tube: Add a failing test.
πŸ‘” :necktie: Add or update business logic
🩺 :stethoscope: Add or update healthcheck.
🧱 :bricks: Infrastructure related changes.
πŸ§‘β€πŸ’» :technologist: Improve developer experience
πŸ’Έ :money_with_wings: Add sponsorships or money related infrastructure.
🧡 :thread: Add or update code related to multithreading or concurrency.