Skip to content

noLabelVar (since v1.0.0)

Diagnostic Category: lint/suspicious/noLabelVar

Sources:

Disallow labels that share a name with a variable

const x1 = "test";
x1: expr;
suspicious/noLabelVar.js:2:1 lint/suspicious/noLabelVar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Do not use the x1 variable name as a label
  
    1 │ const x1 = "test";
  > 2 │ x1: expr;
   ^^
    3 │ 
  
   The variable is declared here
  
  > 1 │ const x1 = "test";
         ^^
    2 │ x1: expr;
    3 │ 
  
   Creating a label with the same name as an in-scope variable leads to confusion.
  
const x = "test";
z: expr;