I have added ESLint to my TypeScript project by installing:
npm install eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev
and adding this script:
"lint": "eslint src/**/*.ts"
and this config file .eslintrc.json
:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
// Add your custom rules here
}
}
In VS Code, if I install the ESLint extension. Will it also use that same config file or do I have to redefine this config in VS Code?
2
Answers
VS Code will use this file, if it can find it (best is to place it in the project root). You can then go to the OUTPUT tab for
ESlint
, to see that it started normally. Should be something like:if the config file was found and is correct. To check that introduce a syntax error in the config file (e.g. remove a needed comma) which will then print an error in that OUTPUT channel like:
Yes it supports. Same file is used for the extension and project. If doesn’t try creating config file from a different format
ESLint