JavaScript has two bottom values βDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt
Use this file to discover all available pages before exploring further.
null and undefined β which creates unnecessary complexity. Using undefined exclusively keeps the language model simpler: uninitialized variables, missing object properties, and absent function arguments are all naturally undefined. This rule disallows the null literal and encourages undefined as the single bottom value.
| Recommended | β
recommended |
| Fixable | π§ Auto-fixable |
| Suggestions | π‘ Has suggestions |
Autofix and suggestions
The ruleβs fix behavior depends on context:- Loose equality (
== null,!= null) β automatically replaced withundefined. return nullβ suggests either removingnull(making the return implicit) or replacing it withundefined.let foo = nullβ suggests either removing the initializer entirely or replacing it withundefined.- All other cases β suggests replacing
nullwithundefined.
Configuration options
checkStrictEquality
Type: booleanDefault:
false
By default, strict equality checks (=== null, !== null) are ignored, since they are a common and intentional pattern for detecting null specifically. Set to true to report those as well.
Automatic exceptions
The following patterns are always allowed regardless of configuration:| Pattern | Reason |
|---|---|
Object.create(null) | Creates a prototype-less object β a well-established pattern |
useRef(null) / React.useRef(null) | React ref initialization requires null |
node.insertBefore(child, null) | DOM API uses null as a sentinel to append at the end |
This rule aligns with the TypeScript coding guidelines, which recommend using
undefined and avoiding null.