← Back to Pull requests

fix(exports-last): treat TypeScript `export =` and `export as namespace` as exports #651

Closed
unknown closed this pull request without merging on Nov 27, 2026 01:09 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 09:16 UTC
Author

exports-last only counts ExportDefaultDeclaration, ExportNamedDeclaration and ExportAllDeclaration as exports. TypeScript's export = foo (TSExportAssignment) and export as namespace Foo (TSNamespaceExportDeclaration) are treated as normal statements.

This gives a false report on the usual UMD .d.ts shape:

export declare function foo(): void
export as namespace Foo

  • actual: export declare function foo is reported ("Export statements should appear at the end of the file"), because export as namespace Foo counts as the last non-export statement

  • expected: no report, every statement is an export
  • And the other way, an export = or export as namespace placed before other code is never reported:

    export = foo
    declare function foo(): void
    

    Cause: isNonExportStatement in src/rules/exports-last.ts:16 does not list the two TypeScript export nodes.

    Fix: add TSExportAssignment and TSNamespaceExportDeclaration to the export node types. A file like export = React; export as namespace React; declare namespace React {} will now get both exports reported, same as any other export placed before a declaration.

    Tests: two valid cases (the UMD one above, and export = at the end) and two invalid cases (export = and export as namespace before a declaration). 3 tests fail before the change; yarn test (4158 passed) and yarn lint pass. A changeset is added.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    The exports-last rule now recognizes TypeScript export = assignments and export as namespace declarations as exports. These declarations are checked for placement alongside other exports, and the rule reports them when a non-export statement follows. This improves consistency when enforcing export ordering in TypeScript files.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 249 lines (+186 / -63) across 3 files Reviewer: thekhegay Review duration: 953m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 249 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.330
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #651"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.0% (MEDIUM) · Higher = larger blast radius
    39.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%