Skip to content

chore: lint test/, accept string algorithms in subtle types, unblock CI - #1078

Merged
boorad merged 4 commits into
mainfrom
fix/eslint-tests
Oct 5, 2026
Merged

boorad merged 4 commits into
mainfrom
fix/eslint-tests

Conversation

@boorad

@boorad boorad commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

ESLint was skipping packages/react-native-quick-crypto/test/ entirely. The folder is outside the package tsconfig's include (src/**/*.ts), so the typed parser couldn't load the files, and the folder had been added to ignores to work around that. Raised while reviewing #1076.

Type-checking the tests also showed that the public subtle methods reject algorithm names as strings: subtle.sign('HMAC', key, data) fails to compile. WebCrypto takes an AlgorithmIdentifier (an object or a name string), and normalizeAlgorithm already handles strings at runtime, so only the types were wrong.

Changes

  • Add test/tsconfig.json, which extends the package tsconfig with jest/node types and composite: false, so the ESLint project service picks up the tests.
  • Remove **/test/** from the ESLint ignores.
  • test/jestMock.test.ts: use jest.requireActual('../jest') in the mock factory instead of a bare require, which is the only lint error the tests had.
  • src/subtle.ts: widen the algorithm parameters of sign, verify, encrypt, decrypt, deriveBits, deriveKey, generateKey, wrapKey, unwrapKey, and the encapsulate/decapsulate methods to | AnyAlgorithm, matching digest and importKey. Each one passes the value to normalizeAlgorithm before reading .name. This only changes types; the emitted JS is the same.

CI fixes

These checks were also failing on main and on #1076:

  • bun audit: ignore GHSA-vfj7-8cjw-p6xm (braces <=3.0.3, no patched release yet). Like the two existing ignores, it only reaches the audit through metro via the react-native peer, not a consumer's runtime bundle.
  • Android Build/Emulator: bump android-actions/setup-android to v4. v3 installs the tools package, which Google no longer serves, so setup failed with "Failed to find package 'tools'" (Stop installing the deprecated tools package android-actions/setup-android#538).
  • Compile JS (tsc) on main: reviewdog's github-pr-review reporter needs a PR, so this check failed on every push. It now uses github-check (check annotations) outside pull_request events.

Testing

  • bun lint: clean, now including test/
  • jest: 19/19
  • tsc --noEmit and bob build run by the pre-commit hook: pass
  • tsc -p test: the string-algorithm errors are gone

Not in this PR

generateKey is still typed to return CryptoKey | CryptoKeyPair, with no per-algorithm overloads, so callers have to narrow the result. Fixing that is a separate change.

🤖 Generated with Claude Code

Tests were excluded from ESLint because they sit outside tsconfig's include,
so the typed parser couldn't load them. Add test/tsconfig.json so the project
service finds them, drop the test/ ignore, and use jest.requireActual in the
mock factory instead of a bare require.
@boorad boorad self-assigned this Oct 5, 2026
@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-quick-crypto Ready Ready Preview Oct 5, 2026 7:48pm UTC

Request Review

WebCrypto takes an AlgorithmIdentifier (object or name string), and
normalizeAlgorithm already handles strings at runtime, but the public
signatures only allowed objects, so subtle.sign('HMAC', ...) failed to
type-check. Widen them to | AnyAlgorithm, matching digest/importKey.
@boorad boorad changed the title chore(lint): lint test/ with ESLint chore: lint test/ with ESLint; accept string algorithms in subtle types Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🤖 End-to-End Test Results - iOS

Status: ✅ Passed
Platform: iOS
Run: 37365691778

📸 Final Test Screenshot

Maestro Test Results - ios

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

- Ignore GHSA-vfj7-8cjw-p6xm (braces <=3.0.3, no patched release). Like
  the existing ignores, it only reaches the audit through metro via the
  react-native peer, not a consumer's runtime bundle.
- Bump android-actions/setup-android to v4. v3 installs the 'tools'
  package, which Google no longer serves, so setup fails with "Failed to
  find package 'tools'" (android-actions/setup-android#538).
@boorad boorad changed the title chore: lint test/ with ESLint; accept string algorithms in subtle types chore: lint test/, accept string algorithms in subtle types, unblock CI Oct 5, 2026
reviewdog's github-pr-review reporter needs a PR, so Compile JS (tsc)
failed on every push to main. Use github-check outside pull_request
events.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🤖 End-to-End Test Results - Android

Status: ✅ Passed
Platform: Android
Run: 37365691795

📸 Final Test Screenshot

Maestro Test Results - android

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@boorad
boorad merged commit 85b2533 into main Oct 5, 2026
19 of 25 checks passed
@boorad
boorad deleted the fix/eslint-tests branch October 5, 2026 21:46

This branch was successfully deployed

1 active deployment
Preview — 1507ff7e Deployed Oct 5, 2026 by vercel[bot]
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.

1 participant