Skip to content

test(language/lint): add unit tests for empty-block pass - #48

Merged
awli merged 1 commit into
salesforce:mainfrom
dsorajisto:test-empty-block-lint-pass
Jun 10, 2026
Merged

awli merged 1 commit into
salesforce:mainfrom
dsorajisto:test-empty-block-lint-pass

Conversation

@dsorajisto

Copy link
Copy Markdown
Contributor

What

Adds 5 unit tests for the empty-block lint pass in packages/language/src/lint/empty-block.ts. Brings the rule's test count from 0 to 5.

Why

The empty-block rule flags empty inputs: and outputs: blocks (a common authoring mistake) but had no tests pinning down its behavior. This change closes the gap using the same pattern PR #38 (required-fields.test.ts) established for lint-rule tests.

How

New test file at packages/language/src/lint/empty-block.test.ts using vitest. Follows required-fields.test.ts exactly: single describe block, flat it cases, shared getDiagnostics helper, ActionsBlock-based test schema.

The 5 cases:

  1. Flags a bare inputs: with no entries
  2. Does not flag a populated inputs: block
  3. Flags a bare outputs: with no entries
  4. Reports two diagnostics when both inputs: and outputs: are empty
  5. Reports one diagnostic per action when multiple actions have empty blocks

Test Plan

pnpm --filter @agentscript/language test empty-block

Result:

✓ src/lint/empty-block.test.ts (5 tests) 11ms
Test Files  1 passed (1)
     Tests  5 passed (5)
  • pnpm --filter @agentscript/language test empty-block — 5/5 passing
  • npx eslint --config eslint.config.js packages/language/src/lint/empty-block.test.ts — exit 0
  • New/updated tests cover the change — N/A (this PR is the tests)

Checklist

  • My code follows the project's coding style
  • I have reviewed my own diff
  • I have added/updated documentation as needed
  • This change does not introduce new warnings

Adds 5 unit tests for the empty-block lint pass in
packages/language/src/lint/empty-block.ts, which flags `inputs:`
or `outputs:` blocks that have no entries.

Coverage:
- Bare `inputs:` and `outputs:` (null-ish value) → flagged
- Populated blocks → not flagged
- Both blocks empty → two diagnostics
- Multiple actions → one diagnostic per affected action

Follows the same test pattern as required-fields.test.ts (salesforce#38).

All tests pass via:

    pnpm --filter @agentscript/language test empty-block

@awli awli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@awli
awli merged commit ff05329 into salesforce:main Jun 10, 2026
6 checks passed
setu4993 pushed a commit that referenced this pull request Sep 3, 2026
Adds 5 unit tests for the unreachable-code lint pass in
packages/language/src/lint/unreachable-code.ts, which detects code
that follows a terminal statement (transition, or an if/else where
all branches transition).

Coverage:
- Code after a transition → flagged
- Procedure ending in a transition → not flagged
- Code after a fully-transitioning if/else → flagged
- Code after a half-transitioning if/else → not flagged
- Unreachable code inside a nested if body → flagged

Follows the same test pattern as required-fields.test.ts (#38),
empty-block.test.ts (#48), and unused-variable.test.ts (#60).

All tests pass via:

    pnpm --filter @agentscript/language test unreachable-code
dsorajisto added a commit to dsorajisto/agentscript that referenced this pull request Oct 18, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants