---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: noDoubleEquals
description: Learn more about noDoubleEquals
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JavaScript (and super languages)" icon="seti:javascript">
## Summary
- Rule available since: `v1.0.0`
- Diagnostic Category: [`lint/suspicious/noDoubleEquals`](/reference/diagnostics#diagnostic-category)
- This rule is **recommended**, meaning it is enabled by default.
- This rule has an [**unsafe**](/linter/#unsafe-fixes) fix.
- The default severity of this rule is [**error**](/reference/diagnostics#error).
- Sources: 
  - Same as [`eqeqeq`](https://eslint.org/docs/latest/rules/eqeqeq)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"suspicious": {
				"noDoubleEquals": "error"
			}
		}
	}
}

```
## Description
Require the use of `===` and `!==`.

It is generally bad practice to use `==` for comparison instead of
`===`. Double operators will trigger implicit [type coercion](https://developer.mozilla.org/en-US/docs/Glossary/Type_coercion)
and are thus not preferred. Using strict equality operators is almost
always best practice.

For ergonomic reasons, this rule makes by default an exception for `== null` for
comparing to both `null` and `undefined`.

## Examples

### Invalid

```js
foo == bar
```

<pre class="language-text"><code class="language-text">code-block.js:1:5 <a href="https://biomejs.dev/linter/rules/no-double-equals">lint/suspicious/noDoubleEquals</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Using </span><span style="color: Tomato;"><strong>==</strong></span><span style="color: Tomato;"> may be unsafe if you are relying on type coercion.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>foo == bar<br />   <strong>   │ </strong>    <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>==</strong></span><span style="color: lightgreen;"> is only allowed when comparing against </span><span style="color: lightgreen;"><strong>null</strong></span><span style="color: lightgreen;">.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Use </span><span style="color: lightgreen;"><strong>===</strong></span><span style="color: lightgreen;"> instead.</span><br />  <br />  <strong>  1 │ </strong>foo<span style="opacity: 0.8;">·</span>==<span style="color: MediumSeaGreen;">=</span><span style="opacity: 0.8;">·</span>bar<br />  <strong>    │ </strong>      <span style="color: MediumSeaGreen;">+</span>    <br /></code></pre>

### Valid

```js
foo == null
```

```js
foo != null
```

```js
null == foo
```

```js
null != foo
```

## Options

The rule provides the option described below.

```json
{
    "//":"...",
    "options": {
        "ignoreNull": true
    }
}
```

### ignoreNull

When this option is set to `true`, an exception will be made for checking against `null`,
as relying on the double equals operator to compare with `null` is frequently used to check
equality with either `null` or `undefined`.

When the option is set to `false`, all double equal operators will be forbidden without
exceptions.

Default: `true`

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/suspicious/no_double_equals.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/suspicious/noDoubleEquals)

</TabItem>
</Tabs>