noImportAssign
Diagnostic Category: lint/suspicious/noImportAssign
Since: v1.0.0
Sources:
- Same as: 
no-import-assign 
Description
Section titled “Description”Disallow assigning to imported bindings
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import x from "y";x = 1;code-block.js:2:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable x is read-only
  
    1 │ import x from “y”;
  > 2 │ x = 1;
      │ ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import x from “y”;
      │        ^
    2 │ x = 1;
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import y from "y";[y] = 1;code-block.js:2:2 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable y is read-only
  
    1 │ import y from “y”;
  > 2 │ [y] = 1;
      │  ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import y from “y”;
      │        ^
    2 │ [y] = 1;
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import z from "y";({ z } = 1);code-block.js:2:4 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable z is read-only
  
    1 │ import z from “y”;
  > 2 │ ({ z } = 1);
      │    ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import z from “y”;
      │        ^
    2 │ ({ z } = 1);
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import a from "y";[...a] = 1;code-block.js:2:5 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable a is read-only
  
    1 │ import a from “y”;
  > 2 │ […a] = 1;
      │     ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import a from “y”;
      │        ^
    2 │ […a] = 1;
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import b from "y";({ ...b } = 1);code-block.js:2:7 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable b is read-only
  
    1 │ import b from “y”;
  > 2 │ ({ …b } = 1);
      │       ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import b from “y”;
      │        ^
    2 │ ({ …b } = 1);
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import c from "y";for (c in y) {};code-block.js:2:6 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable c is read-only
  
    1 │ import c from “y”;
  > 2 │ for (c in y) {};
      │      ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import c from “y”;
      │        ^
    2 │ for (c in y) {};
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import d from "y";d += 1;code-block.js:2:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable d is read-only
  
    1 │ import d from “y”;
  > 2 │ d += 1;
      │ ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import d from “y”;
      │        ^
    2 │ d += 1;
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
import * as e from "y";e = 1;code-block.js:2:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The imported variable e is read-only
  
    1 │ import * as e from “y”;
  > 2 │ e = 1;
      │ ^
    3 │ 
  
  ℹ The variable is imported here
  
  > 1 │ import * as e from “y”;
      │             ^
    2 │ e = 1;
    3 │ 
  
  ℹ Use a local variable instead of reassigning an import.
  
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "suspicious": {        "noImportAssign": "error"      }    }  }}