Skip to content

Fix stale names in the formatter README - #1

Open
lgriffin wants to merge 2 commits into
mainfrom
fix/format-readme-go-names
Open

lgriffin wants to merge 2 commits into
mainfrom
fix/format-readme-go-names

Conversation

@lgriffin

@lgriffin lgriffin commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Requested by Leigh · project thread

Fixes microsoft#64939

AI disclosure: this change was written by Claude Code (an AI coding agent) at the request of @lgriffin, who chose this fix and will review it. The problem was found by running CSH on the repository, and then checked by hand.

Problem

tsc/internal/format/README.md still describes the formatter as it was in the TypeScript 6 code base:

  • It links rules.ts, which does not exist, so the link is broken on GitHub. The rules are in tsc/internal/format/rules.go.
  • It says processPair requests rules "via createRulesMap". The Go port has no such function. processPair calls getRules (span.go), which reads the map that buildRulesMap builds once (rulesmap.go).

The other functions the README names (FormatSpan, processNode, processPair) still exist in api.go and span.go.

Implementation

  • Two edits in tsc/internal/format/README.md. The link now points at rules.go, and the sentence names getRules and buildRulesMap. The file's CRLF line endings are kept.
  • A new test, tsc/internal/format/readme_test.go (TestReadmeMatchesCode), keeps the README from drifting again. It fails if the README links to a relative file that does not exist. It also fails if the README names a backticked identifier that the package neither declares nor uses. Names used from other packages, such as ast.SourceFile, count, and a trailing *, as in Format*, matches a prefix.
  • Renaming buildRulesMap to match the old README was rejected. It would not fix the rules.ts link, and it would break from the Go port's naming.

Tests

  • go test ./internal/format/ passes.
  • With the README from a91e938 restored, TestReadmeMatchesCode fails with exactly the two findings above: the ./rules.ts link and createRulesMap.
  • go vet and gofmt -l are clean for the package.
  • npx hereby test, lint and check:format have not been run yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_012ndbBRjC5MKTRJzMUr4KAy

@lgriffin lgriffin self-assigned this Oct 23, 2026
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix stale Go formatter names in the README

📝 Documentation 🕐 Less than 5 minutes

Grey Divider

AI Description

• Replace the broken rules.ts link with the Go formatter’s rules.go file.
• Describe the existing getRules and buildRulesMap path instead of the obsolete createRulesMap name.
Diagram

graph TD
  P["processPair"] --> G["getRules"] --> M["Cached rule map"]
  R["rules.go"] --> B["buildRulesMap"] --> M
Loading
High-Level Assessment

Correcting the README to match the existing Go implementation is appropriate; changing formatter code to match obsolete documentation would add unnecessary risk.

Files changed (1) +2 / -2

Documentation (1) +2 / -2
README.mdCorrect formatter rule lookup names and link +2/-2

Correct formatter rule lookup names and link

• Replaces the obsolete createRulesMap reference with getRules and the once-built buildRulesMap. Changes the broken rules.ts link to rules.go.

tsc/internal/format/README.md

@lgriffin
lgriffin force-pushed the fix/format-readme-go-names branch from 5eb3e78 to e2f3b8b Compare October 23, 2026 18:13
@lgriffin lgriffin changed the title Fix stale TypeScript 6 names in the formatter README Fix stale names in the formatter README Oct 23, 2026
@lgriffin
lgriffin force-pushed the fix/format-readme-go-names branch from 395cc5a to ad1c799 Compare October 23, 2026 18:27
The formatter README linked rules.ts and said processPair requests rules
via createRulesMap. Neither exists in the Go port: the rules are in
rules.go, and processPair calls getRules, which reads the map
buildRulesMap builds once.

Found with CSH (https://github.com/lgriffin/CSH).
The test fails if README.md links to a file that does not exist, or
mentions a backticked identifier that the package neither declares nor
uses. Against the old README it reports the two stale TypeScript 6
names fixed in the previous commit.
@lgriffin
lgriffin force-pushed the fix/format-readme-go-names branch from ad1c799 to 7df966e Compare October 23, 2026 18:29
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.

Formatter README links rules.ts and names createRulesMap, which the Go port does not have

1 participant