Browse Source

:wrench: Spec: Fix style issues

Felix Rieseberg 7 years ago
parent
commit
9f0df695ca

+ 5 - 1
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: `<html><body><h1>${request.url}</h1></body></html>`
@@ -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)

+ 1 - 0
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/)
 

+ 2 - 0
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')

+ 11 - 0
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()

+ 3 - 0
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'

+ 3 - 0
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

+ 4 - 1
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

+ 3 - 0
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

+ 3 - 0
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) => {

+ 3 - 0
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

+ 2 - 1
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
       })
     })
 

+ 4 - 0
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)
   })
 }

+ 5 - 2
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('<webview> tag', function () {
   this.timeout(3 * 60 * 1000)
 
@@ -1423,7 +1426,7 @@ describe('<webview> 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('<webview> tag', function () {
         })
 
         webview.style.display = 'none'
-        webview.offsetHeight
+        webview.offsetHeight  // eslint-disable-line
         webview.style.display = 'block'
       })
       webview.src = `file://${fixtures}/pages/a.html`