Skip to content

no-with

Reports a with statement.

Inside with (obj) { ... } every name may be a property of obj or a variable, and which one it is depends on obj at run time, so neither a reader nor a tool can tell what b in with (a) { b } refers to. The statement is a syntax error in strict mode and in ES modules, so a file that uses it cannot be turned into a module later.

To fix, name the object in each access (a.b) or copy the properties you need into variables before the block.

Reported
...
with (a) { b; }
...
js:
lint:
rules:
no-with: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-with in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-with full