noWith
Diagnostic Category: lint/complexity/noWith
Since: v1.0.0
Sources:
- Same as: 
no-with 
Description
Section titled DescriptionDisallow 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.
Examples
Section titled ExamplesInvalid
Section titled Invalidfunction 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.
  
How to configure
Section titled How to configure{  "linter": {    "rules": {      "complexity": {        "noWith": "error"      }    }  }}