Skip to main content

no-electron-enable-webview-tag

Disallow enabling Electron webPreferences.webviewTag.

Targeted pattern scopeโ€‹

This rule targets Electron BrowserWindow and BrowserView constructor options that set webPreferences.webviewTag to true.

What this rule reportsโ€‹

This rule reports webPreferences.webviewTag: true in Electron renderer configuration objects.

Why this rule existsโ€‹

Electron recommends avoiding webview unless absolutely necessary. Enabling the webviewTag opt-in expands renderer capabilities and can make isolation harder to reason about.

โŒ Incorrectโ€‹

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

โœ… Correctโ€‹

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

Behavior and migration notesโ€‹

This rule includes an autofix for literal boolean values.

  • webviewTag: true is rewritten to webviewTag: false.

ESLint flat config exampleโ€‹

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

export default [
{
plugins: { sdl },

rules: {
"sdl/no-electron-enable-webview-tag": "error",
},
},
];

When not to use itโ€‹

Disable only if your Electron application has a reviewed webview threat model and cannot migrate away from webviewTag yet.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R047