Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 975 Bytes

no-null.md

File metadata and controls

52 lines (35 loc) · 975 Bytes

Disallow the use of the null literal.

Disallow the use of the null literal, to encourage using undefined instead.

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