test(language/lint): add unit tests for unused-variable pass#60
Open
dsorajisto wants to merge 1 commit into
Open
test(language/lint): add unit tests for unused-variable pass#60dsorajisto wants to merge 1 commit into
dsorajisto wants to merge 1 commit into
Conversation
Adds 5 unit tests for the unused-variable lint pass in packages/language/src/lint/unused-variable.ts, which flags variables declared in the `variables:` block that are never referenced via `@variables.<name>` expressions elsewhere. Coverage: - Declared-but-unreferenced variable → flagged - Variable referenced in an expression → not flagged - Mixed used/unused → only the unused ones flagged - One diagnostic per unused variable when multiple are unused - No `variables:` block → no diagnostics Follows the same test pattern as required-fields.test.ts (salesforce#38) and empty-block.test.ts (salesforce#48). All tests pass via: pnpm --filter @agentscript/language test unused-variable
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
Adds 5 unit tests for the
unused-variablelint pass inpackages/language/src/lint/unused-variable.ts. Brings the rule's test count from 0 to 5.Why
The
unused-variablerule flags variables declared in thevariables:block that are never referenced via@variables.<name>expressions, but had no tests pinning down its behavior. This closes the gap using the same pattern PRs #38 (required-fields.test.ts) and #48 (empty-block.test.ts) established for single-rule lint tests.How
New test file at
packages/language/src/lint/unused-variable.test.tsusing vitest. Followsempty-block.test.tsexactly: singledescribeblock, flatitcases, sharedgetDiagnosticshelper. The test schema combinesVariablesBlock(for variable declarations) with a small customValueBlockwhoseexpr: ExpressionValuefield provides somewhere for expressions to reference those variables.The 5 cases:
variables:block is declaredTest Plan
Result:
pnpm --filter @agentscript/language test unused-variable— 5/5 passingnpx eslint --config eslint.config.js packages/language/src/lint/unused-variable.test.ts— exit 0Checklist