eslint/valid-typeof Correctness
What it does
Enforce comparing typeof
expressions against valid strings
Why is this bad?
It is usually a typing mistake to compare the result of a typeof
operator to other string literals.
Example
js
// requireStringLiterals: false
// incorrect:
typeof foo === "strnig";
// correct:
typeof foo === "string";
typeof foo === baz;
// requireStringLiterals: true
// incorrect:
typeof foo === baz;
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny valid-typeof
json
{
"rules": {
"valid-typeof": "error"
}
}