npm install eslint @singularit/eslint-config -D
module.exports = {
extends: "@singularit"
}
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
- Install and setup husky
npx husky-init && npm install
- Add
lint-staged
to pre-commit hook
# .husky/pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
- npm test
+ npx lint-staged
- Configure
lint-staged
// package.json
{
...
+ "lint-staged": {
+ "*.{js,jsx,ts,tsx,vue,md,yml,yaml}": "eslint --fix --max-warnings 0"
+ }
...
}
-
Install the ESLint extension
-
Add file .vscode/settings.json or add to file if it already exists
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
MIT