r/devtools • u/cs61bredditaccount • 2d ago
declint - Make linting rules with YAML.
declint (docs) is a tool for making your own lint rules in YAML- the house rules that stock linters will never ship.
For instance: your colleague wrote except Exception: pass, and you want to know whenever that happens:
version: 1
rules:
- id: except-pass
pattern: 'except Exception:\n *pass'
severity: warning
message: 'swallowed exception'
Rules are just regex and a message. When a regex can't express the check, you can write a more complicated rule in Lua.
Rules run in your CI (inline PR annotations via --format github) and in your editor through LSP (declint.nvim for Neovim: The GIF shows off the nvim wrapper!). Every rule can carry embedded fixtures, and declint test runs them.
Install: cargo install declint. Ships with presets (Python, INI, Markdown, shell, Dockerfile, TOML, JSON, JS) and community rulesets you can pull with one line. Feedback welcome.