Why am I getting these TypeScript ESLint errors even though VSCode doesn't complain?
Here is my repo. It was bootstrapped with
create-t3-app
: https://github.com/ChromeUniverse/luccanotes
And here is the full output of npm run lint
:
Why am I getting these errors? VSCode and the Next.js dev server don't seem to be complaining.GitHub
GitHub - ChromeUniverse/luccanotes: A full-stack note-taking app fo...
A full-stack note-taking app for Markdown lovers ❤️ - GitHub - ChromeUniverse/luccanotes: A full-stack note-taking app for Markdown lovers ❤️
3 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
So, two things:
- VS Code probably doesn't complain because you don't have the ESLint extension enabled (See @Cloud 's message), or the extension cannot find the ESLint config file. Make sure to open the repo's root folder in VS Code.
- If you look at the rules inside the ESLint config
.eslintrc.json
(https://github.com/ChromeUniverse/luccanotes/blob/main/.eslintrc.json) you can check which rulesets/plugins are enabled for your project. As you can see @typescript-eslint
's recommended-requiring-type-checking
is enabled for Typescript files, as well as next/core-web-vitals
and @typescript-eslint/recommended
. On line 20 you can also see a rule override "@typescript-eslint/consistent-type-imports": "warn"
which warns you if you don't add the type
keyword to your imports (See @PedeEli 's message).
Generally, whenever you have questions about an ESLint rule/error, I recommend googling its definition (https://typescript-eslint.io/rules/consistent-type-imports/). Most rules are well explained, and you can then decide if you want to disable some of them or not. Also, many rules are automatically fixable. You can run the fixing either through the linting CLIs or through your IDE's ESLint extensions.GitHub
luccanotes/.eslintrc.json at main · ChromeUniverse/luccanotes
A full-stack note-taking app for Markdown lovers ❤️ - luccanotes/.eslintrc.json at main · ChromeUniverse/luccanotes
This was it - never heard of either plugin but they immediately picked up on the
.eslintrc.json
and prettier.config.cjs
and showed me all errors and warnings in VSCode.
Also had to rearrange some exported types and change the import statement per @PedeEli's suggestion
Thanks for the detailed explanation! I'll check out the ESLint docs