eslint
is peerDependencies, make sure you had already installed eslint
# pnpm
pnpm add -D @yutengjing/eslint-config-typescript
# npm
npm add -D @yutengjing/eslint-config-typescript
# yarn
yarn add -D @yutengjing/eslint-config-typescript
# bun
bun add -d @yutengjing/eslint-config-typescript
add this preset to .eslintrc
or .eslintrc.js
{
"extends": "@yutengjing/eslint-config-typescript"
}
or you can simply add it to package.json:
{
"eslintConfig": {
"extends": "@yutengjing/eslint-config-typescript"
}
}
You don't need
.eslintignore
normally as it has been provided by the preset.
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
Install VS Code ESLint extension and create .vscode/settings.json
{
"eslint.enable": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"json",
"json5",
"jsonc",
"markdown",
"yml",
"yaml",
"html"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
Some useful personal eslint rules:
- @yutengjing/comment-autocorrect
- @yutengjing/no-missing-script
- @yutengjing/format-mui-sx-selector.js
- @yutengjing/no-mui-sx-selector-missing-dot
- @yutengjing/no-reference-deps
- @yutengjing/matching-remove-event-listener.js
- @yutengjing/no-uppercase-module-path
- @yutengjing/no-declare-implicit-any-var.js
- @yutengjing/no-vue-filename-index
- @yutengjing/no-inline-function-event-listener
- @yutengjing/prefer-jsdoc
- @yutengjing/no-invalid-mui-breakpoints.js
- @yutengjing/no-missing-remove-event-listener
- @yutengjing/no-relative-import
check the source code or rule docs for details.