Skip to content

Conversation

parloti
Copy link

@parloti parloti commented Aug 26, 2025

Description

This PR adds customizable emojis to the Commitlint prompt. This allows users to define richer, more informative options for commit types, which enhances the user experience and provides better context during the commit process.

Motivation and Context

The previous prompt was limited to displaying simple, text-based commit types. There was no way to add visual cues like emojis or descriptive text directly within the prompt's options, which made it less intuitive for developers. This change addresses that limitation.

TODO emoji + title
#3618
#4534

Usage examples

The documentation was updated with examples.

How Has This Been Tested?

Extensive tests were added to confirm that the enumList is formatted correctly, alignment is handled properly, and the emojiInHeader option functions as expected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@parloti
Copy link
Author

parloti commented Aug 26, 2025

Hey guys, tabs like I mentioned here don't work well.
Each terminal handles emojis differently; if you correct them for one, they break in another. So using single spaces allows the user to customize them to their needs.

I only have Windows 11 here, on other systems you may have different behaviors.

Default configuration

vs code
vs-code

git-bash
git-bash

cmd
cmd

power shell
power_shell

Adding space to force alignment in vs code

example

vs code
vs-code

git-bash
git-bash

cmd
cmd

power shell
power-shell

@parloti
Copy link
Author

parloti commented Aug 26, 2025

@ViniDevBR I think a PR with an example with gitmoji in the documentation would be welcome.

@ViniDevBR
Copy link

@ViniDevBR I think a PR with an example with gitmoji in the documentation would be welcome.

Nice. but i think that them will not accept this PR because of the space in powershell. But lets wait for this.
If not approve we can just remove the icon from CLI and just add this in the final message.

About the documentation...
I created one in other issue or PR that you was with me

import { UserConfig } from "@commitlint/types";
import gitmoji from 'commitlint-config-gitmoji'

/**
 * @type {import('@commitlint/types').UserConfig}
 */
module.exports = {
  extends: ['@commitlint/config-conventional'],
  prompt: {
    questions: {
      type: {
        description: "Select the type of change that you're committing",
        enum: {
          feat: {
            description: "A new feature",
            title: "Features",
            emoji: "✨",
          },
          fix: {
            description: "A bug fix",
            title: "Bug Fixes",
            emoji: "🐛",
          },
          docs: {
            description: "Documentation only changes",
            title: "Documentation",
            emoji: "📚",
          },
          style: {
            description:
              "Changes that do not affect the meaning of the code (linters)",
            title: "Styles",
            emoji: "🎨",
          },
          refactor: {
            description:
              "A code change that neither fixes a bug nor adds a feature",
            title: "Code Refactoring",
            emoji: "📦",
          },
          perf: {
            description: "A code change that improves performance",
            title: "Performance Improvements",
            emoji: "🚀",
          },
          test: {
            description: "Adding missing tests or correcting existing tests",
            title: "Tests",
            emoji: "🚨",
          },
          build: {
            description:
              "Changes that affect the build system or external dependencies (yarn)",
            title: "Builds",
            emoji: "🏗️ ",
          },
          ci: {
            description:
              "Changes to our CI configuration files and scripts (GitActions)",
            title: "Continuous Integrations",
            emoji: "⚙️ ",
          },
          chore: {
            description: "Other changes that don't modify src or test files",
            title: "Chores",
            emoji: "♻️ ",
          },
          revert: {
            description: "Reverts a previous commit",
            title: "Reverts",
            emoji: "⏪",
          },
        },
      },
    },
  },
  parserPreset: {
    parserOpts: gitmoji.parserPreset.parserOpts,
    plugins: [gitmoji.parserPreset.plugins],
  },
  ...gitmoji.rules,
  ...gitmoji.plugins
} as UserConfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants