Skip to content

Implement validator for JS syntax in CLI#4911

Merged
jedel1043 merged 2 commits intoboa-dev:mainfrom
jedel1043:strict-input-validation
Mar 9, 2026
Merged

Implement validator for JS syntax in CLI#4911
jedel1043 merged 2 commits intoboa-dev:mainfrom
jedel1043:strict-input-validation

Conversation

@jedel1043
Copy link
Member

Before this change, when being on REPL mode, you could type something that is invalid Javascript but contains unclosed brackets, then press enter and the REPL would happily accept your input. For example:

>> function b() [
       let a = 5;
       let b = 6;
       let c = 7;
]
Uncaught: SyntaxError: expected token '{', got '[' in function declaration at line 1, col 14 (native at core/engine/src/script.rs:95:34)

Note that it prints an error only until the bracket is closed, even if there was already a syntax error from line 1.

What this does is to make it such that the CLI gives feedback when pressing enter if the input is already invalid JS:

>> function b() [
Uncaught SyntaxError expected token '{', got '[' in function declaration at line 1, col 14

@jedel1043 jedel1043 requested a review from a team as a code owner March 7, 2026 01:28
@jedel1043 jedel1043 added A-Enhancement New feature or request C-CLI Issues and PRs related to the Boa command line interface. labels Mar 7, 2026
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 49,713 49,713 0
Ignored 2,262 2,262 0
Failed 988 988 0
Panics 0 0 0
Conformance 93.86% 93.86% 0.00%

Tested main commit: 0919e3b2c00d75fd32968903a328e7b85989d5c5
Tested PR commit: 5dc54a27183dbc27f5189ec2a881cd5b074e8469
Compare commits: 0919e3b...5dc54a2

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.06%. Comparing base (6ddc2b4) to head (5dc54a2).
⚠️ Report is 791 commits behind head on main.

Files with missing lines Patch % Lines
cli/src/helper.rs 0.00% 12 Missing ⚠️
cli/src/main.rs 0.00% 3 Missing ⚠️
core/parser/src/error/mod.rs 0.00% 2 Missing ⚠️
core/parser/src/parser/mod.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4911       +/-   ##
===========================================
+ Coverage   47.24%   58.06%   +10.82%     
===========================================
  Files         476      557       +81     
  Lines       46892    61096    +14204     
===========================================
+ Hits        22154    35478    +13324     
- Misses      24738    25618      +880     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but would like to see #4888 go in first.

@jedel1043 jedel1043 force-pushed the strict-input-validation branch 3 times, most recently from bc94d26 to 7c704aa Compare March 7, 2026 03:07
@rajat552
Copy link

rajat552 commented Mar 8, 2026

Hi @jedel1043 , I noticed that PR #4888 has already been merged.
Do you think rebasing this branch on the latest main could fix the lint failure?
I'd be happy to help test the changes if needed.

@jedel1043 jedel1043 force-pushed the strict-input-validation branch from 7c704aa to a511c26 Compare March 9, 2026 02:52
@jedel1043 jedel1043 requested a review from hansl March 9, 2026 02:52
@jedel1043 jedel1043 force-pushed the strict-input-validation branch from a511c26 to ed8d165 Compare March 9, 2026 03:14
@jedel1043 jedel1043 added this pull request to the merge queue Mar 9, 2026
Merged via the queue into boa-dev:main with commit 109e5f0 Mar 9, 2026
19 checks passed
@jedel1043 jedel1043 deleted the strict-input-validation branch March 9, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Enhancement New feature or request C-CLI Issues and PRs related to the Boa command line interface.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants