noFunctionAssign
诊断类别:lint/suspicious/noFunctionAssign
¥Diagnostic Category: lint/suspicious/noFunctionAssign
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-func-assign
¥Same as:
no-func-assign
禁止重新分配函数声明。
¥Disallow reassigning function declarations.
¥Examples
¥Invalid
code-block.js:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
> 1 │ function foo() { };
│ ^^^
2 │ foo = bar;
3 │
ℹ Reassigned here.
1 │ function foo() { };
> 2 │ foo = bar;
│ ^^^
3 │
ℹ Use a local variable instead.
code-block.js:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
> 1 │ function foo() {
│ ^^^
2 │ foo = bar;
3 │ }
ℹ Reassigned here.
1 │ function foo() {
> 2 │ foo = bar;
│ ^^^
3 │ }
4 │
ℹ Use a local variable instead.
code-block.js:2:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
1 │ foo = bar;
> 2 │ function foo() { };
│ ^^^
3 │
ℹ Reassigned here.
> 1 │ foo = bar;
│ ^^^
2 │ function foo() { };
3 │
ℹ Reassignment happens here because the function declaration is hoisted.
ℹ Use a local variable instead.
code-block.js:2:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
1 │ [foo] = bar;
> 2 │ function foo() { };
│ ^^^
3 │
ℹ Reassigned here.
> 1 │ [foo] = bar;
│ ^^^
2 │ function foo() { };
3 │
ℹ Reassignment happens here because the function declaration is hoisted.
ℹ Use a local variable instead.
code-block.js:2:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
1 │ ({ x: foo = 0 } = bar);
> 2 │ function foo() { };
│ ^^^
3 │
ℹ Reassigned here.
> 1 │ ({ x: foo = 0 } = bar);
│ ^^^
2 │ function foo() { };
3 │
ℹ Reassignment happens here because the function declaration is hoisted.
ℹ Use a local variable instead.
code-block.js:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
> 1 │ function foo() {
│ ^^^
2 │ [foo] = bar;
3 │ }
ℹ Reassigned here.
1 │ function foo() {
> 2 │ [foo] = bar;
│ ^^^
3 │ }
4 │
ℹ Use a local variable instead.
code-block.js:3:14 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not reassign a function declaration.
1 │ (function () {
2 │ ({ x: foo = 0 } = bar);
> 3 │ function foo() { };
│ ^^^
4 │ })();
5 │
ℹ Reassigned here.
1 │ (function () {
> 2 │ ({ x: foo = 0 } = bar);
│ ^^^
3 │ function foo() { };
4 │ })();
ℹ Reassignment happens here because the function declaration is hoisted.
ℹ Use a local variable instead.
¥Valid
¥Related links