sindresorhus/eslint-plugin-unicorn
`prefer-number-properties`: `isNaN` and `isFinite` should be auto-fixed if argument is known to be `number`
Closed
#2,192 opened on Sep 5, 2023
enhancementhelp wanted
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
Description
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