diff --git a/src/pty/index.ts b/src/pty/index.ts index a8c9cff5..d9cc2e1c 100644 --- a/src/pty/index.ts +++ b/src/pty/index.ts @@ -24,6 +24,7 @@ export function require_dlopen(modulename: string) { const module = { exports: {} }; const import__dirname = dirname(fileURLToPath(import.meta.url)); process.dlopen(module, path.join(import__dirname, modulename)); + // eslint-disable-next-line @typescript-eslint/no-explicit-any return module.exports as any; } /** diff --git a/src/pty/node-pty.d.ts b/src/pty/node-pty.d.ts index 0a61f88c..ad244456 100644 --- a/src/pty/node-pty.d.ts +++ b/src/pty/node-pty.d.ts @@ -225,6 +225,7 @@ declare module '@/pty' { * @returns an `IDisposable` to stop listening. */ export interface IEvent { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (listener: (e: T) => any): IDisposable; } } diff --git a/src/pty/prebuild-loader.ts b/src/pty/prebuild-loader.ts index 61794eb7..96eec18f 100644 --- a/src/pty/prebuild-loader.ts +++ b/src/pty/prebuild-loader.ts @@ -1,9 +1,10 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { require_dlopen } from '.'; export function pty_loader() { let pty: any; try { pty = require_dlopen('./pty/' + process.platform + '.' + process.arch + '/pty.node'); - } catch (outerError) { + } catch { pty = undefined; } return pty; diff --git a/src/pty/unixTerminal.ts b/src/pty/unixTerminal.ts index 85a8d469..a5ab873f 100644 --- a/src/pty/unixTerminal.ts +++ b/src/pty/unixTerminal.ts @@ -1,4 +1,5 @@ -/* eslint-disable prefer-rest-params */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable no-undef */ /** * Copyright (c) 2012-2015, Christopher Jeffrey (MIT License) * Copyright (c) 2016, Daniel Imms (MIT License). @@ -26,14 +27,14 @@ const DEFAULT_NAME = 'xterm'; const DESTROY_SOCKET_TIMEOUT_MS = 200; export class UnixTerminal extends Terminal { - protected _fd: number; - protected _pty: string; + protected override _fd: number; + protected override _pty: string; - protected _file: string; - protected _name: string; + protected override _file: string; + protected override _name: string; - protected _readable: boolean; - protected _writable: boolean; + protected override _readable: boolean; + protected override _writable: boolean; private _boundClose: boolean = false; private _emittedClose: boolean = false; @@ -67,9 +68,9 @@ export class UnixTerminal extends Terminal { } const cwd = opt.cwd || process.cwd(); - env.PWD = cwd; - const name = opt.name || env.TERM || DEFAULT_NAME; - env.TERM = name; + env['PWD'] = cwd; + const name = opt.name || env['TERM'] || DEFAULT_NAME; + env['TERM'] = name; const parsedEnv = this._parseEnv(env); const encoding = (opt.encoding === undefined ? 'utf8' : opt.encoding); @@ -212,7 +213,7 @@ export class UnixTerminal extends Terminal { self._pty = term.pty; self._file = process.argv[0] || 'node'; - self._name = process.env.TERM || ''; + self._name = process.env['TERM'] || ''; self._readable = true; self._writable = true; @@ -246,7 +247,7 @@ export class UnixTerminal extends Terminal { public kill(signal?: string): void { try { process.kill(this.pid, signal || 'SIGHUP'); - } catch (e) { /* swallow */ } + } catch { /* swallow */ } } /** @@ -279,7 +280,7 @@ export class UnixTerminal extends Terminal { } private _sanitizeEnv(env: IProcessEnv): void { - // Make sure we didn't start our server from inside tmux. + // Make sure we didn't start our server from inside tmux. delete env['TMUX']; delete env['TMUX_PANE']; diff --git a/src/pty/windowsPtyAgent.ts b/src/pty/windowsPtyAgent.ts index fca9a273..d6a2f71d 100644 --- a/src/pty/windowsPtyAgent.ts +++ b/src/pty/windowsPtyAgent.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable no-undef */ /** * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License) * Copyright (c) 2016, Daniel Imms (MIT License). @@ -147,7 +149,7 @@ export class WindowsPtyAgent { consoleProcessList.forEach((pid: number) => { try { process.kill(pid); - } catch (e) { + } catch{ // Ignore if process cannot be found (kill ESRCH error) } }); @@ -165,7 +167,7 @@ export class WindowsPtyAgent { processList.forEach(pid => { try { process.kill(pid); - } catch (e) { + } catch { // Ignore if process cannot be found (kill ESRCH error) } }); @@ -201,7 +203,7 @@ export class WindowsPtyAgent { const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release()); let buildNumber: number = 0; if (osVersion && osVersion.length === 4) { - buildNumber = parseInt(osVersion[3]); + buildNumber = parseInt(osVersion[3]!); } return buildNumber; } @@ -253,20 +255,20 @@ export function argsToCommandLine(file: string, args: ArgvOrCommandLine): string } const arg = argv[argIndex]; // if it is empty or it contains whitespace and is not already quoted - const hasLopsidedEnclosingQuote = xOr((arg[0] !== '"'), (arg[arg.length - 1] !== '"')); - const hasNoEnclosingQuotes = ((arg[0] !== '"') && (arg[arg.length - 1] !== '"')); + const hasLopsidedEnclosingQuote = xOr((arg![0] !== '"'), (arg![arg!.length - 1] !== '"')); + const hasNoEnclosingQuotes = ((arg![0] !== '"') && (arg![arg!.length - 1] !== '"')); const quote = arg === '' || - (arg.indexOf(' ') !== -1 || - arg.indexOf('\t') !== -1) && - ((arg.length > 1) && + (arg!.indexOf(' ') !== -1 || + arg!.indexOf('\t') !== -1) && + ((arg!.length > 1) && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes)); if (quote) { result += '"'; } let bsCount = 0; - for (let i = 0; i < arg.length; i++) { - const p = arg[i]; + for (let i = 0; i < arg!.length; i++) { + const p = arg![i]; if (p === '\\') { bsCount++; } else if (p === '"') { diff --git a/src/pty/windowsTerminal.ts b/src/pty/windowsTerminal.ts index 9aae295e..a8bd37ed 100644 --- a/src/pty/windowsTerminal.ts +++ b/src/pty/windowsTerminal.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ /** * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License) * Copyright (c) 2016, Daniel Imms (MIT License). @@ -135,7 +136,8 @@ export class WindowsTerminal extends Terminal { * openpty */ - public static open(options?: IPtyOpenOptions): void { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public static open(_options?: IPtyOpenOptions): void { throw new Error('open() not supported on windows, use Fork() instead.'); } @@ -176,6 +178,8 @@ export class WindowsTerminal extends Terminal { }); } + // @ts-expect-error - This is a private method that is not part of the public API. + // eslint-disable-next-line @typescript-eslint/no-unused-vars private _deferNoArgs(deferredFn: () => void): void { // If the terminal is ready, execute. if (this._isReady) { diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index da052d41..7b300cb0 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -1,2 +1,2 @@ -import { NCoreInitShell } from "./base"; +import { NCoreInitShell } from './base'; NCoreInitShell(); \ No newline at end of file