79741959

Date: 2025-08-21 07:13:03
Score: 0.5
Natty:
Report link

Issue
tsconfig.app.json included the whole src folder, which also contained test files. This meant the tests were type-checked by both tsconfig.app.json and tsconfig.test.json, which caused conflicts and ESLint didn’t recognize Vitest globals.

Fix
Exclude test files from tsconfig.app.json so only tsconfig.test.json handles them.

tsconfig.app.json

{
  // Vite defaults...

  "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/tests/setup.ts"]
}

tsconfig.test.json

{
  "compilerOptions": {
    "types": ["vitest/globals"],
    "lib": ["ES2020", "DOM"],
    "module": "ESNext",
    "moduleResolution": "bundler",
    "jsx": "react-jsx"
  },
  "include": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/tests/setup.ts"]
}

After this change, ESLint recognized describe, it, expect, etc.

(Optional): I also added @vitest/eslint-plugin to my ESLint config. Not required for fixing the globals error, but helpful for extra rules and best practices in tests.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Basma Khalil