eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
Rule proposal: `prefer-number-is-safe-integer`
Description
I think in all cases use Number.isInteger, Number.isSafeInteger should be preferred.
Examples
// ❌
if (!Number.isInteger(x)) {}
// ✅
if (!Number.isSafeInteger(x)) {}
Additional Info
No response
Sounds useful. The only problem I can think of are the checks assuming the inverse case is not an integer.
if (Number.isInteger(x)) {
} else {
// Assumes this is not an integer.
}