My personal ESLint config.
npm i -D eslint @will-stone/eslint-config
// eslint.config.js
import config from '@will-stone/eslint-config'
export default config()
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
Install VS Code ESLint extension.
Add the following settings to your .vscode/settings.json
:
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
}
If you would like to apply lint and auto-fix before every commit, you can add
the following to your package.json
:
{
"scripts": {
"prepare": "husky install"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": ["eslint --fix"]
}
}
and then
npm i -D husky lint-staged
npx husky install
npx husky add .husky/pre-commit "npx --no lint-staged"
Inspired by the excellent Flat eslint-config by Anthony Fu.