Skip to content

eslint/no-with Correctness ​

✅ This rule is turned on by default.

What it does ​

Disallow with statements

Why is this bad? ​

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.

Example ​

javascript
with (point) {
  r = Math.sqrt(x * x + y * y); // is r a member of point?
}

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-with
json
{
  "rules": {
    "no-with": "error"
  }
}

References ​

Released under the MIT License.