fix(exports-last): treat TypeScript `export =` and `export as namespace` as exports #651
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
thekhegay
exports-lastonly countsExportDefaultDeclaration,ExportNamedDeclarationandExportAllDeclarationas exports. TypeScript'sexport = foo(TSExportAssignment) andexport as namespace Foo(TSNamespaceExportDeclaration) are treated as normal statements.This gives a false report on the usual UMD
.d.tsshape:export declare function foois reported ("Export statements should appear at the end of the file"), becauseexport as namespace Foocounts as the last non-export statementAnd the other way, an
export =orexport as namespaceplaced before other code is never reported:Cause:
isNonExportStatementinsrc/rules/exports-last.ts:16does not list the two TypeScript export nodes.Fix: add
TSExportAssignmentandTSNamespaceExportDeclarationto the export node types. A file likeexport = 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 =andexport as namespacebefore a declaration). 3 tests fail before the change;yarn test(4158 passed) andyarn lintpass. 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-lastrule now recognizes TypeScriptexport =assignments andexport as namespacedeclarations 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 -->