create tsconfig.json
touch tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"watch": true,
"moduleResolution": "node",
"lib": ["dom", "es2020"], // adds external libraries like Classes from the DOM
"outDir": "dist",
"rootDir": "src",
"strict": true
}
}
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
create .eslintrc
config in root
touch .eslintrc.js
config:
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
}
create eslintignore
in root
touch .eslintignore
ignore the dist
folder and node_modules
node_modules
dist
package.json
:
{
"scripts": {
"lint": "eslint . --ext .ts <mySrcFolder>"
}
}
ctrl + p
> Tasks: Configure Task
> npm: lint
create a tasks.json in .vscode folder
"tasks": [
{
"problemMatcher": ["$eslint-stylish"],
}
]
package.json:
"scripts": {
"lint": "eslint -c .eslintrc --ext .ts src",
"lint-fix": "eslint -c .eslintrc --ext .ts src --fix",
"tsc": "eslint -c .eslintrc --ext .ts src tsc"
},
npm run lint
formating
npm run ling-fix