Skip to content

feat(no-export): disallow exports in files containing tests - #493

Open
unlikelyzero wants to merge 1 commit into
mskelton:mainfrom
unlikelyzero:feat/no-export
Open

feat(no-export): disallow exports in files containing tests#493
unlikelyzero wants to merge 1 commit into
mskelton:mainfrom
unlikelyzero:feat/no-export

Conversation

@unlikelyzero

Copy link
Copy Markdown
Collaborator

Adds a no-export rule, ported from jest/no-export.

Playwright collects spec files by running them, not by importing anything they export, so an export in a spec file has no effect on the test run. It usually means a helper that belongs in a shared module, or a leftover from a file that used to be something else. It's also a subtle footgun: importing a spec file to reuse an export registers its tests a second time.

The rule only fires in files that contain at least one test or test.describe call, so fixture and helper modules are unaffected. ESM exports (export const, export default, export *, export { … }, export type), TypeScript's export =, and CommonJS module.exports / module.exports.foo are all covered. A locally declared module variable is not treated as CommonJS.

Not enabled in the recommended config, matching eslint-plugin-jest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant