ESlint for TypeScript
Based on video course [FrontendMasters] Production-Grade TypeScript
Configured project :
https://github.com/mike-north/professional-ts-my-lib
$ yarn add --dev \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint
// Generate eslint config if needed
// $ ./node_modules/.bin/eslint --init
.eslintrc.json
$ vi .eslintrc.json
{
"env": { "node": true },
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"project": "tsconfig.eslint.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"plugins": ["@typescript-eslint"],
"rules": {
"prefer-const": "error",
"@typscript-eslint/no-unused-vars": "off",
"@typscript-eslint/no-unused-params": "off"
},
"overrides": [
{
"files": ["tests/**/*.ts"],
"env": { "jest": true, "node": true }
}
]
}
no-unused-vars, no-unused-params - are specified in tsconfig already
tsconfig.eslint.json
$ vi tsconfig.eslint.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["jest"]
},
"include": ["src", "tests"]
}
.eslintignore
$ vi .eslintignore
/node_modules/
/build/
// Check
$ npx eslint src/
ESLint Plugin TypeScript
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/README.md