jest/no-export
eslint-plugin-jest
No autofixRecommended
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-export": "error",
},
},
];export function myHelper() {}
module.exports = function () {};
module.exports = {
something: 'that should be moved to a non-test file',
};
describe('a test', () => {
expect(1).toBe(1);
});function myHelper() {}
const myThing = {
something: 'that can live here',
};
describe('a test', () => {
expect(1).toBe(1);
});Examples from the ESLint documentation.
jest/no-export
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-export": "error",
},
},
];jest/no-export
jest plugin · correctness
{
"plugins": [
"jest"
],
"rules": {
"jest/no-export": "error"
}
}suspicious/noExportsInTest
suspicious · since 1.6.0
{
"linter": {
"rules": {
"suspicious": {
"noExportsInTest": "error"
}
}
}
}Disallow duplicate setup and teardown hooks
Disallow explicitly returning from tests