--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx import x from "y"; x = 1; import y from "y"; [y] = 1; import z from "y"; ({ z } = 1); import a from "y"; [...a] = 1; import b from "y"; ({ ...b } = 1); import c from "y"; for (c in y) {}; import d from "y"; d += 1; import * as e from "y"; e = 1; import { f } from "y"; f = 1; f = 2; import {xx} from 'y'; xx=1; import xxx, * as yyy from "d" xxx = 4; yyy = 4; ``` # Diagnostics ``` invalid.js:2:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable x is read-only 1 │ import x from "y"; > 2 │ x = 1; │ ^ 3 │ 4 │ import y from "y"; i The variable is imported here > 1 │ import x from "y"; │ ^ 2 │ x = 1; 3 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:5:2 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable y is read-only 4 │ import y from "y"; > 5 │ [y] = 1; │ ^ 6 │ 7 │ import z from "y"; i The variable is imported here 2 │ x = 1; 3 │ > 4 │ import y from "y"; │ ^ 5 │ [y] = 1; 6 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:8:4 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable z is read-only 7 │ import z from "y"; > 8 │ ({ z } = 1); │ ^ 9 │ 10 │ import a from "y"; i The variable is imported here 5 │ [y] = 1; 6 │ > 7 │ import z from "y"; │ ^ 8 │ ({ z } = 1); 9 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:11:5 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable a is read-only 10 │ import a from "y"; > 11 │ [...a] = 1; │ ^ 12 │ 13 │ import b from "y"; i The variable is imported here 8 │ ({ z } = 1); 9 │ > 10 │ import a from "y"; │ ^ 11 │ [...a] = 1; 12 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:14:7 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable b is read-only 13 │ import b from "y"; > 14 │ ({ ...b } = 1); │ ^ 15 │ 16 │ import c from "y"; i The variable is imported here 11 │ [...a] = 1; 12 │ > 13 │ import b from "y"; │ ^ 14 │ ({ ...b } = 1); 15 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:17:6 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable c is read-only 16 │ import c from "y"; > 17 │ for (c in y) {}; │ ^ 18 │ 19 │ import d from "y"; i The variable is imported here 14 │ ({ ...b } = 1); 15 │ > 16 │ import c from "y"; │ ^ 17 │ for (c in y) {}; 18 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:20:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable d is read-only 19 │ import d from "y"; > 20 │ d += 1; │ ^ 21 │ 22 │ import * as e from "y"; i The variable is imported here 17 │ for (c in y) {}; 18 │ > 19 │ import d from "y"; │ ^ 20 │ d += 1; 21 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:23:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable e is read-only 22 │ import * as e from "y"; > 23 │ e = 1; │ ^ 24 │ 25 │ import { f } from "y"; i The variable is imported here 20 │ d += 1; 21 │ > 22 │ import * as e from "y"; │ ^ 23 │ e = 1; 24 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:26:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable f is read-only 25 │ import { f } from "y"; > 26 │ f = 1; │ ^ 27 │ f = 2; 28 │ i The variable is imported here 23 │ e = 1; 24 │ > 25 │ import { f } from "y"; │ ^ 26 │ f = 1; 27 │ f = 2; i Use a local variable instead of reassigning an import. ``` ``` invalid.js:27:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable f is read-only 25 │ import { f } from "y"; 26 │ f = 1; > 27 │ f = 2; │ ^ 28 │ 29 │ import {xx} from 'y'; i The variable is imported here 23 │ e = 1; 24 │ > 25 │ import { f } from "y"; │ ^ 26 │ f = 1; 27 │ f = 2; i Use a local variable instead of reassigning an import. ``` ``` invalid.js:30:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable xx is read-only 29 │ import {xx} from 'y'; > 30 │ xx=1; │ ^^ 31 │ 32 │ import xxx, * as yyy from "d" i The variable is imported here 27 │ f = 2; 28 │ > 29 │ import {xx} from 'y'; │ ^^ 30 │ xx=1; 31 │ i Use a local variable instead of reassigning an import. ``` ``` invalid.js:33:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable xxx is read-only 32 │ import xxx, * as yyy from "d" > 33 │ xxx = 4; │ ^^^ 34 │ yyy = 4; i The variable is imported here 30 │ xx=1; 31 │ > 32 │ import xxx, * as yyy from "d" │ ^^^ 33 │ xxx = 4; 34 │ yyy = 4; i Use a local variable instead of reassigning an import. ``` ``` invalid.js:34:1 lint/suspicious/noImportAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The imported variable yyy is read-only 32 │ import xxx, * as yyy from "d" 33 │ xxx = 4; > 34 │ yyy = 4; │ ^^^ i The variable is imported here 30 │ xx=1; 31 │ > 32 │ import xxx, * as yyy from "d" │ ^^^ 33 │ xxx = 4; 34 │ yyy = 4; i Use a local variable instead of reassigning an import. ```