> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# use-isnan

[Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0)
## Configuration

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ js.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'use-isnan': 'error',
    },
  },
]);
```

## Rule Details

Requires calls to `isNaN()` when checking for `NaN`. Because `NaN` is unique in JavaScript in that it is not equal to anything, including itself, the results of comparisons to `NaN` are confusing: `NaN === NaN` is `false`. Therefore, use `Number.isNaN()` or the global `isNaN()` function to test whether a value is `NaN`.

## Options

- `enforceForSwitchCase` (default: `true`): Disallows `switch(NaN)` and `case NaN:` in switch statements.
- `enforceForIndexOf` (default: `false`): Disallows calling `indexOf` and `lastIndexOf` with `NaN` as an argument.

Examples of **incorrect** code for this rule:

```javascript
if (foo == NaN) {
}

if (foo === NaN) {
}

if (foo !== NaN) {
}

switch (NaN) {
  case foo:
    break;
}

switch (foo) {
  case NaN:
    break;
}
```

Examples of **correct** code for this rule:

```javascript
if (isNaN(foo)) {
}

if (Number.isNaN(foo)) {
}

if (!isNaN(foo)) {
}
```

## Original Documentation

- [ESLint: use-isnan](https://eslint.org/docs/latest/rules/use-isnan)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/use-isnan.js)
