p5.js-web-editor
p5.js-web-editor copied to clipboard
Using underscores to make numbers more visible produces red underscores with the linter
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)
Expected Behavior
I was expecting it to not have the red underscores, and for the linter to understand it.
Steps to reproduce
Steps:
- 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)
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)
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
hello @raclim @khanniie @SafeyX3 its been a while.. waiting for your approval, can i open a PR ?