src/content/docs/linter/rules/no-equals-to-null.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.8` - Diagnostic Category: [`lint/nursery/noEqualsToNull`](/reference/diagnostics#diagnostic-category) - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-eq-null`](https://eslint.org/docs/latest/rules/no-eq-null){
"linter": {
"rules": {
"nursery": {
"noEqualsToNull": "error"
}
}
}
}
Require the use of === or !== for comparison with null.
Comparing to null with == or != may have unintended results as the
expression evaluates to true when comparing null to undefined.
foo == null;
foo != null;
foo === null;
foo !== null;