Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 5b4c6da

Browse files
Merge pull request #1009 from telerik/vladimirov/prefer-const
Add prefer-const rule to tslint
2 parents 42562f0 + 408e9cd commit 5b4c6da

File tree

136 files changed

+1638
-1634
lines changed

Some content is hidden

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

136 files changed

+1638
-1634
lines changed

appbuilder/device-emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class DeviceEmitter extends EventEmitter {
7171
}
7272

7373
private checkCompanionAppChanged(device: Mobile.IDevice, applicationName: string, eventName: string): void {
74-
let devicePlatform = device.deviceInfo.platform.toLowerCase();
74+
const devicePlatform = device.deviceInfo.platform.toLowerCase();
7575
_.each(this.companionAppIdentifiers, (platformsCompanionAppIdentifiers: IStringDictionary, framework: string) => {
7676
if (applicationName === platformsCompanionAppIdentifiers[devicePlatform]) {
7777
this.emit(eventName, device.deviceInfo.identifier, framework);

appbuilder/device-log-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export class DeviceLogProvider extends DeviceLogProviderBase {
77
}
88

99
public logData(line: string, platform: string, deviceIdentifier: string): void {
10-
let logLevel = this.setDefaultLogLevelForDevice(deviceIdentifier);
10+
const logLevel = this.setDefaultLogLevelForDevice(deviceIdentifier);
1111

12-
let applicationPid = this.getApplicationPidForDevice(deviceIdentifier),
12+
const applicationPid = this.getApplicationPidForDevice(deviceIdentifier),
1313
data = this.$logFilter.filterData(platform, line, applicationPid, logLevel);
1414

1515
if (data) {

appbuilder/mobile/appbuilder-device-app-data-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export abstract class AppBuilderDeviceAppDataBase extends DeviceAppDataBase impl
2424
}
2525

2626
public async isLiveSyncSupported(): Promise<boolean> {
27-
let isApplicationInstalled = await this.device.applicationManager.isApplicationInstalled(this.appIdentifier);
27+
const isApplicationInstalled = await this.device.applicationManager.isApplicationInstalled(this.appIdentifier);
2828

2929
if (!isApplicationInstalled) {
3030
await this.$deployHelper.deploy(this.platform.toString());

appbuilder/project/project-base.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export abstract class ProjectBase implements Project.IProjectBase {
5151
}
5252

5353
public get capabilities(): Project.ICapabilities {
54-
let projectData = this.projectData;
54+
const projectData = this.projectData;
5555
if (projectData) {
5656
if (projectData.Framework && projectData.Framework.toLowerCase() === TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase()) {
5757
return this.$nativeScriptProjectCapabilities;
@@ -83,10 +83,10 @@ export abstract class ProjectBase implements Project.IProjectBase {
8383
if (platform &&
8484
platform.toLowerCase() === this.$projectConstants.ANDROID_PLATFORM_NAME.toLowerCase() &&
8585
this.projectData.Framework === TARGET_FRAMEWORK_IDENTIFIERS.Cordova) {
86-
let pathToAndroidResources = path.join(this.projectDir, this.$staticConfig.APP_RESOURCES_DIR_NAME, this.$projectConstants.ANDROID_PLATFORM_NAME);
86+
const pathToAndroidResources = path.join(this.projectDir, this.$staticConfig.APP_RESOURCES_DIR_NAME, this.$projectConstants.ANDROID_PLATFORM_NAME);
8787

88-
let pathToAndroidManifest = path.join(pathToAndroidResources, ProjectBase.ANDROID_MANIFEST_NAME);
89-
let appIdentifierInAndroidManifest = this.getAppIdentifierFromConfigFile(pathToAndroidManifest, /package\s*=\s*"(\S*)"/);
88+
const pathToAndroidManifest = path.join(pathToAndroidResources, ProjectBase.ANDROID_MANIFEST_NAME);
89+
const appIdentifierInAndroidManifest = this.getAppIdentifierFromConfigFile(pathToAndroidManifest, /package\s*=\s*"(\S*)"/);
9090

9191
if (appIdentifierInAndroidManifest && appIdentifierInAndroidManifest !== ProjectBase.APP_IDENTIFIER_PLACEHOLDER) {
9292
platformSpecificAppIdentifier = appIdentifierInAndroidManifest;
@@ -100,19 +100,19 @@ export abstract class ProjectBase implements Project.IProjectBase {
100100
protected abstract saveProjectIfNeeded(): void;
101101

102102
protected readProjectData(): void {
103-
let projectDir = this.getProjectDir();
103+
const projectDir = this.getProjectDir();
104104
this.setShouldSaveProject(false);
105105
if (projectDir) {
106-
let projectFilePath = path.join(projectDir, this.$projectConstants.PROJECT_FILE);
106+
const projectFilePath = path.join(projectDir, this.$projectConstants.PROJECT_FILE);
107107
try {
108108
this.projectData = this.getProjectData(projectFilePath);
109109
this.validate();
110110

111111
_.each(this.$fs.enumerateFilesInDirectorySync(projectDir), (configProjectFile: string) => {
112-
let configMatch = path.basename(configProjectFile).match(ProjectBase.CONFIGURATION_FROM_FILE_NAME_REGEX);
112+
const configMatch = path.basename(configProjectFile).match(ProjectBase.CONFIGURATION_FROM_FILE_NAME_REGEX);
113113
if (configMatch && configMatch.length > 1) {
114-
let configurationName = configMatch[1];
115-
let configProjectContent = this.$fs.readJson(configProjectFile),
114+
const configurationName = configMatch[1];
115+
const configProjectContent = this.$fs.readJson(configProjectFile),
116116
configurationLowerCase = configurationName.toLowerCase();
117117
this.configurationSpecificData[configurationLowerCase] = <any>_.merge(_.cloneDeep(this._projectData), configProjectContent);
118118
this._hasBuildConfigurations = true;
@@ -134,7 +134,7 @@ export abstract class ProjectBase implements Project.IProjectBase {
134134
}
135135

136136
private getProjectData(projectFilePath: string): Project.IData {
137-
let data = this.$fs.readJson(projectFilePath);
137+
const data = this.$fs.readJson(projectFilePath);
138138
if (data.projectVersion && data.projectVersion.toString() !== "1") {
139139
this.$errors.fail("FUTURE_PROJECT_VER");
140140
}
@@ -155,9 +155,9 @@ export abstract class ProjectBase implements Project.IProjectBase {
155155

156156
private getAppIdentifierFromConfigFile(pathToConfigFile: string, regExp: RegExp): string {
157157
if (this.$fs.exists(pathToConfigFile)) {
158-
let fileContent = this.$fs.readText(pathToConfigFile);
158+
const fileContent = this.$fs.readText(pathToConfigFile);
159159

160-
let matches = fileContent.match(regExp);
160+
const matches = fileContent.match(regExp);
161161

162162
if (matches && matches[1]) {
163163
return matches[1];

appbuilder/proton-static-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ProtonStaticConfig extends StaticConfigBase {
77
}
88

99
public async getAdbFilePath(): Promise<string> {
10-
let value = await super.getAdbFilePath();
10+
const value = await super.getAdbFilePath();
1111
return value.replace("app.asar", "app.asar.unpacked");
1212
}
1313

appbuilder/providers/device-app-data-provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AndroidAppIdentifier extends AppBuilderDeviceAppDataBase implements
1919
public async getDeviceProjectRootPath(): Promise<string> {
2020
let deviceTmpDirFormat = "";
2121

22-
let version = await this.getLiveSyncVersion();
22+
const version = await this.getLiveSyncVersion();
2323
if (version === 2) {
2424
deviceTmpDirFormat = LiveSyncConstants.DEVICE_TMP_DIR_FORMAT_V2;
2525
} else if (version === 3) {
@@ -102,7 +102,7 @@ export class IOSAppIdentifier extends AppBuilderDeviceAppDataBase implements ILi
102102
@cache()
103103
public async getDeviceProjectRootPath(): Promise<string> {
104104
if (this.device.isEmulator) {
105-
let applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier);
105+
const applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier);
106106
return path.join(applicationPath, "www");
107107
}
108108

@@ -127,7 +127,7 @@ export class IOSNativeScriptAppIdentifier extends AppBuilderDeviceAppDataBase im
127127
@cache()
128128
public async getDeviceProjectRootPath(): Promise<string> {
129129
if (this.device.isEmulator) {
130-
let applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier);
130+
const applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier);
131131
return applicationPath;
132132
}
133133

@@ -217,7 +217,7 @@ export class DeviceAppDataProvider implements Mobile.IDeviceAppDataProvider {
217217
constructor(private $project: any) { }
218218

219219
public createFactoryRules(): IDictionary<Mobile.IDeviceAppDataFactoryRule> {
220-
let rules: IDictionary<IDictionary<Mobile.IDeviceAppDataFactoryRule>> = {
220+
const rules: IDictionary<IDictionary<Mobile.IDeviceAppDataFactoryRule>> = {
221221
Cordova: {
222222
Android: {
223223
vanilla: AndroidAppIdentifier,

appbuilder/providers/project-files-provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase {
77
private _projectDir: string = null;
88
private get projectDir(): string {
99
if (!this._projectDir) {
10-
let project = this.$injector.resolve("project");
10+
const project = this.$injector.resolve("project");
1111
this._projectDir = project.getProjectDir();
1212
}
1313

@@ -23,7 +23,7 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase {
2323
}
2424

2525
public isFileExcluded(filePath: string): boolean {
26-
let exclusionList = ProjectFilesProvider.INTERNAL_NONPROJECT_FILES.concat(this.getIgnoreFilesRules());
26+
const exclusionList = ProjectFilesProvider.INTERNAL_NONPROJECT_FILES.concat(this.getIgnoreFilesRules());
2727
return this.$pathFilteringService.isFileExcluded(filePath, exclusionList, this.projectDir);
2828
}
2929

@@ -43,9 +43,9 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase {
4343
}
4444

4545
private get ignoreFilesConfigurations(): string[] {
46-
let configurations: string[] = [ProjectFilesProvider.IGNORE_FILE];
46+
const configurations: string[] = [ProjectFilesProvider.IGNORE_FILE];
4747
// unless release is explicitly set, we use debug config
48-
let configFileName = "." +
48+
const configFileName = "." +
4949
(this.$options.release ? this.$projectConstants.RELEASE_CONFIGURATION_NAME : this.$projectConstants.DEBUG_CONFIGURATION_NAME) +
5050
ProjectFilesProvider.IGNORE_FILE;
5151
configurations.push(configFileName);

appbuilder/services/livesync/android-livesync-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class AppBuilderAndroidLiveSyncService extends AndroidLiveSyncService imp
1111
}
1212

1313
public async refreshApplication(deviceAppData: Mobile.IDeviceAppData): Promise<void> {
14-
let commands = [this.liveSyncCommands.SyncFilesCommand()];
14+
const commands = [this.liveSyncCommands.SyncFilesCommand()];
1515
if (this.$options.watch || this.$options.file) {
1616
commands.push(this.liveSyncCommands.RefreshCurrentViewCommand());
1717
} else {
@@ -23,10 +23,10 @@ export class AppBuilderAndroidLiveSyncService extends AndroidLiveSyncService imp
2323

2424
public async removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
2525
if (localToDevicePaths && localToDevicePaths.length) {
26-
let deviceProjectRootPath = localToDevicePaths[0].deviceProjectRootPath;
27-
let commands = _.map(localToDevicePaths, ldp => {
26+
const deviceProjectRootPath = localToDevicePaths[0].deviceProjectRootPath;
27+
const commands = _.map(localToDevicePaths, ldp => {
2828

29-
let relativePath = path.relative(deviceProjectRootPath, ldp.getDevicePath()),
29+
const relativePath = path.relative(deviceProjectRootPath, ldp.getDevicePath()),
3030
unixPath = helpers.fromWindowsRelativePathToUnix(relativePath);
3131

3232
return this.liveSyncCommands.DeleteFile(unixPath);

appbuilder/services/livesync/companion-apps-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export class CompanionAppsService implements ICompanionAppsService {
1212

1313
@exported("companionAppsService")
1414
public getCompanionAppIdentifier(framework: string, platform: string): string {
15-
let lowerCasedFramework = (framework || "").toLowerCase();
16-
let lowerCasedPlatform = (platform || "").toLowerCase();
15+
const lowerCasedFramework = (framework || "").toLowerCase();
16+
const lowerCasedPlatform = (platform || "").toLowerCase();
1717

1818
if (lowerCasedFramework === TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase()) {
1919
if (this.$mobileHelper.isAndroidPlatform(lowerCasedPlatform)) {
@@ -34,23 +34,23 @@ export class CompanionAppsService implements ICompanionAppsService {
3434

3535
@exported("companionAppsService")
3636
public getAllCompanionAppIdentifiers(): IDictionary<IStringDictionary> {
37-
let platforms = [
37+
const platforms = [
3838
this.$devicePlatformsConstants.Android,
3939
this.$devicePlatformsConstants.iOS,
4040
this.$devicePlatformsConstants.WP8
4141
];
4242

43-
let frameworks = [
43+
const frameworks = [
4444
TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase(),
4545
TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase()
4646
];
4747

48-
let companionAppIdentifiers: IDictionary<IStringDictionary> = {};
48+
const companionAppIdentifiers: IDictionary<IStringDictionary> = {};
4949
_.each(frameworks, framework => {
50-
let lowerCasedFramework = framework.toLowerCase();
50+
const lowerCasedFramework = framework.toLowerCase();
5151
companionAppIdentifiers[lowerCasedFramework] = companionAppIdentifiers[lowerCasedFramework] || {};
5252
_.each(platforms, platform => {
53-
let lowerCasedPlatform = platform.toLowerCase();
53+
const lowerCasedPlatform = platform.toLowerCase();
5454
companionAppIdentifiers[lowerCasedFramework][lowerCasedPlatform] = this.getCompanionAppIdentifier(lowerCasedFramework, lowerCasedPlatform);
5555
});
5656
});

appbuilder/services/livesync/ios-livesync-service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22
import * as shell from "shelljs";
3-
let osenv = require("osenv");
3+
const osenv = require("osenv");
44
import * as constants from "../../../constants";
55

66
export class IOSLiveSyncService implements IDeviceLiveSyncService {
@@ -25,15 +25,15 @@ export class IOSLiveSyncService implements IDeviceLiveSyncService {
2525

2626
public async refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
2727
if (this.device.isEmulator) {
28-
let simulatorLogFilePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Library/Logs/system.log`);
29-
let simulatorLogFileContent = this.$fs.readText(simulatorLogFilePath) || "";
28+
const simulatorLogFilePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Library/Logs/system.log`);
29+
const simulatorLogFileContent = this.$fs.readText(simulatorLogFilePath) || "";
3030

31-
let simulatorCachePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Containers/Data/Application/`);
32-
let regex = new RegExp(`^(?:.*?)${deviceAppData.appIdentifier}(?:.*?)${simulatorCachePath}(.*?)$`, "gm");
31+
const simulatorCachePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Containers/Data/Application/`);
32+
const regex = new RegExp(`^(?:.*?)${deviceAppData.appIdentifier}(?:.*?)${simulatorCachePath}(.*?)$`, "gm");
3333

3434
let guid = "";
3535
while (true) {
36-
let parsed = regex.exec(simulatorLogFileContent);
36+
const parsed = regex.exec(simulatorLogFileContent);
3737
if (!parsed) {
3838
break;
3939
}
@@ -45,16 +45,16 @@ export class IOSLiveSyncService implements IDeviceLiveSyncService {
4545
this.$errors.failWithoutHelp(`Unable to find application GUID for application ${deviceAppData.appIdentifier}. Make sure application is installed on Simulator.`);
4646
}
4747

48-
let sourcePath = await deviceAppData.getDeviceProjectRootPath();
49-
let destinationPath = path.join(simulatorCachePath, guid, constants.LiveSyncConstants.IOS_PROJECT_PATH);
48+
const sourcePath = await deviceAppData.getDeviceProjectRootPath();
49+
const destinationPath = path.join(simulatorCachePath, guid, constants.LiveSyncConstants.IOS_PROJECT_PATH);
5050

5151
this.$logger.trace(`Transferring from ${sourcePath} to ${destinationPath}`);
5252
shell.cp("-Rf", path.join(sourcePath, "*"), destinationPath);
5353

5454
await this.device.applicationManager.restartApplication(deviceAppData.appIdentifier);
5555
} else {
5656
await this.device.fileSystem.deleteFile("/Documents/AppBuilder/ServerInfo.plist", deviceAppData.appIdentifier);
57-
let notification = this.$project.projectData.Framework === constants.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript ? "com.telerik.app.refreshApp" : "com.telerik.app.refreshWebView";
57+
const notification = this.$project.projectData.Framework === constants.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript ? "com.telerik.app.refreshApp" : "com.telerik.app.refreshWebView";
5858
const notificationData = {
5959
deviceId: this.device.deviceInfo.identifier,
6060
notificationName: notification,
@@ -67,7 +67,7 @@ export class IOSLiveSyncService implements IDeviceLiveSyncService {
6767
public async removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
6868
const devicePaths = localToDevicePaths.map(localToDevicePath => localToDevicePath.getDevicePath());
6969

70-
for (let deviceFilePath of devicePaths) {
70+
for (const deviceFilePath of devicePaths) {
7171
await this.device.fileSystem.deleteFile(deviceFilePath, appIdentifier);
7272
}
7373
}

0 commit comments

Comments
 (0)