Add linting for RRI URL construction - #5847
Draft
backspace wants to merge 2 commits into
Draft
Conversation
`RealmIdentifier` and `RealmResourceIdentifier` are branded strings, so `new URL(identifier)` typechecks and throws only at runtime, and only for the canonical form. Nothing in the repo can currently see that: the compiler is structurally blind to it, and no package lints with type information, so a type-aware ESLint rule has nowhere to run yet. This asks the question directly through the TypeScript API instead — walking a program's types for `new URL(x)` where x's type carries either brand — so the inventory is available without changing how anything is linted. Reports 19 sites across runtime-common, base and host. Two caveats for whoever triages them: roughly half are test fixtures passing a branded constant that happens to be URL-shaped, and `.gts` files are invisible here because a raw TypeScript program cannot parse them, so host component coverage is partial. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The realm-identifier types are branded strings, so `new URL(identifier)` typechecks and throws only at runtime, and only for the canonical prefix form. The compiler is structurally unable to flag it, which is why the same defect has recurred: two sites fixed in May were broken again by August, and a one-step canonicalization later failed every host shard on it. The brand is a type, so a rule with type information can see what the compiler permits. This asks whether an argument's type carries either brand, walking intersections and unions, and points at the alternatives rather than only refusing. Reads parser services directly rather than taking a dependency on `@typescript-eslint/utils`, and returns no visitors when type information is absent — so the rule is inert rather than wrong wherever a config has no `parserOptions.project`, and can be adopted per package. Turned on for runtime-common, the first package here to lint with type information. It reports six existing sites as warnings; they need triage into genuine network boundaries and parses that should never have happened, and the rule goes to error once that list is empty. Type information costs this package's lint roughly five seconds (4s to 9s), which is why the scope is one package rather than the repo. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
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.
If this can’t work in
hostthough it might not be worth it.