build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -1,29 +1,29 @@
'use strict'
'use strict';
const clipboard = process.electronBinding('clipboard')
const clipboard = process.electronBinding('clipboard');
if (process.type === 'renderer') {
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils')
const typeUtils = require('@electron/internal/common/type-utils')
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils');
const typeUtils = require('@electron/internal/common/type-utils');
const makeRemoteMethod = function (method) {
return (...args) => {
args = typeUtils.serialize(args)
const result = ipcRendererUtils.invokeSync('ELECTRON_BROWSER_CLIPBOARD', method, ...args)
return typeUtils.deserialize(result)
}
}
args = typeUtils.serialize(args);
const result = ipcRendererUtils.invokeSync('ELECTRON_BROWSER_CLIPBOARD', method, ...args);
return typeUtils.deserialize(result);
};
};
if (process.platform === 'linux') {
// On Linux we could not access clipboard in renderer process.
for (const method of Object.keys(clipboard)) {
clipboard[method] = makeRemoteMethod(method)
clipboard[method] = makeRemoteMethod(method);
}
} else if (process.platform === 'darwin') {
// Read/write to find pasteboard over IPC since only main process is notified of changes
clipboard.readFindText = makeRemoteMethod('readFindText')
clipboard.writeFindText = makeRemoteMethod('writeFindText')
clipboard.readFindText = makeRemoteMethod('readFindText');
clipboard.writeFindText = makeRemoteMethod('writeFindText');
}
}
module.exports = clipboard
module.exports = clipboard;

View file

@ -1,95 +1,95 @@
let deprecationHandler: ElectronInternal.DeprecationHandler | null = null
let deprecationHandler: ElectronInternal.DeprecationHandler | null = null;
function warnOnce (oldName: string, newName?: string) {
let warned = false
let warned = false;
const msg = newName
? `'${oldName}' is deprecated and will be removed. Please use '${newName}' instead.`
: `'${oldName}' is deprecated and will be removed.`
: `'${oldName}' is deprecated and will be removed.`;
return () => {
if (!warned && !process.noDeprecation) {
warned = true
deprecate.log(msg)
warned = true;
deprecate.log(msg);
}
}
};
}
const deprecate: ElectronInternal.DeprecationUtil = {
warnOnce,
setHandler: (handler) => { deprecationHandler = handler },
setHandler: (handler) => { deprecationHandler = handler; },
getHandler: () => deprecationHandler,
warn: (oldName, newName) => {
if (!process.noDeprecation) {
deprecate.log(`'${oldName}' is deprecated. Use '${newName}' instead.`)
deprecate.log(`'${oldName}' is deprecated. Use '${newName}' instead.`);
}
},
log: (message) => {
if (typeof deprecationHandler === 'function') {
deprecationHandler(message)
deprecationHandler(message);
} else if (process.throwDeprecation) {
throw new Error(message)
throw new Error(message);
} else if (process.traceDeprecation) {
return console.trace(message)
return console.trace(message);
} else {
return console.warn(`(electron) ${message}`)
return console.warn(`(electron) ${message}`);
}
},
// remove a function with no replacement
removeFunction: (fn, removedName) => {
if (!fn) { throw Error(`'${removedName} function' is invalid or does not exist.`) }
if (!fn) { throw Error(`'${removedName} function' is invalid or does not exist.`); }
// wrap the deprecated function to warn user
const warn = warnOnce(`${fn.name} function`)
const warn = warnOnce(`${fn.name} function`);
return function (this: any) {
warn()
fn.apply(this, arguments)
}
warn();
fn.apply(this, arguments);
};
},
// change the name of a function
renameFunction: (fn, newName) => {
const warn = warnOnce(`${fn.name} function`, `${newName} function`)
const warn = warnOnce(`${fn.name} function`, `${newName} function`);
return function (this: any) {
warn()
return fn.apply(this, arguments)
}
warn();
return fn.apply(this, arguments);
};
},
moveAPI: (fn: Function, oldUsage: string, newUsage: string) => {
const warn = warnOnce(oldUsage, newUsage)
const warn = warnOnce(oldUsage, newUsage);
return function (this: any) {
warn()
return fn.apply(this, arguments)
}
warn();
return fn.apply(this, arguments);
};
},
// change the name of an event
event: (emitter, oldName, newName) => {
const warn = newName.startsWith('-') /* internal event */
? warnOnce(`${oldName} event`)
: warnOnce(`${oldName} event`, `${newName} event`)
: warnOnce(`${oldName} event`, `${newName} event`);
return emitter.on(newName, function (this: NodeJS.EventEmitter, ...args) {
if (this.listenerCount(oldName) !== 0) {
warn()
this.emit(oldName, ...args)
warn();
this.emit(oldName, ...args);
}
})
});
},
// deprecate a getter/setter function pair in favor of a property
fnToProperty: (prototype: any, prop: string, getter: string, setter?: string) => {
const withWarnOnce = function (obj: any, key: any, oldName: string, newName: string) {
const warn = warnOnce(oldName, newName)
const method = obj[key]
const warn = warnOnce(oldName, newName);
const method = obj[key];
return function (this: any, ...args: any) {
warn()
return method.apply(this, args)
}
}
warn();
return method.apply(this, args);
};
};
prototype[getter.substr(1)] = withWarnOnce(prototype, getter, `${getter.substr(1)} function`, `${prop} property`)
prototype[getter.substr(1)] = withWarnOnce(prototype, getter, `${getter.substr(1)} function`, `${prop} property`);
if (setter) {
prototype[setter.substr(1)] = withWarnOnce(prototype, setter, `${setter.substr(1)} function`, `${prop} property`)
prototype[setter.substr(1)] = withWarnOnce(prototype, setter, `${setter.substr(1)} function`, `${prop} property`);
}
},
@ -98,55 +98,55 @@ const deprecate: ElectronInternal.DeprecationUtil = {
// if the property's already been removed, warn about it
const info = Object.getOwnPropertyDescriptor((o as any).__proto__, removedName) // eslint-disable-line
if (!info) {
deprecate.log(`Unable to remove property '${removedName}' from an object that lacks it.`)
return o
deprecate.log(`Unable to remove property '${removedName}' from an object that lacks it.`);
return o;
}
if (!info.get || !info.set) {
deprecate.log(`Unable to remove property '${removedName}' from an object does not have a getter / setter`)
return o
deprecate.log(`Unable to remove property '${removedName}' from an object does not have a getter / setter`);
return o;
}
// wrap the deprecated property in an accessor to warn
const warn = warnOnce(removedName)
const warn = warnOnce(removedName);
return Object.defineProperty(o, removedName, {
configurable: true,
get: () => {
warn()
return info.get!.call(o)
warn();
return info.get!.call(o);
},
set: newVal => {
if (!onlyForValues || onlyForValues.includes(newVal)) {
warn()
warn();
}
return info.set!.call(o, newVal)
return info.set!.call(o, newVal);
}
})
});
},
// change the name of a property
renameProperty: (o, oldName, newName) => {
const warn = warnOnce(oldName, newName)
const warn = warnOnce(oldName, newName);
// if the new property isn't there yet,
// inject it and warn about it
if ((oldName in o) && !(newName in o)) {
warn()
o[newName] = (o as any)[oldName]
warn();
o[newName] = (o as any)[oldName];
}
// wrap the deprecated property in an accessor to warn
// and redirect to the new property
return Object.defineProperty(o, oldName, {
get: () => {
warn()
return o[newName]
warn();
return o[newName];
},
set: value => {
warn()
o[newName] = value
warn();
o[newName] = value;
}
})
});
}
}
};
export default deprecate
export default deprecate;

View file

@ -5,4 +5,4 @@ export const commonModuleList: ElectronInternal.ModuleEntry[] = [
{ name: 'shell', loader: () => require('./shell') },
// The internal modules, invisible unless you know their names.
{ name: 'deprecate', loader: () => require('./deprecate'), private: true }
]
];

View file

@ -1,5 +1,5 @@
'use strict'
'use strict';
const { nativeImage } = process.electronBinding('native_image')
const { nativeImage } = process.electronBinding('native_image');
module.exports = nativeImage
module.exports = nativeImage;

View file

@ -1,3 +1,3 @@
'use strict'
'use strict';
module.exports = process.electronBinding('shell')
module.exports = process.electronBinding('shell');