From 9f0df695ca4899ae2e351677dc5a875b80cec585 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Thu, 23 Nov 2017 14:22:43 -0800 Subject: [PATCH] :wrench: Spec: Fix style issues --- spec/api-browser-window-spec.js | 6 +++++- spec/api-ipc-spec.js | 1 + spec/api-native-image-spec.js | 2 ++ spec/api-net-spec.js | 11 +++++++++++ spec/api-protocol-spec.js | 3 +++ spec/api-session-spec.js | 3 +++ spec/api-web-contents-spec.js | 5 ++++- spec/api-web-frame-spec.js | 3 +++ spec/api-web-request-spec.js | 3 +++ spec/chromium-spec.js | 3 +++ spec/node-spec.js | 3 ++- spec/static/main.js | 4 ++++ spec/webview-spec.js | 7 +++++-- 13 files changed, 49 insertions(+), 5 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 066d47d9b70..fb7e6bf2755 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -153,7 +153,7 @@ describe('BrowserWindow module', () => { ] const responseEvent = 'window-webContents-destroyed' - function* genNavigationEvent () { + function * genNavigationEvent () { let eventOptions = null while ((eventOptions = events.shift()) && events.length) { let w = new BrowserWindow({show: false}) @@ -1056,6 +1056,8 @@ describe('BrowserWindow module', () => { // http protocol to simulate accessing another domain. This is required // because the code paths for cross domain popups is different. function crossDomainHandler (request, callback) { + // Disabled due to false positive in StandardJS + // eslint-disable-next-line standard/no-callback-literal callback({ mimeType: 'text/html', data: `

${request.url}

` @@ -3025,6 +3027,8 @@ const isScaleFactorRounding = () => { function serveFileFromProtocol (protocolName, filePath) { return new Promise((resolve, reject) => { protocol.registerBufferProtocol(protocolName, (request, callback) => { + // Disabled due to false positive in StandardJS + // eslint-disable-next-line standard/no-callback-literal callback({ mimeType: 'text/html', data: fs.readFileSync(filePath) diff --git a/spec/api-ipc-spec.js b/spec/api-ipc-spec.js index 4bb563184ad..b7b233adc3d 100644 --- a/spec/api-ipc-spec.js +++ b/spec/api-ipc-spec.js @@ -195,6 +195,7 @@ describe('ipc module', () => { const foo = remote.require(path.join(fixtures, 'module', 'error-properties.js')) assert.throws(() => { + // eslint-disable-next-line foo.bar }, /getting error/) diff --git a/spec/api-native-image-spec.js b/spec/api-native-image-spec.js index a86bda75af9..c604d391702 100644 --- a/spec/api-native-image-spec.js +++ b/spec/api-native-image-spec.js @@ -1,5 +1,7 @@ 'use strict' +/* eslint-disable no-unused-expressions */ + const {expect} = require('chai') const {nativeImage} = require('electron') const path = require('path') diff --git a/spec/api-net-spec.js b/spec/api-net-spec.js index 69aa1154ee8..4f9abfe1a5f 100644 --- a/spec/api-net-spec.js +++ b/spec/api-net-spec.js @@ -6,6 +6,9 @@ const url = require('url') const {net} = remote const {session} = remote +/* The whole net API doesn't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + function randomBuffer (size, start, end) { start = start || 0 end = end || 255 @@ -855,6 +858,8 @@ describe('net module', () => { (details, callback) => { if (details.url === `${server.url}${requestUrl}`) { requestIsIntercepted = true + // Disabled due to false positive in StandardJS + // eslint-disable-next-line standard/no-callback-literal callback({ redirectURL: `${server.url}${redirectUrl}` }) @@ -907,6 +912,8 @@ describe('net module', () => { customSession.webRequest.onBeforeRequest((details, callback) => { if (details.url === `${server.url}${requestUrl}`) { requestIsIntercepted = true + // Disabled due to false positive in StandardJS + // eslint-disable-next-line standard/no-callback-literal callback({ redirectURL: `${server.url}${redirectUrl}` }) @@ -1154,6 +1161,8 @@ describe('net module', () => { url: `${server.url}${requestUrl}`, session: 1 }) + + // eslint-disable-next-line urlRequest } catch (exception) { done() @@ -1223,6 +1232,8 @@ describe('net module', () => { url: `${server.url}${requestUrl}`, partition: 1 }) + + // eslint-disable-next-line urlRequest } catch (exception) { done() diff --git a/spec/api-protocol-spec.js b/spec/api-protocol-spec.js index a9d69867157..f214bfc6d27 100644 --- a/spec/api-protocol-spec.js +++ b/spec/api-protocol-spec.js @@ -10,6 +10,9 @@ const {BrowserWindow, ipcMain, protocol, session, webContents} = remote // and use Stream instances created in the browser process. const stream = remote.require('stream') +/* The whole protocol API doesn't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('protocol module', () => { const protocolName = 'sp' const text = 'valar morghulis' diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js index 50504ccadae..cf6296cd448 100644 --- a/spec/api-session-spec.js +++ b/spec/api-session-spec.js @@ -10,6 +10,9 @@ const {closeWindow} = require('./window-helpers') const {ipcRenderer, remote} = require('electron') const {ipcMain, session, BrowserWindow, net} = remote +/* The whole session API doesn't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('session module', () => { let fixtures = path.resolve(__dirname, 'fixtures') let w = null diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index 39e466d56bc..4e5cc022df7 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -10,6 +10,9 @@ const {BrowserWindow, webContents, ipcMain, session} = remote const isCi = remote.getGlobal('isCi') +/* The whole webContents API doesn't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('webContents module', () => { const fixtures = path.resolve(__dirname, 'fixtures') let w @@ -634,7 +637,7 @@ describe('webContents module', () => { ] const responseEvent = 'webcontents-destroyed' - function* genNavigationEvent () { + function * genNavigationEvent () { let eventOptions = null while ((eventOptions = events.shift()) && events.length) { eventOptions.responseEvent = responseEvent diff --git a/spec/api-web-frame-spec.js b/spec/api-web-frame-spec.js index ce0d0436ec5..a62c075d8e8 100644 --- a/spec/api-web-frame-spec.js +++ b/spec/api-web-frame-spec.js @@ -4,6 +4,9 @@ const {closeWindow} = require('./window-helpers') const {remote, webFrame} = require('electron') const {BrowserWindow, protocol, ipcMain} = remote +/* Most of the APIs here don't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('webFrame module', function () { var fixtures = path.resolve(__dirname, 'fixtures') var w = null diff --git a/spec/api-web-request-spec.js b/spec/api-web-request-spec.js index 6ad0550eb7d..7dc1f370ce8 100644 --- a/spec/api-web-request-spec.js +++ b/spec/api-web-request-spec.js @@ -4,6 +4,9 @@ const qs = require('querystring') const remote = require('electron').remote const session = remote.session +/* The whole webRequest API doesn't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('webRequest module', () => { const ses = session.defaultSession const server = http.createServer((req, res) => { diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 1420fed7c6a..f068ef75f12 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -11,6 +11,9 @@ const {app, BrowserWindow, ipcMain, protocol, session, webContents} = remote const isCI = remote.getGlobal('isCi') +/* Most of the APIs here don't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe('chromium feature', () => { const fixtures = path.resolve(__dirname, 'fixtures') let listener = null diff --git a/spec/node-spec.js b/spec/node-spec.js index ae639167ff0..6f2390e93ea 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -298,6 +298,7 @@ describe('node feature', () => { describe('process.stdout', () => { it('does not throw an exception when accessed', () => { assert.doesNotThrow(() => { + // eslint-disable-next-line process.stdout }) }) @@ -332,7 +333,7 @@ describe('node feature', () => { describe('process.stdin', () => { it('does not throw an exception when accessed', () => { assert.doesNotThrow(() => { - process.stdin + process.stdin // eslint-disable-line }) }) diff --git a/spec/static/main.js b/spec/static/main.js index 4a4dfd109df..80c8e716c67 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -32,9 +32,11 @@ app.commandLine.appendSwitch('disable-renderer-backgrounding') // Accessing stdout in the main process will result in the process.stdout // throwing UnknownSystemError in renderer process sometimes. This line makes // sure we can reproduce it in renderer process. +// eslint-disable-next-line process.stdout // Access console to reproduce #3482. +// eslint-disable-next-line console ipcMain.on('message', function (event, ...args) { @@ -378,6 +380,8 @@ const suspendListeners = (emitter, eventName, callback) => { listeners.forEach((listener) => { emitter.on(eventName, listener) }) + + // eslint-disable-next-line standard/no-callback-literal callback(...args) }) } diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 0ce043069f2..4ac8136b81f 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -9,6 +9,9 @@ const {closeWindow} = require('./window-helpers') const isCI = remote.getGlobal('isCi') const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled') +/* Most of the APIs here don't use standard callbacks */ +/* eslint-disable standard/no-callback-literal */ + describe(' tag', function () { this.timeout(3 * 60 * 1000) @@ -1423,7 +1426,7 @@ describe(' tag', function () { }) webview.style.display = 'none' - webview.offsetHeight + webview.offsetHeight // eslint-disable-line webview.style.display = 'block' }) webview.src = `file://${fixtures}/pages/a.html` @@ -1442,7 +1445,7 @@ describe(' tag', function () { }) webview.style.display = 'none' - webview.offsetHeight + webview.offsetHeight // eslint-disable-line webview.style.display = 'block' }) webview.src = `file://${fixtures}/pages/a.html`