Merge pull request #11235 from electron/standard-10

infra: Upgrade to StandardJS 10
This commit is contained in:
Cheng Zhao 2017-11-27 15:42:52 +09:00 committed by GitHub
commit 1c0ea0286e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 105 additions and 43 deletions

View file

@ -28,7 +28,9 @@ var spawnUpdate = function (args, detached, callback) {
// Process spawned, different args: Return with error
// No process spawned: Spawn new process
if (spawnedProcess && !isSameArgs(args)) {
return callback('AutoUpdater process with arguments ' + args + ' is already running')
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`AutoUpdater process with arguments ${args} is already running`)
} else if (!spawnedProcess) {
spawnedProcess = spawn(updateExe, args, {
detached: detached
@ -68,7 +70,9 @@ var spawnUpdate = function (args, detached, callback) {
// Process terminated with error.
if (code !== 0) {
return callback('Command failed: ' + (signal != null ? signal : code) + '\n' + stderr)
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`Command failed: ${signal != null ? signal : code}\n${stderr}`)
}
// Success.
@ -93,7 +97,9 @@ exports.checkForUpdate = function (updateURL, callback) {
json = stdout.trim().split('\n').pop()
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : void 0 : void 0 : void 0
} catch (jsonError) {
return callback('Invalid result:\n' + stdout)
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`Invalid result:\n${stdout}`)
}
return callback(null, update)
})

View file

@ -79,7 +79,6 @@ class IncomingMessage extends Readable {
this.shouldPush = true
this._pushInternalData()
}
}
URLRequest.prototype._emitRequestEvent = function (isAsync, ...rest) {
@ -103,7 +102,6 @@ URLRequest.prototype._emitResponseEvent = function (isAsync, ...rest) {
}
class ClientRequest extends EventEmitter {
constructor (options, callback) {
super()
@ -354,7 +352,6 @@ class ClientRequest extends EventEmitter {
abort () {
this.urlRequest.cancel()
}
}
function writeAfterEndNT (self, error, callback) {

View file

@ -26,6 +26,8 @@ Session.prototype.setCertificateVerifyProc = function (verifyProc) {
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
this._setCertificateVerifyProc(({hostname, certificate, verificationResult}, cb) => {
verifyProc(hostname, certificate, (result) => {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
cb(result ? 0 : -2)
})
})

View file

@ -6,6 +6,7 @@ const {app, ipcMain, session, NavigationController} = electron
// session is not used here, the purpose is to make sure session is initalized
// before the webContents module.
// eslint-disable-next-line
session
let nextId = 0

View file

@ -311,6 +311,8 @@ const chromeExtensionHandler = function (request, callback) {
const page = backgroundPages[parsed.hostname]
if (page && parsed.path === `/${page.name}`) {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
return callback({
mimeType: 'text/html',
data: page.html
@ -319,6 +321,8 @@ const chromeExtensionHandler = function (request, callback) {
fs.readFile(path.join(manifest.srcDirectory, parsed.path), function (err, content) {
if (err) {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
return callback(-6) // FILE_NOT_FOUND
} else {
return callback(content)

View file

@ -367,6 +367,8 @@
return invalidArchiveError(asarPath, callback)
}
process.nextTick(function () {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
callback(archive.stat(filePath) !== false)
})
}
@ -482,7 +484,7 @@
}
if (info.size === 0) {
return process.nextTick(function () {
callback(null, encoding ? '' : new Buffer(0))
callback(null, encoding ? '' : Buffer.alloc(0))
})
}
if (info.unpacked) {
@ -490,7 +492,7 @@
return fs.readFile(realPath, options, callback)
}
const buffer = new Buffer(info.size)
const buffer = Buffer.alloc(info.size)
const fd = archive.getFd()
if (!(fd >= 0)) {
return notFoundError(asarPath, filePath, callback)
@ -519,7 +521,7 @@
if (options) {
return ''
} else {
return new Buffer(0)
return Buffer.alloc(0)
}
}
if (info.unpacked) {
@ -538,7 +540,7 @@
throw new TypeError('Bad arguments')
}
const {encoding} = options
const buffer = new Buffer(info.size)
const buffer = Buffer.alloc(info.size)
const fd = archive.getFd()
if (!(fd >= 0)) {
notFoundError(asarPath, filePath)
@ -611,7 +613,7 @@
encoding: 'utf8'
})
}
const buffer = new Buffer(info.size)
const buffer = Buffer.alloc(info.size)
const fd = archive.getFd()
if (!(fd >= 0)) {
return

View file

@ -147,6 +147,8 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
executeScript (tabId, details, callback) {
const requestId = ++nextId
ipcRenderer.once(`CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, (event, result) => {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
callback([event.result])
})
ipcRenderer.send('CHROME_TABS_EXECUTESCRIPT', requestId, tabId, extensionId, details)

View file

@ -51,6 +51,8 @@ const getStorage = (storageType, extensionId, cb) => {
if (data !== null) {
cb(JSON.parse(data))
} else {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
cb({})
}
})
@ -82,6 +84,9 @@ const getStorageManager = (storageType, extensionId) => {
}
break
}
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
if (keys.length === 0) return callback({})
let items = {}