Skip to main content

no-electron-node-integration

Disallow enabling Electron Node.js integration for renderers with remote content.

Targeted pattern scopeโ€‹

This rule targets Electron BrowserWindow and webPreferences configurations that enable nodeIntegration where remote content is loaded.

What this rule reportsโ€‹

This rule reports renderer configurations that combine untrusted content with Node.js APIs.

Why this rule existsโ€‹

Enabling Node.js integration for remote content increases remote code execution risk in Electron apps.

โŒ Incorrectโ€‹

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

โœ… Correctโ€‹

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

ESLint flat config exampleโ€‹

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

export default [
{
plugins: { sdl },
rules: {
"sdl/no-electron-node-integration": "error",
},
},
];

When not to use itโ€‹

Disable only for offline renderers with no untrusted input and compensating controls.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R016