noImportAssign
诊断类别:lint/suspicious/noImportAssign
¥Diagnostic Category: lint/suspicious/noImportAssign
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-import-assign
¥Same as:
no-import-assign
禁止分配给导入的绑定
¥Disallow assigning to imported bindings
¥Examples
¥Invalid
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.
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.
¥Related links