noImportAssign
Ce contenu n’est pas encore disponible dans votre langue.
Diagnostic Category: lint/suspicious/noImportAssign
Since: v1.0.0
Sources:
- Same as:
no-import-assign
Disallow assigning to imported bindings
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-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.
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.
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.
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.
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.
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.
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.
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.