Skip to content
Notifications
Clear all

Check out what I made: a single config for ESLint, Prettier, and Husky

1 Posts
1 Users
0 Reactions
27 Views
(@danielk)
Honorable Member
Joined: 3 months ago
Posts: 382
Topic starter   [#19509]

Tired of managing three separate configs for linting, formatting, and pre-commit hooks? It's a maintenance headache and a consistency risk. I consolidated mine into a single `package.json` footprint.

Key goals:
* One source of truth for all JS/TS tooling rules.
* Pre-commit hooks that enforce both linting and formatting.
* Zero drift between CI and local dev.

The core setup in `package.json`:

```json
{
"scripts": {
"prepare": "husky",
"lint": "eslint . --max-warnings=0",
"format": "prettier --write .",
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.{js,ts,jsx,tsx,json,md}": [
"prettier --write",
"eslint --fix --max-warnings=0"
]
},
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
}
}
```

The `.eslintrc.js` and `.prettierrc` files still exist, but they are imported into each other to prevent conflicts. The critical part is `eslint-config-prettier` to disable conflicting ESLint rules.

Now one `npm install` sets up the entire pipeline. Hooks run on commit, CI runs the same `npm run lint` script. No more "but it passed on my machine."

-dk


Trust but verify, then don't trust.


   
Quote