no-eq-null
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"no-eq-null": "error",
},
},
];if (foo == null) {
bar();
}
while (qux != null) {
baz();
}if (foo === null) {
bar();
}
while (qux !== null) {
baz();
}
if (foo === null || foo === undefined) {
bar();
}
while (qux !== null && qux !== undefined) {
baz();
}Examples from the ESLint documentation.
no-eq-null
eslint
export default [
{
rules: {
"no-eq-null": "error",
},
},
];no-eq-null
eslint plugin · restriction
{
"rules": {
"no-eq-null": "error"
}
}suspicious/noEqualsToNull
suspicious · since 2.3.8
{
"linter": {
"rules": {
"suspicious": {
"noEqualsToNull": "error"
}
}
}
}Require function names to match the name of the variable or property to which they are assigned
Disallow specified modules when loaded by import
Disallow declarations in the global scope
Disallow specified warning terms in comments
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Enforce using named capture group in regular expression