π 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
// β
let foo = null;
// β
let foo;// β
if (bar == null) {}
// β
if (bar == undefined) {}// β
const foo = Object.create(null);// β
if (foo === null) {}Type: object
Type: boolean
Default: false
Strict equality(===) and strict inequality(!==) is ignored by default.
/* eslint unicorn/no-null: ["error", {"checkStrictEquality": true}] */
// β
if (foo === null) {}- βIntent to stop using
nullin my JS codeβ. - TypeScript coding guidelines.
- ESLint rule proposal.
- Douglas Crockford on bottom values in JavaScript.