Skip to content

Rules tests that assert on an un-awaited rule.run() result may pass vacuously #1863

Closed

Description

@nc9

Found while typechecking packages/rules tests (#1859, pub#1862). rule.run() returns Promise<RuleResult> | RuleResult. Many tests use the result without await; with a matcher such as toBeUndefined, not.toContain, toBe(false) or a length check on .items, the assertion runs against a Promise and can pass whatever the rule does. A heuristic grep flagged 20 files; the 10 most likely: empty-heading, form-field-multiple-labels-1249, identical-links-same-purpose, no-contextual-inbound, dom-size, content-unrendered-markup, probe-path-not-approved-1655, framework-data-payload-1143, security/leaked-secrets-budget-overrun-1556, security/leaked-secrets-public-tier (all under packages/rules/tests). packages/rules/tsconfig.test.json (not in CI yet) reports 952 errors, mostly this pattern.

Acceptance Criteria

  • Every rules test awaits rule.run() (or uses a helper that does) before asserting on its result.
  • Each test in the 10 files above is shown to fail when the rule's verdict is inverted (one mutation check per file, listed in the PR), or is fixed so it does.
  • bunx tsgo --noEmit -p packages/rules/tsconfig.test.json reaches 0 errors and is wired into the package typecheck, so CI keeps it at 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions