chore: lint code blocks in docs with ESLint (#42113)

This commit is contained in:
David Sanders 2025-05-29 12:45:26 -07:00 committed by GitHub
commit 0d70389ccb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 308 additions and 34 deletions

View file

@ -281,7 +281,8 @@ security-conscious developers might want to assume the very opposite.
```js title='main.js (Main Process)'
const { session } = require('electron')
const { URL } = require('url')
const { URL } = require('node:url')
session
.fromPartition('some-partition')
@ -611,9 +612,10 @@ sometimes be fooled - a `startsWith('https://example.com')` test would let
`https://example.com.attacker.com` through.
```js title='main.js (Main Process)'
const { URL } = require('url')
const { app } = require('electron')
const { URL } = require('node:url')
app.on('web-contents-created', (event, contents) => {
contents.on('will-navigate', (event, navigationUrl) => {
const parsedUrl = new URL(navigationUrl)
@ -690,12 +692,14 @@ leveraged to execute arbitrary commands.
```js title='main.js (Main Process)' @ts-type={USER_CONTROLLED_DATA_HERE:string}
// Bad
const { shell } = require('electron')
shell.openExternal(USER_CONTROLLED_DATA_HERE)
```
```js title='main.js (Main Process)'
// Good
const { shell } = require('electron')
shell.openExternal('https://example.com/index.html')
```