Skip to content

compat-eslint: migrate 11 mechanical classes to SHAPES factory#92

Closed
johnsoncodehk wants to merge 1 commit into
masterfrom
refactor/factory-dsl-more-shapes
Closed

compat-eslint: migrate 11 mechanical classes to SHAPES factory#92
johnsoncodehk wants to merge 1 commit into
masterfrom
refactor/factory-dsl-more-shapes

Conversation

@johnsoncodehk
Copy link
Copy Markdown
Owner

Summary

11 hand-written subclasses migrated to the SHAPES factory. Each had only a type field plus mechanical convertChild/convertChildren slot getters — exactly the pattern the factory absorbs. Migration eliminates the per-class top-down/bottom-up drift surface (the factory's single registry serves both directions).

Pattern Classes
Pure type tag SuperNode, ThisExpressionNode, TSThisTypeNode, EmptyStatementNode, JSXOpeningFragmentNode, JSXClosingFragmentNode
defaults (static fields) NullLiteralNode (value, raw)
consts (derived from tsNode) PrivateIdentifierNode (name)
Single-slot convertChild JSXSpreadAttributeNode
Slot via callback JSXClosingElementNode (convertJSXTagName), StaticBlockNode (default decorators + nested body.statements access)

Hand-written *Node extends LazyNode count: 91 → 81. SHAPES entries: 46 → 57. Net −56 lines.

Test plan

  • predicate-coverage (152/152, 16 ignored)
  • lazy-estree.test (parity sweep + factory tests + phantom-types invariant)
  • scope-compat (24/24 clean)
  • selector-analysis / ts-ast-scan / compat-pipeline / jsx-react-x (parity ✓)
  • dogfood.js — 30 files × 107 rules, 0 divergences, 0 crashes
  • Dify web cold lint — 5.3-6.4s on this branch vs 5.1-5.5s on master (within noise, no regression)

Each class had only `type` plus simple convertChild/convertChildren
slot getters — exactly the mechanical pattern the factory was designed
to absorb. Migration eliminates 11 hand-written subclass + switch-case
pairs and pushes them through the single-source-of-truth registry that
both top-down getters and bottom-up materialise consult.

Migrated:

- Pure type tag: SuperNode, ThisExpressionNode, TSThisTypeNode,
  EmptyStatementNode, JSXOpeningFragmentNode, JSXClosingFragmentNode
- defaults (static fields): NullLiteralNode (value/raw)
- consts (derived from tsNode): PrivateIdentifierNode (name)
- single-slot convertChild: JSXSpreadAttributeNode
- slot via callback: JSXClosingElementNode (convertJSXTagName),
  StaticBlockNode (decorators default + body via callback for nested
  block.statements access)

Hand-written class count 91 → 81; SHAPES entries 46 → 57. Net -56 lines.

Tested: predicate-coverage / lazy-estree / scope-compat /
selector-analysis / ts-ast-scan / compat-pipeline / jsx-react-x +
dogfood (107 rules × 30 files clean) + Dify cold/warm bench (no
regression).
@johnsoncodehk
Copy link
Copy Markdown
Owner Author

Superseded by #95 — squashed and consolidated.

@johnsoncodehk johnsoncodehk deleted the refactor/factory-dsl-more-shapes branch May 27, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant