Error: npm lint not seeing env type
I converted my existing project over to use the same template as ct3a. However, when I run
npm run lint
it throws a @typescript-eslint/no-unsafe-member-access
error for every place in my codebase where I import { env } from "~/env.mjs"
, saying env is an any type. I can't seem to figure out what is causing this, since vscode still shows the env type when I hover over the import and I've double checked that my eslintrc.cjs and tsconfig.json are setup correctly.8 Replies
Does your
tsconfig.json
's "include" field look like this?
Yeah it's exactly that. I've copy pasted it from the t3ca repo
Hm, do you have more than one
.eslintrc
file?
by default most projects have .eslinrc.json
whereas ct3a uses a .cjs filejust the one .cjs file
The fact VSCode can see the type, but eslint can't see it is a sign eslint isn't configured correctly
Ah, I thought this error was when you ran eslint, not a VSCode-only error
Seems like VSCode eslint extension may be loading default configs instead of the proper .eslintrc file
I cleared my next cache and the error finally started to show inline in vscode. However, when I hover over the
env
import, it still shows the valid type. Running npm lint
still errors.
Here's an example output:
And here's an example of my env.mjs
Nothing out of the ordinary, so i'm assuming it's a config issueYeah, seems like like an odd config issue, are you maybe on an old version of node or typescript or something?
yeah i'll check
I've narrowed it down to commenting out this part of the .eslintrc.cjs: