Skip to content

ci(lint): reject duplicate webhook switch cases - #1648

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
huong8373tt-beep:ci/836-switch-and-truncation
Nov 1, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
huong8373tt-beep:ci/836-switch-and-truncation

Conversation

@huong8373tt-beep

@huong8373tt-beep huong8373tt-beep commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is one small anti-slop follow-up under #836, combining two genuine diagnostics in the same cleanup class:

  • enable unicorn/no-useless-switch-case and remove the redundant case 'json' in webhook formatting—the default branch already formats generic JSON payloads;
  • enable unicorn/prefer-array-index-of and replace a predicate-only equality findIndex() with indexOf() in the git-exclude fixture helper.

Both rules are currently outside the enabled categories, and each probe identified exactly one safe diagnostic in the tree. This is not a repeat of a category-default rule.

Related to #836.

Rule probes

unicorn/no-useless-switch-case
  src/webhook.ts:130: redundant case 'json' before default

unicorn/prefer-array-index-of
  src/__tests__/e2e/git-exclude-uninstall-915.test.ts:182
  equality-only findIndex() -> indexOf()

After the changes, the full type-aware lint pass reports 0 warnings / 0 errors.

Verification

npx oxlint --type-aware --deny-warnings --report-unused-disable-directives src oxlint-plugin-teamai
  0 warnings / 0 errors
npx vitest run src/__tests__/webhook.test.ts src/__tests__/webhook-formatters.test.ts
  28 passed
npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/git-exclude-uninstall-915.test.ts
  suite skipped by its existing E2E gate on this host
npm run typecheck
  passed
npm run build
  passed
node dist/index.js --version
  0.22.0
node dist/index.js webhook test --help
  exit 0
git diff --check
  passed

npm run lint completed its Oxlint phase with 0 warnings / 0 errors. Its following repository documentation verifier reports existing generated-doc/workflow example drift unrelated to these files.

Slai Agent Runtime performed the investigation, implementation, and verification. The account owner authorized this contribution and is responsible for its content.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing real-CLI verification of webhook formatting — src/webhook.ts:130: The recorded --version and webhook test --help runs do not exercise the changed formatter. The Code Review Rules require end-to-end / real-CLI verification when runtime code is touched. Record one real webhook invocation using generic JSON and verify its output; no provider × agent matrix is required.

No other findings in the specified diff.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the P1 with a real built-CLI webhook invocation (generic JSON endpoint; no provider × agent matrix needed). Using head 025ddb68 after npm run build, I started a local HTTP receiver and ran node dist/index.js webhook test with a temporary HOME/team config pointing to it.

Observed:

npm run build                         passed
teamai webhook test                   exit 0
Webhook test successful: http://127.0.0.1:<ephemeral-port>/hook
Content-Type                            application/json
payload.event                           webhook-test
payload.tool                            teamai-cli
payload.data.message                   This is a test webhook from TeamAI CLI

The receiver returned 200 and verified the parsed JSON payload and content type. The verification harness was temporary and was not added to the PR. This directly exercises the changed generic JSON formatter through the built CLI.

The Node 24 Ubuntu check currently has one unrelated flaky concurrency assertion in src/__tests__/workflow-local-driver.test.ts (retryStep received busy); the same suite passes on Node 20/22 and macOS Node 20/22/24. No source change is needed for that environment failure.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified on latest main (4ea4bf2): merges cleanly; tsc / lint / build pass; webhook unit tests 28/28. Probe on main: each of the two rules fires exactly once (src/webhook.ts redundant case 'json', git-exclude test findIndex). Real CLI: built CLI with a team repo whose sharing.webhooks has one type: json endpoint; teamai webhook test exits 0 and the receiver gets application/json {event: webhook-test, ...}, same payload as main. The Node 24 ubuntu failure was the flaky workflow-local-driver concurrency case; it passed on rerun. Approving.

@jeff-r2026
jeff-r2026 merged commit 6ef00e8 into Tencent:main Nov 1, 2026
33 of 34 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
* ci(lint): reject duplicate webhook switch cases

* ci(lint): prefer direct array value lookup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants