VS Code showing eslint error but vitest is working. 'vi' is not defined

Viewed 111

I have a tsconfig file like this

{
  "include": ["tests/**/*.ts"],
  "exclude": [],
  "compilerOptions": {
    "composite": true,
    "lib": [],
    "skipLibCheck": true,
    "outDir": "lib",
    "types": ["vitest/globals"]
  }
}

as I have defined types for vitest/globals so yarn vitest cmd is working fine and executing the tests cases as well. But in the VS Code its showing me error
enter image description here

How I can fix/silent it in vs-code?

1 Answers

I had to add the following to my .eslintrc.json file for .js files (specifically a test setup file):

"globals": {
  "vi": true
},

However if you're using TypeScript, you should also add this to your compilerOptions in your tsconfig.json:

"types": ["vitest/globals"]
Related