reenabled @typescript-eslint/no-unnecessary-condition

This commit is contained in:
Eugene Pankov
2021-01-02 20:10:00 +01:00
parent 946f4292ef
commit 4d9cc91e91
36 changed files with 197 additions and 164 deletions

View File

@@ -24,7 +24,7 @@ export enum SSHAlgorithmType {
export interface SSHConnection {
name: string
host: string
port: number
port?: number
user: string
auth?: null|'password'|'publicKey'|'agent'|'keyboardInteractive'
password?: string
@@ -112,7 +112,7 @@ export class ForwardedPort {
export class SSHSession extends BaseSession {
scripts?: LoginScript[]
shell: ClientChannel
shell?: ClientChannel
ssh: Client
forwardedPorts: ForwardedPort[] = []
logger: Logger
@@ -282,17 +282,15 @@ export class SSHSession extends BaseSession {
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`)
return reject()
}
if (stream) {
const socket = accept()
stream.pipe(socket)
socket.pipe(stream)
stream.on('close', () => {
socket.destroy()
})
socket.on('close', () => {
stream.close()
})
}
const socket = accept()
stream.pipe(socket)
socket.pipe(stream)
stream.on('close', () => {
socket.destroy()
})
socket.on('close', () => {
stream.close()
})
}
)
}).then(() => {

View File

@@ -52,6 +52,7 @@ export class EditConnectionModalComponent {
this.connection.auth = this.connection.auth ?? null
for (const k of Object.values(SSHAlgorithmType)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this.connection.algorithms[k]) {
this.connection.algorithms[k] = this.defaultAlgorithms[k]
}

View File

@@ -19,8 +19,8 @@ import { Subscription } from 'rxjs'
animations: BaseTerminalTabComponent.animations,
})
export class SSHTabComponent extends BaseTerminalTabComponent {
connection: SSHConnection
session: SSHSession
connection?: SSHConnection
session?: SSHSession
private sessionStack: SSHSession[] = []
private homeEndSubscription: Subscription
@@ -72,7 +72,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
jumpSession.destroyed$.subscribe(() => session.destroy())
session.jumpStream = await new Promise((resolve, reject) => jumpSession.ssh.forwardOut(
'127.0.0.1', 0, session.connection.host, session.connection.port,
'127.0.0.1', 0, session.connection.host, session.connection.port ?? 22,
(err, stream) => {
if (err) {
jumpSession.emitServiceMessage(colors.bgRed.black(' X ') + ` Could not set up port forward on ${jumpConnection.name}`)
@@ -156,7 +156,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
async reconnect (): Promise<void> {
this.session?.destroy()
await this.initializeSession()
this.session.releaseInitialDataBuffer()
this.session?.releaseInitialDataBuffer()
}
async canClose (): Promise<boolean> {

View File

@@ -7,7 +7,7 @@ import { SSHTabComponent } from './components/sshTab.component'
@Injectable()
export class RecoveryProvider extends TabRecoveryProvider {
async recover (recoveryToken: RecoveryToken): Promise<RecoveredTab|null> {
if (recoveryToken?.type === 'app:ssh-tab') {
if (recoveryToken.type === 'app:ssh-tab') {
return {
type: SSHTabComponent,
options: {