unicorn/no-null
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-null": "error",
},
},
];let foo = null;if (bar == null) {}let foo: string | null;let foo;if (bar == undefined) {}let foo: string | undefined;Examples from the ESLint documentation.
unicorn/no-null
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-null": "error",
},
},
];unicorn/no-null
unicorn plugin · style
{
"rules": {
"unicorn/no-null": "error"
}
}nursery/noNull
nursery · since 2.6.4
{
"linter": {
"rules": {
"nursery": {
"noNull": "error"
}
}
}
}Disallow nested ternary expressions.
Enforce explicitly comparing the length or size property of a value.
Prevent passing a function reference directly to iterator methods.
Require streaming decoding of fetch-body chunks with TextDecoder.
Enforce consistent naming for boolean names.