Linters vs Formatters
Linters have 2 sets of rules:
- Formatting rules: eg: max-len, no-mixed-spaces-and-tabs, keyword-spacing, comma-style…
- Code-quality rules: eg no-unused-vars, no-extra-bind, no-implicit-globals, prefer-promise-reject-errors…
While formatters only have formatting rules.
ES Lint + Prettier
- ES Lint is a battle tested linter, while it’s bloody slow on large codebases, faster alternatives like Biome are still on it’s early days
- Prettier is an opinionated linter, and it’s opinions are spot on except for native use of spaces for indentation!
- Use the prettier-tailwind plugin for making your Tailwind classes look consistent
Install
bun add --dev eslint
bun add --dev --exact prettier
bun add -D prettier-plugin-tailwindcssIn prettier config,
{ "plugins": ["prettier-plugin-tailwindcss"]}
Run,
bun run eslint .
bun run esliont --fix
bunx prettier . --check
bunx prettier . --write --use-tabs