fix(lint): require single to target on transition statement#62
Merged
Conversation
Adds `transitionTargetPass` enforcing SPEC §5.10: a `transition` statement must have exactly one `to <target>` clause. - Bare `transition` (no target) was silently accepted. - Multiple `to` clauses (`transition to @A, to @b`) were silently accepted. Both now produce ERROR diagnostics with stable codes `transition-missing-target` and `transition-multiple-targets` and spec-referenced messages. Fixtures cover the bare form, `with`-only, missing-`to` typo, and multi-target cases.
The four finding-*.agent fixtures were not referenced by any test — inline source strings in transition-target.test.ts already cover all cases, matching the pattern used by every other lint pass in the repo.
Match the existing convention — no other lint pass cites SPEC § in its user-facing message.
attachDiagnostic expects AstNodeLike; TransitionStatement does not widen automatically, so the guard is load-bearing for the type check even though the runtime invariant is already established by enterNode.
setu4993
approved these changes
Jun 15, 2026
Comment on lines
+20
to
+25
| const MISSING_TARGET_MESSAGE = | ||
| "'transition' requires a target. Use 'transition to <target>'."; | ||
|
|
||
| const MULTIPLE_TARGETS_MESSAGE = | ||
| "'transition' accepts a single 'to' target. " + | ||
| "Multiple 'to' clauses are not allowed."; |
Member
There was a problem hiding this comment.
These just get used here, so weird to have them defined as constants.
Contributor
Author
There was a problem hiding this comment.
java habbit :)
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.
Summary
Adds a new lint pass
transitionTargetPassenforcing SPEC §5.10: atransitionstatement must have exactly oneto <target>clause.Two silent acceptance bugs are fixed:
transitionwith no target — currently parsed and compiled with zero diagnostics.toclauses on a single transition (e.g.transition to @a, to @b) — silently accepted; only one target is meaningful.Both now produce ERROR diagnostics with stable codes
transition-missing-targetandtransition-multiple-targetsand spec-referenced messages. The missing-target diagnostic range is narrowed to thetransitionkeyword token so the squiggle points at the actual problem.Test plan
packages/language/src/lint/transition-target.test.ts(5 cases: valid form, bare, two-target, three-target, validto ... with k=v)pnpm --filter @agentscript/language test→ 192/192 passingpnpm --filter @agentscript/compiler test— no new regressions (pre-existing failures onmainare unrelated to this change)