noEqualsToNull
此内容尚不支持你的语言。
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noEqualsToNull - This rule has an unsafe fix.
- The default severity of this rule is error.
- Sources:
- Same as
no-eq-null
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEqualsToNull": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.