Inherit `project` configuration from `@typescript-eslint/parser`'s `parserOptions`
Using @typescript-eslint/parser is recommended to set project in parserOptions.
We also need to add the project in import/resolver-> typescript when using eslint-import-resolver-typescript.
Can we omit the first project or do we need both even though they are almost the same?
Thanks!
PR welcome if you have the idea about how to implement it.
Instead of reading project from import/resolver -> typescript can we read it from parserOptions?
As far as I know, to add Typescript support to eslint, @typescript-eslint/parser is a must. Therefore, I think project option should be read from the latter and not from a custom one that can create confusion and duplication.
Please, add your thoughts on this. Maybe I am wrong or this has been done for a known issue/purpose.
eslint-import-resolver-typescript is used by eslint-plugin-import, not any parser, so it can only use things passed by eslint-plugin-import, it has no idea about the parserOptions.
Ok, there is a purpose. So, there are no workarounds (as far as I understood)?
Right
One of the problems I am running in to is that eslint-import-resolver-typescript does not allow me to add (or doesn't care about adding) tsconfigRootDir: __dirname, into the settings like the below:
//...
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
},
},
Adding the tsconfigRoorDir is required in a monorepo to make @typescript-eslint work with each individual package, otherwise eslint keeps only looking for configs in the monorepo root, rather than linting rules set by each package.
If the import/resolver were able to use the same values as passed by parserOptions, that would help to solve this issue.
I still don't get it why not just project: __dirname
This issue would be resolved after https://github.com/import-js/eslint-plugin-import/pull/2519 been merged.