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

chore: Require explicit and inline type imports #969

Closed

Conversation

VincentSmedinga
Copy link
Contributor

We want to export and import types explicitly.

We can use inline type modifiers to combine type and component imports in one statement.

Let’s use ESLint to do this for us.

@VincentSmedinga
Copy link
Contributor Author

This results in the following error and my attempts to resolve it are fruitless. Can either of you get this to work?

Error: Error while loading rule '@typescript-eslint/consistent-type-exports': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Volumes/Code/amsterdam/design-system/design-system/packages/react/.eslintrc.json

@alimpens
Copy link
Contributor

This results in the following error and my attempts to resolve it are fruitless. Can either of you get this to work?

Error: Error while loading rule '@typescript-eslint/consistent-type-exports': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Volumes/Code/amsterdam/design-system/design-system/packages/react/.eslintrc.json

I can't quite get it to work either. Do we need both import/consistent-type-specifier-style and @typescript-eslint/consistent-type-imports? Everything seems to work when just using the first rule

@VincentSmedinga
Copy link
Contributor Author

VincentSmedinga commented Dec 21, 2023

I can't quite get it to work either. Do we need both import/consistent-type-specifier-style and @typescript-eslint/consistent-type-imports? Everything seems to work when just using the first rule

For me it only inlines existing type imports with the former, doesn’t fix the currently untyped ones.

They should be usable at the same time: https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how

The packages/react/.eslintrc.json doesn’t explicitly extend the root .eslintrc.json where parserOptions.project does get configured. Can that be a problem or are they merged in the background?

If you can’t get it to work in a reasonable amount of time, just close this.

@VincentSmedinga VincentSmedinga deleted the chore/eslint-consistent-type-exports branch January 9, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants