In a new project, I installed typescript
, eslint
, @typescript-eslint/parser
, @typescipt-eslint/eslint-plugin
. I also added the following .eslintrc
file:
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"]
}
and the following tsconfig.json
file:
{
"compilerOptions": {
"strict": true
}
}
The problem is that the option from tsconfig.json
is not applied when I run the command eslint
. It works as expected with the command tsc
, though.
For example, with a file index.ts
containing:
function sum(a, b) {}
If I run npx eslint index.js
, I have no error while if I run tsc --noEmit
, I have two:
I would like the eslint
command to return the same errors as the tsc
command.
Any idea?
Edit I tried with and without the following in the .eslintrc
:
"parserOptions": {
"project": "./tsconfig.json"
}
typescript-eslint does not report compiler warnings. It only reports warnings generated by its own validation rules. Also, enabling the strict
option in TypeScript has no effect on the code analysis performed by typescript-eslint, which does not rely on the project settings.
There have been some discussions about creating a new @typescript-eslint/no-undef
rule (modeled on ESLint no-undef
rule) that would catch at least some of the warnings generated by the tsc compiler with strict type checking on.
The best approach for now is probably integrating the execution of tsc --noEmit
it the lint process.