ci: add web frontend lint and type check workflow#2444
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
| run: npm run lint | ||
| - name: TypeScript type check | ||
| run: npx tsc --noEmit |
There was a problem hiding this comment.
TypeScript check will always fail —
next-env.d.ts not generated
web/app/layout.tsx contains import "./globals.css". TypeScript needs a declare module "*.css" ambient declaration to resolve that import, which Next.js normally provides via the /// <reference types="next" /> directive in next-env.d.ts. That file is listed in web/.gitignore, so it won't exist in a fresh checkout after npm ci. With no .d.ts file supplying the CSS module declaration, the type-check step will emit TS2307: Cannot find module './globals.css' or its corresponding type declarations. and exit non-zero on every run.
The most reliable CI fix is to replace the bare npx tsc --noEmit with npm run build -- --no-lint, which generates next-env.d.ts internally before checking types. A lighter alternative is to add a dedicated script to package.json that runs next build --no-lint for CI type checking, or to un-gitignore and commit the small, stable next-env.d.ts file.
Add a dedicated GitHub Actions workflow for the Next.js web frontend that runs on changes to the web/ directory: - ESLint checks via 'npm run lint' - TypeScript type checking via 'tsc --noEmit' - Runs on push to main and PRs targeting main - Uses npm cache for faster dependency installation
b5e16d8 to
40d0113
Compare
There was a problem hiding this comment.
HUQIANTAO has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Add a dedicated GitHub Actions workflow for the Next.js web frontend:
Triggers: Runs on push to main and PRs targeting main, scoped to
web/**path changes only.Steps:
npm ciwith cache (usesweb/package-lock.jsonfor cache key)npm run linttsc --noEmitCurrently there is no CI for the web frontend — TypeScript errors and lint issues can land on main undetected. This workflow catches those at PR time.
Greptile Summary
This PR introduces a GitHub Actions workflow that runs ESLint and TypeScript type checking on the Next.js
web/frontend, scoped to path changes underweb/**. The workflow structure is sound — it usesactions/checkout@v4,actions/setup-node@v4with npm caching, and correct least-privilege permissions — but the TypeScript step has a defect that will cause it to fail on every run.npx tsc --noEmitstep runs without first generatingnext-env.d.ts, which is listed inweb/.gitignoreand is therefore absent after a cleannpm ci. This file is needed to resolveimport \"./globals.css\"inweb/app/layout.tsx(via/// <reference types=\"next\" />); without it, TypeScript emitsTS2307and exits non-zero.npm run lint) and caching configuration are correct and should work as expected.Confidence Score: 3/5
The workflow will fail on every run due to a missing type-generation step; merging it as-is adds a permanently broken CI job.
The TypeScript check step is broken out of the box:
web/app/layout.tsximports./globals.css, and the CSS module type declarations that resolve that import are only loaded vianext-env.d.ts, which is gitignored and never generated in this workflow. Every run of the type-check step will exit withTS2307, making the job permanently red. The ESLint step and overall workflow structure are correct..github/workflows/web.yml — specifically the
TypeScript type checkstep at the bottom of the job.Important Files Changed
next-env.d.ts(gitignored, required to resolveimport "./globals.css") is never generated beforetsc --noEmit.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Push or PR triggers workflow] --> B[checkout] B --> C[setup-node v4 with npm cache] C --> D[npm ci] D --> E[npm run lint] E --> F[npx tsc --noEmit] F --> G{next-env.d.ts exists?} G -->|No - gitignored missing| H[TS2307 error on globals.css import - FAILS] G -->|Yes - if generated first| I[Type check passes]Reviews (1): Last reviewed commit: "ci: add web frontend lint and type check..." | Re-trigger Greptile