Repository navigation
chore(lint): fail CI on new lint errors in packages, with a baseline - #8172
Merged
Merged
Conversation
… type-aware lint Fixes every hit of no-floating-promises, no-misused-promises, await-thenable, switch-exhaustiveness-check and only-throw-error in package source so those rules can start as errors with no baseline. Runtime behavior is unchanged: intended fire-and-forget calls are marked with void, switches name their missing members, and non-Error throws are wrapped with the original value as cause. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pure compare logic for the upcoming lint gate: rule -> file -> count, over-baseline and stale detection, prune that never raises a count, and a staged-files mode that skips the stale check. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Flags empty catch blocks and empty .catch()/.then() rejection handlers. A comment inside the handler marks the ignore as intentional. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
oxlint-disable and eslint-disable directives must say why, using the '-- reason' suffix oxlint already understands. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ignores showcase, examples, codemods, tools and the non-JS packages so a single knip run fits in memory, and maps package entries back to source. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
pnpm lint now runs oxlint twice (a plain pass over the repo and a type-aware pass over packages, via the newly pinned oxlint-tsgolint), merges the results, and fails only on errors that go past the checked-in baseline or on stale baseline entries. pnpm lint:dead-code does the same for knip. Both have prune and baseline commands, and a file-list mode for the pre-commit hook. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The move to Bundler module resolution (#8167) typed imports that used to resolve to any, and type-checking angular and vue for lint did the same. That surfaced floating promises, async callbacks passed where void is expected, and non-exhaustive switches in runtime, react-core, shared, angular and vue. Same fix style as the previous commit, no behavior change. ChatState.submitInput and selectSuggestion in angular may now return a promise, matching finishTranscription. Also sets rootDir in the angular tsconfig and drops baseUrl from the vue tsconfig so tsgolint can load them; check-types and build stay green. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
no-explicit-any, the type-aware promise and assertion rules, ban-ts-comment, and the two copilotkit rules are now errors in packages/ source (tests excluded). The 928 existing hits are recorded in .lint-baseline/oxlint.json, so the gate starts green and only shrinks. no-unnecessary-type-assertion moves out of the global rules, where it never ran because CI was not type-aware. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
68 findings (unused devDependencies, exports, types, files and unlisted jsdom) are baselined. phoenix is ignored where tests only use it through vi.mock. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The oxlint job builds packages first, because the type-aware pass needs dist/ to type imports across packages, and runs the gate. A new knip job runs pnpm lint:dead-code. The pre-commit hook runs the gate on staged files with --fix, so files that only carry baselined errors still commit. The hook also now exits on a lint failure: before, the trailing ruff loop set the script's exit status, so lint errors never blocked a commit. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
dev-docs/static-analysis.md covers fixing a failing check, pruning a stale baseline and the pre-commit hook. dev-docs/static-analysis-rules.md covers changing rules, adding a custom rule and tuning knip. AGENTS.md and CLAUDE.md list the banned patterns, and CONTRIBUTING.md links the guide. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
#6761 moved web-inspector out of its single index.ts into domain modules, so the earlier fixes and baseline entries pointed at old paths. This re-applies the exhaustive-switch and void-callback fixes at the new locations and moves the existing baselined errors to the new files. No new error is allowed: the oxlint baseline drops from 928 to 924, and knip moves from 68 to 69 only because the split itself left an unused file. Refs PE-1069 Co-Authored-By: Claude Opus 5.5 <[email protected]>
AlemTuzlak
requested review from
jpr5,
mme,
rainerhahnekamp,
tylerslaton and
wolfmanfx
as code owners
November 3, 2026 16:48
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/markdown
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/runtime
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
Contributor
|
Size Change: +1.27 kB (+0.06%) Total Size: 2.21 MB 📦 View Changed
ℹ️ View Unchanged
|
…start The page came into 2.0.0 from main and still imported @copilotkit/react-core/v2 and @copilotkit/runtime/v2, which #8084 removed. Use the root entry points and CopilotKitProvider, and drop the stylesheet import, so check-docs-snippets passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Production Digest-Pinning AuditAll 43 services digest-pinned. Run 2026-11-04 01:33:50 PST — 0 finding(s). |
…s browser test The test read the live notification feed. An unread post renamed the launcher to "Web Inspector, What's new unread", so the exact-name click timed out on 2.0.0. Stub the feed with an empty list, as the other browser tests do. The Learning error signal also opens the inspector on Automatic Learning, and the workbench toolbar covers the sidebar Home button. Reach Home by keyboard before checking the Home Learning row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-static-analysis # Conflicts: # packages/web-inspector/dev/learning-status.browser.ts
AlemTuzlak
added a commit
that referenced
this pull request
Nov 4, 2026
Brings in the lint gate (#8172), the inspector feed fixture (#8187) and the CI checkout fix (#8198). The Angular copy buttons keep the stack's core copy feedback, which already voids its promise. Core lists jsdom as a devDependency, so knip no longer flags its jsdom tests as unlisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 of 4 tasks
AlemTuzlak
added a commit
that referenced
this pull request
Nov 4, 2026
…ze in packages (#8200) Next step for a maintainer: make the `oxlint` and `knip` jobs of the `static / quality` workflow required checks for `2.0.0`. This PR does not change branch protection. The lint gate in `packages/` source now fails on unsafe `as` casts, dead branches, files with more than 800 lines of code, and every other rule in the oxlint `correctness` and `suspicious` categories. Before this PR, those rules only gave warnings. Old hits are in the baselines, so only new errors fail CI. ## What does this PR do? `2.0.0` already had most of PE-1069 from #8172: type-aware oxlint, `no-explicit-any`, `no-swallowed-error`, knip, and a baseline. This PR closes the remaining gaps: 1. **Correctness and suspicious rules are errors.** An oxlint override cannot set a category, so `.oxlintrc.json` lists all 186 rules by name. It sets them to `error` for package source and back to `warn` for tests. The new `scripts/__tests__/lint-category-rules.test.ts` fails when an oxlint upgrade adds a rule that the list does not have. 2. **Dead branches and oversized modules are errors.** `typescript/no-unnecessary-condition` changes from `warn` to `error`. `eslint/max-lines` is `error` at 800 lines of code (blank lines and comments are not counted). 3. **knip finds more.** It now also reports `duplicates` (one value exported under two names) and `enumMembers`. The gate counts each duplicate group as one finding. 4. **CI.** The `oxlint` job runs the gate unit tests. No job ran them before. The workflow also runs on pushes to release lines such as `2.0.0`. PRs into `2.0.0` already ran it. 5. **Real fixes, not baselined.** About 64 hits are fixed in source, with no behavior change: 45 type arguments that equal the default, 16 unused imports or bindings, 2 `void` operators on calls that return `void`, and one dead function (`setRecallQuery`). `unicorn/no-useless-spread` is now `off`. All 11 of its hits are `for (const listener of [...listeners])`. That copy is on purpose, because a listener can unsubscribe while the loop runs. Its fix would remove the copy and cause a bug. ### Baseline size per package The baselines record counts of allowed errors for each rule and file. A count can only go down (`pnpm lint:prune`). | Package | oxlint before | oxlint after | knip before | knip after | | --- | --- | --- | --- | --- | | `runtime` | 99 | 928 | 15 | 15 | | `react-core` | 115 | 317 | 22 | 41 | | `core` | 71 | 301 | 1 | 1 | | `angular` | 181 | 257 | 4 | 4 | | `a2ui-renderer` | 30 | 187 | 5 | 7 | | `web-inspector` | 16 | 186 | 6 | 6 | | `channels-core` | 52 | 182 | 0 | 0 | | `channels-slack` | 25 | 177 | 0 | 0 | | `markdown` | 54 | 129 | 0 | 0 | | `sdk-js` | 43 | 110 | 6 | 6 | | `shared` | 41 | 103 | 1 | 3 | | `channels-teams` | 9 | 96 | 0 | 0 | | `channels-discord` | 18 | 90 | 0 | 0 | | `vue` | 15 | 80 | 3 | 4 | | `channels-intelligence` | 13 | 73 | 0 | 0 | | `react-native` | 24 | 54 | 1 | 1 | | `channels-whatsapp` | 8 | 39 | 0 | 0 | | `learning` | 2 | 26 | 0 | 0 | | `web-components` | 7 | 22 | 1 | 1 | | `mcp-apps-renderer` | 7 | 19 | 1 | 1 | | `channels-ui` | 1 | 18 | 2 | 3 | | `sqlite-runner` | 3 | 14 | 0 | 0 | | `intelligence-langgraph` | 3 | 14 | 0 | 0 | | `intelligence-mastra` | 2 | 6 | 0 | 0 | | `agentcore-runner` | 1 | 3 | 0 | 0 | | `voice` | 0 | 1 | 0 | 0 | | **Total** | **840** | **3,432** | **68** | **93** | The new oxlint entries by rule. The largest are: - `no-unnecessary-condition` (dead branches): 1,128 - `no-unsafe-type-assertion`: 952 - `no-unnecessary-boolean-literal-compare`: 181 - `no-base-to-string`: 91 - `max-lines`: 30 files The knip additions are 24 `duplicates` and 1 `enumMembers`. Most duplicates are React components exported both by name and as `default`. Old baseline entries did not change. ## Related PRs and Issues - Linear PE-1069 - Builds on #8172 ## Checklist - [ ] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [x] If the PR changes or adds functionality, I have updated the relevant documentation (`dev-docs/static-analysis.md`, `dev-docs/static-analysis-rules.md`) - [ ] If the PR contains a breaking change, the title has `!` and the description has a `BREAKING CHANGE:` line. Not applicable: no breaking change. - [ ] "Allow edits by maintainers" is checked ## Testing **Commands run** - `pnpm lint`: OK, 3,432 errors, all within the baseline. Run after `pnpm build`. - `pnpm lint:dead-code`: OK, 93 errors, all within the baseline. - `pnpm exec vitest run scripts/__tests__/lint-{gate,baseline,category-rules}.test.ts`: 41 passed. I also removed one rule from the list by hand, and the drift test failed and named it. - `nx run-many -t check-types` for the 8 packages with source changes: passed. - `nx affected -t lint,check-types,test --base=origin/2.0.0`: 36 projects. 8 tasks failed. None of the failures come from this branch: - `react-native:test` (`CopilotChatInterrupt.test.tsx`, an `Animated` mock error): the same failure occurs with the `origin/2.0.0` source. - `react-core:test` (2 chart tests): these pass alone, with both this branch and the `origin/2.0.0` source. They fail only under parallel load. - `vue:lint`: ESLint errors in files that this PR does not change, most of them in tests. - `runtime:test` (an MCP integration test timed out after 5 s), `genui-eval:test` (`@copilotkit/shared` was being rebuilt at the same time), `showcase-angular-host:test` (Nx marked it flaky): this PR does not change these projects' source. - `next-pages-router:lint`: `next lint` stops at an interactive prompt. - `react-native-demo:test`: a Jest ESM setup error. **Manual test** 1. Add `const x = value as unknown as string;` to any file in `packages/core/src/`. 2. Run `pnpm lint -- <that file>`. 3. Make sure that the gate fails with `no-unsafe-type-assertion` and names the line. **How this PR makes testing easy** - `scripts/__tests__/lint-category-rules.test.ts` keeps the rule list in sync with oxlint. - `scripts/__tests__/lint-gate.test.ts` now covers the knip `duplicates` and `enumMembers` shapes. ## Risk / rollback - A PR that adds a new hit of these rules in `packages/` source now fails `oxlint`. Fix it, or add a disable comment with a reason. The fix table is in `dev-docs/static-analysis.md`. - `no-unnecessary-condition` is in the oxlint `nursery` category. An oxlint upgrade can change its counts. If that happens, run `pnpm lint:baseline` in the upgrade PR. - For `max-lines`, the baseline holds one count per file. A file that is already over 800 lines can grow more without a failure. - Rollback: revert the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Run
pnpm lintandpnpm lint:dead-code. With this PR, CI fails when a change adds a new lint error inpackages/source. Old errors are recorded in.lint-baseline/, so the check starts green and the baseline can only get smaller.Before this PR, lint blocked nothing. Every rule was a warning, CI was not type-aware, and the pre-commit hook did not fail on lint errors.
What does this PR do?
scripts/lint/gate.tsruns oxlint or knip and compares the errors per rule and per file with.lint-baseline/. It fails on a higher count, a new file, or a stale entry.pnpm lint:pruneonly lowers counts.no-explicit-any,require-await,no-unnecessary-type-assertion, andban-ts-comment(a reason is required).tools/oxlint-rules/:copilotkit/no-swallowed-error(emptycatch {}and.catch(() => {})) andcopilotkit/require-disable-reason(a disable comment needs-- reason).oxlint-tsgolint7.0.2005, and knip 5.88.1, both pinned exactly.oxlintjob builds packages first, because the type-aware pass needsdist/. A newknipjob runspnpm lint:dead-code. The pre-commit hook runs the gate on the staged files./v2subpaths, socheck-docs-snippetswas red on2.0.0. It now uses the root entry points andCopilotKitProvider.dev-docs/static-analysis.md(fix a failing check),dev-docs/static-analysis-rules.md(change the rules), and a short section inAGENTS.mdandCLAUDE.md.The baselines today: 924 oxlint errors (490 of them
any) and 69 knip findings.Related PRs and Issues
Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.md (not applicable: no breaking change)Testing
Commands run
pnpm lint: OK, 924 errors, all in the baseline (about 7 s).pnpm lint:dead-code: OK, 69 findings, all in the baseline (about 9 s).pnpm exec vitest run tools/oxlint-rules scripts/__tests__/lint-gate.test.ts scripts/__tests__/lint-baseline.test.ts: 102 tests pass.pnpm nx run repo-scripts:check-docs-snippets: 1615 snippets pass.pnpm exec playwright test --config dev/playwright.config.tsinpackages/web-inspector): 23 tests pass after the merge of2.0.0.check-typesandtestpass for every package with source changes, run per package with Nx.test-packagespre-commit hook. The machine load was above 180, so tests timed out. I ran the same suites by hand, and they pass.oxlintandknipjobs.Manual test
export const probe: any = 1;topackages/core/src/index.ts.pnpm lint. It fails and namestypescript-eslint(no-explicit-any): 1 (allowed 0)for that file.git commit. The hook blocks the commit with the same error.any, remove oneany.pnpm lint. It fails because the baseline is stale. Runpnpm lint:prune, thenpnpm lint. It passes.How this PR makes testing easy
pnpm lintandpnpm lint:dead-code. They are the same commands that CI runs.Risk / rollback
oxlintjob now builds all packages. Its timeout goes from 10 to 25 minutes. The 25 minutes is an estimate, not a measured value.packages/must move the baseline entries too. Runpnpm lint:baselineafter a rebase like this, and make sure that the diff shows only moved entries.oxlintandknipto the branch protection for2.0.0..oxlintrc.jsonandstatic_quality.ymlalso works.Public API change
In
@copilotkit/angular,ChatState.submitInputandChatState.selectSuggestioncan now return a promise, the same asfinishTranscription. Code that calls them does not change. Callers can now await the result.Before
After
🤖 Generated with Claude Code