Skip to main content

no-electron-disable-context-isolation

Disallow disabling Electron webPreferences.contextIsolation.

Targeted pattern scopeโ€‹

This rule targets Electron BrowserWindow and BrowserView constructor options that set webPreferences.contextIsolation to false.

What this rule reportsโ€‹

This rule reports webPreferences.contextIsolation: false in Electron renderer configuration objects.

Why this rule existsโ€‹

Disabling context isolation collapses separation between preload and renderer contexts, increasing exposure of privileged APIs.

โŒ Incorrectโ€‹

new BrowserWindow({
webPreferences: {
contextIsolation: false,
},
});

โœ… Correctโ€‹

new BrowserWindow({
webPreferences: {
contextIsolation: true,
},
});

ESLint flat config exampleโ€‹

import sdl from "eslint-plugin-sdl-2";

export default [
{
plugins: { sdl },
rules: {
"sdl/no-electron-disable-context-isolation": "error",
},
},
];

When not to use itโ€‹

Disable only for legacy renderer code that cannot migrate yet and is protected with strict, documented compensating controls.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R011