From 43981ea8a2298fc0ce8497c04710c27c8e8b1906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Fri, 1 Aug 2025 17:31:09 +0200 Subject: [PATCH 1/8] Fixing tsconfig hierarchy --- packages/cmake-rn/tsconfig.json | 3 +++ packages/host/tsconfig.json | 3 +++ packages/node-addon-examples/tsconfig.json | 3 +++ packages/node-tests/tsconfig.json | 8 +++++++- tsconfig.json | 6 +++++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/cmake-rn/tsconfig.json b/packages/cmake-rn/tsconfig.json index a1c18413..95abca17 100644 --- a/packages/cmake-rn/tsconfig.json +++ b/packages/cmake-rn/tsconfig.json @@ -1,4 +1,7 @@ { + "compilerOptions": { + "composite": true + }, "files": [], "references": [ { "path": "./tsconfig.node.json" }, diff --git a/packages/host/tsconfig.json b/packages/host/tsconfig.json index 00410045..6f503295 100644 --- a/packages/host/tsconfig.json +++ b/packages/host/tsconfig.json @@ -1,4 +1,7 @@ { + "compilerOptions": { + "composite": true + }, "files": [], "references": [ { "path": "./tsconfig.node.json" }, diff --git a/packages/node-addon-examples/tsconfig.json b/packages/node-addon-examples/tsconfig.json index 4b659503..7ad187c2 100644 --- a/packages/node-addon-examples/tsconfig.json +++ b/packages/node-addon-examples/tsconfig.json @@ -1,4 +1,7 @@ { + "compilerOptions": { + "composite": true + }, "files": [], "references": [ { "path": "./tsconfig.tests.json" }, diff --git a/packages/node-tests/tsconfig.json b/packages/node-tests/tsconfig.json index ac70f799..666767cf 100644 --- a/packages/node-tests/tsconfig.json +++ b/packages/node-tests/tsconfig.json @@ -1,5 +1,11 @@ { - "files": [], + "extends": "@tsconfig/node22", + "compilerOptions": { + "composite": true, + "outDir": "./dist", + "emitDeclarationOnly": true + }, + "files": ["rolldown.config.mts"], "references": [ { "path": "./tsconfig.common.json" }, { "path": "./tsconfig.node-scripts.json" } diff --git a/tsconfig.json b/tsconfig.json index f5c80f57..66a9a0e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,9 @@ { - "files": [], + "extends": "@tsconfig/node22", + "compilerOptions": { + "noEmit": true + }, + "files": ["prettier.config.mjs", "eslint.config.js"], "references": [ { "path": "./packages/host/tsconfig.json" }, { "path": "./packages/gyp-to-cmake/tsconfig.json" }, From 2fd39356a1d07949a85ed85d75f2a19ac58191ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 2 Aug 2025 20:37:56 +0200 Subject: [PATCH 2/8] Tuning eslint config --- eslint.config.js | 21 +++++++++++++++++++-- tsconfig.json | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 794defe7..99e2b058 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -9,24 +9,38 @@ 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, + { + 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", @@ -45,7 +59,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, diff --git a/tsconfig.json b/tsconfig.json index 66a9a0e7..25d505a0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@tsconfig/node22", "compilerOptions": { - "noEmit": true + "noEmit": true, + "allowJs": true }, "files": ["prettier.config.mjs", "eslint.config.js"], "references": [ From 18d4f4735e9b603b0a46e0b6dc434d70f30fdb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 2 Aug 2025 22:28:36 +0200 Subject: [PATCH 3/8] Configure no-floating-promises --- eslint.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/eslint.config.js b/eslint.config.js index 99e2b058..c0af837e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,6 +23,18 @@ export default tseslint.config( ]), eslint.configs.recommended, tseslint.configs.recommendedTypeChecked, + { + rules: { + "@typescript-eslint/no-floating-promises": [ + "error", + { + allowForKnownSafeCalls: [ + { from: "package", name: ["suite", "test"], package: "node:test" }, + ], + }, + ], + }, + }, { languageOptions: { parserOptions: { From ed56fceb95c1fcd7bbfbcd34a5f0bede41777127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 2 Aug 2025 22:29:58 +0200 Subject: [PATCH 4/8] Updating lint related packages --- package-lock.json | 266 ++++++++++++++++++++++++++++------------------ package.json | 12 +-- 2 files changed, 167 insertions(+), 111 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e84baf8..051c13fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,20 +18,20 @@ ], "devDependencies": { "@changesets/cli": "^2.29.5", - "@eslint/js": "^9.19.0", + "@eslint/js": "^9.32.0", "@prettier/plugin-oxc": "^0.0.4", "@reporters/github": "^1.7.2", "@tsconfig/node22": "^22.0.0", "@tsconfig/react-native": "3.0.5", - "@types/node": "^22.13.0", - "eslint": "^9.19.0", - "eslint-config-prettier": "^10.1.5", + "@types/node": "^22", + "eslint": "^9.32.0", + "eslint-config-prettier": "^10.1.8", "globals": "^16.0.0", "prettier": "^3.6.2", "react-native": "0.79.5", "tsx": "^4.20.3", - "typescript": "^5.7.3", - "typescript-eslint": "^8.22.0" + "typescript": "^5.8", + "typescript-eslint": "^8.38.0" } }, "apps/test-app": { @@ -2984,9 +2984,9 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.6.1.tgz", - "integrity": "sha512-KTsJMmobmbrFLe3LDh0PC2FXpcSYJt/MLjlkh/9LEnmKYLSYmT/0EW9JWANjeoemiuZrmogti0tW5Ch+qNUYDw==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", + "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", "dev": true, "license": "MIT", "dependencies": { @@ -3026,9 +3026,9 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.0.tgz", - "integrity": "sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.0.tgz", + "integrity": "sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3041,9 +3041,9 @@ } }, "node_modules/@eslint/config-helpers": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.1.tgz", - "integrity": "sha512-RI17tsD2frtDu/3dmI7QRrD4bedNKPM08ziRYaC5AhkGrzIAJelm9kJU1TznK+apx6V+cqRz8tfpEeG3oIyjxw==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.0.tgz", + "integrity": "sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==", "dev": true, "license": "Apache-2.0", "engines": { @@ -3051,9 +3051,9 @@ } }, "node_modules/@eslint/core": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.13.0.tgz", - "integrity": "sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==", + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.1.tgz", + "integrity": "sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3101,13 +3101,16 @@ } }, "node_modules/@eslint/js": { - "version": "9.25.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.25.0.tgz", - "integrity": "sha512-iWhsUS8Wgxz9AXNfvfOPFSW4VfMXdVhp1hjkZVhXCrpgh/aLcc45rX6MPu+tIVUWDw0HfNwth7O28M1xDxNf9w==", + "version": "9.32.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.32.0.tgz", + "integrity": "sha512-BBpRFZK3eX6uMLKz8WxFOBIFFcGFJ/g8XuwjTHCqHROSIsopI+ddn/d5Cfh36+7+e5edVS8dbSHnBNhrLEX0zg==", "dev": true, "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" } }, "node_modules/@eslint/object-schema": { @@ -3121,13 +3124,13 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.8.tgz", - "integrity": "sha512-ZAoA40rNMPwSm+AeHpCq8STiNAwzWLJuP8Xv4CHIc9wv/PSuExjMrmjfYNj682vW0OOiZ1HKxzvjQr9XZIisQA==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.4.tgz", + "integrity": "sha512-Ul5l+lHEcw3L5+k8POx6r74mxEYKG5kOb6Xpy2gCRW6zweT6TEhAf8vhxGgjhqrd/VO/Dirhsb+1hNpD1ue9hw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^0.13.0", + "@eslint/core": "^0.15.1", "levn": "^0.4.1" }, "engines": { @@ -6679,21 +6682,21 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.30.1.tgz", - "integrity": "sha512-v+VWphxMjn+1t48/jO4t950D6KR8JaJuNXzi33Ve6P8sEmPr5k6CEXjdGwT6+LodVnEa91EQCtwjWNUCPweo+Q==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.38.0.tgz", + "integrity": "sha512-CPoznzpuAnIOl4nhj4tRr4gIPj5AfKgkiJmGQDaq+fQnRJTYlcBjbX3wbciGmpoPf8DREufuPRe1tNMZnGdanA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.30.1", - "@typescript-eslint/type-utils": "8.30.1", - "@typescript-eslint/utils": "8.30.1", - "@typescript-eslint/visitor-keys": "8.30.1", + "@typescript-eslint/scope-manager": "8.38.0", + "@typescript-eslint/type-utils": "8.38.0", + "@typescript-eslint/utils": "8.38.0", + "@typescript-eslint/visitor-keys": "8.38.0", "graphemer": "^1.4.0", - "ignore": "^5.3.1", + "ignore": "^7.0.0", "natural-compare": "^1.4.0", - "ts-api-utils": "^2.0.1" + "ts-api-utils": "^2.1.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6703,22 +6706,32 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "@typescript-eslint/parser": "^8.38.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/@typescript-eslint/parser": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.30.1.tgz", - "integrity": "sha512-H+vqmWwT5xoNrXqWs/fesmssOW70gxFlgcMlYcBaWNPIEWDgLa4W9nkSPmhuOgLnXq9QYgkZ31fhDyLhleCsAg==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.38.0.tgz", + "integrity": "sha512-Zhy8HCvBUEfBECzIl1PKqF4p11+d0aUJS1GeUiuqK9WmOug8YCmC4h4bjyBvMyAMI9sbRczmrYL5lKg/YMbrcQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.30.1", - "@typescript-eslint/types": "8.30.1", - "@typescript-eslint/typescript-estree": "8.30.1", - "@typescript-eslint/visitor-keys": "8.30.1", + "@typescript-eslint/scope-manager": "8.38.0", + "@typescript-eslint/types": "8.38.0", + "@typescript-eslint/typescript-estree": "8.38.0", + "@typescript-eslint/visitor-keys": "8.38.0", "debug": "^4.3.4" }, "engines": { @@ -6733,15 +6746,37 @@ "typescript": ">=4.8.4 <5.9.0" } }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.38.0.tgz", + "integrity": "sha512-dbK7Jvqcb8c9QfH01YB6pORpqX1mn5gDZc9n63Ak/+jD67oWXn3Gs0M6vddAN+eDXBCS5EmNWzbSxsn9SzFWWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.38.0", + "@typescript-eslint/types": "^8.38.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.30.1.tgz", - "integrity": "sha512-+C0B6ChFXZkuaNDl73FJxRYT0G7ufVPOSQkqkpM/U198wUwUFOtgo1k/QzFh1KjpBitaK7R1tgjVz6o9HmsRPg==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz", + "integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.30.1", - "@typescript-eslint/visitor-keys": "8.30.1" + "@typescript-eslint/types": "8.38.0", + "@typescript-eslint/visitor-keys": "8.38.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6751,17 +6786,35 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.38.0.tgz", + "integrity": "sha512-Lum9RtSE3EroKk/bYns+sPOodqb2Fv50XOl/gMviMKNvanETUuUcC9ObRbzrJ4VSd2JalPqgSAavwrPiPvnAiQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.30.1.tgz", - "integrity": "sha512-64uBF76bfQiJyHgZISC7vcNz3adqQKIccVoKubyQcOnNcdJBvYOILV1v22Qhsw3tw3VQu5ll8ND6hycgAR5fEA==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.38.0.tgz", + "integrity": "sha512-c7jAvGEZVf0ao2z+nnz8BUaHZD09Agbh+DY7qvBQqLiz8uJzRgVPj5YvOh8I8uEiH8oIUGIfHzMwUcGVco/SJg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.30.1", - "@typescript-eslint/utils": "8.30.1", + "@typescript-eslint/types": "8.38.0", + "@typescript-eslint/typescript-estree": "8.38.0", + "@typescript-eslint/utils": "8.38.0", "debug": "^4.3.4", - "ts-api-utils": "^2.0.1" + "ts-api-utils": "^2.1.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6776,9 +6829,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.30.1.tgz", - "integrity": "sha512-81KawPfkuulyWo5QdyG/LOKbspyyiW+p4vpn4bYO7DM/hZImlVnFwrpCTnmNMOt8CvLRr5ojI9nU1Ekpw4RcEw==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz", + "integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==", "dev": true, "license": "MIT", "engines": { @@ -6790,20 +6843,22 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.30.1.tgz", - "integrity": "sha512-kQQnxymiUy9tTb1F2uep9W6aBiYODgq5EMSk6Nxh4Z+BDUoYUSa029ISs5zTzKBFnexQEh71KqwjKnRz58lusQ==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz", + "integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.30.1", - "@typescript-eslint/visitor-keys": "8.30.1", + "@typescript-eslint/project-service": "8.38.0", + "@typescript-eslint/tsconfig-utils": "8.38.0", + "@typescript-eslint/types": "8.38.0", + "@typescript-eslint/visitor-keys": "8.38.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", - "ts-api-utils": "^2.0.1" + "ts-api-utils": "^2.1.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6843,16 +6898,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.30.1.tgz", - "integrity": "sha512-T/8q4R9En2tcEsWPQgB5BQ0XJVOtfARcUvOa8yJP3fh9M/mXraLxZrkCfGb6ChrO/V3W+Xbd04RacUEqk1CFEQ==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.38.0.tgz", + "integrity": "sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.30.1", - "@typescript-eslint/types": "8.30.1", - "@typescript-eslint/typescript-estree": "8.30.1" + "@eslint-community/eslint-utils": "^4.7.0", + "@typescript-eslint/scope-manager": "8.38.0", + "@typescript-eslint/types": "8.38.0", + "@typescript-eslint/typescript-estree": "8.38.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6867,14 +6922,14 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.30.1.tgz", - "integrity": "sha512-aEhgas7aJ6vZnNFC7K4/vMGDGyOiqWcYZPpIWrTKuTAlsvDNKy2GFDqh9smL+iq069ZvR0YzEeq0B8NJlLzjFA==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz", + "integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.30.1", - "eslint-visitor-keys": "^4.2.0" + "@typescript-eslint/types": "8.38.0", + "eslint-visitor-keys": "^4.2.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6916,9 +6971,9 @@ } }, "node_modules/acorn": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", - "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -8650,20 +8705,20 @@ } }, "node_modules/eslint": { - "version": "9.25.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.25.0.tgz", - "integrity": "sha512-MsBdObhM4cEwkzCiraDv7A6txFXEqtNXOb877TsSp2FCkBNl8JfVQrmiuDqC1IkejT6JLPzYBXx/xAiYhyzgGA==", + "version": "9.32.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.32.0.tgz", + "integrity": "sha512-LSehfdpgMeWcTZkWZVIJl+tkZ2nuSkyyB9C27MZqFWXuph7DvaowgcTvKqxvpLW1JZIk8PN7hFY3Rj9LQ7m7lg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.20.0", - "@eslint/config-helpers": "^0.2.1", - "@eslint/core": "^0.13.0", + "@eslint/config-array": "^0.21.0", + "@eslint/config-helpers": "^0.3.0", + "@eslint/core": "^0.15.0", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.25.0", - "@eslint/plugin-kit": "^0.2.8", + "@eslint/js": "9.32.0", + "@eslint/plugin-kit": "^0.3.4", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", @@ -8674,9 +8729,9 @@ "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.3.0", - "eslint-visitor-keys": "^4.2.0", - "espree": "^10.3.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -8711,9 +8766,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "10.1.5", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.5.tgz", - "integrity": "sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==", + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", "bin": { @@ -8727,9 +8782,9 @@ } }, "node_modules/eslint-scope": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz", - "integrity": "sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -8757,15 +8812,15 @@ } }, "node_modules/espree": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", - "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.14.0", + "acorn": "^8.15.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.2.0" + "eslint-visitor-keys": "^4.2.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -13760,15 +13815,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.30.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.30.1.tgz", - "integrity": "sha512-D7lC0kcehVH7Mb26MRQi64LMyRJsj3dToJxM1+JVTl53DQSV5/7oUGWQLcKl1C1KnoVHxMMU2FNQMffr7F3Row==", + "version": "8.38.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.38.0.tgz", + "integrity": "sha512-FsZlrYK6bPDGoLeZRuvx2v6qrM03I0U0SnfCLPs/XCCPCFD80xU9Pg09H/K+XFa68uJuZo7l/Xhs+eDRg2l3hg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.30.1", - "@typescript-eslint/parser": "8.30.1", - "@typescript-eslint/utils": "8.30.1" + "@typescript-eslint/eslint-plugin": "8.38.0", + "@typescript-eslint/parser": "8.38.0", + "@typescript-eslint/typescript-estree": "8.38.0", + "@typescript-eslint/utils": "8.38.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index cac8f8d6..677d8c50 100644 --- a/package.json +++ b/package.json @@ -43,19 +43,19 @@ "license": "MIT", "devDependencies": { "@changesets/cli": "^2.29.5", - "@eslint/js": "^9.19.0", + "@eslint/js": "^9.32.0", "@prettier/plugin-oxc": "^0.0.4", "@reporters/github": "^1.7.2", "@tsconfig/node22": "^22.0.0", "@tsconfig/react-native": "3.0.5", - "@types/node": "^22.13.0", - "eslint": "^9.19.0", - "eslint-config-prettier": "^10.1.5", + "@types/node": "^22", + "eslint": "^9.32.0", + "eslint-config-prettier": "^10.1.8", "globals": "^16.0.0", "prettier": "^3.6.2", "react-native": "0.79.5", "tsx": "^4.20.3", - "typescript": "^5.7.3", - "typescript-eslint": "^8.22.0" + "typescript": "^5.8.0", + "typescript-eslint": "^8.38.0" } } From 93e31b13a2de4e7254098e6c275d6922097e9dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 3 Aug 2025 15:44:44 +0200 Subject: [PATCH 5/8] Add debug info when running eslint --- .github/workflows/check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c84b9b62..7c9c8338 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,6 +26,8 @@ jobs: node-version: lts/jod - run: npm ci - run: npm run lint + env: + DEBUG: eslint:eslint - run: npm run prettier:check unit-tests: strategy: From cc7ffb459e5e2d1e22bb1e54dbc1e109ac7871e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 3 Aug 2025 15:46:31 +0200 Subject: [PATCH 6/8] Fix lint issues --- apps/test-app/App.tsx | 10 ++- packages/cmake-rn/src/platforms.ts | 7 +- packages/cmake-rn/src/weak-node-api.ts | 2 +- packages/ferric/src/cargo.ts | 2 +- packages/ferric/src/targets.ts | 2 +- packages/gyp-to-cmake/src/cli.ts | 2 +- packages/host/scripts/node-api-functions.ts | 2 +- .../host/src/node/babel-plugin/plugin.test.ts | 2 +- packages/host/src/node/cli/link-modules.ts | 2 +- packages/host/src/node/cli/program.ts | 4 +- packages/host/src/node/path-utils.test.ts | 9 +- packages/host/src/node/path-utils.ts | 25 +++--- packages/host/src/react-native/index.ts | 4 +- packages/node-addon-examples/src/index.ts | 88 ++++++++----------- .../node-addon-examples/tests/async/addon.js | 2 - .../tests/buffers/addon.js | 10 +-- 16 files changed, 75 insertions(+), 98 deletions(-) diff --git a/apps/test-app/App.tsx b/apps/test-app/App.tsx index 102e3c8c..62c59944 100644 --- a/apps/test-app/App.tsx +++ b/apps/test-app/App.tsx @@ -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; + } } }); } @@ -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}`); diff --git a/packages/cmake-rn/src/platforms.ts b/packages/cmake-rn/src/platforms.ts index 5f333a1c..cf892263 100644 --- a/packages/cmake-rn/src/platforms.ts +++ b/packages/cmake-rn/src/platforms.ts @@ -18,6 +18,11 @@ export function findPlatformForTarget(target: unknown) { const platform = Object.values(platforms).find((platform) => platformHasTarget(platform, target), ); - assert(platform, `Unable to determine platform from target: ${target}`); + assert( + platform, + `Unable to determine platform from target: ${ + typeof target === "string" ? target : JSON.stringify(target) + }`, + ); return platform; } diff --git a/packages/cmake-rn/src/weak-node-api.ts b/packages/cmake-rn/src/weak-node-api.ts index 0e247fa6..496905d7 100644 --- a/packages/cmake-rn/src/weak-node-api.ts +++ b/packages/cmake-rn/src/weak-node-api.ts @@ -37,7 +37,7 @@ export function getWeakNodeApiPath(triplet: SupportedTriplet): string { assert(fs.existsSync(libraryPath), `Expected library at ${libraryPath}`); return libraryPath; } else { - throw new Error(`Unexpected triplet: ${triplet}`); + throw new Error(`Unexpected triplet: ${triplet as string}`); } } diff --git a/packages/ferric/src/cargo.ts b/packages/ferric/src/cargo.ts index e63ac74a..da4e8be9 100644 --- a/packages/ferric/src/cargo.ts +++ b/packages/ferric/src/cargo.ts @@ -223,6 +223,6 @@ export function getTargetEnvironmentVariables({ ].join(String.fromCharCode(0x1f)), }; } else { - throw new Error(`Unexpected target: ${target}`); + throw new Error(`Unexpected target: ${target as string}`); } } diff --git a/packages/ferric/src/targets.ts b/packages/ferric/src/targets.ts index c1990d16..5cc7d80f 100644 --- a/packages/ferric/src/targets.ts +++ b/packages/ferric/src/targets.ts @@ -99,6 +99,6 @@ export function filterTargetsByPlatform( } else if (platform === "apple") { return [...targets].filter(isAppleTarget); } else { - throw new Error(`Unexpected platform ${platform}`); + throw new Error(`Unexpected platform ${platform as string}`); } } diff --git a/packages/gyp-to-cmake/src/cli.ts b/packages/gyp-to-cmake/src/cli.ts index 91b64b9c..133bd6f9 100644 --- a/packages/gyp-to-cmake/src/cli.ts +++ b/packages/gyp-to-cmake/src/cli.ts @@ -78,6 +78,6 @@ export const program = new Command("gyp-to-cmake") } else if (stat.isDirectory()) { transformBindingGypsRecursively(targetPath, options); } else { - throw new Error(`Expected either a file or a directory: ${path}`); + throw new Error(`Expected either a file or a directory: ${targetPath}`); } }); diff --git a/packages/host/scripts/node-api-functions.ts b/packages/host/scripts/node-api-functions.ts index b2a22a15..c554a053 100644 --- a/packages/host/scripts/node-api-functions.ts +++ b/packages/host/scripts/node-api-functions.ts @@ -51,7 +51,7 @@ export function getNodeApiHeaderAST(version: NodeApiVersion) { maxBuffer: 1024 * 1024 * 10, }, ); - const parsed = JSON.parse(output); + const parsed = JSON.parse(output) as unknown; return clangAstDump.parse(parsed); } diff --git a/packages/host/src/node/babel-plugin/plugin.test.ts b/packages/host/src/node/babel-plugin/plugin.test.ts index 5f34563a..7dae2979 100644 --- a/packages/host/src/node/babel-plugin/plugin.test.ts +++ b/packages/host/src/node/babel-plugin/plugin.test.ts @@ -10,7 +10,7 @@ import { setupTempDirectory } from "../test-utils.js"; type TestTransformationOptions = { files: Record; inputFilePath: string; - assertion(code: string): void; + assertion: (code: string) => void; options?: PluginOptions; }; diff --git a/packages/host/src/node/cli/link-modules.ts b/packages/host/src/node/cli/link-modules.ts index 883c3e21..6053fc68 100644 --- a/packages/host/src/node/cli/link-modules.ts +++ b/packages/host/src/node/cli/link-modules.ts @@ -152,6 +152,6 @@ export function getLinkedModuleOutputPath( } else if (platform === "apple") { return path.join(getAutolinkPath(platform), libraryName + ".xcframework"); } else { - throw new Error(`Unsupported platform: ${platform}`); + throw new Error(`Unsupported platform: ${platform as string}`); } } diff --git a/packages/host/src/node/cli/program.ts b/packages/host/src/node/cli/program.ts index 0c98021d..4747a23e 100644 --- a/packages/host/src/node/cli/program.ts +++ b/packages/host/src/node/cli/program.ts @@ -38,7 +38,7 @@ function getLinker(platform: PlatformName): ModuleLinker { } else if (platform === "apple") { return linkXcframework; } else { - throw new Error(`Unknown platform: ${platform}`); + throw new Error(`Unknown platform: ${platform as string}`); } } @@ -48,7 +48,7 @@ function getPlatformDisplayName(platform: PlatformName) { } else if (platform === "apple") { return "Apple"; } else { - throw new Error(`Unknown platform: ${platform}`); + throw new Error(`Unknown platform: ${platform as string}`); } } diff --git a/packages/host/src/node/path-utils.test.ts b/packages/host/src/node/path-utils.test.ts index 8195e373..cc6b307b 100644 --- a/packages/host/src/node/path-utils.test.ts +++ b/packages/host/src/node/path-utils.test.ts @@ -399,7 +399,7 @@ describe("findNodeApiModulePaths", () => { }); describe("findNodeApiModulePathsByDependency", () => { - it.only("should find Node-API paths by dependency (excluding certain packages)", async (context) => { + it("should find Node-API paths by dependency (excluding certain packages)", async (context) => { const packagesNames = ["lib-a", "lib-b", "lib-c"]; const tempDir = setupTempDirectory(context, { "app/package.json": JSON.stringify({ @@ -489,16 +489,13 @@ describe("findNodeAddonForBindings()", () => { }; for (const [name, relPath] of Object.entries(expectedPaths)) { - it(`should look for addons in common paths (${name} in "${relPath}")`, async (context) => { + it(`should look for addons in common paths (${name} in "${relPath}")`, (context) => { // Arrange const tempDirectoryPath = setupTempDirectory(context, { [relPath]: "// This is supposed to be a binary file", }); // Act - const actualPath = await findNodeAddonForBindings( - name, - tempDirectoryPath, - ); + const actualPath = findNodeAddonForBindings(name, tempDirectoryPath); // Assert const expectedAbsPath = path.join(tempDirectoryPath, relPath); assert.equal(actualPath, expectedAbsPath); diff --git a/packages/host/src/node/path-utils.ts b/packages/host/src/node/path-utils.ts index f0fa846a..ffec330a 100644 --- a/packages/host/src/node/path-utils.ts +++ b/packages/host/src/node/path-utils.ts @@ -24,10 +24,7 @@ export type PathSuffixChoice = (typeof PATH_SUFFIX_CHOICES)[number]; export function assertPathSuffix( value: unknown, ): asserts value is PathSuffixChoice { - assert( - typeof value === "string", - `Expected a string, got ${typeof value} (${value})`, - ); + assert(typeof value === "string", `Expected a string, got ${typeof value}`); assert( (PATH_SUFFIX_CHOICES as readonly string[]).includes(value), `Expected one of ${PATH_SUFFIX_CHOICES.join(", ")}`, @@ -259,17 +256,15 @@ export function findPackageDependencyPaths( const { dependencies = {} } = readPackageSync({ cwd: packageRoot }); return Object.fromEntries( - Object.keys(dependencies) - .map((dependencyName) => { - const resolvedDependencyRoot = resolvePackageRoot( - requireFromPackageRoot, - dependencyName, - ); - return resolvedDependencyRoot - ? [dependencyName, resolvedDependencyRoot] - : undefined; - }) - .filter((item) => typeof item !== "undefined"), + Object.keys(dependencies).flatMap((dependencyName) => { + const resolvedDependencyRoot = resolvePackageRoot( + requireFromPackageRoot, + dependencyName, + ); + return resolvedDependencyRoot + ? [[dependencyName, resolvedDependencyRoot]] + : []; + }), ); } diff --git a/packages/host/src/react-native/index.ts b/packages/host/src/react-native/index.ts index 1ac49c67..c34ae8b7 100644 --- a/packages/host/src/react-native/index.ts +++ b/packages/host/src/react-native/index.ts @@ -1,5 +1,3 @@ import native from "./NativeNodeApiHost"; -const { requireNodeAddon } = native; - -export { requireNodeAddon }; +export const requireNodeAddon = native.requireNodeAddon.bind(native); diff --git a/packages/node-addon-examples/src/index.ts b/packages/node-addon-examples/src/index.ts index e77f5a17..869d4825 100644 --- a/packages/node-addon-examples/src/index.ts +++ b/packages/node-addon-examples/src/index.ts @@ -32,76 +32,58 @@ function assertLogs(cb: () => void, expectedMessages: string[]) { export const suites: Record< string, - Record void | (() => void)> + Record void | (() => void | Promise)> > = { "1-getting-started": { "1_hello_world/napi": () => - assertLogs( - () => - require("../examples/1-getting-started/1_hello_world/napi/hello.js"), - ["world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/1_hello_world/napi/hello.js"); + }, ["world"]), "1_hello_world/node-addon-api": () => - assertLogs( - () => - require("../examples/1-getting-started/1_hello_world/node-addon-api/hello.js"), - ["world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/1_hello_world/node-addon-api/hello.js"); + }, ["world"]), "1_hello_world/node-addon-api-addon-class": () => - assertLogs( - () => - require("../examples/1-getting-started/1_hello_world/node-addon-api-addon-class/hello.js"), - ["world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/1_hello_world/node-addon-api-addon-class/hello.js"); + }, ["world"]), "2_function_arguments/napi": () => - assertLogs( - () => - require("../examples/1-getting-started/2_function_arguments/napi/addon.js"), - ["This should be eight: 8"], - ), + assertLogs(() => { + require("../examples/1-getting-started/2_function_arguments/napi/addon.js"); + }, ["This should be eight: 8"]), "2_function_arguments/node-addon-api": () => - assertLogs( - () => - require("../examples/1-getting-started/2_function_arguments/node-addon-api/addon.js"), - ["This should be eight: 8"], - ), + assertLogs(() => { + require("../examples/1-getting-started/2_function_arguments/node-addon-api/addon.js"); + }, ["This should be eight: 8"]), "3_callbacks/napi": () => - assertLogs( - () => - require("../examples/1-getting-started/3_callbacks/napi/addon.js"), - ["hello world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/3_callbacks/napi/addon.js"); + }, ["hello world"]), "3_callbacks/node-addon-api": () => - assertLogs( - () => - require("../examples/1-getting-started/3_callbacks/node-addon-api/addon.js"), - ["hello world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/3_callbacks/node-addon-api/addon.js"); + }, ["hello world"]), "4_object_factory/napi": () => - assertLogs( - () => - require("../examples/1-getting-started/4_object_factory/napi/addon.js"), - ["hello world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/4_object_factory/napi/addon.js"); + }, ["hello world"]), "4_object_factory/node-addon-api": () => - assertLogs( - () => - require("../examples/1-getting-started/4_object_factory/node-addon-api/addon.js"), - ["hello world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/4_object_factory/node-addon-api/addon.js"); + }, ["hello world"]), "5_function_factory": () => - assertLogs( - () => - require("../examples/1-getting-started/5_function_factory/napi/addon.js"), - ["hello world"], - ), + assertLogs(() => { + require("../examples/1-getting-started/5_function_factory/napi/addon.js"); + }, ["hello world"]), }, "5-async-work": { // TODO: This crashes (SIGABRT) // "async_work_thread_safe_function": () => require("../examples/5-async-work/async_work_thread_safe_function/napi/index.js"), }, tests: { - buffers: () => require("../tests/buffers/addon.js"), - async: () => require("../tests/async/addon.js"), + buffers: () => { + require("../tests/buffers/addon.js"); + }, + async: () => require("../tests/async/addon.js") as () => Promise, }, }; diff --git a/packages/node-addon-examples/tests/async/addon.js b/packages/node-addon-examples/tests/async/addon.js index f30d87d2..a4a4bc6e 100644 --- a/packages/node-addon-examples/tests/async/addon.js +++ b/packages/node-addon-examples/tests/async/addon.js @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable no-undef */ const assert = require("assert"); const test_async = require("bindings")("addon.node"); diff --git a/packages/node-addon-examples/tests/buffers/addon.js b/packages/node-addon-examples/tests/buffers/addon.js index a5ccd75f..04ead189 100644 --- a/packages/node-addon-examples/tests/buffers/addon.js +++ b/packages/node-addon-examples/tests/buffers/addon.js @@ -1,9 +1,7 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable no-undef */ const assert = require("assert"); const addon = require("bindings")("addon.node"); -const toLocaleString = (text) => { +const toLocale = (text) => { return text .toString() .split(",") @@ -12,9 +10,9 @@ const toLocaleString = (text) => { }; module.exports = () => { - assert.strictEqual(toLocaleString(addon.newBuffer()), addon.theText); - assert.strictEqual(toLocaleString(addon.newExternalBuffer()), addon.theText); - assert.strictEqual(toLocaleString(addon.copyBuffer()), addon.theText); + assert.strictEqual(toLocale(addon.newBuffer()), addon.theText); + assert.strictEqual(toLocale(addon.newExternalBuffer()), addon.theText); + assert.strictEqual(toLocale(addon.copyBuffer()), addon.theText); let buffer = addon.staticBuffer(); assert.strictEqual(addon.bufferHasInstance(buffer), true); assert.strictEqual(addon.bufferInfo(buffer), true); From fcb20deb2f594b517a61bfae3750110ac7e1aa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sun, 3 Aug 2025 15:55:12 +0200 Subject: [PATCH 7/8] Build before linting --- .github/workflows/check.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7c9c8338..52aa06c7 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,7 +24,24 @@ 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 From 0e4c8885508e27ecf96db36a74973ee7aa6e0a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Mon, 4 Aug 2025 12:32:58 +0200 Subject: [PATCH 8/8] Renaming prettier config to fix vscode extension loading it --- prettier.config.mjs => prettier.config.js | 0 tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename prettier.config.mjs => prettier.config.js (100%) diff --git a/prettier.config.mjs b/prettier.config.js similarity index 100% rename from prettier.config.mjs rename to prettier.config.js diff --git a/tsconfig.json b/tsconfig.json index 25d505a0..77eba035 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "noEmit": true, "allowJs": true }, - "files": ["prettier.config.mjs", "eslint.config.js"], + "files": ["prettier.config.js", "eslint.config.js"], "references": [ { "path": "./packages/host/tsconfig.json" }, { "path": "./packages/gyp-to-cmake/tsconfig.json" },