fix: add error handling in whitespace.js and whitespace-async.js - #3319
Open
bodapatisaikrishna wants to merge 1 commit into
Open
bodapatisaikrishna wants to merge 1 commit into
bodapatisaikrishna wants to merge 1 commit into
Conversation
Fixes airbnb#3237. Fixes airbnb#3238. - In whitespace-async.js: Add .catch() handler to onlyErrorOnRules to prevent unhandled promise rejections and ensure the process exits with a non-zero exit code on failure. - In whitespace.js: Wrap execSync and JSON.parse in try/catch to provide a descriptive error message with underlying cause when child process execution or JSON parsing fails.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3237.
Fixes #3238.
Summary
When ESLint 9 is used (or
CLIEngineis not available):whitespace-async.jspreviously executedonlyErrorOnRules(...).then(...)without a.catch()handler. Any promise rejection resulted in an unhandled promise rejection and potentially non-zero output to stdout.whitespace.js, the fallback path calledJSON.parse(String(execSync(...)))with notry...catchwrapper. If the child process exited with an error or emitted non-JSON diagnostics,JSON.parseorexecSyncfailed with an opaque error, making troubleshooting difficult.Changes
.catch()handler inwhitespace-async.jsthat outputs the error to stderr and setsprocess.exitCode = 1.execSyncandJSON.parseinwhitespace.jswithin atry...catchblock that surfaces a descriptive error including the underlying cause.eslint-config-airbnb-baseandeslint-config-airbnb.Verification
node --check) across all modified files.