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: run the client lint step through biome

Adam Eivye7a8c922fe04
diff --git a/scripts/run-ci-lint.js b/scripts/run-ci-lint.js
index 78d6d67f9a..01c2bd7a10 100644
--- a/scripts/run-ci-lint.js
+++ b/scripts/run-ci-lint.js
@@ -1,39 +1,75 @@
#!/usr/bin/env node
import { spawnSync } from 'child_process';
-import { dirname, join } from 'path';
+import { existsSync } from 'fs';
+import { dirname, join, resolve } from 'path';
import { fileURLToPath } from 'url';
-const mode = process.env.CI_LINT_MODE || 'full';
-const repoFiles = JSON.parse(process.env.CI_LINT_FILES || '[]');
-const clientFiles = repoFiles
- .filter((path) => /^client\/src\/.*\.(?:js|jsx)$/i.test(path))
- .map((path) => path.replace(/^client\//, ''));
+const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
+
+// Biome ships a Node wrapper (`#!/usr/bin/env node`) as its bin, which then execs
+// the platform binary from the matching @biomejs/cli-* optional dependency. So it
+// is spawned through the current `process.execPath` exactly like the old eslint bin
+// was — no PATH lookup, and no Windows `.cmd` shim in play.
+export const BIOME_BIN = join(
+ repoRoot, 'client', 'node_modules', '@biomejs', 'biome', 'bin', 'biome',
+);
+
+export const LINT_MODES = ['files', 'full'];
-if (mode === 'files' && clientFiles.length === 0) {
- console.log('No changed client JavaScript files require linting.');
- process.exit(0);
+/** Narrow a repo-wide changed-file list to the client sources Biome lints. */
+export function selectClientFiles(repoFiles) {
+ return repoFiles
+ .filter((path) => /^client\/src\/.*\.(?:js|jsx)$/i.test(path))
+ .map((path) => path.replace(/^client\//, ''));
}
-if (!['files', 'full'].includes(mode)) {
- console.error(`Unsupported CI lint mode: ${mode}`);
- process.exit(2);
+
+/** 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
+ // 'error' or off, never 'warn'. Biome defaults many rules to warn, so a rule
+ // added later without an explicit severity would otherwise slip through CI.
+ const base = ['lint', '--error-on-warnings'];
+ if (mode === 'full') return [...base, 'src'];
+ // A changed-files run can name a path that biome.jsonc's `files.includes`
+ // excludes, or one the PR deleted. Biome treats "no files processed" as an
+ // error by default, which would fail CI for a PR that only removes files.
+ return [...base, '--no-errors-on-unmatched', ...clientFiles];
}
-const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
-const eslintBin = join(repoRoot, 'client', 'node_modules', 'eslint', 'bin', 'eslint.js');
-const args = mode === 'full'
- ? [eslintBin, 'src', '--ext', '.js,.jsx']
- : [eslintBin, ...clientFiles];
-
-console.log(`Running client lint in ${mode} mode${mode === 'files' ? ` (${clientFiles.length} file(s))` : ''}.`);
-const result = spawnSync(process.execPath, args, {
- cwd: join(repoRoot, 'client'),
- stdio: 'inherit',
- env: process.env,
-});
-
-if (result.error) {
- console.error(result.error.message);
- process.exit(1);
+function main() {
+ const mode = process.env.CI_LINT_MODE || 'full';
+ if (!LINT_MODES.includes(mode)) {
+ console.error(`Unsupported CI lint mode: ${mode}`);
+ 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.');
+ process.exit(0);
+ }
+
+ if (!existsSync(BIOME_BIN)) {
+ console.error(`❌ Biome not found at ${BIOME_BIN} — run \`npm ci --prefix client\` first.`);
+ 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);
+ }
+ process.exit(result.status ?? 1);
}
-process.exit(result.status ?? 1);
+
+const isMain = process.argv[1]
+ && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url));
+
+if (isMain) main();
diff --git a/scripts/run-ci-lint.test.js b/scripts/run-ci-lint.test.js
new file mode 100644
index 0000000000..8a83bf2254
--- /dev/null
+++ b/scripts/run-ci-lint.test.js
@@ -0,0 +1,56 @@
+import { describe, expect, it } from 'vitest';
+
+import { BIOME_BIN, LINT_MODES, buildLintArgs, selectClientFiles } from './run-ci-lint.js';
+
+describe('CI client lint runner', () => {
+ it('lints the whole client src tree in full mode', () => {
+ expect(buildLintArgs({ mode: 'full' })).toEqual(['lint', '--error-on-warnings', 'src']);
+ });
+
+ it('lints only the changed files in files mode, tolerating unmatched paths', () => {
+ expect(buildLintArgs({
+ mode: 'files',
+ clientFiles: ['src/pages/Dashboard.jsx', 'src/lib/uuid.js'],
+ })).toEqual([
+ 'lint',
+ '--error-on-warnings',
+ '--no-errors-on-unmatched',
+ 'src/pages/Dashboard.jsx',
+ 'src/lib/uuid.js',
+ ]);
+ });
+
+ it('keeps only client/src JavaScript, stripping the workspace prefix', () => {
+ expect(selectClientFiles([
+ 'client/src/pages/Dashboard.jsx',
+ 'client/src/lib/uuid.js',
+ 'client/src/components/Deep/Nested.JSX',
+ 'server/services/backup.js',
+ 'client/vite.config.js',
+ 'client/src/styles.css',
+ 'client/src/types.ts',
+ 'docs/DEPS.md',
+ ])).toEqual([
+ 'src/pages/Dashboard.jsx',
+ 'src/lib/uuid.js',
+ 'src/components/Deep/Nested.JSX',
+ ]);
+ });
+
+ it('supports exactly the two documented modes', () => {
+ expect(LINT_MODES).toEqual(['files', 'full']);
+ });
+
+ // Regression guard for the ESLint -> Biome migration: the runner must not go
+ // looking for the removed eslint bin, and must not pass eslint-only flags
+ // (`--ext` is not a Biome flag and makes it exit non-zero).
+ it('invokes biome, not eslint', () => {
+ expect(BIOME_BIN).toContain('@biomejs');
+ expect(BIOME_BIN).not.toContain('eslint');
+ for (const mode of LINT_MODES) {
+ const args = buildLintArgs({ mode, clientFiles: ['src/a.js'] });
+ expect(args).not.toContain('--ext');
+ expect(args[0]).toBe('lint');
+ }
+ });
+});