跳转到内容

noWith

此内容尚不支持你的语言。

Diagnostic Category: lint/complexity/noWith

Since: v1.0.0

Sources:

Disallow with statements in non-strict contexts.

The with statement is potentially problematic because it adds members of an object to the current scope, making it impossible to tell what a variable inside the block actually refers to.

function f() {
with (point) {
r = Math.sqrt(x * x + y * y); // is r a member of point?
}
}
code-block.cjs:2:3 lint/complexity/noWith ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected use of with statement.

1 │ function f() {
> 2 │ with (point) {
^^^^^^^^^^^^^^
> 3 │ r = Math.sqrt(x * x + y * y); // is r a member of point?
> 4 │ }
^
5 │ }
6 │

The with statement is potentially problematic because it adds members of an object to the current
scope, making it impossible to tell what a variable inside the block actually refers to.