Add ESLint unicorn plugin (#627)

Rules disabled by default to allow incremental integration.
This commit is contained in:
filtered
2025-02-27 19:41:51 +11:00
committed by GitHub
parent 9c8cc571e2
commit 6f51767451
6 changed files with 610 additions and 63 deletions

View File

@@ -632,11 +632,11 @@ export class LiteGraphGlobal {
// used to create nodes from wrapping functions
getParameterNames(func: (...args: any) => any): string[] {
return (func + "")
.replace(/[/][/].*$/gm, "") // strip single-line comments
.replace(/\/\/.*$/gm, "") // strip single-line comments
.replace(/\s+/g, "") // strip white space
.replace(/[/][*][^/*]*[*][/]/g, "") // strip multi-line comments /**/
.replace(/\/\*[^*/]*\*\//g, "") // strip multi-line comments /**/
.split("){", 1)[0]
.replace(/^[^(]*[(]/, "") // extract the parameters
.replace(/^[^(]*\(/, "") // extract the parameters
.replace(/=[^,]+/g, "") // strip any ES6 defaults
.split(",")
.filter(Boolean) // split & filter [""]

View File

@@ -127,7 +127,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
// Handle center click - show prompt
canvas.prompt("Value", this.value, (v: string) => {
// Check if v is a valid equation or a number
if (/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(v)) {
if (/^[\d\s()*+/-]+|\d+\.\d+$/.test(v)) {
// Solve the equation if possible
try {
v = eval(v)