style: Code Formatting Changes
Learn when to use the style commit type for formatting-only changes. Covers white space, semicolons, quotes, and the difference between style and refactor.
Detailed Explanation
The style Commit Type
The style type is used for changes that do not affect the meaning or behavior of the code. This includes formatting, white space, semicolons, quotes, trailing commas, and other cosmetic changes. Under Semantic Versioning, style commits do not trigger any version bump.
Example Messages
style: apply prettier formatting to all files
style(components): convert double quotes to single quotes
style: fix indentation in config files
When to Use style
Use style when your commit:
- Applies auto-formatting (Prettier, ESLint --fix, Black, etc.)
- Changes indentation (tabs to spaces or vice versa)
- Changes quote style (single to double or vice versa)
- Adds or removes trailing commas
- Fixes whitespace issues (trailing spaces, blank lines)
- Reorders imports without changing which imports are used
When NOT to Use style
| Change | Use instead |
|---|---|
| Renaming a variable | refactor |
| Adding comments that explain logic | docs |
| Removing unused code | refactor |
| Fixing a linting error that changes behavior | fix |
style vs refactor
The key distinction:
style: Only whitespace, formatting, and cosmetic changes. A diff tool would show changes, but an AST comparison would show identical trees.refactor: The code structure changes (different AST), but behavior stays the same.
Best Practices
- Separate formatting commits from logic changes. This makes code reviews easier.
- Use automated formatters and commit their output as a single
stylecommit. - Mention the tool used in the description:
style: apply prettier v3.2 formatting - Batch formatting changes into a single commit rather than formatting file by file.
Use Case
You have just added Prettier to your project and run it across the entire codebase. The formatting changes are purely cosmetic and do not alter any logic. You need a commit message that makes it clear this is a style-only change so reviewers can skip detailed code review and focus on verifying that no behavior changed.