jest/prefer-importing-jest-globals
eslint-plugin-jest
Safe autofix
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-importing-jest-globals": "error",
},
},
];describe('foo', () => {
it('accepts this input', () => {
// ...
});
});import { describe, it } from '@jest/globals';
describe('foo', () => {
it('accepts this input', () => {
// ...
});
});Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
jest/prefer-importing-jest-globals
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-importing-jest-globals": "error",
},
},
];jest/prefer-importing-jest-globals
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/prefer-importing-jest-globals": "error"
}
}nursery/noTestGlobals
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"noTestGlobals": "error"
}
}
}
}Suggest having hooks before any test cases
Prefer having hooks in a consistent order
Suggest using the built-in equality matchers