Add unicorn lint rules - DOM built-in functions (#628)

- Prefer append(), remove(), replaceAll()
- Wrap nested ternaries in parenthesis
This commit is contained in:
filtered
2025-02-27 20:18:25 +11:00
committed by GitHub
parent 6f51767451
commit 1e8938ceff
11 changed files with 60 additions and 56 deletions

View File

@@ -105,9 +105,9 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
// Determine if clicked on left/right arrows
const delta = x < 40
? -1
: x > width - 40
: (x > width - 40
? 1
: 0
: 0)
if (delta) {
// Handle left/right arrow clicks
@@ -131,7 +131,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
// Solve the equation if possible
try {
v = eval(v)
} catch { }
} catch {}
}
const newValue = Number(v)
if (!isNaN(newValue)) {
@@ -154,9 +154,9 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
const x = e.canvasX - node.pos[0]
const delta = x < 40
? -1
: x > width - 40
: (x > width - 40
? 1
: 0
: 0)
if (delta && (x > -3 && x < width + 3)) return