Skip to content

Commit 183f848

Browse files
committed
chore: fix eslint rule violations
1 parent 092f3f4 commit 183f848

File tree

86 files changed

+825
-826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+825
-826
lines changed

lib/commands/install.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class InstallCommand implements ICommand {
3636
await this.$pluginsService.ensureAllDependenciesAreInstalled(this.$projectData);
3737

3838
for (const platform of this.$mobileHelper.platformNames) {
39-
const platformData = this.$platformsDataService.getPlatformData(platform, this.$projectData);
39+
const platformData = this.$platformsDataService.getPlatformData(platform, this.$projectData);
4040
const frameworkPackageData = this.$projectDataService.getRuntimePackage(this.$projectData.projectDir, <PlatformTypes>platformData.platformNameLowerCase);
4141
if (frameworkPackageData && frameworkPackageData.version) {
4242
try {

lib/common/decorators.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ export function exported(moduleName: string): any {
8989
};
9090
}
9191

92-
export function performanceLog(injector?: IInjector): any {
93-
injector = injector || (<any>global).$injector;
92+
export function performanceLog(localInjector?: IInjector): any {
93+
localInjector = localInjector || injector;
9494
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor): any {
9595
const originalMethod = descriptor.value;
9696
const className = target.constructor.name;
9797
const trackName = `${className}${AnalyticsEventLabelDelimiter}${propertyKey}`;
98-
const performanceService: IPerformanceService = injector.resolve("performanceService");
98+
const performanceService: IPerformanceService = localInjector.resolve("performanceService");
9999

100100
//needed for the returned function to have the same name as the original - used in hooks decorator
101101
const functionWrapper = {
@@ -135,12 +135,12 @@ export function performanceLog(injector?: IInjector): any {
135135
}
136136

137137
// inspired by https://github.com/NativeScript/NativeScript/blob/55dfe25938569edbec89255008e5ad9804901305/tns-core-modules/globals/globals.ts#L121-L137
138-
export function deprecated(additionalInfo?: string, injector?: IInjector): any {
139-
const isDeprecatedMessage = " is deprecated.";
138+
export function deprecated(additionalInfo?: string, localInjector?: IInjector): any {
139+
const isDeprecatedMessage = " is deprecated.";
140140
return (target: Object, key: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
141-
injector = injector || (<any>global).$injector;
141+
localInjector = localInjector || injector;
142142
additionalInfo = additionalInfo || "";
143-
const $logger = <ILogger>injector.resolve("logger");
143+
const $logger = <ILogger>localInjector.resolve("logger");
144144
if (descriptor) {
145145
if (descriptor.value) {
146146
// method

lib/common/errors.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function resolveCallStack(error: Error): Promise<string> {
3232
return line;
3333
});
3434

35-
const fs = require("fs");
35+
const fs = require("fs");
3636

3737
const remapped = await Promise.all(_.map(parsed, async (parsedLine) => {
3838
if (_.isString(parsedLine)) {
@@ -103,18 +103,18 @@ export function installUncaughtExceptionListener(actionOnException?: () => void)
103103
process.on("unhandledRejection", handler);
104104
}
105105

106-
async function tryTrackException(error: Error, injector: IInjector): Promise<void> {
106+
async function tryTrackException(error: Error, localInjector: IInjector): Promise<void> {
107107
let disableAnalytics: boolean;
108108
try {
109-
disableAnalytics = injector.resolve("staticConfig").disableAnalytics;
109+
disableAnalytics = localInjector.resolve("staticConfig").disableAnalytics;
110110
} catch (err) {
111111
// We should get here only in our unit tests.
112112
disableAnalytics = true;
113113
}
114114

115115
if (!disableAnalytics) {
116116
try {
117-
const analyticsService = injector.resolve("analyticsService");
117+
const analyticsService = localInjector.resolve("analyticsService");
118118
await analyticsService.trackException(error, error.message);
119119
} catch (e) {
120120
// Do not replace with logger due to cyclic dependency

lib/common/file-system.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -260,27 +260,27 @@ export class FileSystem implements IFileSystem {
260260

261261
public createReadStream(path: string, options?: {
262262
flags?: string;
263-
encoding?: BufferEncoding;
264-
fd?: number;
265-
mode?: number;
266-
autoClose?: boolean;
267-
emitClose?: boolean;
268-
start?: number;
269-
end?: number;
270-
highWaterMark?: number;
263+
encoding?: BufferEncoding;
264+
fd?: number;
265+
mode?: number;
266+
autoClose?: boolean;
267+
emitClose?: boolean;
268+
start?: number;
269+
end?: number;
270+
highWaterMark?: number;
271271
}): NodeJS.ReadableStream {
272272
return fs.createReadStream(path, options);
273273
}
274274

275275
public createWriteStream(path: string, options?: {
276276
flags?: string;
277-
encoding?: BufferEncoding;
278-
fd?: number;
279-
mode?: number;
280-
autoClose?: boolean;
281-
emitClose?: boolean;
282-
start?: number;
283-
highWaterMark?: number;
277+
encoding?: BufferEncoding;
278+
fd?: number;
279+
mode?: number;
280+
autoClose?: boolean;
281+
emitClose?: boolean;
282+
start?: number;
283+
highWaterMark?: number;
284284
}): any {
285285
return fs.createWriteStream(path, options);
286286
}

lib/common/helpers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ export function getRelativeToRootPath(rootPath: string, filePath: string): strin
278278
let customIsInteractive: any;
279279

280280
export function setIsInteractive(override?: () => boolean) {
281-
customIsInteractive = override;
281+
customIsInteractive = override;
282282
}
283283

284284
export function isInteractive(): boolean {
285-
if (customIsInteractive) {
286-
return customIsInteractive();
287-
}
285+
if (customIsInteractive) {
286+
return customIsInteractive();
287+
}
288288
const result = isRunningInTTY() && !isCIEnvironment();
289289
return result;
290290
}

lib/common/services/cancellation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CancellationService implements ICancellationService {
4646
const watcher = this.watches[name];
4747
if (watcher) {
4848
delete this.watches[name];
49-
watcher.close();
49+
watcher.close().then().catch();
5050
}
5151
}
5252

lib/common/test/unit-tests/analytics-service.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ function createTestInjector(testScenario: ITestScenario): IInjector {
8585
});
8686
testInjector.register("hostInfo", HostInfo);
8787
testInjector.register("osInfo", OsInfo);
88-
testInjector.register("userSettingsService", new UserSettingsServiceStub(testScenario.featureTracking, testScenario.exceptionsTracking, testInjector));
89-
setIsInteractive(() => {
88+
testInjector.register("userSettingsService", new UserSettingsServiceStub(testScenario.featureTracking, testScenario.exceptionsTracking, testInjector));
89+
setIsInteractive(() => {
9090
return testScenario.isInteractive;
9191
});
9292
testInjector.register("childProcess", {});
@@ -119,7 +119,7 @@ describe("analytics-service", () => {
119119
});
120120

121121
after(() => {
122-
setIsInteractive(null);
122+
setIsInteractive(null);
123123
});
124124

125125
describe("isEnabled", () => {
@@ -191,23 +191,23 @@ describe("analytics-service", () => {
191191
const testInjector = createTestInjector(baseTestScenario);
192192
service = testInjector.resolve<IAnalyticsService>("analyticsService");
193193
const staticConfig: Config.IStaticConfig = testInjector.resolve("staticConfig");
194-
assert.deepEqual(JSON.stringify({ "enabled": true }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
194+
assert.deepStrictEqual(JSON.stringify({ "enabled": true }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
195195
});
196196

197197
it("returns correct json results when status is disabled", async () => {
198198
baseTestScenario.featureTracking = false;
199199
const testInjector = createTestInjector(baseTestScenario);
200200
service = testInjector.resolve<IAnalyticsService>("analyticsService");
201201
const staticConfig: Config.IStaticConfig = testInjector.resolve("staticConfig");
202-
assert.deepEqual(JSON.stringify({ "enabled": false }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
202+
assert.deepStrictEqual(JSON.stringify({ "enabled": false }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
203203
});
204204

205205
it("returns correct json results when status is not confirmed", async () => {
206206
baseTestScenario.featureTracking = undefined;
207207
const testInjector = createTestInjector(baseTestScenario);
208208
service = testInjector.resolve<IAnalyticsService>("analyticsService");
209209
const staticConfig: Config.IStaticConfig = testInjector.resolve("staticConfig");
210-
assert.deepEqual(JSON.stringify({ "enabled": null }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
210+
assert.deepStrictEqual(JSON.stringify({ "enabled": null }), await service.getStatusMessage(staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, true, ""));
211211
});
212212
});
213213

@@ -273,7 +273,7 @@ describe("analytics-service", () => {
273273
const testInjector = createTestInjector(baseTestScenario);
274274
service = testInjector.resolve<IAnalyticsService>("analyticsService");
275275
await service.checkConsent();
276-
assert.deepEqual(savedSettingNamesAndValues, "");
276+
assert.deepStrictEqual(savedSettingNamesAndValues, "");
277277
});
278278

279279
it("does nothing when cannot make request", async () => {
@@ -282,7 +282,7 @@ describe("analytics-service", () => {
282282
const testInjector = createTestInjector(baseTestScenario);
283283
service = testInjector.resolve<IAnalyticsService>("analyticsService");
284284
await service.checkConsent();
285-
assert.deepEqual(savedSettingNamesAndValues, "");
285+
assert.deepStrictEqual(savedSettingNamesAndValues, "");
286286
});
287287

288288
it("does nothing when values are not set and console is not interactive", async () => {
@@ -291,7 +291,7 @@ describe("analytics-service", () => {
291291
const testInjector = createTestInjector(baseTestScenario);
292292
service = testInjector.resolve<IAnalyticsService>("analyticsService");
293293
await service.checkConsent();
294-
assert.deepEqual(savedSettingNamesAndValues, "");
294+
assert.deepStrictEqual(savedSettingNamesAndValues, "");
295295
});
296296
});
297297
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ describe("androidLogFilter", () => {
326326
testInjector.register("loggingLevels", LoggingLevels);
327327
const androidLogFilter = <Mobile.IPlatformLogFilter>testInjector.resolve(AndroidLogFilter);
328328
const filteredData = androidLogFilter.filterData(inputData, { logLevel: _logLevel, applicationPid: _pid, projectDir: null });
329-
assert.deepEqual(filteredData, expectedOutput, `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.`);
329+
assert.deepStrictEqual(filteredData, expectedOutput, `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.`);
330330
};
331331

332332
let logLevel = "INFO";

lib/common/test/unit-tests/appbuilder/device-emitter.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("deviceEmitter", () => {
5353
describe(deviceEvent, () => {
5454
const attachDeviceEventVerificationHandler = (expectedDeviceInfo: any, done: mocha.Done) => {
5555
deviceEmitter.on(deviceEvent, (deviceInfo: Mobile.IDeviceInfo) => {
56-
assert.deepEqual(deviceInfo, expectedDeviceInfo);
56+
assert.deepStrictEqual(deviceInfo, expectedDeviceInfo);
5757
// Wait for all operations to be completed and call done after that.
5858
setTimeout(() => done(), 0);
5959
});
@@ -69,7 +69,7 @@ describe("deviceEmitter", () => {
6969
describe("openDeviceLogStream", () => {
7070
const attachDeviceEventVerificationHandler = (expectedDeviceInfo: any, done: mocha.Done) => {
7171
deviceEmitter.on(DeviceDiscoveryEventNames.DEVICE_FOUND, (deviceInfo: Mobile.IDeviceInfo) => {
72-
assert.deepEqual(deviceInfo, expectedDeviceInfo);
72+
assert.deepStrictEqual(deviceInfo, expectedDeviceInfo);
7373

7474
// Wait for all operations to be completed and call done after that.
7575
setTimeout(() => {
@@ -97,8 +97,8 @@ describe("deviceEmitter", () => {
9797

9898
const attachDeviceLogDataVerificationHandler = (expectedDeviceIdentifier: string, done: mocha.Done) => {
9999
deviceEmitter.on(DEVICE_LOG_EVENT_NAME, (identifier: string, data: any) => {
100-
assert.deepEqual(identifier, expectedDeviceIdentifier);
101-
assert.deepEqual(data, expectedDeviceLogData);
100+
assert.deepStrictEqual(identifier, expectedDeviceIdentifier);
101+
assert.deepStrictEqual(data, expectedDeviceLogData);
102102
// Wait for all operations to be completed and call done after that.
103103
setTimeout(() => done(), 0);
104104
});
@@ -118,8 +118,8 @@ describe("deviceEmitter", () => {
118118

119119
const attachApplicationEventVerificationHandler = (expectedDeviceIdentifier: string, done: mocha.Done) => {
120120
deviceEmitter.on(applicationEvent, (deviceIdentifier: string, appIdentifier: string) => {
121-
assert.deepEqual(deviceIdentifier, expectedDeviceIdentifier);
122-
assert.deepEqual(appIdentifier, expectedApplicationIdentifier);
121+
assert.deepStrictEqual(deviceIdentifier, expectedDeviceIdentifier);
122+
assert.deepStrictEqual(appIdentifier, expectedApplicationIdentifier);
123123

124124
// Wait for all operations to be completed and call done after that.
125125
setTimeout(() => done(), 0);
@@ -139,7 +139,7 @@ describe("deviceEmitter", () => {
139139

140140
const attachDebuggableEventVerificationHandler = (expectedDebuggableAppInfo: Mobile.IDeviceApplicationInformation, done: mocha.Done) => {
141141
deviceEmitter.on(applicationEvent, (debuggableAppInfo: Mobile.IDeviceApplicationInformation) => {
142-
assert.deepEqual(debuggableAppInfo, expectedDebuggableAppInfo);
142+
assert.deepStrictEqual(debuggableAppInfo, expectedDebuggableAppInfo);
143143

144144
// Wait for all operations to be completed and call done after that.
145145
setTimeout(() => done(), 0);
@@ -179,11 +179,11 @@ describe("deviceEmitter", () => {
179179

180180
const attachDebuggableEventVerificationHandler = (expectedDeviceIdentifier: string, expectedAppIdentifier: string, expectedDebuggableViewInfo: Mobile.IDebugWebViewInfo, done: mocha.Done) => {
181181
deviceEmitter.on(applicationEvent, (deviceIdentifier: string, appIdentifier: string, debuggableViewInfo: Mobile.IDebugWebViewInfo) => {
182-
assert.deepEqual(deviceIdentifier, expectedDeviceIdentifier);
182+
assert.deepStrictEqual(deviceIdentifier, expectedDeviceIdentifier);
183183

184-
assert.deepEqual(appIdentifier, expectedAppIdentifier);
184+
assert.deepStrictEqual(appIdentifier, expectedAppIdentifier);
185185

186-
assert.deepEqual(debuggableViewInfo, expectedDebuggableViewInfo);
186+
assert.deepStrictEqual(debuggableViewInfo, expectedDebuggableViewInfo);
187187

188188
// Wait for all operations to be completed and call done after that.
189189
setTimeout(done, 0);

lib/common/test/unit-tests/appbuilder/device-log-provider.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("proton deviceLogProvider", () => {
4141
emittedData = data;
4242
});
4343
deviceLogProvider.logData(testData, "platform");
44-
assert.deepEqual(emittedData, filteredInfoData);
44+
assert.deepStrictEqual(emittedData, filteredInfoData);
4545
});
4646

4747
it("does not emit data when whole data is filtered", () => {
@@ -52,7 +52,7 @@ describe("proton deviceLogProvider", () => {
5252
emittedData = data;
5353
});
5454
deviceLogProvider.logData(testData, "platform");
55-
assert.deepEqual(emittedData, 'some default value that should NOT be changed');
55+
assert.deepStrictEqual(emittedData, 'some default value that should NOT be changed');
5656
});
5757
});
5858

@@ -67,8 +67,8 @@ describe("proton deviceLogProvider", () => {
6767
expectedDeviceIdentifier = deviceIdentifier;
6868
});
6969
deviceLogProvider.logData(testData, "platform", "deviceId");
70-
assert.deepEqual(emittedData, filteredInfoData);
71-
assert.deepEqual(expectedDeviceIdentifier, "deviceId");
70+
assert.deepStrictEqual(emittedData, filteredInfoData);
71+
assert.deepStrictEqual(expectedDeviceIdentifier, "deviceId");
7272
});
7373

7474
it("does not emit data when whole data is filtered", () => {
@@ -81,8 +81,8 @@ describe("proton deviceLogProvider", () => {
8181
expectedDeviceIdentifier = deviceIdentifier;
8282
});
8383
deviceLogProvider.logData(testData, "platform");
84-
assert.deepEqual(emittedData, 'some default value that should NOT be changed');
85-
assert.deepEqual(expectedDeviceIdentifier, null);
84+
assert.deepStrictEqual(emittedData, 'some default value that should NOT be changed');
85+
assert.deepStrictEqual(expectedDeviceIdentifier, null);
8686
});
8787
});
8888
});
@@ -93,15 +93,15 @@ describe("proton deviceLogProvider", () => {
9393
deviceLogProvider = testInjector.resolve(DeviceLogEmitter);
9494
deviceLogProvider.setLogLevel(fullLogLevel);
9595
const logFilter = testInjector.resolve("logFilter");
96-
assert.deepEqual(logFilter.loggingLevel, fullLogLevel);
96+
assert.deepStrictEqual(logFilter.loggingLevel, fullLogLevel);
9797
});
9898

9999
it("does not change logFilter's loggingLevel when device identifier is specified", () => {
100100
testInjector = createTestInjector(infoLogLevel);
101101
deviceLogProvider = testInjector.resolve(DeviceLogEmitter);
102102
deviceLogProvider.setLogLevel(fullLogLevel, "deviceID");
103103
const logFilter = testInjector.resolve("logFilter");
104-
assert.deepEqual(logFilter.loggingLevel, infoLogLevel);
104+
assert.deepStrictEqual(logFilter.loggingLevel, infoLogLevel);
105105
});
106106
});
107107

@@ -120,14 +120,14 @@ describe("proton deviceLogProvider", () => {
120120
expectedDeviceIdentifier = deviceIdentifier;
121121
});
122122
deviceLogProvider.logData(testData, "platform", "device1");
123-
assert.deepEqual(emittedData, filteredFullData);
124-
assert.deepEqual(expectedDeviceIdentifier, "device1");
123+
assert.deepStrictEqual(emittedData, filteredFullData);
124+
assert.deepStrictEqual(expectedDeviceIdentifier, "device1");
125125
deviceLogProvider.logData(testData, "platform", "device2");
126-
assert.deepEqual(emittedData, filteredInfoData);
127-
assert.deepEqual(expectedDeviceIdentifier, "device2");
126+
assert.deepStrictEqual(emittedData, filteredInfoData);
127+
assert.deepStrictEqual(expectedDeviceIdentifier, "device2");
128128
deviceLogProvider.logData(testData, "platform", "device1");
129-
assert.deepEqual(emittedData, filteredFullData);
130-
assert.deepEqual(expectedDeviceIdentifier, "device1");
129+
assert.deepStrictEqual(emittedData, filteredFullData);
130+
assert.deepStrictEqual(expectedDeviceIdentifier, "device1");
131131
});
132132

133133
it("emits info log level for all devices, when setLogLevel is called without identifier", () => {
@@ -139,18 +139,18 @@ describe("proton deviceLogProvider", () => {
139139
expectedDeviceIdentifier = deviceIdentifier;
140140
});
141141
deviceLogProvider.logData(testData, "platform", "device1");
142-
assert.deepEqual(emittedData, filteredFullData);
143-
assert.deepEqual(expectedDeviceIdentifier, "device1");
142+
assert.deepStrictEqual(emittedData, filteredFullData);
143+
assert.deepStrictEqual(expectedDeviceIdentifier, "device1");
144144

145145
// Reset log level for all devices
146146
deviceLogProvider.setLogLevel(infoLogLevel);
147147

148148
deviceLogProvider.logData(testData, "platform", "device2");
149-
assert.deepEqual(emittedData, filteredInfoData);
150-
assert.deepEqual(expectedDeviceIdentifier, "device2");
149+
assert.deepStrictEqual(emittedData, filteredInfoData);
150+
assert.deepStrictEqual(expectedDeviceIdentifier, "device2");
151151
deviceLogProvider.logData(testData, "platform", "device1");
152-
assert.deepEqual(emittedData, filteredInfoData);
153-
assert.deepEqual(expectedDeviceIdentifier, "device1");
152+
assert.deepStrictEqual(emittedData, filteredInfoData);
153+
assert.deepStrictEqual(expectedDeviceIdentifier, "device1");
154154
});
155155
});
156156
});

0 commit comments

Comments
 (0)