Skip to content

chore: modernise repository#234

Merged
JP-Ellis merged 9 commits intomasterfrom
chore/modernize-repo
Mar 12, 2026
Merged

chore: modernise repository#234
JP-Ellis merged 9 commits intomasterfrom
chore/modernize-repo

Conversation

@JP-Ellis
Copy link
Copy Markdown
Contributor

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

This PR modernises the example repo.

The following main replacements have been performed:

  • react-scripts (CRA) — replaced by Vite
  • prop-types — replaced by TypeScript
  • dotenv — no longer needed with Vite's env handling
  • eslintConfig field and browserslist field from package.json
  • .eslintrc.json and prettier — replaced by Biome
  • cypress.json / cypress-stubbed.json — replaced by cypress.config.ts
  • cypress/plugins/ — replaced by setupNodeEvents in cypress.config.ts
  • cy.server() / cy.route() (removed in Cypress v9) — replaced by cy.intercept()
  • rimraf, rambda, @pact-foundation/pact-node — no longer needed

All remaining dependencies should be up to date.

All source files converted from .js to .ts/.tsx:

  • api.ts — full method signatures; REACT_APP_API_BASE_URLimport.meta.env.VITE_API_BASE_URL; substrslice; removes
    deprecated axios/lib/adapters/http import
  • App.tsx, ProductPage.tsx, ErrorPage.tsx — class components → functional with useState/useEffect; PropTypes removed;
    withRouteruseNavigate/useParams
  • Heading.tsx, Layout.tsx — typed functional components; PropTypes removed
  • index.tsxReactDOM.rendercreateRoot; <Switch>/<Route component><Routes>/<Route element>

Cypress files updated for v14:

  • cypress/support/pact-tasks.ts — replaces cypress/plugins/cypress-pact.js; rimrafnode:fs/promises rm(); converted from CJS
    to ESM
  • cypress/support/commands.ts — removes cy.server()/cy.route() and browser-level request interception; app now calls the Pact mock
    server directly on a fixed port so cy.intercept() is used for aliasing only
  • cypress/e2e/products.cy.ts — moved from cypress/integration/test/products.js; imports from @pact-foundation/pact instead of
    @pact-foundation/pact-web; cy.visit uses relative path via baseUrl

Config files added:

  • tsconfig.json — strict mode, moduleResolution: bundler, noEmit, jsx: react-jsx, vite/client types
  • tsconfig.cypress.json — CommonJS module resolution for Cypress support files
  • vite.config.ts — React plugin, port 3000, outDir: build, envPrefix: ["VITE_", "PACT_", "PROVIDER_"]
  • biome.jsonc — VCS gitignore integration; recommended rules; noExcessiveLinesPerFunction suppressed for cypress/** where test
    suites are intentionally long
  • .editorconfig — UTF-8, LF, 2-space indent, final newline
  • index.html — root Vite entry point (replaces public/index.html)

Other:

  • package.json"type": "module", "engines": {"node": ">=24.0.0"}; full script suite including dev, type-check, lint,
    check
  • MakefileREACT_APP_API_BASE_URLVITE_API_BASE_URL
  • .github/workflows/build.yml — Node 14 → 24; npm inpm ci; env var renamed; quality gates added before test: type-check,
    check, build; complete job follows standard Test completion check pattern

Ref: PACT-6017

Signed-off-by: JP-Ellis <josh@jpellis.me>
Copy link
Copy Markdown

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

Modernises the repository by migrating the React app from CRA/JS to Vite/TypeScript, replacing ESLint/Prettier with Biome, and updating Cypress + Pact integration for newer Cypress versions.

Changes:

  • Migrate build tooling to Vite + TypeScript (new Vite config, TS configs, new Vite entry index.html).
  • Convert React source from .js to .ts/.tsx and update routing/rendering to current React Router + createRoot.
  • Update Cypress setup to cypress.config.ts and replace legacy cy.server()/cy.route() approach with cy.intercept() + Node-side Pact tasks.

Reviewed changes

Copilot reviewed 39 out of 43 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
vite.config.ts Adds Vite configuration (React plugin, dev server port, build output).
tsconfig.json Introduces strict TS config for app source.
tsconfig.cypress.json Adds Cypress-specific TS config (node resolution, Cypress types).
src/setupTests.js Removes CRA/Jest setup.
src/index.tsx Adds Vite/React entrypoint using createRoot and Routes.
src/index.js Removes legacy CRA entrypoint.
src/index.css Formatting updates (quotes/line wrapping).
src/api.ts Replaces JS API client with typed TS implementation using Vite env vars.
src/api.js Removes legacy JS API client.
src/ProductPage.tsx Converts Product page to functional TS component using hooks + router hooks.
src/ProductPage.js Removes legacy class component implementation.
src/Layout.tsx Adds typed Layout component.
src/Layout.js Removes legacy Layout component + PropTypes.
src/Heading.tsx Adds typed Heading component.
src/Heading.js Removes legacy Heading component + PropTypes.
src/ErrorPage.tsx Converts Error page to functional TS component using useLocation.
src/ErrorPage.js Removes legacy Error page implementation.
src/App.tsx Converts App to functional TS component using hooks + updated routing patterns.
src/App.js Removes legacy class App + PropTypes.
public/index.html Removes CRA HTML template.
package.json Updates dependencies/scripts for Vite, TS, Biome, Cypress v14, Node engine.
index.html Adds Vite root HTML entrypoint.
cypress/support/pact-tasks.ts Adds Cypress node event tasks for Pact mock server lifecycle.
cypress/support/index.js Removes legacy Cypress support index file.
cypress/support/index.d.ts Adds TS typings for custom Cypress commands.
cypress/support/e2e.ts Adds Cypress support entrypoint for e2e (imports commands).
cypress/support/commands.ts Reimplements custom Cypress Pact commands using cy.intercept() + tasks.
cypress/support/commands.js Removes legacy Cypress Pact command implementation (CJS).
cypress/plugins/index.js Removes legacy Cypress plugins entrypoint.
cypress/plugins/cypress-pact.js Removes legacy Pact plugin implementation.
cypress/integration/test/products.js Keeps legacy integration spec (now largely obsolete with new config).
cypress/fixtures/example.json Minor formatting change.
cypress/e2e/products.cy.ts Adds new Cypress v10+ style e2e spec in TS.
cypress.json Removes legacy Cypress config.
cypress.config.ts Adds Cypress v10+ config with setupNodeEvents + env defaults.
cypress-stubbed.json Removes legacy stubbed Cypress config.
biome.jsonc Adds Biome config (lint/format rules).
Makefile Updates env var naming for Vite (VITE_API_BASE_URL).
.github/workflows/build.yml Updates CI to Node 24, uses npm ci, adds type-check/lint/build gates, adds completion job.
.github/renovate.json Minor JSON formatting cleanup.
.eslintrc.json Removes ESLint config (replaced by Biome).
.editorconfig Adds editorconfig defaults (2-space indent, LF, etc.).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cypress/support/commands.ts Outdated
Comment thread cypress/support/commands.ts
Comment thread cypress/integration/test/products.js Outdated
Comment thread package.json
Comment thread src/api.ts Outdated
Comment thread src/App.tsx Outdated
Comment thread .github/workflows/build.yml Outdated
Comment thread Makefile Outdated
@JP-Ellis JP-Ellis force-pushed the chore/modernize-repo branch 3 times, most recently from 0b36ef5 to e3cc181 Compare March 4, 2026 11:21
JP-Ellis added 2 commits March 5, 2026 09:22
This includes:

- converting class components to functional components with hooks
- using TS interfaces instead of prop types
- Update some React Router APIs to v7
- Update some env vars to use VITE_ in preparation for vite support

Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis force-pushed the chore/modernize-repo branch 2 times, most recently from 570fcc0 to 563f0d2 Compare March 5, 2026 00:11
JP-Ellis added 6 commits March 5, 2026 15:51
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
- Upgrade Node.js from 14 to 24
- Use npm ci instead of npm i
- Add quality gate steps: type-check, check (Biome), build before test
- Add complete job as single required status check

Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis force-pushed the chore/modernize-repo branch from 563f0d2 to 04c4410 Compare March 5, 2026 04:51
@JP-Ellis JP-Ellis merged commit e1d9698 into master Mar 12, 2026
8 of 10 checks passed
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