add knowledge
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# Linting & Formatting
|
||||
|
||||
Catch bugs and style issues automatically — before review, before CI, ideally before saving.
|
||||
|
||||
## Tools by Language
|
||||
|
||||
| Language | Recommended | Alternatives |
|
||||
|---|---|---|
|
||||
| Python | `ruff` | flake8 + isort + black |
|
||||
| JavaScript/TS | `biome` | eslint + prettier |
|
||||
| Go | `gofmt`, `golangci-lint` | staticcheck |
|
||||
| C++ | `clang-tidy`, `clang-format` | cppcheck |
|
||||
|
||||
## Python — `ruff`
|
||||
|
||||
Replaces flake8, isort, and black in one tool. Extremely fast.
|
||||
|
||||
```bash
|
||||
ruff check . # lint
|
||||
ruff check --fix . # lint + auto-fix
|
||||
ruff format . # format (replaces black)
|
||||
```
|
||||
|
||||
Configure in `pyproject.toml`:
|
||||
|
||||
```toml
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py312"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I", "UP"]
|
||||
```
|
||||
|
||||
## JavaScript — `biome`
|
||||
|
||||
Single tool for lint + format, no config needed to start.
|
||||
|
||||
```bash
|
||||
biome check . # lint + format check
|
||||
biome check --write . # auto-fix
|
||||
```
|
||||
|
||||
## Go
|
||||
|
||||
`gofmt` is part of the toolchain — just run it.
|
||||
|
||||
```bash
|
||||
gofmt -w .
|
||||
golangci-lint run # broader lint suite
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Run on save in your editor (not just in CI)
|
||||
- Auto-fix on commit via a pre-commit hook or `invoke lint --fix`
|
||||
- Format is non-negotiable; lint violations should be treated as errors in CI
|
||||
Reference in New Issue
Block a user