Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.53 KB

no-null.md

File metadata and controls

59 lines (39 loc) · 1.53 KB

Disallow the use of the null literal

💼 This rule is enabled in the ✅ recommended config.

🔧💡 This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

Disallow the use of the null literal, to encourage using undefined instead. You can learn why in sindresorhus/meta#7

Fail

let foo = null;
if (bar == null) {}

Pass

let foo;
const foo = Object.create(null);
if (foo === null) {}

Options

Type: object

checkStrictEquality

Type: boolean
Default: false

Strict equality(===) and strict inequality(!==) is ignored by default.

Fail

// eslint unicorn/no-null: ["error", {"checkStrictEquality": true}]
if (foo === null) {}

Why