Skip to content

test: match generated/ at any depth in api-deprecated-paths #245

Description

@thecodedrift

What

typeScriptSources in packages/cli/test/api-deprecated-paths.test.ts:51 excludes the generated schema transcript from the deprecated-path scan. The current filter only matches a top-level generated/:

.filter(
  // `generated/` is the schema's own transcript: it necessarily names every
  // path, deprecated ones included, and is not a call site.
  (file) => !relative(directory, file).startsWith(`generated${sep}`)
);

The hand-rolled recursion this replaced (in #243) skipped a generated directory at any depth. The narrowing was incidental to the cleanup, not intended.

Why it is not urgent

There is exactly one such directory today — packages/cli/src/generated — so the filter is currently a no-op difference. And the failure direction is the safe one: if a nested src/**/generated/ is ever added, the test starts failing loudly with false offenders rather than quietly letting a real deprecated call site through.

Why it is still worth doing

It restores the pre-#243 semantics rather than inventing new ones, and the comment's own rationale — generated/ is a transcript, not a call site — is about what a generated directory is. That does not depend on how deep it sits.

Fix

(file) => !relative(directory, file).split(sep).includes("generated")

One line, says the intent directly.

Verifying it bites

Add a nested src/**/generated/*.ts containing a deprecated path (/cli/api/rule/…), confirm the test reports it as a false offender before the change and is silent after, then remove the fixture. Note the negative-lookahead detail nearby: /cli/api/rule must not match /cli/api/rule-hash-vectors, a live path sharing the stem.

Found by review on #243.

Refs #241

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIRelated to the taskless CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions