src/content/docs/linter/rules/no-with.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noWith`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-with`](https://eslint.org/docs/latest/rules/no-with){
"linter": {
"rules": {
"suspicious": {
"noWith": "error"
}
}
}
}
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?
}
}