Fix: ESLint 9+ path: handle child script errors in whitespace-async.js#3239
Fix: ESLint 9+ path: handle child script errors in whitespace-async.js#3239dataCenter430 wants to merge 4 commits intoairbnb:masterfrom
Conversation
|
Hey, @ljharb |
ljharb
left a comment
There was a problem hiding this comment.
All this does is exit when there’s an error - i thought the issue was an eslint 9+ bug that could be fixed?
|
hey, @ljharb
I understood you. you really want fix the real ESLint 9+ bug so the config loads correctly; not just better behavior when it errors, right? |
|
Hey, @ljharb could you pls review the PR again? 🙏 |
Summary
When
CLIEngineis not available (ESLint 9+),whitespace.jsloads config by runningwhitespace-async.jswithexecSyncand parsing its stdout as JSON. The async script had no.catch()on its promise, so rejections became unhandled: the child could exit non-zero and print to stderr while the parent received empty or partial stdout and failed with a genericJSON.parseerror, hiding the real failure.Approach
whitespace.js; errors should still crash.Changes
packages/eslint-config-airbnb-base/whitespace-async.js: Add.catch()so that on rejection we log the error to stderr andprocess.exit(1).packages/eslint-config-airbnb/whitespace-async.js: Same change.On success, only JSON is written to stdout, so the parent’s
execSync+JSON.parsecontinues to work. On failure, the real error goes to stderr and the process exits 1, soexecSyncthrows and the thrown error includes the child’s stderr, making the root cause visible without masking crashes.Fixes #3238