diff --git a/docs/tutorial/accessibility.md b/docs/tutorial/accessibility.md index a2c47d47d13c..ee9a074ff22b 100644 --- a/docs/tutorial/accessibility.md +++ b/docs/tutorial/accessibility.md @@ -21,7 +21,7 @@ In the testing framework Spectron, you can now audit each window and `` tag in your application. For example: ```javascript -app.client.auditAccessibility().then(function (audit) { +app.client.auditAccessibility().then((audit) => { if (audit.failed) { console.error(audit.message) } diff --git a/docs/tutorial/automated-testing-with-a-custom-driver.md b/docs/tutorial/automated-testing-with-a-custom-driver.md index a5e7920eb368..15a59218c1a8 100644 --- a/docs/tutorial/automated-testing-with-a-custom-driver.md +++ b/docs/tutorial/automated-testing-with-a-custom-driver.md @@ -84,11 +84,15 @@ class TestDriver { In the app, you'd need to write a simple handler for the RPC calls: ```js -if (process.env.APP_TEST_DRIVER) { - process.on('message', onMessage) +const METHODS = { + isReady () { + // do any setup needed + return true + } + // define your RPC-able methods here } -async function onMessage ({ msgId, cmd, args }) { +const onMessage = async ({ msgId, cmd, args }) => { let method = METHODS[cmd] if (!method) method = () => new Error('Invalid method: ' + cmd) try { @@ -104,12 +108,8 @@ async function onMessage ({ msgId, cmd, args }) { } } -const METHODS = { - isReady () { - // do any setup needed - return true - } - // define your RPC-able methods here +if (process.env.APP_TEST_DRIVER) { + process.on('message', onMessage) } ``` diff --git a/docs/tutorial/dark-mode.md b/docs/tutorial/dark-mode.md index b6777da28434..bf16303e4ecb 100644 --- a/docs/tutorial/dark-mode.md +++ b/docs/tutorial/dark-mode.md @@ -138,7 +138,7 @@ Finally, the `main.js` file represents the main process and contains the actual const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron') const path = require('path') -function createWindow () { +const createWindow = () => { const win = new BrowserWindow({ width: 800, height: 600, diff --git a/docs/tutorial/in-app-purchases.md b/docs/tutorial/in-app-purchases.md index f9c2e9381ecb..3c4929fa5744 100644 --- a/docs/tutorial/in-app-purchases.md +++ b/docs/tutorial/in-app-purchases.md @@ -39,7 +39,7 @@ inAppPurchase.on('transactions-updated', (event, transactions) => { } // Check each transaction. - transactions.forEach(function (transaction) { + transactions.forEach((transaction) => { const payment = transaction.payment switch (transaction.transactionState) { diff --git a/docs/tutorial/keyboard-shortcuts.md b/docs/tutorial/keyboard-shortcuts.md index af510a197b62..30b9429e83cd 100644 --- a/docs/tutorial/keyboard-shortcuts.md +++ b/docs/tutorial/keyboard-shortcuts.md @@ -82,7 +82,7 @@ listen for the `keyup` and `keydown` [DOM events][dom-events] inside the renderer process using the [addEventListener() API][addEventListener-api]. ```javascript fiddle='docs/fiddles/features/keyboard-shortcuts/web-apis|focus=renderer.js' -function handleKeyPress(event) { +const handleKeyPress = (event) => { // You can put code here to handle the keypress. document.getElementById("last-keypress").innerText = event.key; console.log(`You pressed ${event.key}`); diff --git a/docs/tutorial/launch-app-from-url-in-another-app.md b/docs/tutorial/launch-app-from-url-in-another-app.md index 29caf479893f..7cd6c63670c1 100644 --- a/docs/tutorial/launch-app-from-url-in-another-app.md +++ b/docs/tutorial/launch-app-from-url-in-another-app.md @@ -44,7 +44,7 @@ if (process.defaultApp) { We will now define the function in charge of creating our browser window and load our application's `index.html` file. ```js -function createWindow () { +const createWindow = () => { // Create the browser window. mainWindow = new BrowserWindow({ width: 800, @@ -112,7 +112,7 @@ Finally, we will add some additional code to handle when someone closes our appl // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. -app.on('window-all-closed', function () { +app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit() }) ``` diff --git a/docs/tutorial/macos-dock.md b/docs/tutorial/macos-dock.md index b5527a4956b5..b82b7cc7f0c3 100644 --- a/docs/tutorial/macos-dock.md +++ b/docs/tutorial/macos-dock.md @@ -25,7 +25,7 @@ Starting with a working application from the ```javascript fiddle='docs/fiddles/features/macos-dock-menu' const { app, BrowserWindow, Menu } = require('electron') -function createWindow () { +const createWindow = () => { const win = new BrowserWindow({ width: 800, height: 600, diff --git a/docs/tutorial/message-ports.md b/docs/tutorial/message-ports.md index f8c4ea594a78..9f1e9bf467af 100644 --- a/docs/tutorial/message-ports.md +++ b/docs/tutorial/message-ports.md @@ -134,7 +134,7 @@ app.whenReady().then(async () => {