Skip to content

Commit aab8b32

Browse files
Polish: zero lint warnings, test coverage, CI improvements
- Suppress intentional console.error with eslint-disable comments - Suppress mount-only useEffect dependency warnings - Suppress no-img-element for external SVG badge - Add @vitest/coverage-v8 with coverage report in CI - Add test:coverage script Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 21e1fd6 commit aab8b32

10 files changed

Lines changed: 216 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
node-version: 20
3030
cache: npm
3131
- run: npm ci
32-
- run: npm test
32+
- run: npm run test:coverage
3333

3434
build:
3535
name: Build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ sdk/js/node_modules/
2525

2626
# Test database
2727
data/test.db*
28+
29+
# Coverage reports
30+
coverage/

app/agents/client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ function ShareBar({ agentId, agentName }: { agentId: string; agentName: string }
392392
className="px-3 py-1.5 rounded-lg text-xs bg-white/5 hover:bg-white/10 text-white/50 hover:text-white transition-all">Social Card</a>
393393
</div>
394394
<div className="mt-3">
395+
{/* eslint-disable-next-line @next/next/no-img-element */}
395396
<img src={badgeUrl} alt={`${agentName} badge`} className="mx-auto max-h-8 opacity-60 hover:opacity-100 transition-opacity" />
396397
</div>
397398
</div>

app/api/[...path]/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ async function safeHandle(req: NextRequest, params: Promise<{ path: string[] }>)
5353
const { path } = await params;
5454
return await handle(req, path);
5555
} catch (e: any) {
56+
// eslint-disable-next-line no-console
5657
console.error("API Error:", e);
5758
return json({ error: e.message || "Internal Server Error" }, 500);
5859
}

app/confessions/client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default function ConfessionsClient({ initialConfessions, initialTotal }:
4949
setLoading(false);
5050
}, [confessions]);
5151

52+
// eslint-disable-next-line react-hooks/exhaustive-deps
5253
useEffect(() => { if (initialConfessions.length === 0) load('new', 0); }, []);
5354
const changeSort = (s: string) => { setSort(s); setPage(0); load(s, 0, query); };
5455
const doSearch = () => { setPage(0); load(sort, 0, query); };

app/leaderboard/client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default function LeaderboardClient({ initialAgents, initialCouples, initi
1717
const [agents, setAgents] = useState<any[]>(initialAgents);
1818
const [loading, setLoading] = useState(false);
1919

20+
// eslint-disable-next-line react-hooks/exhaustive-deps
2021
useEffect(() => { if (initialAgents.length === 0) changeTab('popular'); }, []);
2122
const changeTab = async (t: string) => {
2223
setTab(t);

lib/api-server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ export async function apiFetch<T = any>(path: string, revalidateSec = 120): Prom
1212
try {
1313
const res = await fetch(url, { next: { revalidate: revalidateSec } });
1414
if (!res.ok) {
15+
// eslint-disable-next-line no-console
1516
console.error(`[apiFetch] ${url}${res.status}`);
1617
return null;
1718
}
1819
return res.json();
1920
} catch (err) {
21+
// eslint-disable-next-line no-console
2022
console.error(`[apiFetch] ${url} → error:`, err);
2123
return null;
2224
}

package-lock.json

Lines changed: 198 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"test": "vitest run",
11+
"test:coverage": "vitest run --coverage",
1112
"test:watch": "vitest",
1213
"format": "prettier --write .",
1314
"format:check": "prettier --check ."
@@ -27,6 +28,7 @@
2728
"@tailwindcss/postcss": "^4.1.18",
2829
"@types/node": "^20.14.2",
2930
"@types/react": "^18.3.3",
31+
"@vitest/coverage-v8": "^4.0.18",
3032
"autoprefixer": "^10.4.24",
3133
"eslint": "^8.57.1",
3234
"eslint-config-next": "^14.2.5",

vitest.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export default defineConfig({
1010
testTimeout: 15000,
1111
fileParallelism: false,
1212
sequence: { shuffle: false },
13+
coverage: {
14+
provider: "v8",
15+
reporter: ["text", "lcov"],
16+
include: ["lib/**", "middleware.ts"],
17+
reportsDirectory: "./coverage",
18+
},
1319
},
1420
resolve: {
1521
alias: {

0 commit comments

Comments
 (0)