Add new lint to disallow use of confusing isNaN (#4999)

This commit is contained in:
Jonathan Tran
2025-01-11 00:28:12 -05:00
committed by GitHub
parent 013cb10961
commit c6fad2e2dc
3 changed files with 9 additions and 2 deletions

View File

@ -15,6 +15,13 @@
"rules": {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"no-restricted-globals": [
"error",
{
"name": "isNaN",
"message": "Use Number.isNaN() instead."
}
],
"semi": [
"error",
"never"

View File

@ -42,7 +42,7 @@ export default class StreamDemuxer extends Queue<Uint8Array> {
// try to parse the content-length from the headers
const length = parseInt(match[1])
if (isNaN(length))
if (Number.isNaN(length))
return Promise.reject(new Error('invalid content length'))
// slice the headers since we now have the content length

View File

@ -345,7 +345,7 @@ export function onDragNumberCalculation(text: string, e: MouseEvent) {
)
const newVal = roundOff(addition, precision)
if (isNaN(newVal)) {
if (Number.isNaN(newVal)) {
return
}