"매 style debate 의 종결자". Code formatting 은 코드의 visual structure (whitespace, indent, line breaks, quote style) 를 deterministic rule 로 enforce 하는 tooling 영역. 2026 현재 매 모든 mainstream language 는 official 또는 de-facto formatter 를 가지며 (Black, Ruff format, Prettier, gofmt, rustfmt, dart format, ktlint), CI 의 commit hook 의 universal 으로 적용. 매 "어떻게 보일지" 의 human discussion 의 X — 매 tool 의 결정.
매 핵심
매 formatter 의 철학
Opinionated (매 ideal): 매 minimal config — Black, gofmt, Prettier. 매 bikeshedding 의 elimination.
Configurable (매 legacy): 매 ESLint stylistic rules, autopep8 — 매 team config drift 의 risk.
Idempotent: format(format(x)) == format(x). 매 essential property — CI loop safety.
AST-based: 매 token stream 의 parse → reformat. 매 regex 의 X.
매 linter vs formatter
Formatter: whitespace, line breaks, quotes (style only). 매 semantics 의 X-change.
Linter: bugs, anti-patterns, unused vars (semantics). 매 ESLint, Ruff check, golangci-lint.
2026 trend: Ruff (Python) 의 both 의 unify — ruff format + ruff check 의 매 single binary. Biome (JS/TS) 의 same path.
매 응용
Pre-commit hook: pre-commit (Python), lefthook, husky 의 매 staged file 의 format.
CI gate: ruff format --check / prettier --check — diff 가 있으면 fail.
Editor on-save: VS Code editor.formatOnSave: true + defaultFormatter.
Mass migration: git ls-files | xargs ruff format — 매 single PR 의 entire repo reformat.
# format all files in repo
npx prettier --write .
# CI check
npx prettier --check .
Ruff format (Python) — 2026 default Python formatter
# pyproject.toml[tool.ruff]line-length=100target-version="py312"[tool.ruff.format]quote-style="double"indent-style="space"docstring-code-format=true# format code in docstrings
ruff format . # write
ruff format --check . # CI
ruff check --fix . # lint + autofix
Opinionated formatter 의 즉시 채택 — 매 discussion close
기본값: Ruff (Python), Prettier 또는 Biome (web), gofmt (Go), rustfmt (Rust). 매 pre-commit + CI check.
🔗 Graph
부모: Code Quality · Developer Experience
변형: Linter · Static Analysis
응용: 153_pre-commit과_품질_게이트
Adjacent: Prettier
🤖 LLM 활용
언제: Generated code 의 file write 후 항상 ruff format / prettier --write 의 run — LLM output 의 indent inconsistency 의 normalize. PR diff 의 minimize.
언제 X: Format-only PR 의 logic change 와 mix 의 X — separate commit / PR 로 분리. Reviewer 의 noise 의 reduction.
❌ 안티패턴
Custom rules everywhere: 매 team-specific style 의 invention. 매 onboarding cost 의 increase. 매 Black/Prettier default 의 accept.
Format on commit only: Editor save 의 X-format 의 경우 매 every commit 의 noise. Editor integration 의 essential.
Format + logic 의 mixed PR: Review impossible. 매 separate PR.
No CI check: Pre-commit 의 bypass 의 가능 (-n). 매 CI 의 source of truth.
tabWidth debate: 매 EditorConfig 의 fix — once and forget.
🧪 검증 / 중복
Verified (Prettier docs 2026, Ruff docs 0.6+, Go style guide).