refactor: extract local autorouter strategies - #2898
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| import { | ||
| type AutorouterOptions, | ||
| TscircuitAutorouter, | ||
| } from "./CapacityMeshAutorouter" | ||
| import type { GenericLocalAutorouter } from "./GenericLocalAutorouter" | ||
| import type { SimpleRouteJson } from "./SimpleRouteJson" | ||
| import type { NormalizedAutorouterConfig } from "./getPresetAutoroutingConfig" | ||
|
|
||
| export interface LocalAutorouterStrategyContext { | ||
| simpleRouteJson: SimpleRouteJson | ||
| commonAutorouterOptions: AutorouterOptions | ||
| } | ||
|
|
||
| export interface LocalAutorouterStrategy { | ||
| cacheable: boolean | ||
| create: (context: LocalAutorouterStrategyContext) => GenericLocalAutorouter | ||
| } | ||
|
|
||
| const defaultLocalAutorouterStrategy: LocalAutorouterStrategy = { | ||
| cacheable: true, | ||
| create: ({ simpleRouteJson, commonAutorouterOptions }) => | ||
| new TscircuitAutorouter(simpleRouteJson, commonAutorouterOptions), | ||
| } | ||
|
|
||
| const localAutorouterStrategies = new Map<string, LocalAutorouterStrategy>() | ||
|
|
||
| export const getLocalAutorouterStrategy = ( | ||
| preset: NormalizedAutorouterConfig["preset"], | ||
| ): LocalAutorouterStrategy => | ||
| localAutorouterStrategies.get(preset ?? "") ?? defaultLocalAutorouterStrategy |
There was a problem hiding this comment.
The file name localAutorouterStrategies.ts uses camelCase, but the project's convention for utility files is kebab-case (e.g., should-skip-autorouting-because-of-placement-errors.ts, get-bounds-of-pcb-components.ts, getPresetAutoroutingConfig also exists but the dominant pattern in the autorouting directory includes kebab-case files). File names should be consistent with the project's naming conventions. This file should be renamed to local-autorouter-strategies.ts to match the kebab-case pattern used by other utility files in the project (e.g., should-skip-autorouting-because-of-placement-errors.ts). The corresponding test file and import in Group.ts should also be updated accordingly.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
Summary
Group.tsTscircuitAutorouterwith the original SimpleRouteJsonThis is deliberately behavior-neutral. It creates the extension point needed by specialized autorouters without including fanout presets, fanout dependencies, multi-stage routing, or breakout behavior.
Validation
bunx tsc --noEmitgit diff --check