@noctcore/eslint-plugin-electron
A bad fit for flags set from variables, which the literal-only check does not see, and for handlers passed by name, which it does not follow.
Electron main-process security: renderer isolation flags, IPC sender checks, and shell kept to one checked module.
What it solves
Section titled “What it solves”An Electron renderer is a web page with a line into Node. The defaults keep that line narrow, and three kinds of edit widen it without anything failing: a webPreferences flag flipped for a debugging session, an IPC handler that acts on a message from any frame, and a shell.openExternal called with a URL nobody checked. Each works in development and becomes a path from web content to the operating system the day the app shows something it did not ship.
What it will yell at you about
Section titled “What it will yell at you about”It will yell at you about a webPreferences flag that turns off isolation (nodeIntegration: true, contextIsolation: false, sandbox: false and the rest), the one rule recommended turns on. Two opt-in rules need a fact about your app: IPC handlers that do not check their sender first (name your guard in guards) and shell used outside the module you list in allowIn. It is a bad fit for flags set from variables, which the literal-only check does not see, and for handlers passed by name, which it does not follow.
Install and configure
Section titled “Install and configure”npm install --save-dev @noctcore/eslint-plugin-electron @typescript-eslint/parser# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-electron @typescript-eslint/parserThe recommended preset enables 1 of 3 rules. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.
Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first
read is webpreferences-locked.
--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.
ipcMain.handle / ipcMain.on handler to check its sender (event.senderFrame) in its first statement, before it does anything else.shell (openExternal, openPath) to the files listed in allowIn, so URLs and paths reach the operating system through one checked module.nodeIntegration, webviewTag or allowRunningInsecureContent set to true, or contextIsolation, sandbox or webSecurity set to false.