Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update eslint + eslint plugins #22777

Merged
merged 5 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/browser/api/auto-updater/squirrel-update-win.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/browser/api/menu-item-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,28 +254,28 @@ 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
return roles[role].nonNativeMacOSRole
}

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]

Expand Down
8 changes: 4 additions & 4 deletions lib/browser/api/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

Expand Down Expand Up @@ -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')
}

Expand Down Expand Up @@ -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'))
}

Expand Down
2 changes: 1 addition & 1 deletion lib/browser/api/net-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion lib/browser/api/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down Expand Up @@ -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\''))
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
} else if (this._redirectPolicy === 'manual') {
let _followRedirect = false
this._followRedirectCb = () => { _followRedirect = true }
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/api/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/api/touch-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/browser/api/web-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/browser/message-port-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ export class MessagePortMain extends EventEmitter {
this.emit(channel, event)
}
}

start () {
return this._internalPort.start()
}

close () {
return this._internalPort.close()
}

postMessage (...args: any[]) {
if (Array.isArray(args[1])) {
args[1] = args[1].map((o: any) => o instanceof MessagePortMain ? o._internalPort : o)
Expand Down
5 changes: 3 additions & 2 deletions lib/browser/remote/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const throwRPCError = function (message: string) {

const removeRemoteListenersAndLogWarning = (sender: any, callIntoRenderer: (...args: any[]) => void) => {
const location = v8Util.getHiddenValue(callIntoRenderer, 'location')
let message = `Attempting to call a function in a renderer window that has been closed or released.` +
let message = 'Attempting to call a function in a renderer window that has been closed or released.' +
`\nFunction provided here: ${location}`

if (sender instanceof EventEmitter) {
Expand Down Expand Up @@ -281,11 +281,12 @@ const unwrapArgs = function (sender: electron.WebContents, frameId: number, cont
}
return ret
}
case 'function-with-return-value':
case 'function-with-return-value': {
const returnValue = metaToValue(meta.value)
return function () {
return returnValue
}
}
case 'function': {
// Merge contextId and meta.id, since meta.id can be the same in
// different webContents.
Expand Down
2 changes: 1 addition & 1 deletion lib/common/reset-search-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Object.defineProperty(electronModule, 'exports', {
get: () => require('electron')
})

Module._cache['electron'] = electronModule
Module._cache.electron = electronModule

const originalResolveFilename = Module._resolveFilename
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion lib/content_script/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ v8Util.setHiddenValue(global, 'ipc-internal', v8Util.getHiddenValue(isolatedWorl
// The process object created by webpack is not an event emitter, fix it so
// the API is more compatible with non-sandboxed renderers.
for (const prop of Object.keys(EventEmitter.prototype)) {
if (process.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(process, prop)) {
nornagon marked this conversation as resolved.
Show resolved Hide resolved
delete process[prop]
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/renderer/api/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function setObjectMembers (ref, object, metaId, members) {
if (!Array.isArray(members)) return

for (const member of members) {
if (object.hasOwnProperty(member.name)) continue
if (Object.prototype.hasOwnProperty.call(object, member.name)) continue

const descriptor = { enumerable: member.enumerable }
if (member.type === 'method') {
Expand Down Expand Up @@ -188,7 +188,7 @@ function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
return true
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
if (!Object.prototype.hasOwnProperty.call(target, property)) loadRemoteProperties()
const value = target[property]
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)
Expand Down
2 changes: 1 addition & 1 deletion lib/renderer/extensions/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const replacePlaceholders = (message: string, placeholders: Record<string, Place

const getMessage = (extensionId: number, messageName: string, substitutions: string[]) => {
const messages = getMessages(extensionId)
if (messages.hasOwnProperty(messageName)) {
if (Object.prototype.hasOwnProperty.call(messages, messageName)) {
const { message, placeholders } = messages[messageName]
return replacePlaceholders(message, placeholders, substitutions)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/renderer/ipc-renderer-internal-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const handle = function <T extends IPCHandler> (channel: string, handler:
}

export function invokeSync<T> (command: string, ...args: any[]): T {
const [ error, result ] = ipcRendererInternal.sendSync(command, ...args)
const [error, result] = ipcRendererInternal.sendSync(command, ...args)

if (error) {
throw error
Expand Down
2 changes: 1 addition & 1 deletion lib/renderer/security-warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const warnAboutExperimentalFeatures = function (webPreferences?: Electron.WebPre
*/
const warnAboutEnableBlinkFeatures = function (webPreferences?: Electron.WebPreferences) {
if (!webPreferences ||
!webPreferences.hasOwnProperty('enableBlinkFeatures') ||
!Object.prototype.hasOwnProperty.call(webPreferences, 'enableBlinkFeatures') ||
(webPreferences.enableBlinkFeatures && webPreferences.enableBlinkFeatures.length === 0)) {
return
}
Expand Down
6 changes: 3 additions & 3 deletions lib/renderer/web-view/guest-view-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const WEB_VIEW_EVENTS: Record<string, Array<string>> = {
'did-frame-navigate': ['url', 'httpResponseCode', 'httpStatusText', 'isMainFrame', 'frameProcessId', 'frameRoutingId'],
'did-navigate-in-page': ['url', 'isMainFrame', 'frameProcessId', 'frameRoutingId'],
'focus-change': ['focus', 'guestInstanceId'],
'close': [],
'crashed': [],
close: [],
crashed: [],
'plugin-crashed': ['name', 'version'],
'destroyed': [],
destroyed: [],
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
'page-title-updated': ['title', 'explicitSet'],
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],
Expand Down
4 changes: 2 additions & 2 deletions lib/renderer/web-view/web-view-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class WebViewImpl {
// heard back from createGuest yet. We will not reset the flag in this case so
// that we don't end up allocating a second guest.
if (this.guestInstanceId) {
this.guestInstanceId = void 0
this.guestInstanceId = undefined
}

this.beforeFirstNavigation = true
Expand Down Expand Up @@ -173,7 +173,7 @@ export class WebViewImpl {
}

for (const attributeName in this.attributes) {
if (this.attributes.hasOwnProperty(attributeName)) {
if (Object.prototype.hasOwnProperty.call(this.attributes, attributeName)) {
nornagon marked this conversation as resolved.
Show resolved Hide resolved
params[attributeName] = this.attributes[attributeName].getValue()
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/renderer/window-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class BrowserWindowProxy {
public get location (): LocationProxy | any {
return this._location
}

public set location (url: string | any) {
url = resolveURL(url, this.location.href)
this._invokeWebContentsMethod('loadURL', url)
Expand Down
2 changes: 1 addition & 1 deletion lib/sandboxed_renderer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ v8Util.setHiddenValue(global, 'ipc-internal', new EventEmitter())
// The process object created by webpack is not an event emitter, fix it so
// the API is more compatible with non-sandboxed renderers.
for (const prop of Object.keys(EventEmitter.prototype)) {
if (process.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(process, prop)) {
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
delete process[prop]
}
}
Expand Down
2 changes: 1 addition & 1 deletion script/download-circleci-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function downloadArtifact (name, buildNum, dest) {
url: circleArtifactUrl,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
}
}, true).catch(err => {
if (args.verbose) {
Expand Down
2 changes: 1 addition & 1 deletion script/gn-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools'

const OUT_DIR = getOutDir({ outDir: args.outDir })
if (!OUT_DIR) {
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`)
throw new Error('No viable out dir: one of Debug, Testing, or Release must exist.')
}

const env = Object.assign({
Expand Down
6 changes: 3 additions & 3 deletions script/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function isObjCHeader (filename) {
return /\/(mac|cocoa)\//.test(filename)
}

const LINTERS = [ {
const LINTERS = [{
key: 'c++',
roots: ['shell'],
test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
Expand Down Expand Up @@ -104,7 +104,7 @@ const LINTERS = [ {
test: filename => filename.endsWith('.js') || filename.endsWith('.ts'),
run: (opts, filenames) => {
const cmd = path.join(SOURCE_ROOT, 'node_modules', '.bin', 'eslint')
const args = [ '--cache', '--ext', '.js,.ts', ...filenames ]
const args = ['--cache', '--ext', '.js,.ts', ...filenames]
if (opts.fix) args.unshift('--fix')
spawnAndCheckExitCode(cmd, args, { cwd: SOURCE_ROOT })
}
Expand Down Expand Up @@ -202,7 +202,7 @@ const LINTERS = [ {
function parseCommandLine () {
let help
const opts = minimist(process.argv.slice(2), {
boolean: [ 'c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only' ],
boolean: ['c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only'],
alias: { 'c++': ['cc', 'cpp', 'cxx'], javascript: ['js', 'es'], python: 'py', changed: 'c', help: 'h', verbose: 'v' },
unknown: arg => { help = true }
})
Expand Down
6 changes: 3 additions & 3 deletions script/release/ci-release-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ async function makeRequest (requestOptions, parseResponse) {
async function circleCIcall (targetBranch, job, options) {
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
const buildRequest = {
'branch': targetBranch,
'parameters': {
branch: targetBranch,
parameters: {
'run-lint': false,
'run-build-linux': false,
'run-build-mac': false
Expand Down Expand Up @@ -185,7 +185,7 @@ async function circleCIRequest (url, method, requestBody) {
url,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
},
body: requestBody ? JSON.stringify(requestBody) : null
}, true).catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions script/release/notes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ async function getReleaseNotes (range, newVersion, explicitLinks) {

async function main () {
const opts = minimist(process.argv.slice(2), {
boolean: [ 'explicit-links', 'help' ],
string: [ 'version' ]
boolean: ['explicit-links', 'help'],
string: ['version']
})
opts.range = opts._.shift()
if (opts.help || !opts.range) {
Expand Down