Skip to content

Commit d0cc8c6

Browse files
committed
Clean up tslint warings in rest of top-level ts files
1 parent d7db831 commit d0cc8c6

File tree

10 files changed

+275
-280
lines changed

10 files changed

+275
-280
lines changed

src/debugAdapter.ts

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import fs = require('fs');
6-
import path = require('path');
7-
import net = require('net');
8-
import utils = require('./utils');
9-
import { Logger } from './logging';
5+
import fs = require("fs");
6+
import net = require("net");
7+
import path = require("path");
8+
import { Logger } from "./logging";
9+
import utils = require("./utils");
1010

1111
// NOTE: The purpose of this file is to serve as a bridge between
1212
// VS Code's debug adapter client (which communicates via stdio) and
1313
// PowerShell Editor Services' debug service (which communicates via
1414
// named pipes or a network protocol). It is purely a naive data
1515
// relay between the two transports.
1616

17-
var logBasePath = path.resolve(__dirname, "../../logs");
17+
const logBasePath = path.resolve(__dirname, "../../logs");
1818

19-
var debugAdapterLogWriter =
19+
const debugAdapterLogWriter =
2020
fs.createWriteStream(
2121
path.resolve(
2222
logBasePath,
@@ -26,13 +26,13 @@ var debugAdapterLogWriter =
2626
// debug server
2727
process.stdin.pause();
2828

29-
var debugSessionFilePath = utils.getDebugSessionFilePath();
29+
const debugSessionFilePath = utils.getDebugSessionFilePath();
3030
debugAdapterLogWriter.write("Session file path: " + debugSessionFilePath + ", pid: " + process.pid + " \r\n");
3131

3232
function startDebugging() {
3333
// Read the details of the current session to learn
3434
// the connection details for the debug service
35-
let sessionDetails = utils.readSessionFile(debugSessionFilePath);
35+
const sessionDetails = utils.readSessionFile(debugSessionFilePath);
3636

3737
// Delete the session file after it has been read so that
3838
// it isn't used mistakenly by another debug session
@@ -42,33 +42,33 @@ function startDebugging() {
4242
debugAdapterLogWriter.write("Connecting to port: " + sessionDetails.debugServicePort + "\r\n");
4343

4444
let isConnected = false;
45-
let debugServiceSocket = net.connect(sessionDetails.debugServicePort, '127.0.0.1');
45+
const debugServiceSocket = net.connect(sessionDetails.debugServicePort, "127.0.0.1");
4646

4747
// Write any errors to the log file
4848
debugServiceSocket.on(
49-
'error',
49+
"error",
5050
(e) => {
51-
debugAdapterLogWriter.write("Socket ERROR: " + e + "\r\n")
51+
debugAdapterLogWriter.write("Socket ERROR: " + e + "\r\n");
5252
debugAdapterLogWriter.close();
5353
debugServiceSocket.destroy();
5454
process.exit(0);
5555
});
5656

5757
// Route any output from the socket through stdout
5858
debugServiceSocket.on(
59-
'data',
59+
"data",
6060
(data: Buffer) => process.stdout.write(data));
6161

6262
// Wait for the connection to complete
6363
debugServiceSocket.on(
64-
'connect',
64+
"connect",
6565
() => {
6666
isConnected = true;
6767
debugAdapterLogWriter.write("Connected to socket!\r\n\r\n");
6868

6969
// When data comes on stdin, route it through the socket
7070
process.stdin.on(
71-
'data',
71+
"data",
7272
(data: Buffer) => debugServiceSocket.write(data));
7373

7474
// Resume the stdin stream
@@ -77,7 +77,7 @@ function startDebugging() {
7777

7878
// When the socket closes, end the session
7979
debugServiceSocket.on(
80-
'close',
80+
"close",
8181
() => {
8282
debugAdapterLogWriter.write("Socket closed, shutting down.");
8383
debugAdapterLogWriter.close();
@@ -88,17 +88,17 @@ function startDebugging() {
8888
setTimeout(() => {
8989
process.exit(0);
9090
}, 2000);
91-
}
92-
)
91+
},
92+
);
9393

9494
process.on(
95-
'exit',
95+
"exit",
9696
(e) => {
9797
if (debugAdapterLogWriter) {
9898
debugAdapterLogWriter.write("Debug adapter process is exiting...");
9999
}
100-
}
101-
)
100+
},
101+
);
102102
}
103103

104104
function waitForSessionFile(triesRemaining: number) {
@@ -109,28 +109,26 @@ function waitForSessionFile(triesRemaining: number) {
109109
if (utils.checkIfFileExists(debugSessionFilePath)) {
110110
debugAdapterLogWriter.write(`Session file present, connecting to debug adapter...\r\n\r\n`);
111111
startDebugging();
112-
}
113-
else {
112+
} else {
114113
// Wait for a second and try again
115114
setTimeout(
116115
() => waitForSessionFile(triesRemaining - 1),
117116
1000);
118117
}
119-
}
120-
else {
118+
} else {
121119
debugAdapterLogWriter.write(`Timed out waiting for session file!\r\n`);
122-
var errorJson =
120+
const errorJson =
123121
JSON.stringify({
124122
type: "response",
125123
request_seq: 1,
126124
command: "initialize",
127125
success: false,
128-
message: "Timed out waiting for the PowerShell extension to start."
126+
message: "Timed out waiting for the PowerShell extension to start.",
129127
});
130128

131129
process.stdout.write(
132-
`Content-Length: ${Buffer.byteLength(errorJson, 'utf8')}\r\n\r\n${errorJson}`,
133-
'utf8');
130+
`Content-Length: ${Buffer.byteLength(errorJson, "utf8")}\r\n\r\n${errorJson}`,
131+
"utf8");
134132
}
135133
}
136134

src/feature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import vscode = require('vscode');
6-
import { LanguageClient } from 'vscode-languageclient';
7-
export { LanguageClient } from 'vscode-languageclient';
5+
import vscode = require("vscode");
6+
import { LanguageClient } from "vscode-languageclient";
7+
export { LanguageClient } from "vscode-languageclient";
88

99
export interface IFeature extends vscode.Disposable {
1010
setLanguageClient(languageclient: LanguageClient);

src/features/DebugSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Settings = require('../settings');
88
import { dirname } from 'path';
99
import { IFeature } from '../feature';
1010
import { SessionManager } from '../session';
11-
import { OperatingSystem, PlatformDetails, getPlatformDetails } from '../platform';
11+
import { OperatingSystem, IPlatformDetails, getPlatformDetails } from '../platform';
1212

1313
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
1414
import { CancellationToken, DebugConfiguration, DebugConfigurationProvider,

src/logging.ts

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import fs = require('fs');
6-
import os = require('os');
7-
import path = require('path');
8-
import vscode = require('vscode');
9-
import utils = require('./utils');
10-
import jsonrpc = require('vscode-jsonrpc');
5+
import fs = require("fs");
6+
import os = require("os");
7+
import path = require("path");
8+
import vscode = require("vscode");
9+
import jsonrpc = require("vscode-jsonrpc");
10+
import utils = require("./utils");
1111

1212
export enum LogLevel {
1313
Verbose,
1414
Normal,
1515
Warning,
16-
Error
16+
Error,
1717
}
1818

1919
export class Logger {
2020

21-
private commands: vscode.Disposable[];
22-
private logChannel: vscode.OutputChannel;
23-
private logFilePath: string;
24-
2521
public logBasePath: string;
2622
public logSessionPath: string;
2723
public MinimumLogLevel: LogLevel = LogLevel.Normal;
2824

25+
private commands: vscode.Disposable[];
26+
private logChannel: vscode.OutputChannel;
27+
private logFilePath: string;
28+
2929
constructor() {
3030
this.logChannel = vscode.window.createOutputChannel("PowerShell Extension Logs");
3131

@@ -34,13 +34,18 @@ export class Logger {
3434

3535
this.commands = [
3636
vscode.commands.registerCommand(
37-
'PowerShell.ShowLogs',
37+
"PowerShell.ShowLogs",
3838
() => { this.showLogPanel(); }),
3939

4040
vscode.commands.registerCommand(
41-
'PowerShell.OpenLogFolder',
42-
() => { this.openLogFolder(); })
43-
]
41+
"PowerShell.OpenLogFolder",
42+
() => { this.openLogFolder(); }),
43+
];
44+
}
45+
46+
public dispose() {
47+
this.commands.forEach((command) => { command.dispose(); });
48+
this.logChannel.dispose();
4449
}
4550

4651
public getLogFilePath(baseName: string): string {
@@ -49,7 +54,7 @@ export class Logger {
4954

5055
public writeAtLevel(logLevel: LogLevel, message: string, ...additionalMessages: string[]) {
5156
if (logLevel >= this.MinimumLogLevel) {
52-
this.writeLine(message, logLevel)
57+
this.writeLine(message, logLevel);
5358

5459
additionalMessages.forEach((line) => {
5560
this.writeLine(line, logLevel);
@@ -116,11 +121,6 @@ export class Logger {
116121
}
117122
}
118123

119-
public dispose() {
120-
this.commands.forEach((command) => { command.dispose() });
121-
this.logChannel.dispose();
122-
}
123-
124124
private showLogPanel() {
125125
this.logChannel.show();
126126
}
@@ -130,47 +130,49 @@ export class Logger {
130130
// Open the folder in VS Code since there isn't an easy way to
131131
// open the folder in the platform's file browser
132132
vscode.commands.executeCommand(
133-
'vscode.openFolder',
133+
"vscode.openFolder",
134134
vscode.Uri.file(this.logSessionPath),
135135
true);
136136
}
137137
}
138138

139139
private writeLine(message: string, level: LogLevel = LogLevel.Normal) {
140-
let now = new Date();
141-
let timestampedMessage = `${now.toLocaleDateString()} ${now.toLocaleTimeString()} [${LogLevel[level].toUpperCase()}] - ${message}`
140+
const now = new Date();
141+
const timestampedMessage =
142+
`${now.toLocaleDateString()} ${now.toLocaleTimeString()} [${LogLevel[level].toUpperCase()}] - ${message}`;
142143

143144
this.logChannel.appendLine(timestampedMessage);
144145
if (this.logFilePath) {
145146
fs.appendFile(
146147
this.logFilePath,
147148
timestampedMessage + os.EOL,
148-
err => {
149+
(err) => {
149150
if (err) {
150-
console.log(`Error writing to vscode-powershell log file: ${err}`)
151+
// tslint:disable-next-line:no-console
152+
console.log(`Error writing to vscode-powershell log file: ${err}`);
151153
}
152154
});
153155
}
154156
}
155157
}
156158

157-
export class LanguageClientLogger implements jsonrpc.Logger {
159+
// export class LanguageClientLogger implements jsonrpc.Logger {
158160

159-
constructor(private logger: Logger) { }
161+
// constructor(private logger: Logger) { }
160162

161-
public error(message: string) {
162-
this.logger.writeError(message);
163-
}
163+
// public error(message: string) {
164+
// this.logger.writeError(message);
165+
// }
164166

165-
public warn(message: string) {
166-
this.logger.writeWarning(message);
167-
}
167+
// public warn(message: string) {
168+
// this.logger.writeWarning(message);
169+
// }
168170

169-
public info(message: string) {
170-
this.logger.write(message);
171-
}
171+
// public info(message: string) {
172+
// this.logger.write(message);
173+
// }
172174

173-
public log(message: string) {
174-
this.logger.writeVerbose(message);
175-
}
176-
}
175+
// public log(message: string) {
176+
// this.logger.writeVerbose(message);
177+
// }
178+
// }

0 commit comments

Comments
 (0)