sindresorhus/eslint-plugin-unicorn

`prefer-number-properties`: `isNaN` and `isFinite` should be auto-fixed if argument is known to be `number`

クローズ

#2,192 opened on 2023/09/05

 (0 件のコメント) (6 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
enhancementhelp wanted

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 4h 30m) (30d で 26 merged PRs)

説明

The documentation for this rule mentions that Number.isNaN and isNaN have slightly diffent behavior, as Number.isNaN doesn't coerce to number first. However when the argument is known to be a number (see example code below), auto-fixing to Number.isNaN does not change the behavior

if (typeof offset !== "number" || isNaN(offset)) {
  // this should be auto-fixed
}

const num: number = 5;
isNaN(num); // This too

コントリビューターガイド