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

Using underscores to make numbers more visible produces red underscores with the linter

Open SafeyX3 opened this issue 2 months ago • 3 comments

p5.js version

2.0.5

What is your operating system?

iOS

Web browser and version

Safari 18.7.1

Actual Behavior

Using underscores to make numbers more visible produces red underscores from the linter, even though it doesn’t actually error and is supported in js. (Example, 5_000_000 instead of 5000000)

Image

Expected Behavior

I was expecting it to not have the red underscores, and for the linter to understand it.

Steps to reproduce

Steps:

  1. Try to use underscores between numbers in a number

Snippet:

// Is fine with the linter
console.log(5000000)
// Warns from the linter
console.log(5_000_000)

SafeyX3 avatar Oct 28 '25 13:10 SafeyX3

Image @SafeyX3 , do you want to see 5_00_000 in console or is it just 50000 but you don't want that red line errors

MishtiGarg250 avatar Oct 30 '25 13:10 MishtiGarg250

hey! @raclim @khanniie @SafeyX3

i was so excited, i fixed this already(locally).

below's a 50-Second screenrecording of the fix: (SEE no RED squiggles/underscores anymore)

Image

Proposed Solution: (What i Already did, just waiting for your approval and then i'll open a PR)

  • Enabled ES2021 syntax support by setting ecmaVersion: 2021 in the AST analyzer.
  • Updated JSHint config with esversion: 2021 for modern JavaScript syntax.
  • Filtered numeric separator errors (_ in numbers) from lint annotations to prevent false red squiggles.
  • Overrode CodeMirror’s JS linter to auto-ignore numeric separator–related errors before display.
  • Added robust filtering logic to detect and remove various underscore-related syntax warnings.
  • Improved linting stability by ensuring valid ES2021 syntax no longer triggers lint errors.
  • Verified formatting and lint fixes via ESLint/Prettier cleanup (npm run lint -- --fix).

If everyone's ready, im happy to open a PR immediately! 😄

there you can review the code changes i made!!

https://github.com/user-attachments/assets/c3ca4aa7-01bd-4318-89cc-126c3669a07c

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

hello @raclim @khanniie @SafeyX3 its been a while.. waiting for your approval, can i open a PR ?

Shubhashish-Chakraborty avatar Nov 14 '25 11:11 Shubhashish-Chakraborty