Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit project configuration from @typescript-eslint/parser's parserOptions #102

Open
carlocorradini opened this issue Apr 5, 2022 · 8 comments

Comments

@carlocorradini
Copy link

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!

@JounQin
Copy link
Collaborator

JounQin commented Apr 5, 2022

PR welcome if you have the idea about how to implement it.

@carlocorradini
Copy link
Author

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.

@JounQin
Copy link
Collaborator

JounQin commented Apr 5, 2022

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.

@carlocorradini
Copy link
Author

Ok, there is a purpose. So, there are no workarounds (as far as I understood)?

@JounQin
Copy link
Collaborator

JounQin commented Apr 5, 2022

Right

@MWhite-22
Copy link

MWhite-22 commented Jun 14, 2022

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.

@JounQin
Copy link
Collaborator

JounQin commented Jun 14, 2022

I still don't get it why not just project: __dirname

@JounQin JounQin reopened this Jun 14, 2022
@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2022
@JounQin
Copy link
Collaborator

JounQin commented Aug 17, 2022

This issue would be resolved after import-js/eslint-plugin-import#2519 been merged.

@JounQin JounQin reopened this Aug 17, 2022
@JounQin JounQin changed the title Question: project tsconfig.json Inherit project tsconfig.json configuration from @typescript-eslint/parser's parserOptions Aug 17, 2022
@JounQin JounQin changed the title Inherit project tsconfig.json configuration from @typescript-eslint/parser's parserOptions Inherit project configuration from @typescript-eslint/parser's parserOptions Aug 17, 2022
@JounQin JounQin self-assigned this Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants