Repository navigation
refactor(scripts): walk the AST with estree-walker in arch-lint - #561
Merged
Merged
Conversation
arch-lint.ts walked the oxc-parser tree with a hand-rolled recursive generator, nodesOf, that descended every object and array for anything carrying a string `type`. estree-walker, already a declared devDependency, does that walk: it ducktypes children by their `type` field, so oxc's TypeScript nodes walk like the ESTree ones. Only its estree-typed signature needs a cast, at the one call. The differential check ran the old walk, importSpecifiers, and lintArchitecture against the new over every .ts file under src/, test/, and .github/scripts/ (536 files, 584,305 nodes in visit order) and over 5,000 seeded generated modules covering every import form the tests list, in nested positions, with computed specifiers and non-parsing files. Node sequences, specifier lists, and refusal messages were identical throughout. lintArchitecture gives the same empty verdict on the repository, and the same single forbidden-import line on a scratch copy of src/ with an undeclared text -> problem import injected.
Contributor
File size check0 over a hard cap (fails), 6 warning(s).
Split the file, wrap the line, shorten or exempt the comment, or list the path in 5 managed file(s) skipped; repo-platform owns them. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactor has no identified blocking defects, with existing coverage and reported differential checks supporting behavior preservation.
No open issues 🎉
What changed in this PR
Replaces arch-lint's custom recursive AST traversal with estree-walker, simplifying import analysis without changing its intended behavior.
Changes:
- Adds a typed adapter between oxc-parser nodes and
estree-walker. - Converts import collection to a visit callback, preserving filtering and refusal messages.
| File | Description |
|---|---|
.github/scripts/arch-lint.ts |
Replaces nodesOf with the eachNode adapter and updates import collection. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
How
walk()is typed to estree's Node with no generic, so the oxc program crosses that boundary with one cast, the pattern refusal-messages.test.ts already uses.importSpecifierspasses its body as the visit callback; every thrown message is unchanged.estree-walker3.0.3, already a declared devDependency, covers the walk.Proof
bun run lint:archgives the same verdict.Technical details
isModuleLoad's switch into handler keys..github/scripts/arch-lint.ts.