Skip to content

Commit 8aed8e3

Browse files
committed
chore: fix tslint errors after tslint update
1 parent 1f02415 commit 8aed8e3

30 files changed

+232
-231
lines changed

lib/common/file-system.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from "fs";
2-
import * as path from "path";
2+
import { join, dirname, basename, resolve as pathResolve, extname, normalize } from "path";
33
import * as minimatch from "minimatch";
44
import * as injector from "./yok";
55
import * as crypto from "crypto";
@@ -74,7 +74,7 @@ export class FileSystem implements IFileSystem {
7474

7575
let proc: string;
7676
if ($hostInfo.isWindows) {
77-
proc = path.join(__dirname, "resources/platform-tools/unzip/win32/unzip");
77+
proc = join(__dirname, "resources/platform-tools/unzip/win32/unzip");
7878
} else if ($hostInfo.isDarwin) {
7979
proc = "unzip"; // darwin unzip is info-zip
8080
} else if ($hostInfo.isLinux) {
@@ -98,11 +98,11 @@ export class FileSystem implements IFileSystem {
9898
}
9999

100100
private findFileCaseInsensitive(file: string): string {
101-
const dir = path.dirname(file);
102-
const basename = path.basename(file);
101+
const dir = dirname(file);
102+
const baseName = basename(file);
103103
const entries = this.readDirectory(dir);
104-
const match = minimatch.match(entries, basename, { nocase: true, nonegate: true, nonull: true })[0];
105-
const result = path.join(dir, match);
104+
const match = minimatch.match(entries, baseName, { nocase: true, nonegate: true, nonull: true })[0];
105+
const result = join(dir, match);
106106
return result;
107107
}
108108

@@ -204,7 +204,7 @@ export class FileSystem implements IFileSystem {
204204
}
205205

206206
public writeFile(filename: string, data: string | NodeBuffer, encoding?: string): void {
207-
this.createDirectory(path.dirname(filename));
207+
this.createDirectory(dirname(filename));
208208
fs.writeFileSync(filename, data, { encoding: encoding });
209209
}
210210

@@ -218,7 +218,7 @@ export class FileSystem implements IFileSystem {
218218
}
219219

220220
let stringifiedData;
221-
if (path.basename(filename) === PACKAGE_JSON_FILE_NAME) {
221+
if (basename(filename) === PACKAGE_JSON_FILE_NAME) {
222222
let newline = EOL;
223223
if (fs.existsSync(filename)) {
224224
const existingFile = this.readText(filename);
@@ -233,11 +233,11 @@ export class FileSystem implements IFileSystem {
233233
}
234234

235235
public copyFile(sourceFileName: string, destinationFileName: string): void {
236-
if (path.resolve(sourceFileName) === path.resolve(destinationFileName)) {
236+
if (pathResolve(sourceFileName) === pathResolve(destinationFileName)) {
237237
return;
238238
}
239239

240-
this.createDirectory(path.dirname(destinationFileName));
240+
this.createDirectory(dirname(destinationFileName));
241241

242242
// MobileApplication.app is resolved as a directory on Mac,
243243
// therefore we need to copy it recursively as it's not a single file.
@@ -284,8 +284,8 @@ export class FileSystem implements IFileSystem {
284284
if (!this.exists(baseName)) {
285285
return baseName;
286286
}
287-
const extension = path.extname(baseName);
288-
const prefix = path.basename(baseName, extension);
287+
const extension = extname(baseName);
288+
const prefix = basename(baseName, extension);
289289

290290
for (let i = 2; ; ++i) {
291291
const numberedName = prefix + i + extension;
@@ -301,8 +301,8 @@ export class FileSystem implements IFileSystem {
301301
}
302302

303303
public isRelativePath(p: string): boolean {
304-
const normal = path.normalize(p);
305-
const absolute = path.resolve(p);
304+
const normal = normalize(p);
305+
const absolute = pathResolve(p);
306306
return normal !== absolute;
307307
}
308308

@@ -357,7 +357,7 @@ export class FileSystem implements IFileSystem {
357357

358358
const contents = this.readDirectory(directoryPath);
359359
for (let i = 0; i < contents.length; ++i) {
360-
const file = path.join(directoryPath, contents[i]);
360+
const file = join(directoryPath, contents[i]);
361361
let stat: fs.Stats = null;
362362
if (this.exists(file)) {
363363
stat = this.getFsStats(file);
@@ -420,11 +420,11 @@ export class FileSystem implements IFileSystem {
420420
}
421421

422422
public deleteEmptyParents(directory: string): void {
423-
let parent = this.exists(directory) ? directory : path.dirname(directory);
423+
let parent = this.exists(directory) ? directory : dirname(directory);
424424

425425
while (this.isEmptyDir(parent)) {
426426
this.deleteDirectory(parent);
427-
parent = path.dirname(parent);
427+
parent = dirname(parent);
428428
}
429429
}
430430

lib/common/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ export function versionCompare(version1: string | IVersionData, version2: string
309309
}
310310

311311
export function isInteractive(): boolean {
312-
const isInteractive = isRunningInTTY() && !isCIEnvironment();
313-
return isInteractive;
312+
const result = isRunningInTTY() && !isCIEnvironment();
313+
return result;
314314
}
315315

316316
/**

lib/common/host-info.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ export class HostInfo implements IHostInfo {
5454

5555
const systemProfileCommand = "system_profiler SPSoftwareDataType -detailLevel mini";
5656
this.$logger.trace("Trying to get macOS version.");
57+
let macOSVersion: string;
5758
try {
5859
const systemProfileOutput = await this.$childProcess.exec(systemProfileCommand);
5960

6061
const versionRegExp = /System Version:\s+?macOS\s+?(\d+\.\d+)(\.\d+)?\s+/g;
6162
const regExpMatchers = versionRegExp.exec(systemProfileOutput);
62-
const macOSVersion = regExpMatchers && regExpMatchers[1];
63+
macOSVersion = regExpMatchers && regExpMatchers[1];
6364
if (macOSVersion) {
6465
this.$logger.trace(`macOS version based on system_profiler is ${macOSVersion}.`);
6566
return macOSVersion;
@@ -75,7 +76,7 @@ export class HostInfo implements IHostInfo {
7576
// So the version becomes "10.12" in this case.
7677
const osRelease = this.$osInfo.release();
7778
const majorVersion = osRelease && _.first(osRelease.split("."));
78-
const macOSVersion = majorVersion && `10.${+majorVersion - 4}`;
79+
macOSVersion = majorVersion && `10.${+majorVersion - 4}`;
7980
this.$logger.trace(`macOS version based on os.release() (${osRelease}) is ${macOSVersion}.`);
8081
return macOSVersion;
8182
}

lib/common/http-client.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,24 @@ export class HttpClient implements Server.IHttpClient {
160160
stuckRequestTimerId = null;
161161
});
162162
})
163-
.on("response", (response: Server.IRequestResponseData) => {
164-
cleanupRequestData.res = response;
163+
.on("response", (responseData: Server.IRequestResponseData) => {
164+
cleanupRequestData.res = responseData;
165165
let lastChunkTimestamp = Date.now();
166166
cleanupRequestData.stuckResponseIntervalId = setInterval(() => {
167167
if (Date.now() - lastChunkTimestamp > HttpClient.STUCK_RESPONSE_CHECK_INTERVAL) {
168168
this.setResponseResult(promiseActions, cleanupRequestData, { err: new Error(HttpClient.STUCK_RESPONSE_ERROR_MESSAGE) });
169169
}
170170
}, HttpClient.STUCK_RESPONSE_CHECK_INTERVAL);
171-
const successful = helpers.isRequestSuccessful(response);
171+
const successful = helpers.isRequestSuccessful(responseData);
172172
if (!successful) {
173173
pipeTo = undefined;
174174
}
175175

176-
let responseStream = response;
176+
let responseStream = responseData;
177177
responseStream.on("data", (chunk: string) => {
178178
lastChunkTimestamp = Date.now();
179179
});
180-
switch (response.headers["content-encoding"]) {
180+
switch (responseData.headers["content-encoding"]) {
181181
case "gzip":
182182
responseStream = responseStream.pipe(zlib.createGunzip());
183183
break;
@@ -188,8 +188,8 @@ export class HttpClient implements Server.IHttpClient {
188188

189189
if (pipeTo) {
190190
pipeTo.on("finish", () => {
191-
this.$logger.trace("httpRequest: Piping done. code = %d", response.statusCode.toString());
192-
this.setResponseResult(promiseActions, cleanupRequestData, { response });
191+
this.$logger.trace("httpRequest: Piping done. code = %d", responseData.statusCode.toString());
192+
this.setResponseResult(promiseActions, cleanupRequestData, { response: responseData });
193193
});
194194

195195
responseStream.pipe(pipeTo);
@@ -201,15 +201,15 @@ export class HttpClient implements Server.IHttpClient {
201201
});
202202

203203
responseStream.on("end", () => {
204-
this.$logger.trace("httpRequest: Done. code = %d", response.statusCode.toString());
204+
this.$logger.trace("httpRequest: Done. code = %d", responseData.statusCode.toString());
205205
const responseBody = data.join("");
206206

207207
if (successful) {
208-
this.setResponseResult(promiseActions, cleanupRequestData, { body: responseBody, response });
208+
this.setResponseResult(promiseActions, cleanupRequestData, { body: responseBody, response: responseData });
209209
} else {
210-
const errorMessage = this.getErrorMessage(response.statusCode, responseBody);
210+
const errorMessage = this.getErrorMessage(responseData.statusCode, responseBody);
211211
const err: any = new Error(errorMessage);
212-
err.response = response;
212+
err.response = responseData;
213213
err.body = responseBody;
214214
this.setResponseResult(promiseActions, cleanupRequestData, { err });
215215
}

lib/common/mobile/android/android-application-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EOL } from "os";
22
import { ApplicationManagerBase } from "../application-manager-base";
3-
import {TARGET_FRAMEWORK_IDENTIFIERS, LiveSyncPaths } from "../../constants";
3+
import { TARGET_FRAMEWORK_IDENTIFIERS, LiveSyncPaths } from "../../constants";
44
import { hook, sleep, regExpEscape } from "../../helpers";
55
import { cache } from "../../decorators";
66

lib/common/prompter.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,33 @@ export class Prompter implements IPrompter {
2222
});
2323
});
2424
try {
25-
this.muteStdout();
25+
this.muteStdout();
2626

27-
if (!helpers.isInteractive()) {
28-
if (_.some(questions, s => !s.default)) {
29-
throw new Error("Console is not interactive and no default action specified.");
30-
} else {
31-
const result: any = {};
27+
if (!helpers.isInteractive()) {
28+
if (_.some(questions, s => !s.default)) {
29+
throw new Error("Console is not interactive and no default action specified.");
30+
} else {
31+
const result: any = {};
3232

33-
_.each(questions, s => {
34-
// Curly brackets needed because s.default() may return false and break the loop
35-
result[s.name] = s.default();
36-
});
33+
_.each(questions, s => {
34+
// Curly brackets needed because s.default() may return false and break the loop
35+
result[s.name] = s.default();
36+
});
3737

38-
return result;
39-
}
40-
} else {
41-
const result = await prompt.prompt(questions);
4238
return result;
4339
}
40+
} else {
41+
const result = await prompt.prompt(questions);
42+
return result;
43+
}
4444
} finally {
4545
this.unmuteStdout();
4646
}
4747
}
4848

49-
public async getPassword(prompt: string, options?: IAllowEmpty): Promise<string> {
49+
public async getPassword(message: string, options?: IAllowEmpty): Promise<string> {
5050
const schema: prompt.Question = {
51-
message: prompt,
51+
message,
5252
type: "password",
5353
name: "password",
5454
validate: (value: any) => {
@@ -61,14 +61,14 @@ export class Prompter implements IPrompter {
6161
return result.password;
6262
}
6363

64-
public async getString(prompt: string, options?: IPrompterOptions): Promise<string> {
64+
public async getString(message: string, options?: IPrompterOptions): Promise<string> {
6565
const schema: prompt.Question = {
66-
message: prompt,
66+
message,
6767
type: "input",
6868
name: "inputString",
6969
validate: (value: any) => {
7070
const doesNotAllowEmpty = options && _.has(options, "allowEmpty") && !options.allowEmpty;
71-
return (doesNotAllowEmpty && !value) ? `${prompt} must be non-empty` : true;
71+
return (doesNotAllowEmpty && !value) ? `${message} must be non-empty` : true;
7272
},
7373
default: options && options.defaultAction
7474
};
@@ -109,12 +109,12 @@ export class Prompter implements IPrompter {
109109
return result.userAnswer;
110110
}
111111

112-
public async confirm(prompt: string, defaultAction?: () => boolean): Promise<boolean> {
112+
public async confirm(message: string, defaultAction?: () => boolean): Promise<boolean> {
113113
const schema = {
114114
type: "confirm",
115115
name: "prompt",
116116
default: defaultAction,
117-
message: prompt
117+
message
118118
};
119119

120120
const result = await this.get([schema]);

lib/common/services/messages-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as util from "util";
2-
import * as path from "path";
2+
import { join } from "path";
33

44
export class MessagesService implements IMessagesService {
55
private _pathsToMessageJsonFiles: string[] = null;
66
private _messageJsonFilesContentsCache: any[] = null;
77

88
private get pathToDefaultMessageJson(): string {
9-
return path.join(__dirname, "..", "resources", "messages", "errorMessages.json");
9+
return join(__dirname, "..", "resources", "messages", "errorMessages.json");
1010
}
1111

1212
private get messageJsonFilesContents(): any[] {

lib/common/test/unit-tests/android-log-filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ const androidApiLevel23MapForPid8141 = [
320320

321321
describe("androidLogFilter", () => {
322322

323-
const assertFiltering = (inputData: string, expectedOutput: string, logLevel?: string, pid?: string) => {
323+
const assertFiltering = (inputData: string, expectedOutput: string, _logLevel?: string, _pid?: string) => {
324324
const testInjector = new Yok();
325325
testInjector.register("loggingLevels", LoggingLevels);
326326
const androidLogFilter = <Mobile.IPlatformLogFilter>testInjector.resolve(AndroidLogFilter);
327-
const filteredData = androidLogFilter.filterData(inputData, { logLevel, applicationPid: pid });
327+
const filteredData = androidLogFilter.filterData(inputData, { logLevel: _logLevel, applicationPid: _pid });
328328
assert.deepEqual(filteredData, expectedOutput, `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.`);
329329
};
330330

lib/common/test/unit-tests/ios-log-filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ const iosTestData = [
109109

110110
describe("iOSLogFilter", () => {
111111

112-
const assertFiltering = (inputData: string, expectedOutput: string, logLevel?: string, pid?: string) => {
112+
const assertFiltering = (inputData: string, expectedOutput: string, _logLevel?: string, _pid?: string) => {
113113
const testInjector = new Yok();
114114
testInjector.register("loggingLevels", LoggingLevels);
115115
const iOSLogFilter = <Mobile.IPlatformLogFilter>testInjector.resolve(IOSLogFilter);
116-
const filteredData = iOSLogFilter.filterData(inputData, { logLevel, applicationPid: pid });
116+
const filteredData = iOSLogFilter.filterData(inputData, { logLevel: _logLevel, applicationPid: _pid });
117117
assert.deepEqual(filteredData, expectedOutput, `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.`);
118118
};
119119

0 commit comments

Comments
 (0)