noImportAssign
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/suspicious/noImportAssign¥Diagnostic Category:
lint/suspicious/noImportAssign -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
-
与
no-import-assign相同¥Same as
no-import-assign
-
¥How to configure
{ "linter": { "rules": { "suspicious": { "noImportAssign": "error" } } }}¥Description
禁止分配给导入的绑定
¥Disallow assigning to imported bindings
¥Examples
¥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.
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号