Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,27 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: lts/jod
# Set up JDK and Android SDK only because we need weak-node-api, to build ferric-example and to run the linting
# TODO: Remove this once we have a way to run linting without building the native code
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
- run: rustup target add x86_64-linux-android
- run: npm ci
- run: npm run build
# Bootstrap host package to get weak-node-api and ferric-example to get types
# 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
- run: npm run bootstrap --workspace react-native-node-api
- run: npm run bootstrap --workspace @react-native-node-api/ferric-example
- run: npm run lint
env:
DEBUG: eslint:eslint
- run: npm run prettier:check
unit-tests:
strategy:
Expand Down
10 changes: 7 additions & 3 deletions apps/test-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function loadTests({
it(exampleName, async () => {
const test = requireExample();
if (test instanceof Function) {
await test();
const result = test();
if (result instanceof Promise) {
await result;
}
}
});
}
Expand All @@ -67,8 +70,9 @@ function loadTests({

describeIf(ferricExample, "ferric-example", () => {
it("exports a callable sum function", () => {
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
const exampleAddon = require("ferric-example");
const exampleAddon =
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
require("ferric-example") as typeof import("ferric-example");
const result = exampleAddon.sum(1, 3);
if (result !== 4) {
throw new Error(`Expected 1 + 3 to equal 4, but got ${result}`);
Expand Down
33 changes: 31 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,50 @@ import eslintConfigPrettier from "eslint-config-prettier/flat";
export default tseslint.config(
globalIgnores([
"**/dist/**",
"**/build/**",
"apps/test-app/ios/**",
"packages/host/hermes/**",
"packages/node-addon-examples/examples/**",
"packages/ferric-example/ferric_example.js",
"packages/ferric-example/ferric_example.d.ts",
"packages/ferric-example/target/**",
"packages/node-tests/node/**",
"packages/node-tests/tests/**",
"packages/node-tests/*.generated.js",
"packages/node-tests/*.generated.d.ts",
]),
eslint.configs.recommended,
tseslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
rules: {
"@typescript-eslint/no-floating-promises": [
"error",
{
allowForKnownSafeCalls: [
{ from: "package", name: ["suite", "test"], package: "node:test" },
],
},
],
},
Comment on lines +28 to +36
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround for nodejs/node#51292

},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
eslintConfigPrettier,
{
files: [
"apps/test-app/*.js",
"packages/node-addon-examples/*.js",
"packages/node-addon-examples/**/*.js",
"packages/host/babel-plugin.js",
"packages/host/react-native.config.js",
"packages/node-tests/tests.generated.js",
],
extends: [tseslint.configs.disableTypeChecked],
languageOptions: {
parserOptions: {
sourceType: "commonjs",
Expand All @@ -45,7 +71,10 @@ export default tseslint.config(
"packages/gyp-to-cmake/bin/*.js",
"packages/host/bin/*.mjs",
"packages/host/scripts/*.mjs",
"packages/ferric/bin/*.js",
"packages/cmake-rn/bin/*.js",
],
extends: [tseslint.configs.disableTypeChecked],
languageOptions: {
globals: {
...globals.node,
Expand Down
Loading
Loading