feat(lint): add bun:test expect-expect oxlint plugin#373
Merged
Conversation
oxlint ships `jest/expect-expect`, but its Rust implementation only recognizes `jest`/`vitest` imports and silently ignores `bun:test`, so assertion-less tests passed silently and accumulated over time. Adds a custom oxlint JS plugin (`lint/expect-expect.ts`, rule `bun-test/expect-expect`) registered via `jsPlugins` in `.oxlintrc.json` and scoped to `tests/**/*.test.ts`. It fails the build for any runnable `test()`/`it()` (incl. `test.skipIf(...)()`, `test.each(...)()`) whose body contains no `expect()` call, while ignoring `test.skip`/`test.todo`. Also fixes the 44 pre-existing assertion-less smoke tests it surfaced by making their implicit "does not throw" contracts explicit, and documents the new convention in ARCH-005. Closes #353 Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
8b12e7a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://784c375a.archgate-cli.pages.dev |
| Branch Preview URL: | https://claude-blissful-feynman-5abd.archgate-cli.pages.dev |
…an-5abd24 Signed-off-by: Rhuan Barreto <rhuan@barreto.work> # Conflicts: # .archgate/adrs/ARCH-005-testing-standards.md # .claude/agent-memory/archgate-developer/MEMORY.md
Contributor
Code Coverage
Full HTML report available in workflow artifacts. Per-directory breakdown
|
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
Tests with no
expect()calls silently pass and give false confidence. oxlint shipsjest/expect-expect, but its Rust implementation only recognizesjest/vitestimports and silently ignoresbun:test— so assertion-less tests accumulated over time (discovered in #352).This PR adds a custom oxlint JS plugin that implements
expect-expectforbun:test, wires it up, and fixes the violations it surfaces.Closes #353.
What changed
lint/expect-expect.tsbun-test/expect-expect). Plain TypeScript, runs natively under Bun — no build step..oxlintrc.jsonjsPlugins; enable the rule (error) scoped totests/**/*.test.ts.tests/helpers/{telemetry,sentry,auth,credential-store-impl,platform,git}.test.ts.archgate/adrs/ARCH-005-testing-standards.mdHow the rule works
Flags any runnable
test()/it()call whose body contains noexpect():test(),it(),test.only(...),test.skipIf(cond)(...),test.each(rows)(...), etc. — it resolves the leftmost callee identifier (test/it) through member/call chains.test.skipandtest.todo(intentional placeholders), per the rule's own guidance.test.skipIf(cond)call (only the outermost invocation carrying the callback is checked).Fixing the 44 violations
Rather than add tautological assertions, the implicit "does not throw" contract is made explicit:
expect(() => fn()).not.toThrow()await expect(promise).resolves.toBeUndefined()git.test.ts(which previously asserted nothing and even documented that it didn't) is turned into a real test by stubbingBun.spawn/Bun.whichsoinstallGit()reaches its.rejects.toThrowpath.Reviewer notes
lint/is intentionally outsidetsconfig.jsonincludeandknip.jsonproject, but is linted byoxlint --deny-warnings ., so the plugin file passes all oxlint rules itself..oxlintrc.jsonjsPluginsfeature loads the plugin top-level; the rule is enabled only in thetests/**/*.test.tsoverride.Test plan
bun run lint— 0 errors (rule active; manually verified it fires on empty tests and ignores asserting/test.skipones)bun run typecheck/bun run build:check/bun run format:checkbun run test— 1212 pass, 0 failarchgate check— 31/31 ADR rules pass