noUnassignedVariables
Цей контент ще не доступний вашою мовою.
Summary
Section titled “Summary”- Rule available since: v2.1.0
- Diagnostic Category: lint/suspicious/noUnassignedVariables
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as no-unassigned-vars
 
- Same as 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "suspicious": {        "noUnassignedVariables": "error"      }    }  }}Description
Section titled “Description”Disallow let or var variables that are read but never assigned.
This rule flags let or var declarations that are never assigned a value but are still read or used in the code. Since these variables will always be undefined, their usage is likely a programming mistake.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”let status;if (status === 'ready') {    console.log('Status is ready');}code-block.js:1:5 lint/suspicious/noUnassignedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ The variable ‘status’ is declared but never assigned a value.
  
  > 1 │ let status;
      │     ^^^^^^
    2 │ if (status === ‘ready’) {
    3 │     console.log(‘Status is ready’);
  
  ℹ Variable declared without assignment. Either assign a value or remove the declaration.
  
let value: number | undefined;console.log(value);code-block.ts:1:5 lint/suspicious/noUnassignedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ The variable ‘value’ is declared but never assigned a value.
  
  > 1 │ let value: number | undefined;
      │     ^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ console.log(value);
    3 │ 
  
  ℹ Variable declared without assignment. Either assign a value or remove the declaration.
  
let message = "hello";console.log(message);
let user;user = getUser();console.log(user.name);
let count;count = 0;count++;declare let value: number | undefined;console.log(value);
declare module "my-module" {    let value: string;    export = value;}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.