Skip to content

Commit Message Conventions & Linting · Formatters ​

This page collects ways to standardize and automate two things with rules: commit messages and code style.

Conventional Commit: Rules for Commit Messages ​

Commit messages are a key clue for quickly understanding what changed in the code. They also help a lot when you need to trace the cause of a problem later. Conventional Commit is a set of rules created to do this systematically.

The format looks like this:

<type>(<scope>): <subject>
  • type: the kind of commit
  • scope: the area affected
  • subject: a short description (starting with an imperative verb)

For example, if you added email verification to the login screen:

feat(UserProfile): Add email verification

Common types ​

typeMeaning
featAdd a new feature
fixFix a bug
docsChange documentation
styleCode formatting (no logic change)
refactorImprove code structure without changing behavior
testAdd/modify test code
choreMinor tasks such as build or configuration

Why bother following rules this strictly? ​

When commits pile up in a consistent format, you can later pick out only the feat commits and automatically generate release notes. Nobody has to compile the change history by hand.

Automating Style with Linting and Formatters ​

Developers hate repetitive work. Having people memorize code style rules and fix them by hand every time is inefficient. That is why Linting and Formatters came along.

  • Linting: automatically checks whether code style, syntax and potential errors break the rules
  • Formatter: a tool that automatically fixes code to match the linting rules

Linting unifies the whole team's coding style to improve readability, and lets reviewers focus on logic instead of style. If you keep the config files in the project root and share them through Git, you don't need to explain the rules verbally when a new teammate joins.

JavaScript: ESLint + Prettier ​

Before:

js
const name="John",age=25;function greet(name,age){console.log('Hello, '+name)}

After:

js
const name = 'John',
  age = 25;
function greet(name, age) {
  console.log('Hello, ' + name);
}

.eslintrc sets the lint rules and .prettierrc sets the formatting rules. However, the two can conflict, so you need a plugin such as eslint-config-prettier to turn off the conflicting rules.

Python: Flake8 + Black + isort ​

Python is a dynamically typed language used in many different fields (servers, data, ML and more), so there are several linting tools.

  • Flake8: PEP 8-based style checks + complexity/logic error checks (.flake8 config)
  • Black: a formatter that automatically arranges code according to PEP 8 (pyproject.toml config)
  • isort: automatically sorts import statements in the order standard library / third-party / project-internal (.isort.cfg config)
pip3 install flake8 black isort
flake8 src/
black src/
isort src/

Summary ​

ConceptOne-line summary
Conventional CommitStandardizes commit messages in the <type>(<scope>): <subject> format, enabling automatic documentation
Linting / FormatterAutomatically checks code style (Linting) and automatically corrects it (Formatter)

Source: Codyssey-B1/B2-2