refactor: use optional chaining / nullish coalescing operator (#35217)

This commit is contained in:
Milan Burda 2022-08-08 10:11:04 +02:00 committed by GitHub
parent 76431ac1fa
commit 34b985c556
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 8 deletions

View file

@ -68,7 +68,7 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
if (code !== 0) {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`Command failed: ${signal != null ? signal : code}\n${stderr}`);
return callback(`Command failed: ${signal ?? code}\n${stderr}`);
}
// Success.

View file

@ -9,8 +9,7 @@ let currentlyRunning: {
// |options.types| can't be empty and must be an array
function isValid (options: Electron.SourcesOptions) {
const types = options ? options.types : undefined;
return Array.isArray(types);
return Array.isArray(options?.types);
}
export async function getSources (args: Electron.SourcesOptions) {

View file

@ -395,7 +395,7 @@ class TouchBar extends EventEmitter implements Electron.TouchBar {
this.on('change', changeListener);
const escapeItemListener = (item: Electron.TouchBarItemType | null) => {
window._setEscapeTouchBarItem(item != null ? item : {});
window._setEscapeTouchBarItem(item ?? {});
};
this.on('escape-item-change', escapeItemListener);