After a few months of reviewing pull requests written with AI help, we noticed the same comments over and over. "This promise is not awaited." "This except Exception: pass hides the real error." "unwrap() in a request handler will crash the worker." "This datetime has no time zone." None of these are exotic. They are exactly the mistakes linters were built for, and we were catching them by hand because our lint configs were the defaults from two years earlier.
This post is the configuration we settled on for TypeScript, Python, Go and Rust, organised around the mistakes we actually saw, plus the policy questions that matter as much as the rules: what to autofix, what to fail on, and how to keep the rules from drifting.
The mistakes worth targeting
From our review history, the recurring patterns in AI-assisted code were:
Pattern | Languages | Consequence |
|---|---|---|
Unawaited or unhandled async calls | TS, Python | Errors vanish, ordering bugs |
Swallowed exceptions or ignored errors | All | Failures look like success |
Panicking shortcuts ( | Rust, TS | Crashes or type holes in production paths |
Naive datetimes and local time | Python, TS | Off-by-hours bugs |
Deprecated or old-style APIs | All | Works today, breaks on upgrade |
Unused imports and variables | All | Noise that hides real changes |
Non-exhaustive handling of enums | TS, Go, Rust | New values silently fall through |
String-built SQL or shell commands | All | Injection |
The model writes code that looks like the average of its training data, and these patterns are common in that average. Linters are well suited to catching them because they are mechanical.
TypeScript: ESLint 9 with type-aware rules
The most valuable rules need type information, so we enable the type-checked presets from typescript-eslint in a flat config:
// eslint.config.js
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import { defineConfig } from "eslint/config";
export default defineConfig(
{ ignores: ["dist/**", "coverage/**", "**/*.gen.ts"] },
js.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
},
linterOptions: { reportUnusedDisableDirectives: "error" },
rules: {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/only-throw-error": "error",
"@typescript-eslint/no-deprecated": "warn",
"eqeqeq": ["error", "always"],
"no-console": ["error", { allow: ["warn", "error"] }],
},
},
);
no-floating-promises alone caught more real bugs in AI-written code than any other rule we enabled. switch-exhaustiveness-check catches the case where a union type gains a member and a switch silently ignores it. reportUnusedDisableDirectives keeps old eslint-disable comments from piling up after the code they excused is gone.
Run it with --max-warnings 0 in CI so warnings do not accumulate either.
Python: Ruff with a curated selection
Ruff implements rules from many older tools (pyflakes, pycodestyle, flake8-bugbear, bandit and others) in one fast binary. The default selection is small; we extend it with the families that match our list:
# pyproject.toml
[tool.ruff]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
select = [
"E", "F", # pycodestyle errors, pyflakes
"B", # bugbear: mutable defaults, loop variable capture
"BLE", # blind except
"S", # bandit-derived security checks
"DTZ", # naive datetimes
"ASYNC", # blocking calls in async code
"UP", # pyupgrade: old-style APIs
"SIM", # simplifications
"PT", # pytest style
"RUF", # Ruff-specific, including unused noqa
]
ignore = ["S101"] # assert is fine in tests, see per-file below
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S101", "S105", "S106"]
"src/**" = []
The rules that earned their place: BLE001 (catching bare Exception), B006 (mutable default arguments), DTZ005 (datetime.now() without a time zone), S608 (SQL built with string formatting), ASYNC rules for time.sleep or blocking HTTP calls inside async def, and RUF100, which flags noqa comments that no longer suppress anything. Pair Ruff with a type checker (mypy or pyright); Ruff does not do type inference, and an import of a function that does not exist is a type checker's catch.
Go: golangci-lint v2
golangci-lint 2 changed the configuration format. A v2 file starts with version: "2", uses linters.default to pick a base set and moves formatters to their own section:
# .golangci.yml
version: "2"
linters:
default: standard # errcheck, govet, ineffassign, staticcheck, unused
enable:
- errorlint # wrapped error comparisons with errors.Is/As
- bodyclose # unclosed HTTP response bodies
- noctx # HTTP requests without context
- sqlclosecheck # unclosed sql.Rows and statements
- exhaustive # missing enum cases in switch
- gosec # security issues
- contextcheck # functions that drop the incoming context
settings:
errcheck:
check-type-assertions: true
exhaustive:
default-signifies-exhaustive: false
formatters:
enable:
- gofumpt
- goimports
errcheck in the standard set catches a call whose returned error is silently dropped, such as rows.Close() or tx.Rollback() on a line of its own. errorlint catches err == ErrNotFound where the error was wrapped and the comparison never matches. bodyclose and sqlclosecheck catch resource leaks that only show up under load.
Rust: Clippy lints in Cargo.toml
Since Rust 1.74, lints can be configured in Cargo.toml, which applies them consistently to every build and to every crate in a workspace:
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
unwrap_used = "deny"
expect_used = "warn"
panic = "warn"
todo = "deny"
dbg_macro = "deny"
print_stdout = "warn"
allow_attributes_without_reason = "deny"
unwrap_used is the important one for request-handling code; tests can opt out with #[allow(clippy::unwrap_used, reason = "test fixture")]. allow_attributes_without_reason forces every exception to explain itself, which makes review of suppressions possible. In CI we run cargo clippy --all-targets --all-features -- -D warnings.
Autofix or fail?
We use one simple policy:
Locally and in agent hooks: autofix.
ruff check --fix,eslint --fix,golangci-lint run --fix,cargo clippy --fix. Mechanical fixes such as import sorting and modern syntax should never reach a reviewer.In CI: never fix, only fail. CI runs
ruff check,ruff format --check,eslint --max-warnings 0,golangci-lint runandcargo clippy -- -D warnings. A CI job that rewrites code hides what changed and can mask a bug the fix introduced.
Some fixes are marked unsafe by the tool (they can change behaviour), and Ruff only applies them with --unsafe-fixes. We do not enable that flag in hooks; those fixes go through review like any other change.
Keeping the rules stable
A lint config is a contract. If it changes under people, they stop trusting it.
Pin tool versions in the lockfile, pre-commit config and CI image. A minor release of a linter can add rules to a preset.
Upgrade linters deliberately, in their own pull request, with the new violations fixed or baselined in the same change.
New rules start with a baseline where the tool supports one, for example golangci-lint's
issues.new-from-revto report only issues introduced since a commit, then tighten.Suppressions need reasons.
reportUnusedDisableDirectives,RUF100andallow_attributes_without_reasonmake stale or unexplained suppressions fail.Agents must not edit lint config. Put the config files under CODEOWNERS and say so in
CLAUDE.md. When an agent cannot satisfy a rule, it should explain why in the pull request, not disable the rule.
Common mistakes
Mistake | Why it hurts | Do this instead |
|---|---|---|
Default presets only | Misses async and error-handling bugs | Add type-aware and bug-focused rules |
Autofix in CI | Hides changes and fix-introduced bugs | Fix locally, fail in CI |
Unpinned linter versions | Surprise failures after upgrades | Pin and upgrade in dedicated PRs |
Unexplained suppressions | Exceptions become the norm | Require reasons, flag unused ones |
Lint without a type checker | Hallucinated imports and wrong types pass | tsc, mypy or pyright alongside |
Key takeaways
Target the mistakes you actually see: unhandled async, swallowed errors, panics, naive time, old APIs.
Enable type-aware ESLint rules, curated Ruff families, golangci-lint v2 extras and Clippy
unwrap_used.Autofix locally and in agent hooks; only fail in CI.
Pin versions, upgrade deliberately, require reasons for suppressions and protect config with code owners.
References
typescript-eslint typed linting: https://typescript-eslint.io/getting-started/typed-linting/
ESLint configuration files: https://eslint.org/docs/latest/use/configure/configuration-files
Ruff rules: https://docs.astral.sh/ruff/rules/
golangci-lint configuration (v2): https://golangci-lint.run/docs/configuration/file/
Clippy lints: https://rust-lang.github.io/rust-clippy/master/index.html
Cargo lints table: https://doc.rust-lang.org/cargo/reference/manifest.html#the-lints-section
Comments
0No comments yet. Be the first to comment!
Sign In to post a comment.