Repository navigation
fix(repo): un-skip three lint gates and guard against the shape - #364
Conversation
✅ Deploy Preview for lunorash ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (6)
📒 Files selected for processing (8)
WalkthroughChangesThe pull request adds project target validation to the lint workflow, removes obsolete package lint targets, adds targeted ESLint suppressions, and reorganizes database package code without changing documented runtime behavior. Lint validation and remediation
Database code maintenance
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for confirming the Contributor License Agreement! 🙏 |
|
Thank you for following the naming conventions! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/db/src/apply-plan.ts`:
- Around line 179-182: Update the insert handling in applyPlanToCollections to
validate a present entry.row._id before calling db.insert: reject any non-string
value, including null, instead of silently omitting it. Pass clientId only when
_id is absent or a valid string, preserving the existing insert behavior for
valid rows.
- Around line 179-182: Update the insert call in the apply-plan loop to avoid
spreading the conditional array. Branch on whether clientId is a string and call
db.insert with the client-id option only in that branch; otherwise call it with
just the table and body arguments, preserving the existing behavior.
In `@scripts/check-project-json-targets.js`:
- Around line 61-71: Update the project-manifest validation loop around
projectFiles and its later success summary to fail closed: track unreadable or
malformed manifests, validate that the parsed value is a non-null object before
accessing manifest.targets, and treat missing manifests as errors rather than
successful candidates. Ensure any such error causes a non-zero exit before
printing the success summary, including the corresponding logic referenced near
the later validation block.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d8839261-286e-4883-bd12-cb098178b747
⛔ Files ignored due to path filters (22)
package.jsonis excluded by none and included by nonepackages/ai/__tests__/build-provider.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/ai/__tests__/create-ai.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/ai/__tests__/gateway.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/ai/__tests__/rag-primitives.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/ai/__tests__/rag.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/db/__tests__/apply-plan.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/db/__tests__/define-mutators.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/adapters.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/apply-diff-canonical.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/apply-diff.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/core.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/dsl.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/event-log-append-atomicity.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/event-log-do-client.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/event-log-do.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/events-context.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/integration.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/local-core.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/react.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/runtime-edges.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/replica/__tests__/sync-events.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**
📒 Files selected for processing (13)
.github/file-filters.yml.github/workflows/lint.ymlpackages/ai/project.jsonpackages/db/project.jsonpackages/db/src/apply-plan.tspackages/db/src/collection-options.tspackages/db/src/define-mutators.tspackages/replica/project.jsonpackages/replica/src/define-materializer.tspackages/replica/src/event-log-do.tspackages/replica/src/event-source.tspackages/replica/src/sync-events.tsscripts/check-project-json-targets.js
| const { _id: clientId, ...body } = entry.row; | ||
|
|
||
| // eslint-disable-next-line no-await-in-loop -- see above | ||
| await db.insert(entry.table as never, body, ...(typeof _id === "string" ? [{ clientId: _id }] : [])); | ||
| await db.insert(entry.table as never, body, ...(typeof clientId === "string" ? [{ clientId }] : [])); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reject a non-string _id instead of silently dropping it.
applyPlanToCollections rejects an insert whose _id is not a string at Lines 146-149. This database path removes every _id and forwards only string values. A row with _id: 42 or _id: null is therefore inserted without clientId, which can create a different persisted identity. Validate a present _id before the insert. Omit clientId only when _id is absent.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/db/src/apply-plan.ts` around lines 179 - 182, Update the insert
handling in applyPlanToCollections to validate a present entry.row._id before
calling db.insert: reject any non-string value, including null, instead of
silently omitting it. Pass clientId only when _id is absent or a valid string,
preserving the existing insert behavior for valid rows.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 5 'interface PlanWriter|await db\.insert' packages/db/src/apply-plan.ts
pnpm run lint:affected:typesRepository: anolilab/lunora
Length of output: 14889
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== tsconfig references =="
fd -a 'tsconfig.*json' . | sed 's#^\./##' | head -80
echo
echo "== apply-plan surrounding =="
sed -n '1,230p' packages/db/src/apply-plan.ts
echo
echo "== tsconfig apply-plan relevant =="
rg -n '"files"|"include"|"compilerOptions"|"strict"|"noImplicitThis"|"alwaysStrict"|"moduleResolution"|"rootDir"' -S tsconfig*.json 2>/dev/null | head -120
echo
echo "== standalone type probe =="
tmp="$(mktemp -d)"
cat > "$tmp/probe.ts" <<'TS'
interface PlanWriter {
insert: (tableName: never, document: Record<string, unknown>, options?: { clientId?: string }) => Promise<unknown>;
}
declare function apply(db: PlanWriter): Promise<void>;
async function f(db: PlanWriter) {
const clientId: string | undefined = "x";
await db.insert("t" as never, {} as Record<string, unknown>, ...(typeof clientId === "string" ? [{ clientId }] : []));
}
TS
# Use the repository node_modules TypeScript if available; otherwise print unavailable.
if [ -x node_modules/.bin/tsc ]; then
node_modules/.bin/tsc --strict --noEmit --lib esnext --target esnext "$tmp/probe.ts"
status=$?
echo "tsc status=$status"
else
echo "node_modules/.bin/tsc unavailable"
fi
rm -rf "$tmp"Repository: anolilab/lunora
Length of output: 4236
🏁 Script executed:
#!/usr/bin/env bash
set -u
echo "== apply-plan.ts relevant section =="
sed -n '1,240p' packages/db/src/apply-plan.ts
echo
echo "== packages/db/tsconfig.json =="
cat -n packages/db/tsconfig.json
echo
echo "== package scripts relevant =="
python3 - <<'PY'
import json
from pathlib import Path
for p in [Path("package.json"), Path("packages/db/package.json")]:
if p.exists():
data=json.load(open(p))
print(f"-- {p}")
for k,v in data.get("scripts",{}).items():
if "lint" in k or "affected" in k:
print(f"{k}: {v}")
PY
echo
echo "== standalone TypeScript probe =="
tmp="$(mktemp -d)"
cat > "$tmp/probe.ts" <<'TS'
interface PlanWriter {
insert: (tableName: never, document: Record<string, unknown>, options?: { clientId?: string }) => Promise<unknown>;
}
function apply(db: PlanWriter): void {
const clientId: string | undefined = "x";
const body: Record<string, unknown> = {};
const entry = { table: "t" as never, row: { _id: clientId, body } };
void applyPlanToDb([{ entry }], db);
}
function applyPlanToDb(inserts: {entry: {table: never; row: { clientId?: string; body: Record<string, unknown>}}}[], db: PlanWriter): void {
for (const { entry } of inserts) {
const { _id: clientId, ...body } = entry.row;
void db.insert(entry.table, body, ...(typeof clientId === "string" ? [{ clientId }] : []));
}
}
TS
if [ -x node_modules/.bin/tsc ]; then
node_modules/.bin/tsc --strict --noEmit --lib esnext --target esnext "$tmp/probe.ts"
status=$?
echo "tsc status=$status"
else
echo "node_modules/.bin/tsc unavailable"
fi
rm -rf "$tmp"Repository: anolilab/lunora
Length of output: 9545
🌐 Web query:
TypeScript spread non-empty tuple optional fixed parameters TS2556 rest parameter spread non-tuple array
💡 Result:
The error TS2556 ("A spread argument must either have a tuple type or be passed to a rest parameter") occurs because TypeScript cannot guarantee that a standard array has the exact number of elements required by a function's fixed parameters [1][2][3]. Since a non-tuple array (e.g., number[]) can have any length, spreading it into a function expecting a specific arity is unsafe [4][3]. To resolve this error, you must ensure the spread argument is treated as a tuple or refactor the target function [2][3]. Common solutions include: 1. Use 'as const': If the values are known at the call site, use 'as const' to assert the array as a read-only tuple, which TypeScript can then validate against the function parameters [1][2][3]. function foo(a: number, b: number) {} const args = [1][2] as const; foo(...args); // OK 2. Explicitly Define a Tuple Type: If the array is variable, annotate it as a tuple so TypeScript knows the exact structure [1][2]. const args: [number, number] = [1][2]; foo(...args); // OK 3. Refactor to Rest Parameters: If the function should handle a variable number of arguments, update its definition to use a rest parameter [2][3]. function foo(...args: number[]) {} const args = [1][2][5]; foo(...args); // OK 4. Use Function.prototype.apply: In cases where TypeScript's spread rules are too restrictive (such as with unions of tuples), using.apply may bypass the check [1][6]. Note that TypeScript's spread rules are strict regarding arity [7][3]. Even if a variable is a union of tuples, TypeScript often cannot resolve the correct overload or parameter list when spreading, leading to TS2556 [6]. In such complex scenarios, you may need to use explicit indexing (e.g., fn(args, args[1])) or type assertions [1][6].
Citations:
- 1: https://stackoverflow.com/questions/68884073/spreading-an-array-in-a-typescript-function-error-ts2556
- 2: https://bobbyhadz.com/blog/typescript-spread-argument-must-either-have-tuple-type
- 3: https://typescriptpro.com/errors/ts2556
- 4: https://stackoverflow.com/questions/76692979/a-spread-argument-must-either-have-a-tuple-type-typescript-error-way-too-often
- 5: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html
- 6: "Spread argument must either have a tuple type" err even when spread arg has a tuple type microsoft/TypeScript#49700
- 7: Simplify arity errors, rewording spread errors microsoft/TypeScript#43855
🌐 Web query:
TypeScript 5.3 empty tuple spread non-tuple array no error fixed arguments
💡 Result:
The error "A spread argument must either have a tuple type or be passed to a rest parameter" (TS2556) is a long-standing constraint in TypeScript that has not been fundamentally removed or changed in version 5.3 [1][2][3]. The compiler issues this error when it cannot statically guarantee that an array being spread has enough elements to satisfy the fixed parameters of a function [4][5]. Even if an array or a union of tuples is logically sufficient, TypeScript's current overload resolution and type inference logic often fail to bridge this gap, leading to the error even when developers can verify the safety of the call [6][7][3]. There is no "fix" in TypeScript 5.3 that enables spreading a non-tuple array into fixed arguments without this error [1][2]. The community and the TypeScript team have discussed this behavior extensively, but it remains a known design limitation rather than a bug that has been addressed [7][3][5]. Common workarounds include: 1. Const Assertion: Using as const on the array to force TypeScript to treat it as a read-only tuple, which guarantees its length and element types [4]. 2. Explicit Type Annotation: Defining the array explicitly as a tuple type (e.g., const args: [string, number] = ['a', 1];) before spreading it [4]. 3. Rest Parameters: Changing the function signature to accept rest parameters instead of fixed arguments, which allows for dynamic array spreading [4]. 4. Function Apply: Using func.apply(null, args) as an alternative, which is sometimes permitted even when the spread operator ... triggers the error [3]. The issue persists across versions because it involves complex interactions between type parameter inference, contextual typing, and overload resolution that the TypeScript team has been cautious about changing to avoid breaking existing logic [7].
Citations:
- 1: Spread Tuple Union In Function Errors microsoft/TypeScript#43429
- 2: Union of tuples called out as not spreadable. microsoft/TypeScript#57156
- 3: "Spread argument must either have a tuple type" err even when spread arg has a tuple type microsoft/TypeScript#49700
- 4: https://bobbyhadz.com/blog/typescript-spread-argument-must-either-have-tuple-type
- 5: Spread operator should not have worse ergonomics than
apply- unexpected error spreading a union-of-tuples microsoft/TypeScript#49802 - 6: Infer array as tuple when used as rest argument in a complex expression microsoft/TypeScript#56765
- 7: Error when spreading a union of tuples in a call microsoft/TypeScript#42508
🌐 Web query:
TypeScript empty tuple literal [] rest argument non-tuple array TS2556
💡 Result:
The TypeScript error TS2556 ("A spread argument must either have a tuple type or be passed to a rest parameter") occurs because TypeScript cannot guarantee that a standard array has the correct length or structure to satisfy a function's expected fixed arguments [1][2][3]. When you use the spread syntax (...) on an array (e.g., func(...myArray)), TypeScript must ensure that myArray is a tuple with a fixed length and known element types that perfectly match the target function's parameters [1][4]. Standard arrays (like number[]) are mutable and have variable lengths, so the compiler cannot safely assume they will match the function's requirements [2][4]. Even an empty array literal [] is inferred as any[] or never[], which lacks the necessary fixed-tuple structure [5][2]. To resolve TS2556, use one of the following approaches: 1. Const Assertion (Recommended): Add as const to your array literal. This tells TypeScript to treat the array as a read-only tuple, allowing it to accurately infer the length and types [1][3][4]. typescript const args = [1, 2, 3] as const; myFunc(...args); // Correct 2. Explicit Type Annotation: Define the array explicitly as a tuple [1][3]. typescript const args: [number, number, number] = [1, 2, 3]; myFunc(...args); // Correct 3. Update Function Signature: If the function is intended to handle a dynamic number of arguments, update it to use a rest parameter instead of fixed parameters [1][3]. typescript function myFunc(...args: number[]) { /* ... */ } myFunc(...myArray); // Now allowed If you are dealing with a scenario where the array size is not statically known, spreading it into a function expecting a fixed number of arguments is inherently unsafe in TypeScript, as it risks runtime errors [1][6][2]. In such cases, you may need to reconsider the function design or use type assertions if you are certain of the runtime structure [1][2][7].
Citations:
- 1: https://stackoverflow.com/questions/68884073/spreading-an-array-in-a-typescript-function-error-ts2556
- 2: https://stackoverflow.com/questions/76692979/a-spread-argument-must-either-have-a-tuple-type-typescript-error-way-too-often
- 3: https://bobbyhadz.com/blog/typescript-spread-argument-must-either-have-tuple-type
- 4: https://stackoverflow.com/questions/76551922/typescript-error-using-spread-operator-in-function
- 5: Tuples in rest parameters and spread expressions microsoft/TypeScript#24897
- 6: https://stackoverflow.com/questions/70045588/question-about-spread-argument-in-typescript
- 7: https://stackoverflow.com/questions/67033975/typescript-passing-arguments-with-spread-syntax-throws-expected-x-arguments-bu
Avoid spreading an ordinary array into this three-parameter call.
PlanWriter.insert has a fixed three-parameter signature with one optional third parameter, so the conditional array union here is not a tuple and violates strict spread typing. Use inline branches for the client-id path so TypeScript can see exactly 0 or 1 optional option is passed.
Proposed fix
- await db.insert(entry.table as never, body, ...(typeof clientId === "string" ? [{ clientId }] : []));
+ if (typeof clientId === "string") {
+ await db.insert(entry.table as never, body, { clientId });
+ } else {
+ await db.insert(entry.table as never, body);
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { _id: clientId, ...body } = entry.row; | |
| // eslint-disable-next-line no-await-in-loop -- see above | |
| await db.insert(entry.table as never, body, ...(typeof _id === "string" ? [{ clientId: _id }] : [])); | |
| await db.insert(entry.table as never, body, ...(typeof clientId === "string" ? [{ clientId }] : [])); | |
| const { _id: clientId, ...body } = entry.row; | |
| // eslint-disable-next-line no-await-in-loop -- see above | |
| if (typeof clientId === "string") { | |
| await db.insert(entry.table as never, body, { clientId }); | |
| } else { | |
| await db.insert(entry.table as never, body); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/db/src/apply-plan.ts` around lines 179 - 182, Update the insert call
in the apply-plan loop to avoid spreading the conditional array. Branch on
whether clientId is a string and call db.insert with the client-id option only
in that branch; otherwise call it with just the table and body arguments,
preserving the existing behavior.
Sources: Path instructions, MCP tools
| for (const relativePath of projectFiles) { | ||
| let manifest; | ||
|
|
||
| try { | ||
| manifest = JSON.parse(readFileSync(join(rootDir, relativePath), "utf8")); | ||
| } catch { | ||
| continue; | ||
| } | ||
|
|
||
| const targets = manifest.targets ?? {}; | ||
| const nxShaped = Object.keys(targets).filter((name) => typeof targets[name] === "object" && targets[name] !== null && "executor" in targets[name]); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Fail closed on unreadable or malformed project manifests.
The catch at Lines 64-68 treats missing files, read errors, and invalid JSON as clean. This lets the validator ignore a malformed project.json. A valid JSON null then reaches Line 70 and throws because manifest.targets is accessed outside the catch. The success count also includes candidate directories that do not contain a manifest. Track these errors, validate the manifest shape, and exit non-zero before printing the success summary.
Proposed validation fix
-import { readdirSync, readFileSync } from "node:fs";
+import { existsSync, readdirSync, readFileSync } from "node:fs";
+const invalidManifests = [];
- return entries.filter((entry) => entry.isDirectory()).map((entry) => `${workspace}/${entry.name}/project.json`);
+ return entries
+ .filter((entry) => entry.isDirectory() && existsSync(join(rootDir, workspace, entry.name, "project.json")))
+ .map((entry) => `${workspace}/${entry.name}/project.json`);
try {
manifest = JSON.parse(readFileSync(join(rootDir, relativePath), "utf8"));
- } catch {
+ } catch (error) {
+ invalidManifests.push(`${relativePath}: ${error instanceof Error ? error.message : String(error)}`);
continue;
}
+ if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
+ invalidManifests.push(`${relativePath}: root must be a JSON object`);
+ continue;
+ }Also applies to: 105-113
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/check-project-json-targets.js` around lines 61 - 71, Update the
project-manifest validation loop around projectFiles and its later success
summary to fail closed: track unreadable or malformed manifests, validate that
the parsed value is a non-null object before accessing manifest.targets, and
treat missing manifests as errors rather than successful candidates. Ensure any
such error causes a non-zero exit before printing the success summary, including
the corresponding logic referenced near the later validation block.
The package declared `lint:eslint` in nx's `executor` + `options.command`
shape, which the task runner does not understand: it reported "No command
configured" and passed in ~13 ms, shadowing the `package.json` script that
carries `--max-warnings=0`. Deleting the block restores the manifest script,
matching the 48 projects that only declare `{name, tags}`.
Un-skipping surfaced 35 errors + 3 warnings, fixed here rather than silenced:
- `import/exports-last` — moved the module-private helpers (`ordered`, the
fallback warner, the two registry WeakMap/WeakSets) above the first export
instead of interleaving them between exported declarations.
- `jsdoc/no-undefined-types` — qualified sibling-member `{@link}`s
(`{@link CheckpointRegistry.resolve}`, `{@link BindMutatorsContext.shardKey}`).
- `@typescript-eslint/naming-convention` — the plan applier destructures the
document id as `clientId`, which is what it is forwarded as anyway.
- `no-void` / `promise/always-return` — the two "has it settled yet?" probes in
the mutator tests now await a tracked async IIFE instead of a floating
`void …then()`.
- `e18e/prefer-static-regex`, `vitest/*`, `arrow-body-style` — mechanical.
No `expect.assertions` counts appear in this diff: unlike `ai` and `replica`,
this package turns `vitest/prefer-expect-assertions` off for test files, and
its tests already carry counts anyway.
One new suppression: `unicorn/prevent-abbreviations` on `applyPlanToDb`, whose
name and `db` parameter mirror the framework's own `ctx.db`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
The package declared `lint:eslint` in nx's `executor` + `options.command` shape, which the task runner does not understand: it reported "No command configured" and passed in ~13 ms, shadowing the `package.json` script that carries `--max-warnings=0`. Deleting the block restores the manifest script. Un-skipping surfaced 117 findings, all in `__tests__` — `src/` was already clean. 109 of them were `vitest/prefer-expect-assertions`: the rule is on in 45 of the 55 linted packages and two of this package's own suites already opened every test with `expect.assertions(n)`, so the fix is to finish the job rather than exempt the package. Each test now declares its count, or `expect.hasAssertions()` where the expects sit inside a loop or a callback and no static count is sound; the suite passing (123 tests) is what proves every count right. The rest: `vitest/require-mock-type-parameters` on four `vi.fn()`s (typed from the callback signatures they stand in for), plus a `unicorn/no-useless-fallback-in-spread`, an `arrow-body-style` and two padding findings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
The package declared `lint:eslint` in nx's `executor` + `options.command` shape, which the task runner does not understand: it reported "No command configured" and passed in ~13 ms, shadowing the `package.json` script that carries `--max-warnings=0`. Deleting the block restores the manifest script. Un-skipping surfaced 303 findings — flagged as pre-existing as far back as the event-log work and never addressed, because nothing ever ran. 274 were `vitest/prefer-expect-assertions`; every test now declares its count, or `expect.hasAssertions()` where the expects sit inside a loop or callback and no static count is sound. Five counts had to include a shared helper that asserts on behalf of its caller — the suite (337 tests) is what proves each one right. Behaviour-affecting cleanups, all verified against the suite: - The canonical-diff PRNG moves its seed into a closure, so no module-level mutable binding is shared across the file. - `start() is idempotent` asserted nothing at all. It now drives the fake clock one poll interval and asserts a single fetch — a second `start()` arming a second loop is what the title always claimed to cover. - The event-log fake's `else if` becomes two guarded branches with the same precedence. - Four `if (…)` narrowing guards become non-null assertions, so a value that never arrives fails instead of silently skipping the work it guarded: three `if (!result.done)` around an async iterator in runtime-edges, and one `if (registeredCallback)` around the subscribe callback in integration. Four suppressions, each where the rule is wrong for that line: `no-console` on the two unknown-event `warn` strategies (reporting the skipped event IS the strategy), on the DO's server-side error log (the response deliberately carries none of it), and on the `onError` fallback; `vitest/require-top-level-describe` on the sql.js WASM init, which is shared by every `describe.each` block in the file; and `vitest/require-to-throw-message` on a post-close query, where two of the three engines throw a bare string rather than an Error. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
A target declared in nx's `executor` + `options.command` shape is not an error to vis — it reports "No command configured" and exits 0, and because a declared target shadows the `package.json` script it would otherwise fall back to, the real command never runs. Ten packages carried one for `lint:eslint`, so the repo lint printed a green tick for each of them after ~13ms of doing nothing, and that aggregate run is a required status check. `scripts/check-project-json-targets.js` scans every `packages/*` and `apps/*` project.json and fails on any target carrying an `executor` key. Config-only blocks (`cache` / `inputs` / `dependsOn`) are untouched — vis merges those onto the manifest script, so they are correct as written. Wired as the FIRST step of the Lint workflow's eslint job, so a skipped gate is reported before the build and cannot be masked by a later step; runnable as `pnpm run lint:project-json`. Deliberately not in the root `postinstall`, where a failing check turns every CI job red in its setup step and buries the cause. `project.json` joins the `frontend_lintable` path filter, since without it a PR touching only a project.json would skip the very job that catches this. One project (`packages/svelte`) is still unmigrated and listed in `KNOWN_UNMIGRATED`. That list is a debt marker, not an exemption: the check also fails when a listed project is already clean, so an entry cannot outlive the fix it points at. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
Review follow-ups on the project.json guard and the two cleanups.
The guard could be switched off by editing the guard. `frontend_lintable`
matched `**/project.json` but not the checker, the workflow, or the filter
file, so a PR deleting the check step matched no filter, skipped the eslint
job, and passed `lint-required-check` — which only fails on `failure` /
`cancelled`, never `skipped`. All three are now listed, the same way
`worker_size` already does it two entries below.
Four defects in the checker itself:
- It swept only `packages` and `apps`. pnpm's workspaces are `apps/*`,
`examples/*`, `packages/*`, `tests/*` — 14 project.json files sat outside the
sweep while the path filter still fired the job.
- `"executor" in target` also rejected `{executor, command}`, which vis runs
correctly — contradicting the error text's own advice to add a `command`. The
predicate now requires an `executor` AND no top-level `command`.
- A malformed project.json was skipped and still counted as clean. A guard
whose premise is "a silent skip must not be possible" now fails on one.
- The summary mapped every directory to a path without checking it existed, so
it reported a denominator one higher than the number of files.
Also: a deleted allowlisted project now reports as deleted rather than as
already-clean, and both defect classes are collected before exiting so one run
shows everything.
@lunora/db was fighting `no-underscore-dangle` instead of configuring it. 45 of
55 packages carry an allow-list block that already contains both `_id` and
`__lunoraRef`; db had none, so it carried five file-level blanket disables that
blinded whole files to the rule — including any genuinely accidental dangle.
Copied the block from a sibling and deleted all eight suppression sites.
Two code-judo cuts: `ordered()` was a five-line `?? []` defaulter that had to
sit above the interfaces its own return type names, so the file read backwards
— inlined at both call sites. And the event-log fake's two guarded branches are
one bound selection and one filter, which is what the `else if` meant before it
was split to satisfy the linter.
`onlyDerivedKey` asserted on its caller's behalf, so five tests baked its `+1`
into their declared counts and one edit inside it would fail all five pointing
at the wrong file. It now returns the keys and each caller asserts the whole
array — the count and the values in one assertion instead of two.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
877570a to
08a3396
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #364 +/- ##
========================================
Coverage ? 87.07%
========================================
Files ? 1170
Lines ? 63254
Branches ? 15551
========================================
Hits ? 55079
Misses ? 7654
Partials ? 521
🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 0.38%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
The svelte cleanup (#363) and the guard that allowlisted it (#364) both landed, so the entry now describes an already-clean project. The check fails on a stale entry by design, which is what makes an allowlist unable to outlive its fix — so alpha went red the moment the second of the two merged, and every open PR inherits it through refs/pull/N/merge. Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What
Three more packages whose lint gate reported success after ~13 ms of doing nothing, plus the guard that stops it coming back (plan 302 phases 7–10).
@lunora/db,@lunora/aiand@lunora/replicaeach declaredlint:eslintin nx's shape (executor+ nestedoptions.command). vis reads only a top-levelcommand, so it printedNo command configuredand recorded a pass — the declared target shadowed the manifest script, and CI's required context is that aggregate run.Each package is one commit: clear the backlog, delete the
targetsblock, so the gate and the cleanup land together.Findings cleared
dbimport/exports-last×12,jsdoc/*×7,no-underscore-dangle×3, plus singlesaivitest/prefer-expect-assertions, all in__tests__;src/was already cleanreplicaprefer-expect-assertions, 12 ×require-mock-type-parameters, 4 ×no-console(the onlysrc/findings)vitest/prefer-expect-assertionswas not exempted: it is on in 45 of 55 packages, off in 10, and no package anywhere uses the rule's granular options — the precedent is binary, so matching the 45 is the call and exempting two more would have been the drift. 383 tests got a count via a ts-morph codemod. Five were wrong because a module-level helper asserts on its caller's behalf; vitest failed loudly and they were corrected.Behaviour-changing edits, disclosed
A lint cleanup that changes behaviour is the risk in a PR like this, so each one is named and was verified by execution, not inspection:
replicacanonical-diff PRNG — module-levellet seed→ closure state. Same LCG, same initial seed, bit-identical sequence.start() is idempotentasserted nothing at all. Rewritten; mutation-tested by deleting the guard atsync-events.ts:192, which now makes it fail.if (x)guards → non-null assertions (result.value!.seq×3,registeredCallback!×1) so an iterator ending early throws instead of silently passing. Same verdict on the same input, worse message. (The replica commit body says three —integration.test.ts:465is the fourth.)else if→ two guarded branches in an event-log fake, mutual exclusion moved toisSince = !isRange && …. Truth table identical.void settled?.then(…)probes indbmutator tests → an awaited tracked async IIFE. Both call sites retain anexpect(done).toBe(false)before the settlement point, so the empty-configscase still fails.Phase 10 — the guard
scripts/check-project-json-targets.js, wired as the first step of the Lint workflow'seslintjob and aspnpm run lint:project-json. Deliberately not in the rootpostinstall: a failing check there turns all ~20 CI jobs red in their setup step, and the cause is invisible in the job that "failed".**/project.jsonjoins the path filter so a PR touching only aproject.jsoncannot skip the job that catches this.KNOWN_UNMIGRATEDis self-cleaning — the check fails on a stale entry as well as a missing one, so an allowlist cannot outlive its fix.KNOWN_UNMIGRATEDlistspackages/svelte, which #363 makes clean. Whichever merges second must empty the allowlist (new Map()) orlint:project-jsonexits 1 onalpha, inside a required check, reading as "svelte lint broken".Review — outstanding items
Both thermo passes ran against the full branch diff. The cleanup itself came back sound: all behaviour-changing edits verified safe, no unreported ones found,
expect.assertions(n)confirmed to be an exact match in vitest (so a too-low count fails rather than passing silently), and all 7 added disables judged genuine against existing precedent.All six findings are now fixed (commit
ci: close the gate's own escape hatches and its blind spots):scripts/check-project-json-targets.js,.github/workflows/lint.ymland.github/file-filters.ymlnow all appear infrontend_lintable, matching theworker_sizeprecedent — a PR that edits the gate now matches a filter and runs it.lint-required-checkfails only onfailure/cancelled, so a skipped job did pass it.dbno longer fightsno-underscore-dangle. The allow-list block frompackages/client/eslint.config.jswas copied in and eight suppression sites deleted — the five file-level blankets plus three line-level ones.apps,examples,packages,tests, and the denominator now counts only files that exist (72, checked againstls).executorwith a top-levelcommandis a shape vis runs correctly and now passes, matching the check's own printed advice.options.commandwithoutexecutorstill passes, as it should.project.jsonnow fails instead of being silently counted clean.dbgained no assertion counts.Also done:
ordered()deleted andplan.deletes ?? []inlined at both call sites; the event-log fake collapsed to one bound selection plus one filter with the regexes hoisted to module constants; andonlyDerivedKeyreworked to return keys rather than assert, which removes the coupling that made five unrelated tests depend on a helper's assertion count.The checker was re-verified across nine branches — clean tree,
executorwithoutcommand,executorwithcommand,options.commandwithoutexecutor, malformed JSON, anexamples/offender, a stale allowance, a deleted allowlisted file, and both defect classes at once — each by mutating a copy of the tree and restoring it.Verification
db 86 / ai 123 / replica 337 tests ·
lint:eslint --max-warnings=0andtsc --noEmitclean on all three · repo-widelint:eslint58 projects, 158 tasks, exit 0 ·api:check47 snapshots ·lint:package-json74 files · Prettier clean on all 35 changed files. Both directions of the new check tested: reintroducing a block → exit 1; allowlisting a clean project → exit 1.🤖 Generated with Claude Code
https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
Summary by CodeRabbit
Bug Fixes
Chores
Documentation