noGlobalAssign
このコンテンツはまだ日本語訳がありません。
Summary
Section titled “Summary”- Rule available since: v1.5.0
- Diagnostic Category: lint/suspicious/noGlobalAssign
- This rule is recommended, which means is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Same as no-global-assign
 
- Same as 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "suspicious": {        "noGlobalAssign": "error"      }    }  }}Description
Section titled “Description”Disallow assignments to native objects and read-only global variables.
JavaScript’s environments contain numerous built-in global variables, such as window in browsers and process in Node.js.
Assigning values to these global variables can be problematic as it can override essential functionality.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”Object = null;code-block.js:1:1 lint/suspicious/noGlobalAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ A global variable should not be reassigned.
  
  > 1 │ Object = null;
      │ ^^^^^^
    2 │ 
  
  ℹ Assigning to a global variable can override essential functionality.
  
window = {};code-block.js:1:1 lint/suspicious/noGlobalAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ A global variable should not be reassigned.
  
  > 1 │ window = {};
      │ ^^^^^^
    2 │ 
  
  ℹ Assigning to a global variable can override essential functionality.
  
undefined = true;code-block.js:1:1 lint/suspicious/noGlobalAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ A global variable should not be reassigned.
  
  > 1 │ undefined = true;
      │ ^^^^^^^^^
    2 │ 
  
  ℹ Assigning to a global variable can override essential functionality.
  
a = 0;let window;window = {};Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.