Open
Conversation
d771616 to
2ea77aa
Compare
There was a problem hiding this comment.
Pull request overview
Modernizes the frontend build/test/lint toolchain by migrating from CRA + Babel + ESLint/PropTypes to Vite + Vitest + TypeScript + Biome, while converting the app codebase from .js/.jsx to .ts/.tsx and updating routing/tests accordingly.
Changes:
- Replace CRA (
react-scripts) with Vite for dev/build and Vitest for testing. - Migrate code to TypeScript and update React components to typed functional patterns (keeping class-based error boundary).
- Replace ESLint/Prettier-style configuration with Biome; update CI workflow/scripts/docs and environment variable naming for Vite.
Reviewed changes
Copilot reviewed 31 out of 33 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Introduces Vite config (plugins/server/build/envPrefix) for the new toolchain. |
vitest.config.ts |
Adds Vitest configuration for jsdom tests + setup files and includes patterns. |
tsconfig.json |
Adds strict TypeScript compiler configuration for the migrated source. |
package.json |
Switches scripts/deps to Vite/Vitest/TS/Biome; adds ESM + Node engine requirement. |
index.html |
Adds Vite entry HTML as the new app root template. |
src/vite-env.d.ts |
Adds Vite client type references for import.meta.env. |
src/setupTests.ts |
Aligns test setup import style for the Vitest environment. |
src/api.ts |
Types the API layer and switches env handling to import.meta.env. |
src/api.pact.spec.ts |
Updates Pact test for Vitest + node environment and TypeScript. |
src/product.ts / src/product.js |
Converts Product model to TypeScript with an explicit data interface. |
src/App.tsx / src/App.js |
Converts App to typed functional component with hooks + updated links. |
src/ProductPage.tsx / src/ProductPage.js |
Converts product page to hooks + router params. |
src/index.tsx / src/index.js |
Updates entrypoint for Vite + router setup and safer root mounting. |
src/Layout.tsx / src/Layout.js |
Converts Layout to typed component and removes PropTypes. |
src/Heading.tsx / src/Heading.js |
Converts Heading to typed component and removes PropTypes. |
src/ErrorBoundary.tsx |
Types the error boundary and removes PropTypes usage. |
src/index.css |
Formatting updates consistent with new formatter rules. |
.github/workflows/build.yml |
Updates CI to use npm ci and adds type-check/lint/build gates. |
Makefile |
Renames env var usage to VITE_API_BASE_URL for fake CI. |
README.md |
Updates documentation to reflect new toolchain, scripts, and env vars. |
biome.jsonc |
Adds Biome configuration and config-file overrides. |
.editorconfig |
Adds repository-wide editor defaults aligned with formatting choices. |
.env.example |
Documents VITE_API_BASE_URL for local configuration. |
public/index.html |
Removes CRA public HTML template (superseded by Vite root index.html). |
.eslintrc.json |
Removes legacy ESLint configuration (replaced by Biome). |
.github/renovate.json |
Minor formatting cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bc2962d to
f54b9cb
Compare
Modernises the entire frontend toolchain in one shot. The app is fully
functional after this commit: `npm run test:pact` still passes, `npm run
build` produces a clean Vite bundle.
The following main replacements have been performed:
- `react-scripts` (CRA) — replaced by Vite
- `prop-types` — replaced by TypeScript
- `cross-env`, `dotenv` — no longer needed with Vite's env handling
- `@babel/preset-react` — superseded by @vitejs/plugin-react
- `eslintConfig` field and `browserslist` field from package.json
- `.eslintrc.json` — replaced by Biome
All remaining dependencies should be up to date.
All 10 source files converted from `.js`/`.jsx` to `.ts`/`.tsx`:
- `product.ts` — adds `ProductData` interface; `Product` class typed
- `api.ts` — full method signatures; `REACT_APP_API_BASE_URL` →
`import.meta.env.VITE_API_BASE_URL`; `substr` → `slice`
- `App.tsx` — class component → functional with `useState`/`useEffect`/
`useMemo`; PropTypes removed; `<Link to={state: ...}>` fixed for RR v7
- `ProductPage.tsx` — class → functional; `window.location.pathname` →
`useParams<{ id: string }>()`
- `ErrorBoundary.tsx` — kept as class component (required by React's error
boundary API); typed with `ErrorBoundaryProps`/`ErrorBoundaryState`
- `Heading.tsx`, `Layout.tsx` — typed functional components; PropTypes removed
- `index.tsx` — removes invalid `history=""` prop from `<BrowserRouter>`
- `api.pact.spec.ts` — adds `// @vitest-environment node` docblock so pact
tests run against a real Node HTTP server rather than jsdom
- `setupTests.ts` — rename only
- `tsconfig.json` — strict mode, `moduleResolution: bundler`, `noEmit`,
`jsx: react-jsx`; types include `vitest/globals`, `@testing-library/jest-dom`,
`node`
- `vite.config.ts` — React plugin, port 3000, `outDir: build`,
`envPrefix: ["VITE_", "PACT_"]`
- `vitest.config.ts` — jsdom environment, globals, 30 s timeout, setup file
- `biome.jsonc` — VCS gitignore integration (excludes build/, pacts/
automatically); `noDefaultExport` suppressed only for `*.config.ts` files
where Vite/Vitest mandate it
- `.editorconfig` — UTF-8, LF, 2-space indent, final newline
- `.env.example` — documents `VITE_API_BASE_URL`
- `index.html` — root Vite entry point (replaces `public/index.html`)
- `src/vite-env.d.ts` — `/// <reference types="vite/client" />`
- `package.json` — `"type": "module"`, `"engines": {"node": ">=24.0.0"}`;
full script suite including `dev`, `type-check`, `check`, `check:fix`
- `Makefile` — `REACT_APP_API_BASE_URL` → `VITE_API_BASE_URL` in fake_ci
- `.github/workflows/build.yml` — `npm i` → `npm ci`; env var renamed;
quality gates added before test step: `type-check`, `check`, `build`
- `README.md` — updated stack table, prerequisites, scripts table, env vars
Ref: PACT-6016
Signed-off-by: JP-Ellis <josh@jpellis.me>
f54b9cb to
0c18a8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernises the entire frontend toolchain in one shot. The app is fully functional after this commit:
npm run test:pactstill passes,npm run buildproduces a clean Vite bundle.The following main replacements have been performed:
react-scripts(CRA) — replaced by Viteprop-types— replaced by TypeScriptcross-env,dotenv— no longer needed with Vite's env handling@babel/preset-react— superseded by @vitejs/plugin-reacteslintConfigfield andbrowserslistfield from package.json.eslintrc.json— replaced by BiomeAll remaining dependencies should be up to date.
All 10 source files converted from
.js/.jsxto.ts/.tsx:product.ts— addsProductDatainterface;Productclass typedapi.ts— full method signatures;REACT_APP_API_BASE_URL→import.meta.env.VITE_API_BASE_URL;substr→sliceApp.tsx— class component → functional withuseState/useEffect/useMemo; PropTypes removed;<Link to={state: ...}>fixed for RR v7ProductPage.tsx— class → functional;window.location.pathname→useParams<{ id: string }>()ErrorBoundary.tsx— kept as class component (required by React's error boundary API); typed withErrorBoundaryProps/ErrorBoundaryStateHeading.tsx,Layout.tsx— typed functional components; PropTypes removedindex.tsx— removes invalidhistory=""prop from<BrowserRouter>api.pact.spec.ts— adds// @vitest-environment nodedocblock so pact tests run against a real Node HTTP server rather than jsdomsetupTests.ts— rename onlytsconfig.json— strict mode,moduleResolution: bundler,noEmit,jsx: react-jsx; types includevitest/globals,@testing-library/jest-dom,nodevite.config.ts— React plugin, port 3000,outDir: build,envPrefix: ["VITE_", "PACT_"]vitest.config.ts— jsdom environment, globals, 30 s timeout, setup filebiome.jsonc— VCS gitignore integration (excludes build/, pacts/ automatically);noDefaultExportsuppressed only for*.config.tsfiles where Vite/Vitest mandate it.editorconfig— UTF-8, LF, 2-space indent, final newline.env.example— documentsVITE_API_BASE_URLindex.html— root Vite entry point (replacespublic/index.html)src/vite-env.d.ts—/// <reference types="vite/client" />package.json—"type": "module","engines": {"node": ">=24.0.0"}; full script suite includingdev,type-check,check,check:fixMakefile—REACT_APP_API_BASE_URL→VITE_API_BASE_URLin fake_ci.github/workflows/build.yml—npm i→npm ci; env var renamed; quality gates added before test step:type-check,check,buildREADME.md— updated stack table, prerequisites, scripts table, env varsRef: PACT-6016