Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

ci: lint server for undeclared identifiers and fix the two it found (#10446)

[._.]/ Adam Eivyc87bef86199c
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.js
index c057841a2c..06186a28f7 100644
--- a/scripts/ci-test-plan.js
+++ b/scripts/ci-test-plan.js
@@ -17,7 +17,11 @@ const MODULE_SOURCE_RE = /\.[cm]?[jt]sx?$/i;
// runnerForTest(isTestFile) filter already narrows a broad hit back down, so
// over-matching here costs nothing.
const TEST_FILE_GLOBS = ['*.test.*', '*.spec.*'];
+// The server tree is linted whole (fast, ~1s) by the same Biome the client installs,
+// so any server JavaScript or its lint config selects the lint job.
const CLIENT_LINT_RE = /^client\/src\/.*\.(?:js|jsx)$/i;
+const SERVER_LINT_RE = /^server\/(?!node_modules\/).*\.(?:m?js)$|^server\/biome\.jsonc$/i;
+const isLintSurface = (path) => CLIENT_LINT_RE.test(path) || SERVER_LINT_RE.test(path);
const EXECUTABLE_RE = /\.(?:cjs|css|html|js|jsx|json|mjs|sql|ts|tsx|ya?ml)$/i;
const MAX_CHANGED_CODE_FILES = 30;
// 125, not 120: the always-run guards grew to the old edge, and the real-repo
@@ -876,8 +880,8 @@ export function buildCiTestPlan(changedFiles, {
lint: {
// Same deleted-path guard as directTests above — ESLint given a
// nonexistent explicit path exits non-zero instead of skipping it.
- mode: changed.some((path) => CLIENT_LINT_RE.test(path) && trackedSet.has(path)) ? 'files' : 'skip',
- files: changed.filter((path) => CLIENT_LINT_RE.test(path) && trackedSet.has(path)),
+ mode: changed.some((path) => isLintSurface(path) && trackedSet.has(path)) ? 'files' : 'skip',
+ files: changed.filter((path) => isLintSurface(path) && trackedSet.has(path)),
},
build: hasClientSource,
smoke: hasServerSource,
diff --git a/scripts/ci-test-plan.test.js b/scripts/ci-test-plan.test.js
index 1a93e959ed..680c246211 100644
--- a/scripts/ci-test-plan.test.js
+++ b/scripts/ci-test-plan.test.js
@@ -618,7 +618,7 @@ describe('CI test impact planner', () => {
server: { mode: 'related' },
client: { mode: 'files' },
db: false,
- lint: { mode: 'skip' },
+ lint: { mode: 'files' },
build: false,
smoke: true,
});
diff --git a/scripts/run-ci-lint.js b/scripts/run-ci-lint.js
index c2e63eb4e0..0951910dbc 100644
--- a/scripts/run-ci-lint.js
+++ b/scripts/run-ci-lint.js
@@ -25,6 +25,18 @@ export function selectClientFiles(repoFiles) {
.map((path) => path.replace(/^client\//, ''));
}
+/** True when a changed-file list touches server code or its Biome config. */
+export function touchesServer(repoFiles) {
+ return repoFiles.some((path) => /^server\/(?!node_modules\/).*\.(?:m?js)$|^server\/biome\.jsonc$/i.test(path));
+}
+
+/**
+ * Biome argv for the server tree. Only `noUndeclaredVariables` is an error; the
+ * unused-variable rule is a warning (server/biome.jsonc), so no `--error-on-warnings`.
+ * Diagnostics are capped so the known unused-variable backlog does not drown real errors.
+ */
+export const SERVER_LINT_ARGS = ['lint', '--max-diagnostics=20', '.'];
+
/** Build the Biome argv for a lint run. Pure, so the CI matrix is testable. */
export function buildLintArgs({ mode, clientFiles = [] }) {
// `--error-on-warnings` holds the client's documented lint policy: every rule is
@@ -38,6 +50,15 @@ export function buildLintArgs({ mode, clientFiles = [] }) {
return [...base, '--no-errors-on-unmatched', ...clientFiles];
}
+function runBiome(args, cwd) {
+ const result = spawnSync(process.execPath, [BIOME_BIN, ...args], { cwd, stdio: 'inherit', env: process.env });
+ if (result.error) {
+ console.error(result.error.message);
+ return 1;
+ }
+ return result.status ?? 1;
+}
+
function main() {
const mode = process.env.CI_LINT_MODE || 'full';
if (!LINT_MODES.includes(mode)) {
@@ -45,9 +66,12 @@ function main() {
process.exit(2);
}
- const clientFiles = selectClientFiles(JSON.parse(process.env.CI_LINT_FILES || '[]'));
- if (mode === 'files' && clientFiles.length === 0) {
- console.log('No changed client JavaScript files require linting.');
+ const repoFiles = JSON.parse(process.env.CI_LINT_FILES || '[]');
+ const clientFiles = selectClientFiles(repoFiles);
+ const lintClient = mode === 'full' || clientFiles.length > 0;
+ const lintServer = mode === 'full' || touchesServer(repoFiles);
+ if (!lintClient && !lintServer) {
+ console.log('No changed client or server JavaScript files require linting.');
process.exit(0);
}
@@ -56,18 +80,16 @@ function main() {
process.exit(1);
}
- console.log(`Running client lint in ${mode} mode${mode === 'files' ? ` (${clientFiles.length} file(s))` : ''}.`);
- const result = spawnSync(process.execPath, [BIOME_BIN, ...buildLintArgs({ mode, clientFiles })], {
- cwd: join(repoRoot, 'client'),
- stdio: 'inherit',
- env: process.env,
- });
-
- if (result.error) {
- console.error(result.error.message);
- process.exit(1);
+ let status = 0;
+ if (lintClient) {
+ console.log(`Running client lint in ${mode} mode${mode === 'files' ? ` (${clientFiles.length} file(s))` : ''}.`);
+ status = runBiome(buildLintArgs({ mode, clientFiles }), join(repoRoot, 'client')) || status;
+ }
+ if (lintServer) {
+ console.log('Running server lint (whole tree).');
+ status = runBiome(SERVER_LINT_ARGS, join(repoRoot, 'server')) || status;
}
- process.exit(result.status ?? 1);
+ process.exit(status);
}
if (isDirectlyInvoked(import.meta.url)) main();
diff --git a/scripts/run-ci-lint.test.js b/scripts/run-ci-lint.test.js
index 8a83bf2254..e711dea3fb 100644
--- a/scripts/run-ci-lint.test.js
+++ b/scripts/run-ci-lint.test.js
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { BIOME_BIN, LINT_MODES, buildLintArgs, selectClientFiles } from './run-ci-lint.js';
+import { BIOME_BIN, LINT_MODES, SERVER_LINT_ARGS, buildLintArgs, selectClientFiles, touchesServer } from './run-ci-lint.js';
describe('CI client lint runner', () => {
it('lints the whole client src tree in full mode', () => {
@@ -53,4 +53,13 @@ describe('CI client lint runner', () => {
expect(args[0]).toBe('lint');
}
});
+
+ // The server has no other static check: a removed declaration (the `d is not
+ // defined` storyboard crash) only fails when a test happens to run that line.
+ it('lints the server tree and only selects the job for server code or its config', () => {
+ expect(SERVER_LINT_ARGS).not.toContain('--error-on-warnings');
+ expect(touchesServer(['server/services/a.js', 'docs/x.md'])).toBe(true);
+ expect(touchesServer(['server/biome.jsonc'])).toBe(true);
+ expect(touchesServer(['server/node_modules/x/index.js', 'client/src/a.js', 'server/README.md'])).toBe(false);
+ });
});
diff --git a/server/biome.jsonc b/server/biome.jsonc
new file mode 100644
index 0000000000..4f14efe9e5
--- /dev/null
+++ b/server/biome.jsonc
@@ -0,0 +1,17 @@
+{
+ "$schema": "../client/node_modules/@biomejs/biome/configuration_schema.json",
+ "root": true,
+ "files": { "includes": ["**/*.js", "**/*.mjs", "!node_modules", "!native"] },
+ "formatter": { "enabled": false },
+ "assist": { "enabled": false },
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "preset": "none",
+ "correctness": {
+ "noUndeclaredVariables": "error",
+ "noUnusedVariables": "warn"
+ }
+ }
+ }
+}
diff --git a/server/package.json b/server/package.json
index 694f4cd0aa..e9bb05b35f 100644
--- a/server/package.json
+++ b/server/package.json
@@ -10,6 +10,7 @@
"scripts": {
"dev": "node --watch start.js",
"start": "node start.js",
+ "lint": "node ../client/node_modules/@biomejs/biome/bin/biome lint --max-diagnostics=20 .",
"test": "vitest run",
"test:fast": "vitest run",
"test:watch": "vitest",
diff --git a/server/routes/screenshots.js b/server/routes/screenshots.js
index 3881b27980..8b0ffd80cf 100644
--- a/server/routes/screenshots.js
+++ b/server/routes/screenshots.js
@@ -2,7 +2,7 @@ import { Router } from 'express';
import { existsSync } from 'fs';
import { resolve } from 'path';
import { v4 as uuidv4 } from '../lib/uuid.js';
-import { asyncHandler } from '../lib/errorHandler.js';
+import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { validateRequest, screenshotUploadBodySchema } from '../lib/validation.js';
import { PATHS, sanitizeFilename, isPathInsideDir, saveImageUpload } from '../lib/fileUtils.js';
import { MAX_SCREENSHOT_BYTES } from '../lib/uploadLimits.js';
diff --git a/server/routes/settings.js b/server/routes/settings.js
index 58348b17b9..f875a85df1 100644
--- a/server/routes/settings.js
+++ b/server/routes/settings.js
@@ -38,7 +38,6 @@ const aiAssignmentUpdateSchema = z.object({
const eidoverseRepoSchema = z.object({
worldsRepoUrl: z.string().trim().max(500).refine(isGitHubRepoUrl, 'Must be a GitHub repository URL'),
- // biome-ignore lint/suspicious/noControlCharactersInRegex: reject control characters in Git branch input
worldsBranch: z.string().trim().max(255).regex(/^[^\u0000-\u001f\u007f]*$/).optional(),
}).strict();
diff --git a/server/services/musicVideo/publish/suno.test.js b/server/services/musicVideo/publish/suno.test.js
index 0e2f67cde1..3b08a8b05d 100644
--- a/server/services/musicVideo/publish/suno.test.js
+++ b/server/services/musicVideo/publish/suno.test.js
@@ -3,11 +3,12 @@ import { sunoAdapter } from './suno.js';
import { markSunoSongMenu } from '../../../lib/sunoPage.js';
const SONG = '12345678-abcd-4abc-8abc-123456789abc';
+const SONG_URL = `https://suno.com/song/${SONG}`;
const LANDED = '87654321-dcba-4cba-8cba-cba987654321';
// A song page: `marks` is what markSunoSongMenu finds; the Publish dialog
// opens on the marked button's click and the run stops there.
-const fakePage = ({ url = `https://suno.com/song/${SONG}`, marks = true } = {}) => {
+const fakePage = ({ url = SONG_URL, marks = true } = {}) => {
const calls = { marked: [], clicked: [] };
return {
calls,
diff --git a/server/services/voice/proactiveSpeech.js b/server/services/voice/proactiveSpeech.js
index 913e4af921..116ff73807 100644
--- a/server/services/voice/proactiveSpeech.js
+++ b/server/services/voice/proactiveSpeech.js
@@ -132,12 +132,6 @@ export const speakProactive = async ({ io, text, priority = 'normal', source = '
ts: Date.now(),
});
// Mirror the per-turn `state.recentTts` write so a proactive line bleeding
- // from speakers back into the mic gets dropped as echo on the next turn — but
- // ONLY on the recipient tab. Only that tab plays the audio, so only its mic
- // can echo it; recording it on other connected devices would falsely suppress
- // their legitimate speech (they never heard the line).
- if (delivery.socket) rememberTtsForSocket(delivery.socket, trimmed);
- // Mirror the per-turn `state.recentTts` write so a proactive line bleeding
// from speakers back into the mic gets dropped as echo on the next turn.
// Deliberately remembered on EVERY socket, not just the recipient: only the
// recipient tab plays the audio, but a *sibling tab on the same machine* that