Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extend linting of code blocks in the docs #40245

Merged
merged 2 commits into from Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/accelerator.md
Expand Up @@ -15,7 +15,7 @@ Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module
using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback)
method, i.e.

```javascript
```js
const { app, globalShortcut } = require('electron')

app.whenReady().then(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/browser-view.md
Expand Up @@ -16,7 +16,7 @@ module is emitted.

### Example

```javascript
```js
// In the main process.
const { app, BrowserView, BrowserWindow } = require('electron')

Expand Down
24 changes: 12 additions & 12 deletions docs/api/browser-window.md
Expand Up @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process)
This module cannot be used until the `ready` event of the `app`
module is emitted.

```javascript
```js
// In the main process.
const { BrowserWindow } = require('electron')

Expand Down Expand Up @@ -38,7 +38,7 @@ While loading the page, the `ready-to-show` event will be emitted when the rende
process has rendered the page for the first time if the window has not been shown yet. Showing
the window after this event will have no visual flash:

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ show: false })
win.once('ready-to-show', () => {
Expand All @@ -59,7 +59,7 @@ For a complex app, the `ready-to-show` event could be emitted too late, making
the app feel slow. In this case, it is recommended to show the window
immediately, and use a `backgroundColor` close to your app's background:

```javascript
```js
const { BrowserWindow } = require('electron')

const win = new BrowserWindow({ backgroundColor: '#2e2c29' })
Expand All @@ -85,7 +85,7 @@ For more information about these color types see valid options in [win.setBackgr

By using `parent` option, you can create child windows:

```javascript
```js
const { BrowserWindow } = require('electron')

const top = new BrowserWindow()
Expand All @@ -101,7 +101,7 @@ The `child` window will always show on top of the `top` window.
A modal window is a child window that disables parent window, to create a modal
window, you have to set both `parent` and `modal` options:

```javascript
```js
const { BrowserWindow } = require('electron')

const top = new BrowserWindow()
Expand Down Expand Up @@ -188,7 +188,7 @@ window should be closed, which will also be called when the window is
reloaded. In Electron, returning any value other than `undefined` would cancel the
close. For example:

```javascript
```js
window.onbeforeunload = (e) => {
console.log('I do not want to be closed')

Expand Down Expand Up @@ -351,7 +351,7 @@ Commands are lowercased, underscores are replaced with hyphens, and the
`APPCOMMAND_` prefix is stripped off.
e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.on('app-command', (e, cmd) => {
Expand Down Expand Up @@ -456,7 +456,7 @@ Returns `BrowserWindow | null` - The window with the given `id`.

Objects created with `new BrowserWindow` have the following properties:

```javascript
```js
const { BrowserWindow } = require('electron')
// In this example `win` is our instance
const win = new BrowserWindow({ width: 800, height: 600 })
Expand Down Expand Up @@ -780,7 +780,7 @@ Closes the currently open [Quick Look][quick-look] panel.

Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()

Expand Down Expand Up @@ -1035,7 +1035,7 @@ Changes the attachment point for sheets on macOS. By default, sheets are
attached just below the window frame, but you may want to display them beneath
a HTML-rendered toolbar. For example:

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()

Expand Down Expand Up @@ -1178,7 +1178,7 @@ To ensure that file URLs are properly formatted, it is recommended to use
Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
method:

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()

Expand All @@ -1194,7 +1194,7 @@ win.loadURL(url)
You can load a URL using a `POST` request with URL-encoded data by doing
the following:

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()

Expand Down
6 changes: 3 additions & 3 deletions docs/api/client-request.md
Expand Up @@ -65,7 +65,7 @@ strictly follow the Node.js model as described in the

For instance, we could have created the same request to 'github.com' as follows:

```javascript
```js
const request = net.request({
method: 'GET',
protocol: 'https:',
Expand Down Expand Up @@ -104,7 +104,7 @@ The `callback` function is expected to be called back with user credentials:
* `username` string
* `password` string

```javascript @ts-type={request:Electron.ClientRequest}
```js @ts-type={request:Electron.ClientRequest}
request.on('login', (authInfo, callback) => {
callback('username', 'password')
})
Expand All @@ -113,7 +113,7 @@ request.on('login', (authInfo, callback) => {
Providing empty credentials will cancel the request and report an authentication
error on the response object:

```javascript @ts-type={request:Electron.ClientRequest}
```js @ts-type={request:Electron.ClientRequest}
request.on('response', (response) => {
console.log(`STATUS: ${response.statusCode}`)
response.on('error', (error) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/clipboard.md
Expand Up @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer
On Linux, there is also a `selection` clipboard. To manipulate it
you need to pass `selection` to each method:

```javascript
```js
const { clipboard } = require('electron')

clipboard.writeText('Example string', 'selection')
Expand Down
4 changes: 2 additions & 2 deletions docs/api/command-line-switches.md
Expand Up @@ -6,7 +6,7 @@ You can use [app.commandLine.appendSwitch][append-switch] to append them in
your app's main script before the [ready][ready] event of the [app][app] module
is emitted:

```javascript
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
Expand Down Expand Up @@ -185,7 +185,7 @@ list of hosts. This flag has an effect only if used in tandem with

For example:

```javascript
```js
const { app } = require('electron')
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api/command-line.md
Expand Up @@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a

The following example shows how to check if the `--disable-gpu` flag is set.

```javascript
```js
const { app } = require('electron')
app.commandLine.hasSwitch('disable-gpu')
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api/content-tracing.md
Expand Up @@ -10,7 +10,7 @@ This module does not include a web interface. To view recorded traces, use
**Note:** You should not use this module until the `ready` event of the app
module is emitted.

```javascript
```js
const { app, contentTracing } = require('electron')

app.whenReady().then(() => {
Expand Down
12 changes: 6 additions & 6 deletions docs/api/context-bridge.md
Expand Up @@ -6,7 +6,7 @@ Process: [Renderer](../glossary.md#renderer-process)

An example of exposing an API to a renderer from an isolated preload script is given below:

```javascript
```js
// Preload (Isolated World)
const { contextBridge, ipcRenderer } = require('electron')

Expand All @@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld(
)
```

```javascript @ts-nocheck
```js @ts-nocheck
// Renderer (Main World)

window.electron.doThing()
Expand Down Expand Up @@ -64,7 +64,7 @@ the API become immutable and updates on either side of the bridge do not result

An example of a complex API is shown below:

```javascript
```js
const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInMainWorld(
Expand Down Expand Up @@ -92,7 +92,7 @@ contextBridge.exposeInMainWorld(

An example of `exposeInIsolatedWorld` is shown below:

```javascript
```js
const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInIsolatedWorld(
Expand All @@ -104,7 +104,7 @@ contextBridge.exposeInIsolatedWorld(
)
```

```javascript @ts-nocheck
```js @ts-nocheck
// Renderer (In isolated world id1004)

window.electron.doThing()
Expand Down Expand Up @@ -145,7 +145,7 @@ The table of supported types described above also applies to Node APIs that you
Please note that many Node APIs grant access to local system resources.
Be very cautious about which globals and APIs you expose to untrusted remote content.

```javascript
```js
const { contextBridge } = require('electron')
const crypto = require('node:crypto')
contextBridge.exposeInMainWorld('nodeCrypto', {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/cookies.md
Expand Up @@ -10,7 +10,7 @@ a `Session`.

For example:

```javascript
```js
const { session } = require('electron')

// Query all cookies.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/crash-reporter.md
Expand Up @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer
The following is an example of setting up Electron to automatically submit
crash reports to a remote server:

```javascript
```js
const { crashReporter } = require('electron')

crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' })
Expand Down
2 changes: 1 addition & 1 deletion docs/api/debugger.md
Expand Up @@ -8,7 +8,7 @@ _This class is not exported from the `'electron'` module. It is only available a
Chrome Developer Tools has a [special binding][rdp] available at JavaScript
runtime that allows interacting with pages and instrumenting them.

```javascript
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()

Expand Down
6 changes: 3 additions & 3 deletions docs/api/desktop-capturer.md
Expand Up @@ -8,7 +8,7 @@ Process: [Main](../glossary.md#main-process)
The following example shows how to capture video from a desktop window whose
title is `Electron`:

```javascript
```js
// In the main process.
const { BrowserWindow, desktopCapturer } = require('electron')

Expand All @@ -24,7 +24,7 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources =
})
```

```javascript @ts-nocheck
```js @ts-nocheck
// In the preload script.
const { ipcRenderer } = require('electron')

Expand Down Expand Up @@ -68,7 +68,7 @@ To capture both audio and video from the entire desktop the constraints passed
to [`navigator.mediaDevices.getUserMedia`][] must include `chromeMediaSource: 'desktop'`,
for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint.

```javascript
```js
const constraints = {
audio: {
mandatory: {
Expand Down
6 changes: 3 additions & 3 deletions docs/api/dialog.md
Expand Up @@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process)

An example of showing a dialog to select multiple files:

```javascript
```js
const { dialog } = require('electron')
console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] }))
```
Expand Down Expand Up @@ -52,7 +52,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind
The `filters` specifies an array of file types that can be displayed or
selected when you want to limit the user to a specific type. For example:

```javascript
```js
{
filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
Expand Down Expand Up @@ -119,7 +119,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind
The `filters` specifies an array of file types that can be displayed or
selected when you want to limit the user to a specific type. For example:

```javascript
```js
{
filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
Expand Down
2 changes: 1 addition & 1 deletion docs/api/dock.md
Expand Up @@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a

The following example shows how to bounce your icon on the dock.

```javascript
```js
const { app } = require('electron')
app.dock.bounce()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api/download-item.md
Expand Up @@ -9,7 +9,7 @@ _This class is not exported from the `'electron'` module. It is only available a
It is used in `will-download` event of `Session` class, and allows users to
control the download item.

```javascript
```js
// In the main process.
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
Expand Down
2 changes: 1 addition & 1 deletion docs/api/environment-variables.md
Expand Up @@ -59,7 +59,7 @@ geolocation webservice. To enable this feature, acquire a
and place the following code in your main process file, before opening any
browser windows that will make geolocation requests:

```javascript
```js
process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE'
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/global-shortcut.md
Expand Up @@ -12,7 +12,7 @@ shortcuts.
not have the keyboard focus. This module cannot be used before the `ready`
event of the app module is emitted.

```javascript
```js
const { app, globalShortcut } = require('electron')

app.whenReady().then(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/incoming-message.md
Expand Up @@ -89,7 +89,7 @@ tuples. So, the even-numbered offsets are key values, and the odd-numbered
offsets are the associated values. Header names are not lowercased, and
duplicates are not merged.

```javascript @ts-type={response:Electron.IncomingMessage}
```js @ts-type={response:Electron.IncomingMessage}
// Prints something like:
//
// [ 'user-agent',
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ipc-renderer.md
Expand Up @@ -120,7 +120,7 @@ The main process should listen for `channel` with

For example:

```javascript @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise<unknown>}
```js @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise<unknown>}
// Renderer process
ipcRenderer.invoke('some-name', someArgument).then((result) => {
// ...
Expand Down