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

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

View File

@@ -50,7 +50,7 @@ export class SelectorModalComponent<T> {
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)

View File

@@ -331,7 +331,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection): Promise<void> {
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<BaseTabProcess|null> {
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 */

View File

@@ -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 ?? '')
}
}

View File

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

View File

@@ -59,7 +59,7 @@ export class ShellIntegrationService {
}
async install (): Promise<void> {
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}"`)

View File

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

View File

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

View File

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

View File

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