useValidTypeof
Esta página aún no está disponible en tu idioma.
Summary
Section titled “Summary”- Rule available since: 
v1.0.0 - Diagnostic Category: 
lint/correctness/useValidTypeof - This rule is recommended, which means is enabled by default.
 - This rule has an unsafe fix.
 - The default severity of this rule is error.
 - Sources:
- Same as 
valid-typeof 
 - Same as 
 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "correctness": {        "useValidTypeof": "error"      }    }  }}Description
Section titled “Description”This rule checks that the result of a typeof expression is compared to a valid value.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”typeof foo === "strnig";code-block.js:1:16 lint/correctness/useValidTypeof ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ “strnig” is not a valid typeof value.
  
  > 1 │ typeof foo === “strnig”;
      │                ^^^^^^^^
    2 │ 
  
typeof foo == "undefimed";code-block.js:1:15 lint/correctness/useValidTypeof ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ “undefimed” is not a valid typeof value.
  
  > 1 │ typeof foo == “undefimed”;
      │               ^^^^^^^^^^^
    2 │ 
  
typeof bar != "nunber";code-block.js:1:15 lint/correctness/useValidTypeof ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ “nunber” is not a valid typeof value.
  
  > 1 │ typeof bar != “nunber”;
      │               ^^^^^^^^
    2 │ 
  
typeof foo === undefined;code-block.js:1:16 lint/correctness/useValidTypeof ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Invalid typeof comparison.
  
  > 1 │ typeof foo === undefined;
      │                ^^^^^^^^^
    2 │ 
  
  ℹ Compare with one of the following string literals:
  
  - “bigint”
  - “boolean”
  - “function”
  - “number”
  - “object”
  - “string”
  - “symbol”
  - “undefined”
  
typeof foo == 0;code-block.js:1:15 lint/correctness/useValidTypeof ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Invalid typeof comparison.
  
  > 1 │ typeof foo == 0;
      │               ^
    2 │ 
  
  ℹ Compare with one of the following string literals:
  
  - “bigint”
  - “boolean”
  - “function”
  - “number”
  - “object”
  - “string”
  - “symbol”
  - “undefined”
  
typeof foo === "string";typeof bar == "undefined";typeof bar === typeof qux;typeof foo === barRelated links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.