By default eslint will flag vitest globals that aren't imported (describe , expect) etc as errors because they violate the no-undef rule:
error 'describe' is not defined no-undef
We can prevent this using :
env: {
'vitest/env': true`
}
Or for flat file config:
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
}
So there are effectively two styles: one where globals are manually imported per test file, and one where they are not. It would make sense to have a rule that covered the latter style and detected imports of globals from 'vitest' in test files.
By default eslint will flag vitest globals that aren't imported (
describe,expect) etc as errors because they violate theno-undefrule:We can prevent this using :
Or for flat file config:
So there are effectively two styles: one where globals are manually imported per test file, and one where they are not. It would make sense to have a rule that covered the latter style and detected imports of globals from 'vitest' in test files.