Ir al contenido

noEqualsToNull

Esta página aún no está disponible en tu idioma.

biome.json
{
"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;
code-block.js:1:5 lint/nursery/noEqualsToNull  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

null comparison with == is disallowed.

> 1 │ foo == null;
^^
2 │

Unsafe fix: Use === instead.

1 │ foo·===·null;
+
foo != null;
code-block.js:1:5 lint/nursery/noEqualsToNull  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

null comparison with != is disallowed.

> 1 │ foo != null;
^^
2 │

Unsafe fix: Use !== instead.

1 │ foo·!==·null;
+
foo === null;
foo !== null;