I'm using a testing library that allows suite
to be used, and if I add Jest
like this to the ESLint globals configuration in eslint.config.js
it works for the test
global, but not for suite
.
import eslint from "@eslint/js";
import globals from "globals";
export default [
// apply recommended rules to JS files
{
languageOptions: {
globals: {
...globals.browser,
...globals.jest
}
}
},
{
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
rules: eslint.configs.recommended.rules
},
{
ignores: ["rollup.config.js", "web-test-runner.config.js", "src/index.bundle.js"]
}
]
Is there are generic global for ESLint that we can use that will cover most of the generic testing globals?
This is the linting error:
/Users/oleersoy/Temp/Remove/fs-javascript-starter/src/hello-world.component.spec.js
4:1 error 'suite' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
OK - I studied the globals json file provided by the globals NPM package, and it looks like mocha is a good fit, in general, and for this question in particular.
I updated the config and this works.
import eslint from "@eslint/js";
import globals from "globals";
export default [
{
languageOptions: {
globals: {
...globals.browser,
...globals.mocha
}
}
},
// apply recommended rules to JS files
{
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
rules: eslint.configs.recommended.rules
},
{
ignores: ["rollup.config.js", "web-test-runner.config.js"]
}
]