From 946f4292ef61eabb72e79d93d510f8e8aba8c7b7 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 2 Jan 2021 19:09:34 +0100 Subject: [PATCH] reenabled @typescript-eslint/prefer-nullish-coalescing --- .eslintrc.yml | 3 +-- app/lib/window.ts | 2 +- .../src/components/appRoot.component.ts | 4 ++-- .../src/components/selectorModal.component.ts | 2 +- .../src/components/splitTab.component.ts | 6 +++--- .../src/components/startPage.component.ts | 4 ++-- terminus-core/src/services/app.service.ts | 4 +--- .../src/services/shellIntegration.service.ts | 2 +- .../src/services/tabRecovery.service.ts | 2 +- terminus-core/src/services/tabs.service.ts | 2 +- terminus-core/src/services/themes.service.ts | 4 ++-- terminus-core/src/services/touchbar.service.ts | 4 ++-- .../src/services/pluginManager.service.ts | 2 +- terminus-serial/src/api.ts | 2 +- .../components/editConnectionModal.component.ts | 2 +- terminus-serial/src/services/serial.service.ts | 3 +-- terminus-ssh/src/api.ts | 13 ++++++------- .../components/editConnectionModal.component.ts | 6 +++--- .../src/components/sshSettingsTab.component.ts | 2 +- terminus-ssh/src/services/ssh.service.ts | 14 ++++++-------- terminus-terminal/src/api/decorator.ts | 2 +- .../colorSchemeSettingsTab.component.ts | 4 ++-- .../src/components/editProfileModal.component.ts | 4 ++-- .../src/components/shellSettingsTab.component.ts | 2 +- .../src/components/terminalTab.component.ts | 2 +- .../src/services/sessions.service.ts | 16 ++++++++-------- .../src/services/terminal.service.ts | 14 +++++++------- terminus-terminal/src/tabContextMenu.ts | 2 +- 28 files changed, 61 insertions(+), 68 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index cf07a4ea..e72d284e 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -95,12 +95,12 @@ rules: - error - single - allowTemplateLiterals: true + '@typescript-eslint/no-confusing-void-expression': off '@typescript-eslint/no-non-null-assertion': off '@typescript-eslint/no-unnecessary-condition': off '@typescript-eslint/no-untyped-public-signature': off # bugs out on constructors '@typescript-eslint/restrict-template-expressions': off '@typescript-eslint/no-dynamic-delete': off - '@typescript-eslint/prefer-nullish-coalescing': off '@typescript-eslint/prefer-readonly-parameter-types': off '@typescript-eslint/no-unsafe-member-access': off '@typescript-eslint/no-unsafe-call': off @@ -112,7 +112,6 @@ rules: - error - exceptAfterSingleLine: true '@typescript-eslint/dot-notation': off - '@typescript-eslint/no-confusing-void-expression': off '@typescript-eslint/no-implicit-any-catch': off '@typescript-eslint/member-ordering': off '@typescript-eslint/no-var-requires': off diff --git a/app/lib/window.ts b/app/lib/window.ts index 165bb1f2..8c9cd541 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -49,7 +49,7 @@ export class Window { constructor (options?: WindowOptions) { this.configStore = loadConfig() - options = options || {} + options = options ?? {} this.windowConfig = new ElectronConfig({ name: 'window' }) this.windowBounds = this.windowConfig.get('windowBoundaries') diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index 16c06999..c028b60c 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -229,8 +229,8 @@ export class AppRootComponent { buttons = buttons.concat(provider.provide()) }) return buttons - .filter(button => (button.weight || 0) > 0 === aboveZero) - .sort((a: ToolbarButton, b: ToolbarButton) => (a.weight || 0) - (b.weight || 0)) + .filter(button => (button.weight ?? 0) > 0 === aboveZero) + .sort((a: ToolbarButton, b: ToolbarButton) => (a.weight ?? 0) - (b.weight ?? 0)) } private updateVibrancy () { diff --git a/terminus-core/src/components/selectorModal.component.ts b/terminus-core/src/components/selectorModal.component.ts index 23cb69d5..5f4eb25b 100644 --- a/terminus-core/src/components/selectorModal.component.ts +++ b/terminus-core/src/components/selectorModal.component.ts @@ -50,7 +50,7 @@ export class SelectorModalComponent { this.filteredOptions = this.options.filter(x => !x.freeInputPattern) } else { // eslint-disable-next-line @typescript-eslint/restrict-plus-operands - this.filteredOptions = this.options.filter(x => x.freeInputPattern || (x.name + (x.description || '')).toLowerCase().includes(f)) + this.filteredOptions = this.options.filter(x => x.freeInputPattern ?? (x.name + (x.description ?? '')).toLowerCase().includes(f)) } this.selectedIndex = Math.max(0, this.selectedIndex) this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex) diff --git a/terminus-core/src/components/splitTab.component.ts b/terminus-core/src/components/splitTab.component.ts index f58c0d61..e0d41717 100644 --- a/terminus-core/src/components/splitTab.component.ts +++ b/terminus-core/src/components/splitTab.component.ts @@ -331,7 +331,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection): Promise { tab.parent = this - let target = (relative ? this.getParentOf(relative) : null) || this.root + let target = (relative ? this.getParentOf(relative) : null) ?? this.root let insertIndex = relative ? target.children.indexOf(relative) : -1 if ( @@ -442,7 +442,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit * @returns the immediate parent of `tab` */ getParentOf (tab: BaseTabComponent | SplitContainer, root?: SplitContainer): SplitContainer|null { - root = root || this.root + root = root ?? this.root for (const child of root.children) { if (child instanceof SplitContainer) { const r = this.getParentOf(tab, child) @@ -469,7 +469,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit /** @hidden */ async getCurrentProcess (): Promise { - return (await Promise.all(this.getAllTabs().map(x => x.getCurrentProcess()))).find(x => !!x) || null + return (await Promise.all(this.getAllTabs().map(x => x.getCurrentProcess()))).find(x => !!x) ?? null } /** @hidden */ diff --git a/terminus-core/src/components/startPage.component.ts b/terminus-core/src/components/startPage.component.ts index 32a577e3..d67341b9 100644 --- a/terminus-core/src/components/startPage.component.ts +++ b/terminus-core/src/components/startPage.component.ts @@ -26,10 +26,10 @@ export class StartPageComponent { .map(provider => provider.provide()) .reduce((a, b) => a.concat(b)) .filter(x => !!x.click) - .sort((a: ToolbarButton, b: ToolbarButton) => (a.weight || 0) - (b.weight || 0)) + .sort((a: ToolbarButton, b: ToolbarButton) => (a.weight ?? 0) - (b.weight ?? 0)) } sanitizeIcon (icon: string): any { - return this.domSanitizer.bypassSecurityTrustHtml(icon || '') + return this.domSanitizer.bypassSecurityTrustHtml(icon ?? '') } } diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 75f92912..46887f65 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -97,9 +97,7 @@ export class AppService { } } - hostApp.windowFocused$.subscribe(() => { - this._activeTab?.emitFocused() - }) + hostApp.windowFocused$.subscribe(() => this._activeTab?.emitFocused()) this.tabClosed$.subscribe(async tab => { const token = await tab.getRecoveryToken() diff --git a/terminus-core/src/services/shellIntegration.service.ts b/terminus-core/src/services/shellIntegration.service.ts index 923cbddf..e3a906b3 100644 --- a/terminus-core/src/services/shellIntegration.service.ts +++ b/terminus-core/src/services/shellIntegration.service.ts @@ -59,7 +59,7 @@ export class ShellIntegrationService { } async install (): Promise { - const exe: string = process.env.PORTABLE_EXECUTABLE_FILE || this.electron.app.getPath('exe') + const exe: string = process.env.PORTABLE_EXECUTABLE_FILE ?? this.electron.app.getPath('exe') if (this.hostApp.platform === Platform.macOS) { for (const wf of this.automatorWorkflows) { await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`) diff --git a/terminus-core/src/services/tabRecovery.service.ts b/terminus-core/src/services/tabRecovery.service.ts index 9d183300..19d97784 100644 --- a/terminus-core/src/services/tabRecovery.service.ts +++ b/terminus-core/src/services/tabRecovery.service.ts @@ -51,7 +51,7 @@ export class TabRecoveryService { const tab = await provider.recover(token) if (tab !== null) { tab.options = tab.options || {} - tab.options.color = token.tabColor || null + tab.options.color = token.tabColor ?? null tab.options.title = token.tabTitle || '' return tab } diff --git a/terminus-core/src/services/tabs.service.ts b/terminus-core/src/services/tabs.service.ts index 17c2986f..e4ce9550 100644 --- a/terminus-core/src/services/tabs.service.ts +++ b/terminus-core/src/services/tabs.service.ts @@ -22,7 +22,7 @@ export class TabsService { const componentRef = componentFactory.create(this.injector) const tab = componentRef.instance tab.hostView = componentRef.hostView - Object.assign(tab, inputs || {}) + Object.assign(tab, inputs ?? {}) return tab } diff --git a/terminus-core/src/services/themes.service.ts b/terminus-core/src/services/themes.service.ts index 93e95f12..1f9488fa 100644 --- a/terminus-core/src/services/themes.service.ts +++ b/terminus-core/src/services/themes.service.ts @@ -18,11 +18,11 @@ export class ThemesService { } findTheme (name: string): Theme|null { - return this.config.enabledServices(this.themes).find(x => x.name === name) || null + return this.config.enabledServices(this.themes).find(x => x.name === name) ?? null } findCurrentTheme (): Theme { - return this.findTheme(this.config.store.appearance.theme) || this.findTheme('Standard')! + return this.findTheme(this.config.store.appearance.theme) ?? this.findTheme('Standard')! } applyTheme (theme: Theme): void { diff --git a/terminus-core/src/services/touchbar.service.ts b/terminus-core/src/services/touchbar.service.ts index a4cd382d..ce60559b 100644 --- a/terminus-core/src/services/touchbar.service.ts +++ b/terminus-core/src/services/touchbar.service.ts @@ -66,7 +66,7 @@ export class TouchbarService { buttons = buttons.concat(provider.provide()) }) buttons = buttons.filter(x => !!x.touchBarNSImage) - buttons.sort((a, b) => (a.weight || 0) - (b.weight || 0)) + buttons.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0)) this.tabSegments = this.app.tabs.map(tab => ({ label: this.shortenTitle(tab.title), })) @@ -102,7 +102,7 @@ export class TouchbarService { private getButton (button: ToolbarButton): SegmentedControlSegment { return { - label: button.touchBarNSImage ? undefined : this.shortenTitle(button.touchBarTitle || button.title), + label: button.touchBarNSImage ? undefined : this.shortenTitle(button.touchBarTitle ?? button.title), icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : undefined, // click: () => this.zone.run(() => button.click()), } diff --git a/terminus-plugin-manager/src/services/pluginManager.service.ts b/terminus-plugin-manager/src/services/pluginManager.service.ts index fab21505..0827793a 100644 --- a/terminus-plugin-manager/src/services/pluginManager.service.ts +++ b/terminus-plugin-manager/src/services/pluginManager.service.ts @@ -40,7 +40,7 @@ export class PluginManagerService { listAvailable (query?: string): Observable { return from( - axios.get(`https://www.npmjs.com/search?q=keywords%3A${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`, { + axios.get(`https://www.npmjs.com/search?q=keywords%3A${KEYWORD}+${encodeURIComponent(query ?? '')}&from=0&size=1000`, { headers: { 'x-spiferack': '1', }, diff --git a/terminus-serial/src/api.ts b/terminus-serial/src/api.ts index 70b371cc..e7eb7311 100644 --- a/terminus-serial/src/api.ts +++ b/terminus-serial/src/api.ts @@ -44,7 +44,7 @@ export class SerialSession extends BaseSession { constructor (public connection: SerialConnection) { super() - this.scripts = connection.scripts || [] + this.scripts = connection.scripts ?? [] } async start (): Promise { diff --git a/terminus-serial/src/components/editConnectionModal.component.ts b/terminus-serial/src/components/editConnectionModal.component.ts index 9c8270b9..d4db3e95 100644 --- a/terminus-serial/src/components/editConnectionModal.component.ts +++ b/terminus-serial/src/components/editConnectionModal.component.ts @@ -37,7 +37,7 @@ export class EditConnectionModalComponent { } async ngOnInit () { - this.connection.scripts = this.connection.scripts || [] + this.connection.scripts = this.connection.scripts ?? [] this.foundPorts = await this.serial.listPorts() } diff --git a/terminus-serial/src/services/serial.service.ts b/terminus-serial/src/services/serial.service.ts index 6cd540dc..f48638f5 100644 --- a/terminus-serial/src/services/serial.service.ts +++ b/terminus-serial/src/services/serial.service.ts @@ -57,7 +57,6 @@ export class SerialService { this.toastr.error(e.message) reject(e) } - }) return serial } @@ -125,7 +124,7 @@ export class SerialService { { connection } ) as SerialTabComponent if (connection.color) { - (this.app.getParentTab(tab) || tab).color = connection.color + (this.app.getParentTab(tab) ?? tab).color = connection.color } setTimeout(() => { this.app.activeTab.emitFocused() diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index 6a9fad3b..66fe4d66 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -123,7 +123,7 @@ export class SSHSession extends BaseSession { constructor (public connection: SSHConnection) { super() - this.scripts = connection.scripts || [] + this.scripts = connection.scripts ?? [] this.destroyed$.subscribe(() => { for (const port of this.forwardedPorts) { if (port.type === PortForwardType.Local) { @@ -232,7 +232,7 @@ export class SSHSession extends BaseSession { this.ssh.on('x11', (details, accept, reject) => { this.logger.info(`Incoming X11 connection from ${details.srcIP}:${details.srcPort}`) - const displaySpec = process.env.DISPLAY || ':0' + const displaySpec = process.env.DISPLAY ?? ':0' this.logger.debug(`Trying display ${displaySpec}`) const xHost = displaySpec.split(':')[0] const xDisplay = parseInt(displaySpec.split(':')[1].split('.')[0] || '0') @@ -273,15 +273,14 @@ export class SSHSession extends BaseSession { await fw.startLocalListener((accept, reject, sourceAddress, sourcePort, targetAddress, targetPort) => { this.logger.info(`New connection on ${fw}`) this.ssh.forwardOut( - sourceAddress || '127.0.0.1', - sourcePort || 0, + sourceAddress ?? '127.0.0.1', + sourcePort ?? 0, targetAddress, targetPort, (err, stream) => { if (err) { this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`) - reject() - return + return reject() } if (stream) { const socket = accept() @@ -345,7 +344,7 @@ export class SSHSession extends BaseSession { kill (signal?: string): void { if (this.shell) { - this.shell.signal(signal || 'TERM') + this.shell.signal(signal ?? 'TERM') } } diff --git a/terminus-ssh/src/components/editConnectionModal.component.ts b/terminus-ssh/src/components/editConnectionModal.component.ts index 733368e5..04ae8466 100644 --- a/terminus-ssh/src/components/editConnectionModal.component.ts +++ b/terminus-ssh/src/components/editConnectionModal.component.ts @@ -47,9 +47,9 @@ export class EditConnectionModalComponent { async ngOnInit () { this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection) - this.connection.algorithms = this.connection.algorithms || {} - this.connection.scripts = this.connection.scripts || [] - this.connection.auth = this.connection.auth || null + this.connection.algorithms = this.connection.algorithms ?? {} + this.connection.scripts = this.connection.scripts ?? [] + this.connection.auth = this.connection.auth ?? null for (const k of Object.values(SSHAlgorithmType)) { if (!this.connection.algorithms[k]) { diff --git a/terminus-ssh/src/components/sshSettingsTab.component.ts b/terminus-ssh/src/components/sshSettingsTab.component.ts index 645d0dd8..17f955f6 100644 --- a/terminus-ssh/src/components/sshSettingsTab.component.ts +++ b/terminus-ssh/src/components/sshSettingsTab.component.ts @@ -127,7 +127,7 @@ export class SSHSettingsTabComponent { this.childGroups = [] for (const connection of this.connections) { - connection.group = connection.group || null + connection.group = connection.group ?? null let group = this.childGroups.find(x => x.name === connection.group) if (!group) { group = { diff --git a/terminus-ssh/src/services/ssh.service.ts b/terminus-ssh/src/services/ssh.service.ts index eb678db0..013dc5f0 100644 --- a/terminus-ssh/src/services/ssh.service.ts +++ b/terminus-ssh/src/services/ssh.service.ts @@ -249,12 +249,12 @@ export class SSHService { try { ssh.connect({ host: session.connection.host, - port: session.connection.port || 22, + port: session.connection.port ?? 22, username: session.connection.user, password: session.connection.privateKey ? undefined : '', - privateKey: privateKey || undefined, + privateKey: privateKey ?? undefined, tryKeyboard: true, - agent: agent || undefined, + agent: agent ?? undefined, agentForward: session.connection.agentForward && !!agent, keepaliveInterval: session.connection.keepaliveInterval, keepaliveCountMax: session.connection.keepaliveCountMax, @@ -284,7 +284,7 @@ export class SSHService { } as any) } catch (e) { this.toastr.error(e.message) - reject(e) + return reject(e) } let keychainPasswordUsed = false @@ -398,12 +398,10 @@ export class SSHService { { connection } ) as SSHTabComponent if (connection.color) { - (this.app.getParentTab(tab) || tab).color = connection.color + (this.app.getParentTab(tab) ?? tab).color = connection.color } - setTimeout(() => { - this.app.activeTab?.emitFocused() - }) + setTimeout(() => this.app.activeTab?.emitFocused()) return tab } catch (error) { diff --git a/terminus-terminal/src/api/decorator.ts b/terminus-terminal/src/api/decorator.ts index 3d4ee63a..3bc636c8 100644 --- a/terminus-terminal/src/api/decorator.ts +++ b/terminus-terminal/src/api/decorator.ts @@ -17,7 +17,7 @@ export abstract class TerminalDecorator { * Make sure to call super() */ detach (terminal: BaseTerminalTabComponent): void { - for (const s of this.smartSubscriptions.get(terminal) || []) { + for (const s of this.smartSubscriptions.get(terminal) ?? []) { s.unsubscribe() } this.smartSubscriptions.delete(terminal) diff --git a/terminus-terminal/src/components/colorSchemeSettingsTab.component.ts b/terminus-terminal/src/components/colorSchemeSettingsTab.component.ts index 60357713..7629c110 100644 --- a/terminus-terminal/src/components/colorSchemeSettingsTab.component.ts +++ b/terminus-terminal/src/components/colorSchemeSettingsTab.component.ts @@ -93,11 +93,11 @@ export class ColorSchemeSettingsTabComponent { } getCurrentSchemeName () { - return (this.currentCustomScheme || this.currentStockScheme)?.name || 'Custom' + return (this.currentCustomScheme ?? this.currentStockScheme)?.name ?? 'Custom' } findMatchingScheme (scheme: TerminalColorScheme, schemes: TerminalColorScheme[]) { - return schemes.find(x => deepEqual(x, scheme)) || null + return schemes.find(x => deepEqual(x, scheme)) ?? null } colorsTrackBy (index) { diff --git a/terminus-terminal/src/components/editProfileModal.component.ts b/terminus-terminal/src/components/editProfileModal.component.ts index f3c64ec4..8e2e0a43 100644 --- a/terminus-terminal/src/components/editProfileModal.component.ts +++ b/terminus-terminal/src/components/editProfileModal.component.ts @@ -18,8 +18,8 @@ export class EditProfileModalComponent { } ngOnInit () { - this.profile.sessionOptions.env = this.profile.sessionOptions.env || {} - this.profile.sessionOptions.args = this.profile.sessionOptions.args || [] + this.profile.sessionOptions.env = this.profile.sessionOptions.env ?? {} + this.profile.sessionOptions.args = this.profile.sessionOptions.args ?? [] } save () { diff --git a/terminus-terminal/src/components/shellSettingsTab.component.ts b/terminus-terminal/src/components/shellSettingsTab.component.ts index e5e075a5..7a745b58 100644 --- a/terminus-terminal/src/components/shellSettingsTab.component.ts +++ b/terminus-terminal/src/components/shellSettingsTab.component.ts @@ -67,7 +67,7 @@ export class ShellSettingsTabComponent { newProfile (shell: Shell): void { const profile: Profile = { - name: shell.name || '', + name: shell.name ?? '', shell: shell.id, sessionOptions: this.terminal.optionsFromShell(shell), } diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 5eaa1224..d7510010 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -69,7 +69,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { type: 'app:terminal-tab', sessionOptions: { ...this.sessionOptions, - cwd: cwd || this.sessionOptions.cwd, + cwd: cwd ?? this.sessionOptions.cwd, }, savedState: this.frontend?.saveState(), } diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index fac1c97e..1702049d 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -102,7 +102,7 @@ export class Session extends BaseSession { } start (options: SessionOptions): void { - this.name = options.name || '' + this.name = options.name ?? '' const env = { ...process.env, @@ -113,7 +113,7 @@ export class Session extends BaseSession { } if (process.platform === 'darwin' && !process.env.LC_ALL) { - const locale = process.env.LC_CTYPE || 'en_US.UTF-8' + const locale = process.env.LC_CTYPE ?? 'en_US.UTF-8' Object.assign(env, { LANG: locale, LC_ALL: locale, @@ -124,17 +124,17 @@ export class Session extends BaseSession { }) } - let cwd = options.cwd || process.env.HOME + let cwd = options.cwd ?? process.env.HOME if (!fs.existsSync(cwd)) { console.warn('Ignoring non-existent CWD:', cwd) cwd = undefined } - this.pty = nodePTY.spawn(options.command, options.args || [], { + this.pty = nodePTY.spawn(options.command, options.args ?? [], { name: 'xterm-256color', - cols: options.width || 80, - rows: options.height || 30, + cols: options.width ?? 80, + rows: options.height ?? 30, encoding: null, cwd, env: env, @@ -142,7 +142,7 @@ export class Session extends BaseSession { useConpty: (isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false) as any, }) - this.guessedCWD = cwd || null + this.guessedCWD = cwd ?? null this.truePID = this.pty['pid'] @@ -181,7 +181,7 @@ export class Session extends BaseSession { } }) - this.pauseAfterExit = options.pauseAfterExit || false + this.pauseAfterExit = options.pauseAfterExit ?? false } resize (columns: number, rows: number): void { diff --git a/terminus-terminal/src/services/terminal.service.ts b/terminus-terminal/src/services/terminal.service.ts index 2b6cfbca..da0e7479 100644 --- a/terminus-terminal/src/services/terminal.service.ts +++ b/terminus-terminal/src/services/terminal.service.ts @@ -38,6 +38,7 @@ export class TerminalService { const shells = await this.shells$.toPromise() return [ ...this.config.store.terminal.profiles, + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing ...skipDefault ? [] : shells.filter(x => includeHidden || !x.hidden).map(shell => ({ name: shell.name, shell: shell.id, @@ -54,7 +55,7 @@ export class TerminalService { async getProfileByID (id: string): Promise { const profiles = await this.getProfiles({ includeHidden: true }) - return profiles.find(x => this.getProfileID(x) === id) || profiles[0] + return profiles.find(x => this.getProfileID(x) === id) ?? profiles[0] } /** @@ -69,7 +70,7 @@ export class TerminalService { } } - cwd = cwd || profile.sessionOptions.cwd + cwd = cwd ?? profile.sessionOptions.cwd if (cwd && !fs.existsSync(cwd)) { console.warn('Ignoring non-existent CWD:', cwd) @@ -89,20 +90,19 @@ export class TerminalService { } } } - cwd = cwd || this.config.store.terminal.workingDirectory - cwd = cwd || null + cwd = cwd ?? this.config.store.terminal.workingDirectory } this.logger.info(`Starting profile ${profile.name}`, profile) const sessionOptions = { ...profile.sessionOptions, pauseAfterExit: pause, - cwd: cwd || undefined, + cwd: cwd ?? undefined, } const tab = this.openTabWithOptions(sessionOptions) if (profile?.color) { - (this.app.getParentTab(tab) || tab).color = profile.color + (this.app.getParentTab(tab) ?? tab).color = profile.color } return tab } @@ -110,7 +110,7 @@ export class TerminalService { optionsFromShell (shell: Shell): SessionOptions { return { command: shell.command, - args: shell.args || [], + args: shell.args ?? [], env: shell.env, } } diff --git a/terminus-terminal/src/tabContextMenu.ts b/terminus-terminal/src/tabContextMenu.ts index 07fd16c2..9a4948bb 100644 --- a/terminus-terminal/src/tabContextMenu.ts +++ b/terminus-terminal/src/tabContextMenu.ts @@ -30,7 +30,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider { const profile = { sessionOptions: { ...tab.sessionOptions, - cwd: await tab.session.getWorkingDirectory() || tab.sessionOptions.cwd, + cwd: await tab.session.getWorkingDirectory() ?? tab.sessionOptions.cwd, }, name: tab.sessionOptions.command, }