Skip to main content

js/noLabelVar

disallow labels that share a name with a variable

ESLint Equivalent: no-label-var

Examples

Invalid

const x = 'test';
x: expr;

 file.ts:2 lint/js/noLabelVar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not use the x variable name as a label.

    1const x = 'test';
  > 2x: expr;
     ^^^^^^^^

  Creating a label with the same name as an in-scope variable leads to
    confusion.

Valid

const x = 'test';
z: expr;