From 60e9051393fca5e72d32425524f2b8af65d42b1a Mon Sep 17 00:00:00 2001 From: "Yerofey S." Date: Tue, 23 Sep 2025 05:09:01 +0200 Subject: [PATCH 1/4] Fix React hooks error by replacing top-level await with async main function - Resolves 'Invalid hook call' error when running CLI globally - Eliminates 'unsettled top-level await' warning - Wraps render logic in async main() function to ensure proper React context - Fixes issue #90 --- source/cli.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/cli.tsx b/source/cli.tsx index 3b572a8..3542a1a 100755 --- a/source/cli.tsx +++ b/source/cli.tsx @@ -49,5 +49,9 @@ const App: React.FC = () => ( /> ); -const app = render(); -await app.waitUntilExit(); +async function main() { + const app = render(); + await app.waitUntilExit(); +} + +main().catch(console.error); From 53d009cfcb0180a54a5a3d0adc2e81c01fcf4fcd Mon Sep 17 00:00:00 2001 From: "Yerofey S." Date: Tue, 23 Sep 2025 05:15:21 +0200 Subject: [PATCH 2/4] chore: upgrade eslint-config-xo-react, eslint-plugin-react-hooks and xo packages --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7fa7aaa..6d81167 100644 --- a/package.json +++ b/package.json @@ -58,13 +58,13 @@ "@sindresorhus/tsconfig": "^8.0.1", "@types/react": "^19.1.13", "ava": "^6.4.1", - "eslint-config-xo-react": "^0.27.0", + "eslint-config-xo-react": "^0.28.0", "eslint-plugin-react": "^7.34.1", - "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-hooks": "^5.2.0", "execa": "^9.6.0", "p-event": "^7.0.0", "tsx": "^4.20.5", - "xo": "^0.59.0" + "xo": "^1.2.2" }, "xo": { "extends": [ From cd22fe8537ee48994191e058f527b2a48488ede4 Mon Sep 17 00:00:00 2001 From: "Yerofey S." Date: Tue, 23 Sep 2025 05:26:23 +0200 Subject: [PATCH 3/4] Fix ESLint configuration compatibility issues - Downgrade XO from 1.2.2 to 0.59.3 to avoid flat config issues - Downgrade eslint-config-xo-react from 0.28.0 to 0.27.0 for compatibility - Fix linting errors in cli.tsx: - Use proper error typing with unknown - Add ESLint disable comment for prefer-top-level-await rule - All tests now pass successfully --- package.json | 4 ++-- source/cli.tsx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6d81167..7545615 100644 --- a/package.json +++ b/package.json @@ -58,13 +58,13 @@ "@sindresorhus/tsconfig": "^8.0.1", "@types/react": "^19.1.13", "ava": "^6.4.1", - "eslint-config-xo-react": "^0.28.0", + "eslint-config-xo-react": "^0.27.0", "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^5.2.0", "execa": "^9.6.0", "p-event": "^7.0.0", "tsx": "^4.20.5", - "xo": "^1.2.2" + "xo": "^0.59.3" }, "xo": { "extends": [ diff --git a/source/cli.tsx b/source/cli.tsx index 3542a1a..fede6e3 100755 --- a/source/cli.tsx +++ b/source/cli.tsx @@ -54,4 +54,7 @@ async function main() { await app.waitUntilExit(); } -main().catch(console.error); +// eslint-disable-next-line unicorn/prefer-top-level-await +main().catch((error: unknown) => { + console.error(error); +}); From a60ef518eeabe55f91c92aae2a8643a59a8b027b Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 24 Sep 2025 01:55:29 +0900 Subject: [PATCH 4/4] Update cli.tsx --- source/cli.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/cli.tsx b/source/cli.tsx index fede6e3..679b268 100755 --- a/source/cli.tsx +++ b/source/cli.tsx @@ -54,6 +54,7 @@ async function main() { await app.waitUntilExit(); } +// It cannot use top-level await as that errors with some React error. // eslint-disable-next-line unicorn/prefer-top-level-await main().catch((error: unknown) => { console.error(error);