My personal ESLint config.
This is meant to be used alongside Prettier (with
@imhoff/prettier-config
).
-
Remove existing
.eslintrc.*
file, if present. -
Install
eslint
and the config.npm install -D eslint @imhoff/eslint-config
-
Add the following to
package.json
:"eslintConfig": { "extends": "@imhoff/eslint-config/recommended" },
📝 You can also use the base rule set: @imhoff/eslint-config
-
Set up Prettier and
@imhoff/prettier-config
. -
When using with Prettier and
@imhoff/prettier-config
, ESLint should run first. Set up your scripts inpackage.json
like this:"scripts": { "lint": "npm run eslint && npm run prettier -- --check", "fmt": "npm run eslint -- --fix && npm run prettier -- --write", "prettier": "prettier \"**/*.ts\"", "eslint": "eslint . --ext .ts", }
npm run lint
: for checking if ESLint and Prettier complainnpm run fmt
: attempt to autofix lint issues and autoformat code
📝 Not every rule in this configuration is autofixable, so
npm run fmt
may continue failing until lint issues are addressed manually.
-
Install captainhook:
npm install -D captainhook
-
Add the following to
package.json
:"hooks": { "pre-commit": "npm run lint" },