npm i eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser prettier eslint-config-prettier eslint-plugin-prettier --save-dev
create .eslintrc.json
and add these settings:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
// "@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-inferrable-types": "off",
"no-console": "warn",
"prefer-const": "error",
"no-var": "error"
},
"env": {
"browser": true,
"node": true,
"es2021": true
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
also add .eslintignore
and add these settings:
# Ignore node_modules
node_modules/
# Ignore build directories
dist/
build/
# Ignore minified JavaScript files
*.min.js
# Ignore specific configuration files
# .eslintrc.js
into package.json
add this two line:
"lint": "eslint src --ignore-path .eslintignore --ext .ts",
"lint:fix": "eslint src --ignore-path .eslintignore --ext .ts --fix",