Skip to content

fix: handle empty and whitespace-only JSON inputs - #259

Open
lumirlumir wants to merge 6 commits into
mainfrom
fix/handle-empty-and-whitespace-only-json-inputs
Open

lumirlumir wants to merge 6 commits into
mainfrom
fix/handle-empty-and-whitespace-only-json-inputs

Conversation

@lumirlumir

@lumirlumir lumirlumir commented Jul 15, 2026

Copy link
Copy Markdown
Member

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR fixes an issue metioned in #249.

What changes did you make? (Give an overview)

I've simply bumped the @humanwhocodes/momoa's version to the latest, and add test cases to verify them.

Related Issues

Fixes: #249

Is there anything you'd like reviewers to focus on?

Previously blocked by:

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of empty and whitespace-only input across JSON, JSONC, and JSON5 parsing modes.
    • Invalid empty input now consistently returns a clear “Unexpected end of input found” error with accurate location details.

@eslint-github-bot eslint-github-bot Bot added the bug Something isn't working label Jul 15, 2026
@eslintbot eslintbot added this to Triage Jul 15, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Jul 15, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Jul 15, 2026
@github-actions

This comment was marked as resolved.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 40b9cf35-d242-4d29-a609-9210535e84ee

📥 Commits

Reviewing files that changed from the base of the PR and between bbaa18f and fada862.

📒 Files selected for processing (2)
  • package.json
  • tests/languages/json-language.test.js

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The parser dependency updates from ^3.3.10 to ^3.3.13. Tests now cover empty and whitespace-only input for json, jsonc, and json5 modes.

Changes

JSON empty input handling

Layer / File(s) Summary
Parser dependency and empty-input validation
package.json, tests/languages/json-language.test.js
The @humanwhocodes/momoa dependency is updated. Tests verify the Unexpected end of input found. error at line 1, column 1, offset 0 for empty and whitespace-only input in all three language modes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to fada8

The parser dependency is updated and empty and whitespace-only inputs are covered without any established merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: handling empty and whitespace-only JSON inputs. It matches the dependency update and added test coverage.
Linked Issues check ✅ Passed For issue #249, package.json updates @humanwhocodes/momoa from ^3.3.10 to ^3.3.13. The PR adds six tests for empty and whitespace-only input in json, jsonc, and json5 modes. Each test ex…
Out of Scope Changes check ✅ Passed The reviewed changes contain only the @humanwhocodes/momoa dependency update and tests for empty or whitespace-only JSON-family inputs. Both changes directly support issue #249. No unrelated change …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/handle-empty-and-whitespace-only-json-inputs

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Sep 16, 2026
@lumirlumir
lumirlumir marked this pull request as ready for review September 16, 2026 07:48
@DMartens

Copy link
Copy Markdown

Changes LGTM, thanks.
I would tag this as test: as only test cases are added.
The version bump in package.json is not needed as ^3.3.10 already includes the newest version and we do not have a package-lock.json.

@DMartens DMartens moved this from Needs Triage to Merge Candidates in Triage Sep 16, 2026
@lumirlumir

Copy link
Copy Markdown
Member Author

Just a small note: There has been a consensus to mark dependency version updates as fix when they affect our use case: eslint/workflows#33 (comment)

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

Labels

accepted bug Something isn't working

Projects

Status: Merge Candidates

Development

Successfully merging this pull request may close these issues.

Bug: Parse error with empty files

3 participants