Cut 1.0.0: native fetch, FormsparkError, modern toolchain + CI tests - #12
Merged
Conversation
Audit-driven hardening pass for the package. Runtime: - Reject with FormsparkError on non-2xx responses (was silently resolving with the error body). - encodeURIComponent the formId before path interpolation. - Drop whatwg-fetch polyfill; native fetch is universal across modern browsers, React Native, and Node 18+. - Memoize submit via useCallback([formId]); destructure formId at hook entry. Build: - Replace unmaintained tsdx (46 npm advisories) with tsup. 0 vulnerabilities after migration. - Drop tslib/importHelpers; tsup handles helpers itself. - Bump engines.node to >=18 and TypeScript to 5. CI: - actions/checkout v2 -> v6, actions/setup-node v2 -> v6, node 16 -> 22. - Replace phips28/gh-action-bump-version@master with first-party npm version + softprops/action-gh-release@v2. Bump type read from commit message. README: fix the form ID / action URL note, add an error-handling section.
Two real-network tests exercising the hook end-to-end: - Happy path posts to https://submit-form.com/echo and verifies the echoed payload. - Error path posts to a non-existent form ID and verifies the FormsparkError + 404 status. Plus two cheap state-shape checks: submitting toggles during a call, and submit identity is stable across renders for the same formId. Runs on: - PR open/sync against master (new pull-request.yml workflow). - Push to master (added before the bump/publish step in continuous-deployment.yml). Tooling: vitest + @testing-library/react + happy-dom (already added as devDeps). 15s per-test timeout to absorb network jitter. tsconfig switched to moduleResolution=bundler + ES2022 target + skipLibCheck for compatibility with vitest's modern type declarations.
Check runs lint/build/test on PRs against master and is also invoked as a workflow_call from Deploy, so a master push runs the same validations before bumping and publishing. No more inline duplication between PR and deploy pipelines. Renames: - pull-request.yml -> check.yml - continuous-deployment.yml -> deploy.yml Updates the README badge to point at the renamed Deploy workflow.
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.
Summary
Audit-driven hardening pass. Ships a coherent 1.0.0 that fixes real bugs, modernizes the toolchain, and adds end-to-end tests in one breaking release.
Runtime
FormsparkError(carryingstatus+ parsedbody) on non-2xx responses. Was previously resolving with the error body, so consumers couldn't tell a successful submit from a 422.encodeURIComponenttheformIdbefore path interpolation.whatwg-fetchpolyfill: nativefetchis universal across modern browsers, React Native, and Node 18+.submitviauseCallback([formId])and destructureformIdat hook entry — stable identity across renders.Build
tsdx(46 npm advisories, last release 2020) withtsup.npm audit: 46 vulnerabilities → 0.tslib/importHelpers;tsuphandles helpers itself.engines.nodeto>=18, TypeScript to 5,moduleResolutiontobundler,targetto ES2022.Tests (new)
tests/use-formspark.test.tsxwith four cases:https://submit-form.com/echoand verifies the echoed payload.FormsparkError+ status 404.trueduring the call andfalseafter.submitreference is stable across renders for the sameformId.CI
actions/checkoutv2 → v6,actions/setup-nodev2 → v6, Node 16 → 22,cache: 'npm'.pull-request.ymlworkflow runslint + build + teston PRs againstmaster.continuous-deployment.ymlnow runsnpm testbefore bump/publish.phips28/gh-action-bump-version@master→@v11.0.7(no more moving-branch ref).tsdx lintin the husky pre-commit hook withtsc --noEmit.README
# Yarntrailing whitespace.Error handlingsection.Peer deps
peerDependencies— now^18.0.0 || ^19.0.0.Breaking changes
FormsparkErrorinstead of resolving silently.whatwg-fetchis no longer bundled. Polyfill manually if targeting pre-fetch runtimes.engines.nodeis now>=18.peerDependencies.reactno longer accepts 16.x or 17.x.Test plan
npm install— 0 vulnerabilitiesnpm run lint(tsc --noEmit) — cleannpm run build— emits CJS + ESM + .d.ts (~2 KB)npm test— 4/4 passing locally, including live/echoand 404 callsphips28/gh-action-bump-version@v11.0.7accepts the existingtag-prefix: ''inputNPM_TOKENsecret is still valid