chore: lint test/, accept string algorithms in subtle types, unblock CI - #1078
Merged
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Contributor
🤖 End-to-End Test Results - iOSStatus: ✅ Passed 📸 Final Test ScreenshotScreenshot 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).
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.
Contributor
🤖 End-to-End Test Results - AndroidStatus: ✅ Passed 📸 Final Test ScreenshotScreenshot automatically captured from End-to-End tests and will expire in 30 days This comment is automatically updated on each test run. |
This branch was successfully deployed
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
ESLint was skipping
packages/react-native-quick-crypto/test/entirely. The folder is outside the package tsconfig'sinclude(src/**/*.ts), so the typed parser couldn't load the files, and the folder had been added toignoresto work around that. Raised while reviewing #1076.Type-checking the tests also showed that the public
subtlemethods reject algorithm names as strings:subtle.sign('HMAC', key, data)fails to compile. WebCrypto takes anAlgorithmIdentifier(an object or a name string), andnormalizeAlgorithmalready handles strings at runtime, so only the types were wrong.Changes
test/tsconfig.json, which extends the package tsconfig withjest/nodetypes andcomposite: false, so the ESLint project service picks up the tests.**/test/**from the ESLint ignores.test/jestMock.test.ts: usejest.requireActual('../jest')in the mock factory instead of a barerequire, which is the only lint error the tests had.src/subtle.ts: widen the algorithm parameters ofsign,verify,encrypt,decrypt,deriveBits,deriveKey,generateKey,wrapKey,unwrapKey, and the encapsulate/decapsulate methods to| AnyAlgorithm, matchingdigestandimportKey. Each one passes the value tonormalizeAlgorithmbefore reading.name. This only changes types; the emitted JS is the same.CI fixes
These checks were also failing on
mainand 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.Build/Emulator: bumpandroid-actions/setup-androidto v4. v3 installs thetoolspackage, which Google no longer serves, so setup failed with "Failed to find package 'tools'" (Stop installing the deprecatedtoolspackage android-actions/setup-android#538).Compile JS (tsc)onmain: reviewdog'sgithub-pr-reviewreporter needs a PR, so this check failed on every push. It now usesgithub-check(check annotations) outsidepull_requestevents.Testing
bun lint: clean, now includingtest/jest: 19/19tsc --noEmitandbob buildrun by the pre-commit hook: passtsc -p test: the string-algorithm errors are goneNot in this PR
generateKeyis still typed to returnCryptoKey | CryptoKeyPair, with no per-algorithm overloads, so callers have to narrow the result. Fixing that is a separate change.🤖 Generated with Claude Code