Skip to content

Commit 0f32d7b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into replace-package-manager
2 parents 44be588 + 5903eca commit 0f32d7b

File tree

25 files changed

+152
-108
lines changed

25 files changed

+152
-108
lines changed

.github/workflows/check.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,26 @@ jobs:
2929
- uses: actions/setup-node@v4
3030
with:
3131
node-version: lts/jod
32+
# Set up JDK and Android SDK only because we need weak-node-api, to build ferric-example and to run the linting
33+
# TODO: Remove this once we have a way to run linting without building the native code
34+
- name: Set up JDK 17
35+
uses: actions/setup-java@v3
36+
with:
37+
java-version: "17"
38+
distribution: "temurin"
39+
- name: Setup Android SDK
40+
uses: android-actions/setup-android@v3
41+
with:
42+
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
43+
- run: rustup target add x86_64-linux-android
3244
- run: pnpm install --frozen-lockfile
45+
- run: pnpm build
46+
# Bootstrap host package to get weak-node-api and ferric-example to get types
47+
# TODO: Solve this by adding an option to ferric to build only types or by committing the types into the repo as a fixture for an "init" command
48+
- run: pnpm --filter react-native-node-api bootstrap --filter @react-native-node-api/ferric-example bootstrap
3349
- run: pnpm lint
50+
env:
51+
DEBUG: eslint:eslint
3452
- run: pnpm prettier:check
3553
unit-tests:
3654
strategy:

apps/test-app/App.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ function loadTests({
4141
it(exampleName, async () => {
4242
const test = requireExample();
4343
if (test instanceof Function) {
44-
await test();
44+
const result = test();
45+
if (result instanceof Promise) {
46+
await result;
47+
}
4548
}
4649
});
4750
}
@@ -67,8 +70,9 @@ function loadTests({
6770

6871
describeIf(ferricExample, "ferric-example", () => {
6972
it("exports a callable sum function", () => {
70-
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
71-
const exampleAddon = require("ferric-example");
73+
const exampleAddon =
74+
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
75+
require("ferric-example") as typeof import("ferric-example");
7276
const result = exampleAddon.sum(1, 3);
7377
if (result !== 4) {
7478
throw new Error(`Expected 1 + 3 to equal 4, but got ${result}`);

eslint.config.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,50 @@ import eslintConfigPrettier from "eslint-config-prettier/flat";
99
export default tseslint.config(
1010
globalIgnores([
1111
"**/dist/**",
12+
"**/build/**",
1213
"apps/test-app/ios/**",
1314
"packages/host/hermes/**",
1415
"packages/node-addon-examples/examples/**",
16+
"packages/ferric-example/ferric_example.js",
1517
"packages/ferric-example/ferric_example.d.ts",
18+
"packages/ferric-example/target/**",
1619
"packages/node-tests/node/**",
1720
"packages/node-tests/tests/**",
21+
"packages/node-tests/*.generated.js",
22+
"packages/node-tests/*.generated.d.ts",
1823
]),
1924
eslint.configs.recommended,
20-
tseslint.configs.recommended,
25+
tseslint.configs.recommendedTypeChecked,
26+
{
27+
rules: {
28+
"@typescript-eslint/no-floating-promises": [
29+
"error",
30+
{
31+
allowForKnownSafeCalls: [
32+
{ from: "package", name: ["suite", "test"], package: "node:test" },
33+
],
34+
},
35+
],
36+
},
37+
},
38+
{
39+
languageOptions: {
40+
parserOptions: {
41+
projectService: true,
42+
tsconfigRootDir: import.meta.dirname,
43+
},
44+
},
45+
},
2146
eslintConfigPrettier,
2247
{
2348
files: [
2449
"apps/test-app/*.js",
25-
"packages/node-addon-examples/*.js",
50+
"packages/node-addon-examples/**/*.js",
2651
"packages/host/babel-plugin.js",
2752
"packages/host/react-native.config.js",
2853
"packages/node-tests/tests.generated.js",
2954
],
55+
extends: [tseslint.configs.disableTypeChecked],
3056
languageOptions: {
3157
parserOptions: {
3258
sourceType: "commonjs",
@@ -45,7 +71,10 @@ export default tseslint.config(
4571
"packages/gyp-to-cmake/bin/*.js",
4672
"packages/host/bin/*.mjs",
4773
"packages/host/scripts/*.mjs",
74+
"packages/ferric/bin/*.js",
75+
"packages/cmake-rn/bin/*.js",
4876
],
77+
extends: [tseslint.configs.disableTypeChecked],
4978
languageOptions: {
5079
globals: {
5180
...globals.node,

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@
3333
"license": "MIT",
3434
"devDependencies": {
3535
"@changesets/cli": "^2.29.5",
36-
"@eslint/js": "^9.19.0",
36+
"@eslint/js": "^9.32.0",
3737
"@prettier/plugin-oxc": "^0.0.4",
3838
"@reporters/github": "^1.7.2",
3939
"@tsconfig/node22": "^22.0.0",
4040
"@tsconfig/react-native": "3.0.5",
41-
"@types/node": "^22.13.0",
42-
"eslint": "^9.19.0",
43-
"eslint-config-prettier": "^10.1.5",
41+
"@types/node": "^22",
42+
"eslint": "^9.32.0",
43+
"eslint-config-prettier": "^10.1.8",
4444
"globals": "^16.0.0",
4545
"prettier": "^3.6.2",
4646
"react-native": "0.79.5",
4747
"tsx": "^4.20.3",
48-
"typescript": "^5.7.3",
49-
"typescript-eslint": "^8.22.0"
48+
"typescript": "^5.8.0",
49+
"typescript-eslint": "^8.38.0"
5050
}
5151
}

packages/cmake-rn/src/platforms.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export function findPlatformForTarget(target: unknown) {
1818
const platform = Object.values(platforms).find((platform) =>
1919
platformHasTarget(platform, target),
2020
);
21-
assert(platform, `Unable to determine platform from target: ${target}`);
21+
assert(
22+
platform,
23+
`Unable to determine platform from target: ${
24+
typeof target === "string" ? target : JSON.stringify(target)
25+
}`,
26+
);
2227
return platform;
2328
}

packages/cmake-rn/src/weak-node-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function getWeakNodeApiPath(triplet: SupportedTriplet): string {
3737
assert(fs.existsSync(libraryPath), `Expected library at ${libraryPath}`);
3838
return libraryPath;
3939
} else {
40-
throw new Error(`Unexpected triplet: ${triplet}`);
40+
throw new Error(`Unexpected triplet: ${triplet as string}`);
4141
}
4242
}
4343

packages/cmake-rn/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"compilerOptions": {
3+
"composite": true
4+
},
25
"files": [],
36
"references": [
47
{ "path": "./tsconfig.node.json" },

packages/ferric/src/cargo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,6 @@ export function getTargetEnvironmentVariables({
223223
].join(String.fromCharCode(0x1f)),
224224
};
225225
} else {
226-
throw new Error(`Unexpected target: ${target}`);
226+
throw new Error(`Unexpected target: ${target as string}`);
227227
}
228228
}

packages/ferric/src/targets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ export function filterTargetsByPlatform(
9999
} else if (platform === "apple") {
100100
return [...targets].filter(isAppleTarget);
101101
} else {
102-
throw new Error(`Unexpected platform ${platform}`);
102+
throw new Error(`Unexpected platform ${platform as string}`);
103103
}
104104
}

packages/gyp-to-cmake/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ export const program = new Command("gyp-to-cmake")
7878
} else if (stat.isDirectory()) {
7979
transformBindingGypsRecursively(targetPath, options);
8080
} else {
81-
throw new Error(`Expected either a file or a directory: ${path}`);
81+
throw new Error(`Expected either a file or a directory: ${targetPath}`);
8282
}
8383
});

0 commit comments

Comments
 (0)