lint(unicorn): enable prefer-number-properties, prefer-array-find, prefer-array-index-of (#7516)
Enable three unicorn rules — one correctness, two performance — and fix every existing violation repo-wide so the rules pass as errors. prefer-number-properties (76 sites) - parseInt/parseFloat/NaN -> Number.* : safe aliases (autofixed). - isNaN -> Number.isNaN (12 sites, hand-converted): global isNaN coerces its argument, Number.isNaN does not. Verified every call site already passes a number (Number.parseInt results, number-typed fields, Date.getTime()), so the conversion is behavior-preserving today and guards against a future non-numeric argument silently coercing. prefer-array-find (26 sites) - .filter(pred)[0] -> .find(pred); .filter(pred).at(-1) / .pop() -> .findLast(pred). Drops the intermediate array and short-circuits. prefer-array-index-of (5 sites) - .findIndex(x => x === v) -> .indexOf(v). Verified: typecheck (node/cli/web) clean, 53 affected suites pass (1679 tests), oxlint clean repo-wide. mobile/ uses findLast safely (already ships ES2023 .toReversed()); config scripts and e2e helpers run on Node 24.
This commit is contained in:
@@ -1395,7 +1395,7 @@ async function countWorkItemsForQuery(
|
||||
],
|
||||
ghOptions
|
||||
)
|
||||
return parseInt(stdout.trim(), 10) || 0
|
||||
return Number.parseInt(stdout.trim(), 10) || 0
|
||||
}
|
||||
|
||||
function sameOwnerRepo(left: OwnerRepo | null, right: OwnerRepo | null): boolean {
|
||||
|
||||
@@ -1578,14 +1578,14 @@ export function parseProjectPaste(input: string): ParsedPaste | null {
|
||||
const m = trimmed.match(urlRe)
|
||||
if (m) {
|
||||
const [, kindSeg, owner, nStr, vStr] = m
|
||||
const number = parseInt(nStr, 10)
|
||||
const number = Number.parseInt(nStr, 10)
|
||||
if (!Number.isInteger(number) || number < 1) {
|
||||
return null
|
||||
}
|
||||
if (!isValidOwnerSlug(owner)) {
|
||||
return null
|
||||
}
|
||||
const viewNumber = vStr ? parseInt(vStr, 10) : undefined
|
||||
const viewNumber = vStr ? Number.parseInt(vStr, 10) : undefined
|
||||
return {
|
||||
kind: kindSeg === 'orgs' ? 'org' : 'user',
|
||||
owner,
|
||||
@@ -1599,7 +1599,7 @@ export function parseProjectPaste(input: string): ParsedPaste | null {
|
||||
const shortRe = /^([A-Za-z0-9][A-Za-z0-9-]*)\/(\d+)$/
|
||||
const sm = trimmed.match(shortRe)
|
||||
if (sm) {
|
||||
const number = parseInt(sm[2], 10)
|
||||
const number = Number.parseInt(sm[2], 10)
|
||||
if (!Number.isInteger(number) || number < 1) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user