Skip to content

No error handling around execSync + JSON.parse in whitespace.js (ESLint 9 path) #3238

Description

@dataCenter430

Summary

When CLIEngine is not available (e.g. ESLint 9), whitespace.js loads the config by running whitespace-async.js with execSync and then doing JSON.parse(String(...)) on the result. There is no try/catch around this.

Impact

  • If the child script exits non-zero, prints errors, or prints non-JSON (e.g. ESLint timing or debug output), execSync may throw or return non-JSON.
  • JSON.parse will then throw and the config load fails with a generic parsing error, making it hard to see that the real failure was in the child script.

Affected files

  • packages/eslint-config-airbnb-base/whitespace.js (line 55)
  • packages/eslint-config-airbnb/whitespace.js (line 55)

Suggested fix

Wrap the execSync call and JSON.parse in try/catch and rethrow with a clear message (and optionally cause: err) so failures are easier to diagnose.

screenshot

Image

I'd love to work on this.

Activity

  1. ljharb commented on Mar 5, 2026

    @ljharb
    Collaborator

    I don't believe there's a released version of the config yet that works with eslint 9. However, unreleased code should, so a PR would be great.

    Please be sure not to use an LLM to generate the code, since LLM-generated code is not copyrightable and thus can't be accepted to any open source project.

  2. dataCenter430 commented on Mar 5, 2026

    @dataCenter430
    Author

    @ljharb Thanks for the clarification.
    I’m sorry if my PR wasn’t clear, I may not have explained it well.
    there is no code to generate using LLM. 😄
    Let me try to clarify it better.

  3. dataCenter430 commented on Mar 5, 2026

    @dataCenter430
    Author

    I think exception handler should be there.
    Does it make sense?
    I've already fixed them on my end.
    if you want, I will open PRs for it right away.

  4. dataCenter430 commented on Mar 5, 2026

    @dataCenter430
    Author

    Hey, @ljharb
    I should be assigned to work on this, right?
    If so, could you pls assign it to me?
    thank you

  5. ljharb commented on Mar 6, 2026

    @ljharb
    Collaborator

    A catch callback will mask an error - if there's an error, things should crash. Instead, fix things for eslint 10 and continue to let errors crash.

    No, nothing is ever assigned in open source, anywhere, ever. Just make a PR.

  6. dataCenter430 commented on Mar 6, 2026

    @dataCenter430
    Author

    okay, if you want, I will make a PR for this issue right away. thanks

  7. dataCenter430 commented on Mar 6, 2026

    @dataCenter430
    Author

    Hi, there @ljharb ?

    A catch callback will mask an error - if there's an error, things should crash. Instead, fix things for eslint 10 and continue to let errors crash.

    One question - would you like me to implement it directly rather than just suggesting a fix for the issue?
    I'm a bit confused about that. so should I fix things for eslint 10 and continue to let errors crash? or do you prefer my suggested fix for the issue?
    Once it's clarified, I can open a PR right away.
    thanks 🙏

  8. ljharb commented on Mar 6, 2026

    @ljharb
    Collaborator

    fix things for eslint 10 and continue to let errors crash

    yes, that seems best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions