# eqeqeq

> Require `===` and `!==` instead of `==` and `!=`

`==` and `!=` convert their operands before comparing them, so `"" == 0` and `[] == false` are both `true`. `===` and `!==` compare without converting.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"eqeqeq" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"eqeqeq" = [
  "error",
  "always", # "always", "smart" or "allow-null"
  {
    null = "always", # "always", "never" or "ignore"
  },
]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
if (count == 0) {
  reset();
}
```

Not reported:

{/* good */}
```js
if (count === 0) {
  reset();
}
```

## Options

```toml bunfig.toml
[lint.rules]
eqeqeq = ["error", "smart"]
```

| Option | What it does |
| --- | --- |
| `"always"` (default) | Report every `==` and `!=`. |
| `"smart"` | Allow `==` when comparing with `null`, comparing two literals, or comparing the result of `typeof`. |

With `"always"`, a second option decides what happens with `null`: `{ "null": "always" }` (default) reports `x == null`, `"ignore"` allows it, and `"never"` reports `x === null` instead.

With `"smart"`, this is allowed, because `== null` is a common way to test for both `null` and `undefined`:

{/* good {"options": ["smart"]} */}
```js
if (value == null) {
  value = fallback;
}
```

And this is still reported:

{/* bad {"options": ["smart"]} */}
```js
if (value == other) {
  merge(value, other);
}
```
