Skip to content

Latest commit

Β 

History

History
64 lines (44 loc) Β· 1.73 KB

File metadata and controls

64 lines (44 loc) Β· 1.73 KB

no-null

πŸ“ Disallow the use of the null literal.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated 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

Examples

// ❌
let foo = null;

// βœ…
let foo;
// ❌
if (bar == null) {}

// βœ…
if (bar == undefined) {}
// βœ…
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.

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

Why