diff --git a/docs/api/breaking-changes.md b/docs/api/breaking-changes.md index c679e6646c5..2462ecf10b1 100644 --- a/docs/api/breaking-changes.md +++ b/docs/api/breaking-changes.md @@ -116,7 +116,7 @@ However, it is recommended to avoid using the `remote` module altogether. // main const { ipcMain, webContents } = require('electron') -const getGuestForWebContents = function (webContentsId, contents) { +const getGuestForWebContents = (webContentsId, contents) => { const guest = webContents.fromId(webContentsId) if (!guest) { throw new Error(`Invalid webContentsId: ${webContentsId}`) diff --git a/docs/api/session.md b/docs/api/session.md index cfd69f4fa34..b8e4815695f 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -519,12 +519,12 @@ A [`Protocol`](protocol.md) object for this session. const { app, session } = require('electron') const path = require('path') -app.on('ready', function () { +app.on('ready', () => { const protocol = session.fromPartition('some-partition').protocol - protocol.registerFileProtocol('atom', function (request, callback) { - var url = request.url.substr(7) + protocol.registerFileProtocol('atom', (request, callback) => { + let url = request.url.substr(7) callback({ path: path.normalize(`${__dirname}/${url}`) }) - }, function (error) { + }, (error) => { if (error) console.error('Failed to register protocol') }) }) @@ -537,7 +537,7 @@ A [`NetLog`](net-log.md) object for this session. ```javascript const { app, session } = require('electron') -app.on('ready', async function () { +app.on('ready', async () => { const netLog = session.fromPartition('some-partition').netLog netLog.startLogging('/path/to/net-log') // After some network events diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index a90c5590816..9c45d6a49a6 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -987,7 +987,7 @@ Injects CSS into the current web page and returns a unique key for the inserted stylesheet. ```js -contents.on('did-finish-load', function () { +contents.on('did-finish-load', () => { contents.insertCSS('html, body { background-color: #f00; }') }) ``` @@ -1002,7 +1002,7 @@ Removes the inserted CSS from the current web page. The stylesheet is identified by its key, which is returned from `contents.insertCSS(css)`. ```js -contents.on('did-finish-load', async function () { +contents.on('did-finish-load', async () => { const key = await contents.insertCSS('html, body { background-color: #f00; }') contents.removeInsertedCSS(key) }) diff --git a/docs/development/build-system-overview.md b/docs/development/build-system-overview.md index 881e4cc653f..bb5a0d60cc2 100644 --- a/docs/development/build-system-overview.md +++ b/docs/development/build-system-overview.md @@ -57,7 +57,7 @@ you're currently working on using Mocha's `.only` to any `describe` or `it` function call: ```js -describe.only('some feature', function () { +describe.only('some feature', () => { // ... only tests in this block will be run }) ``` diff --git a/docs/tutorial/automated-testing-with-a-custom-driver.md b/docs/tutorial/automated-testing-with-a-custom-driver.md index 0284a217d0c..63267648080 100644 --- a/docs/tutorial/automated-testing-with-a-custom-driver.md +++ b/docs/tutorial/automated-testing-with-a-custom-driver.md @@ -5,13 +5,13 @@ To write automated tests for your Electron app, you will need a way to "drive" y To create a custom driver, we'll use Node.js' [child_process](https://nodejs.org/api/child_process.html) API. The test suite will spawn the Electron process, then establish a simple messaging protocol: ```js -var childProcess = require('child_process') -var electronPath = require('electron') +const childProcess = require('child_process') +const electronPath = require('electron') // spawn the process -var env = { /* ... */ } -var stdio = ['inherit', 'inherit', 'inherit', 'ipc'] -var appProcess = childProcess.spawn(electronPath, ['./app'], { stdio, env }) +let env = { /* ... */ } +let stdio = ['inherit', 'inherit', 'inherit', 'ipc'] +let appProcess = childProcess.spawn(electronPath, ['./app'], { stdio, env }) // listen for IPC messages from the app appProcess.on('message', (msg) => { @@ -50,7 +50,7 @@ class TestDriver { // handle rpc responses this.process.on('message', (message) => { // pop the handler - var rpcCall = this.rpcCalls[message.msgId] + let rpcCall = this.rpcCalls[message.msgId] if (!rpcCall) return this.rpcCalls[message.msgId] = null // reject/resolve @@ -70,7 +70,7 @@ class TestDriver { // to use: driver.rpc('method', 1, 2, 3).then(...) async rpc (cmd, ...args) { // send rpc request - var msgId = this.rpcCalls.length + let msgId = this.rpcCalls.length this.process.send({ msgId, cmd, args }) return new Promise((resolve, reject) => this.rpcCalls.push({ resolve, reject })) } @@ -89,13 +89,13 @@ if (process.env.APP_TEST_DRIVER) { } async function onMessage ({ msgId, cmd, args }) { - var method = METHODS[cmd] + let method = METHODS[cmd] if (!method) method = () => new Error('Invalid method: ' + cmd) try { - var resolve = await method(...args) + let resolve = await method(...args) process.send({ msgId, resolve }) } catch (err) { - var reject = { + let reject = { message: err.message, stack: err.stack, name: err.name @@ -116,10 +116,10 @@ const METHODS = { Then, in your test suite, you can use your test-driver as follows: ```js -var test = require('ava') -var electronPath = require('electron') +const test = require('ava') +const electronPath = require('electron') -var app = new TestDriver({ +let app = new TestDriver({ path: electronPath, args: ['./app'], env: { diff --git a/docs/tutorial/in-app-purchases.md b/docs/tutorial/in-app-purchases.md index c689ed12783..eb971639192 100644 --- a/docs/tutorial/in-app-purchases.md +++ b/docs/tutorial/in-app-purchases.md @@ -37,7 +37,7 @@ inAppPurchase.on('transactions-updated', (event, transactions) => { // Check each transaction. transactions.forEach(function (transaction) { - var payment = transaction.payment + let payment = transaction.payment switch (transaction.transactionState) { case 'purchasing':