require-test-file

ProTesting

Require that source files have a corresponding test file with actual test cases

require-test-file

Require that source files have a corresponding test file with actual test cases

Category: Testing | Tier: Pro

Why This Matters

AI often generates implementation code without corresponding test files. Untested code is risky code -- without tests, you have no safety net when refactoring and no way to verify the AI-generated logic is correct.

Bad Code

// src/utils/parser.ts exists but
// tests/utils/parser.test.ts is missing
// No test coverage for this module

Good Code

// src/utils/parser.ts has a corresponding
// tests/utils/parser.test.ts
// Every module has test coverage

Configuration

This rule accepts configuration options:

[
  {
    "type": "object",
    "properties": {
      "excludePatterns": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Additional base name patterns to exclude from test file requirement"
      },
      "testDirectories": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Directories to search for test files (default: [\"__tests__\"])"
      }
    },
    "additionalProperties": false
  }
]

Enabled by default in lintmyai:recommended.