6 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
13 For a vast majority of use cases, the result of the `typeof` operator is one of the following string literals: `"undefined"`, `"object"`, `"boolean"`, `"number"`, `"string"`, `"function"`, `"symbol"`, and `"bigint"`. It is usually a typing mistake to compare the result of a `typeof` operator to other string literals.
17 This rule enforces comparing `typeof` expressions to valid string literals.
21 This rule has an object option:
23 * `"requireStringLiterals": true` requires `typeof` expressions to only be compared to string literals or other `typeof` expressions, and disallows comparisons to any other value.
25 Examples of **incorrect** code for this rule:
30 /*eslint valid-typeof: "error"*/
32 typeof foo === "strnig"
33 typeof foo == "undefimed"
34 typeof bar != "nunber"
35 typeof bar !== "fucntion"
40 Examples of **correct** code for this rule:
45 /*eslint valid-typeof: "error"*/
47 typeof foo === "string"
48 typeof bar == "undefined"
50 typeof bar === typeof qux
55 Examples of **incorrect** code with the `{ "requireStringLiterals": true }` option:
60 /*eslint valid-typeof: ["error", { "requireStringLiterals": true }]*/
62 typeof foo === undefined
64 typeof baz === "strnig"
65 typeof qux === "some invalid type"
66 typeof baz === anotherVariable
72 Examples of **correct** code with the `{ "requireStringLiterals": true }` option:
77 /*eslint valid-typeof: ["error", { "requireStringLiterals": true }]*/
79 typeof foo === "undefined"
80 typeof bar == "object"
81 typeof baz === "string"
82 typeof bar === typeof qux
89 You may want to turn this rule off if you will be using the `typeof` operator on host objects.