Skip to content

chore: modernize repository#337

Open
JP-Ellis wants to merge 1 commit intomasterfrom
chore/modernize-repository
Open

chore: modernize repository#337
JP-Ellis wants to merge 1 commit intomasterfrom
chore/modernize-repository

Conversation

@JP-Ellis
Copy link

@JP-Ellis JP-Ellis commented Mar 4, 2026

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_URLimport.meta.env.VITE_API_BASE_URL; substrslice

  • App.tsx — class component → functional with useState/useEffect/ useMemo; PropTypes removed; <Link to={state: ...}> fixed for RR v7

  • ProductPage.tsx — class → functional; window.location.pathnameuseParams<{ 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

  • MakefileREACT_APP_API_BASE_URLVITE_API_BASE_URL in fake_ci

  • .github/workflows/build.ymlnpm inpm 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

@JP-Ellis JP-Ellis requested review from YOU54F and Copilot March 4, 2026 07:32
@JP-Ellis JP-Ellis self-assigned this Mar 4, 2026
@JP-Ellis JP-Ellis force-pushed the chore/modernize-repository branch from d771616 to 2ea77aa Compare March 4, 2026 07:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JP-Ellis JP-Ellis force-pushed the chore/modernize-repository branch 2 times, most recently from bc2962d to f54b9cb Compare March 4, 2026 08:29
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>
@JP-Ellis JP-Ellis force-pushed the chore/modernize-repository branch from f54b9cb to 0c18a8e Compare March 4, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants