Refer to @antfu/eslint-config.
# for vue
pnpm add eslint @toryz/eslint-config -D
# for react
pnpm add eslint @toryz/eslint-config-react -D
# for svelte
pnpm add eslint @toryz/eslint-config-svelte -D
{
"root": true,
"extends": "@toryz",
"rules": {
// your custom rules
}
}
Tips: if you working on react or svelte, please use @toryz/react
or @toryz/svelte
to instead it.
{
// ...
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
Install VS Code ESLint extension
Add the following settings to your settings.json
:
{
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
// The following is optional.
// It's better to put under project setting `.vscode/settings.json`
// to avoid conflicts with working with different eslint configs
// that does not support all formats.
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"svelte",
"html",
"markdown",
"json",
"jsonc",
"yml",
"yaml"
]
}
If you want to apply lint and auto-fix before every commit, you can add the following to your package.json
:
{
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
}
}
and then
npm i -D lint-staged simple-git-hooks