reenabled @typescript-eslint/prefer-nullish-coalescing

This commit is contained in:
Eugene Pankov
2021-01-02 19:09:34 +01:00
parent eb12b1ae60
commit 946f4292ef
28 changed files with 61 additions and 68 deletions

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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 () {

View File

@@ -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),
}

View File

@@ -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(),
}

View File

@@ -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 {

View File

@@ -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<Profile> {
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,
}
}

View File

@@ -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,
}