build: update eslint + eslint plugins (#22777)

* build: run eslint --fix

* chore: manually fix all hasOwnProperty errors

* chore: manually fix all void 0 vs undefined errors

* chore: manually fix all async-in-promise errors

* chore: manually fix lexical declaration in case block
This commit is contained in:
Samuel Attard 2020-03-20 08:12:18 -07:00 committed by GitHub
parent 42f138282f
commit b87b501161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 280 additions and 280 deletions

View file

@ -93,7 +93,7 @@ exports.checkForUpdate = function (updateURL, callback) {
try {
// Last line of output is the JSON details about the releases
const 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
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : undefined : undefined : undefined
} catch {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal

View file

@ -254,7 +254,7 @@ const roles = {
exports.roleList = roles
const canExecuteRole = (role) => {
if (!roles.hasOwnProperty(role)) return false
if (!Object.prototype.hasOwnProperty.call(roles, role)) return false
if (!isMac) return true
// macOS handles all roles natively except for a few
@ -262,20 +262,20 @@ const canExecuteRole = (role) => {
}
exports.getDefaultLabel = (role) => {
return roles.hasOwnProperty(role) ? roles[role].label : ''
return Object.prototype.hasOwnProperty.call(roles, role) ? roles[role].label : ''
}
exports.getDefaultAccelerator = (role) => {
if (roles.hasOwnProperty(role)) return roles[role].accelerator
if (Object.prototype.hasOwnProperty.call(roles, role)) return roles[role].accelerator
}
exports.shouldRegisterAccelerator = (role) => {
const hasRoleRegister = roles.hasOwnProperty(role) && roles[role].registerAccelerator !== undefined
const hasRoleRegister = Object.prototype.hasOwnProperty.call(roles, role) && roles[role].registerAccelerator !== undefined
return hasRoleRegister ? roles[role].registerAccelerator : true
}
exports.getDefaultSubmenu = (role) => {
if (!roles.hasOwnProperty(role)) return
if (!Object.prototype.hasOwnProperty.call(roles, role)) return
let { submenu } = roles[role]

View file

@ -71,7 +71,7 @@ Menu.prototype.popup = function (options = {}) {
window = wins[0]
}
if (!window) {
throw new Error(`Cannot open Menu without a TopLevelWindow present`)
throw new Error('Cannot open Menu without a TopLevelWindow present')
}
}
@ -106,7 +106,7 @@ Menu.prototype.append = function (item) {
}
Menu.prototype.insert = function (pos, item) {
if ((item ? item.constructor : void 0) !== MenuItem) {
if ((item ? item.constructor : undefined) !== MenuItem) {
throw new TypeError('Invalid item')
}
@ -194,8 +194,8 @@ function areValidTemplateItems (template) {
return template.every(item =>
item != null &&
typeof item === 'object' &&
(item.hasOwnProperty('label') ||
item.hasOwnProperty('role') ||
(Object.prototype.hasOwnProperty.call(item, 'label') ||
Object.prototype.hasOwnProperty.call(item, 'role') ||
item.type === 'separator'))
}

View file

@ -11,7 +11,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
const netLog = session.defaultSession.netLog
if (!Object.getPrototypeOf(netLog).hasOwnProperty(property)) return
if (!Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(netLog), property)) return
// check for properties on the prototype chain that aren't functions
if (typeof netLog[property] !== 'function') return netLog[property]

View file

@ -124,10 +124,12 @@ class SlurpStream extends Writable {
super()
this._data = Buffer.alloc(0)
}
_write (chunk, encoding, callback) {
this._data = Buffer.concat([this._data, chunk])
callback()
}
data () { return this._data }
}
@ -399,7 +401,7 @@ class ClientRequest extends Writable {
this._urlLoader.on('redirect', (event, redirectInfo, headers) => {
const { statusCode, newMethod, newUrl } = redirectInfo
if (this._redirectPolicy === 'error') {
this._die(new Error(`Attempted to redirect, but redirect policy was 'error'`))
this._die(new Error('Attempted to redirect, but redirect policy was \'error\''))
} else if (this._redirectPolicy === 'manual') {
let _followRedirect = false
this._followRedirectCb = () => { _followRedirect = true }

View file

@ -9,7 +9,7 @@ Object.setPrototypeOf(protocol, new Proxy({}, {
if (!app.isReady()) return
const protocol = session.defaultSession!.protocol
if (!Object.getPrototypeOf(protocol).hasOwnProperty(property)) return
if (!Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(protocol), property)) return
// Returning a native function directly would throw error.
return (...args: any[]) => (protocol[property as keyof Electron.Protocol] as Function)(...args)

View file

@ -103,7 +103,7 @@ class TouchBar extends EventEmitter {
const { id } = window
// Already added to window
if (this.windowListeners.hasOwnProperty(id)) return
if (Object.prototype.hasOwnProperty.call(this.windowListeners, id)) return
window._touchBar = this

View file

@ -263,8 +263,8 @@ WebContents.prototype.printToPDF = function (options) {
if (options.pageRanges !== undefined) {
const pageRanges = options.pageRanges
if (!pageRanges.hasOwnProperty('from') || !pageRanges.hasOwnProperty('to')) {
const error = new Error(`pageRanges must be an Object with 'from' and 'to' properties`)
if (!Object.prototype.hasOwnProperty.call(pageRanges, 'from') || !Object.prototype.hasOwnProperty.call(pageRanges, 'to')) {
const error = new Error('pageRanges must be an Object with \'from\' and \'to\' properties')
return Promise.reject(error)
}
@ -333,7 +333,7 @@ WebContents.prototype.printToPDF = function (options) {
return Promise.reject(error)
}
} else {
printSettings.mediaSize = PDFPageSizes['A4']
printSettings.mediaSize = PDFPageSizes.A4
}
// Chromium expects this in a 0-100 range number, not as float