p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

fix(linter): Fix false errors for numeric separators (underscores, eg: 2_000_000)

Open Shubhashish-Chakraborty opened this issue 1 month ago • 1 comments

Fixes #3709

Problem: The code linter (JSHint) was incorrectly flagging valid ES2021 numeric separators (e.g., 1_000_000) as syntax errors. This resulted in red underlines and "Unexpected '_'" messages in the editor, even though the syntax is valid and supported in modern JavaScript.

Changes:

  • I wrapped the standard linter function (CodeMirror.lint.javascript) to act as a "middleman." This allows your code to catch the error report before it gets sent to the editor interface.
  • I added logic that checks the actual code for numeric separators (using the regex /\d+_\d+/). If found, it specifically filters out "unexpected token" or "underscore" errors, ensuring only real syntax errors are shown to the user.

I have verified that this pull request:

  • [x] has no linting errors (npm run lint)
  • [x] has no test errors (npm run test)
  • [x] is from a uniquely-named feature branch and is up to date with the develop branch.
  • [x] is descriptively named and links to an issue number, i.e. Fixes #123
  • [x] meets the standards outlined in the accessibility guidelines

Shubhashish-Chakraborty avatar Nov 28 '25 19:11 Shubhashish-Chakraborty

The Review is pending for a long time, why is it taking so much time..?? by the way the issue is fixed, so just waiting for y'all approval.. @raclim @khanniie

Shubhashish-Chakraborty avatar Nov 29 '25 08:11 Shubhashish-Chakraborty