# NOTE: `__tests__` directories must contain tests only. Shared helpers, registries,
# fixtures, and other imported support modules belong in a nearby `test-helpers/`
# directory so test roots stay easy to scan.

id: no-exports-in-tests-folder
language: Tsx
severity: error
message: 'Do not export from files under __tests__; move shared test support to a test-helpers directory.'
files:
  - '**/__tests__/**/*.ts'
  - '**/__tests__/**/*.mts'
  - '**/__tests__/**/*.cts'
  - '**/__tests__/**/*.tsx'
rule:
  all:
    - kind: export_statement
    - not:
        pattern: export {}
examples:
  - code: 'export const makeThing = () => ({})'
    isValid: false
    file: 'backend/services/example/__tests__/user-helpers.mts'
  - code: 'export type Helper = { id: string }'
    isValid: false
    file: 'web/lib/__tests__/manifest-registry.ts'
  - code: "export { makeThing } from './thing'"
    isValid: false
    file: 'src/__tests__/helpers.mts'
  - code: |
      describe('script rendering', () => {
        it('renders shell exports', () => {
          expect(`export NEXT_PORT=3901`).toContain('export')
        })
      })
    isValid: true
    file: 'src/__tests__/stop-services.test.mts'
  - code: 'const makeThing = () => ({})'
    isValid: true
    file: 'backend/services/example/__tests__/users.test.mts'
  - code: 'export {}'
    isValid: true
    file: 'backend/services/example/__tests__/global-script.test.mts'
  - code: |
      export function renderThing() {
        return <div />
      }
    isValid: false
    file: web/components/example/__tests__/comment-tree-test-helpers.tsx
  - code: export type RenderThing = () => JSX.Element
    isValid: false
    file: web/components/__tests__/render-helpers.tsx
  - code: |
      it('renders shell exports', () => {
        expect(`export NEXT_PORT=3901`).toContain('export')
      })
    isValid: true
    file: web/components/example/__tests__/comment-tree.test.tsx
  - code: |
      function renderThing() {
        return <div />
      }
    isValid: true
    file: web/components/example/__tests__/comment-tree.test.tsx
  - code: export {}
    isValid: true
    file: web/components/example/__tests__/global-jsx.test.tsx
