Operant Studio
KNUCK-A038b

KNUCK-A038: whitespace-fixture lint -- forbid hardcoded multi-space fixtures in scripts tests

Suggested
Justin Cooke

Body

feature_id: FEAT-studio-dependency-map-policy

## Context

`scripts/__tests__/check-view-drift.test.ts` line 323 (before PR #278 fix) matched a literal string with hardcoded whitespace:

```
'  hasMigration    Boolean             @default(false)\n'
```

When `prisma format` shifted alignment (which it did in PR #278 because `createdBy` got 1 char shorter), the literal no longer matched, `source.replace(...)` was a no-op, `patched === source`, and the test asserted against itself. Two CI checks failed downstream (`build`, `No scaffolding stub`) with an obscure "expected X not to be X" message.

The fix in PR #278 swapped the hardcoded whitespace for a `\s+` regex. This ticket generalizes the fix as a lint rule so future tests can't fall into the same trap.

## Acceptance Criteria

- New ESLint rule `operant/no-hardcoded-whitespace-schema-fixtures` under `packages/eslint-plugin`
- Rule flags string literals in `scripts/__tests__/**/*.ts` and `**/__tests__/**/*.prisma-fixture.ts` that contain 3+ consecutive spaces followed by a Prisma scalar type name (`String`, `Int`, `Boolean`, `Float`, `DateTime`, `Json`, `Bytes`, `Decimal`, `BigInt`) or a directive (`@id`, `@default`, `@map`, `@relation`, `@unique`)
- Suggested fix in the rule: replace consecutive spaces with `\s+` (or `\\s+` inside a string that will later become a regex)
- Escape hatch: `// eslint-disable-next-line operant/no-hardcoded-whitespace-schema-fixtures` with mandatory reason comment
- Ships as required check in `Operant-Health/operant-studio`
- Rule ships with test cases covering: matching cases (`  foo    String`), non-matching (`  foo String`, 2 spaces), and escape-hatch usage

## Effort

Single Ledger ticket. Blockers: none.

## Filed as follow-on to

PR #278 (KNUCK-A007b1a).

## Supersedes

KNUCK-A038 first attempt (Task cuid `cmts6cxtl001tky0447ixdgby`), canceled after admission rejected for missing `feature_id`.

Attachments

Loading attachments…

Comments

Loading comments…