Skip to content

Commit e7269d1

Browse files
committed
style(apps): apply eslint autofixes to automated
no-var and prefer-const. ESLint only autofixes a var when no reference precedes it and it is not captured per-iteration in a loop; a check for hoisted function declarations or callbacks that could reach a converted binding before its declaration found none.
1 parent ab87787 commit e7269d1

140 files changed

Lines changed: 2375 additions & 2375 deletions

File tree

Some content is hidden

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

‎apps/automated/src/application-settings/application-settings-tests.ts‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { ApplicationSettings as appSettings } from '@nativescript/core';
22
import * as TKUnit from '../tk-unit';
33

4-
var stringKey: string = 'stringKey';
5-
var boolKey: string = 'boolKey';
6-
var numberKey: string = 'numberKey';
7-
var noStringKey: string = 'noStringKey';
8-
var noBoolKey: string = 'noBoolKey';
9-
var noNumberKey: string = 'noNumberKey';
4+
const stringKey: string = 'stringKey';
5+
const boolKey: string = 'boolKey';
6+
const numberKey: string = 'numberKey';
7+
const noStringKey: string = 'noStringKey';
8+
const noBoolKey: string = 'noBoolKey';
9+
const noNumberKey: string = 'noNumberKey';
1010

1111
export var testBoolean = function () {
1212
appSettings.setBoolean(boolKey, false);
13-
var boolValueBefore = appSettings.getBoolean(boolKey);
13+
const boolValueBefore = appSettings.getBoolean(boolKey);
1414
TKUnit.assert(false === boolValueBefore, 'Cannot set boolean to false, currently it is: ' + appSettings.getBoolean(boolKey));
1515

1616
appSettings.setBoolean('boolKey', true);
17-
var boolValue = appSettings.getBoolean('boolKey', false);
17+
const boolValue = appSettings.getBoolean('boolKey', false);
1818

1919
TKUnit.assert(true === boolValue, 'Cannot set boolean to true');
2020

@@ -23,20 +23,20 @@ export var testBoolean = function () {
2323

2424
export var testString = function () {
2525
appSettings.setString('stringKey', 'String value');
26-
var stringValue = appSettings.getString('stringKey');
26+
const stringValue = appSettings.getString('stringKey');
2727

2828
TKUnit.assert('String value' === stringValue, 'Cannot set string value');
2929
};
3030

3131
export var testNumber = function () {
3232
appSettings.setNumber('numberKey', 54.321);
33-
var value = parseFloat(appSettings.getNumber('numberKey').toFixed(3));
33+
const value = parseFloat(appSettings.getNumber('numberKey').toFixed(3));
3434

3535
TKUnit.assert(54.321 === value, 'Cannot set number value 54.321 != ' + value);
3636
};
3737

3838
export var testDefaults = function () {
39-
var defaultValue = appSettings.getString('noStringKey', 'No string value');
39+
const defaultValue = appSettings.getString('noStringKey', 'No string value');
4040
// will return "No string value" if there is no value for "noStringKey"
4141

4242
TKUnit.assert('No string value' === defaultValue, 'Bad default string value');
@@ -45,7 +45,7 @@ export var testDefaults = function () {
4545
};
4646

4747
export var testDefaultsWithNoDefaultValueProvided = function () {
48-
var defaultValue = appSettings.getString('noStringKey');
48+
const defaultValue = appSettings.getString('noStringKey');
4949
// will return undefined if there is no value for "noStringKey"
5050

5151
TKUnit.assertEqual(defaultValue, undefined, 'Default string value is not undefined');
@@ -55,7 +55,7 @@ export var testDefaultsWithNoDefaultValueProvided = function () {
5555
};
5656

5757
export var testHasKey = function () {
58-
var hasKey = appSettings.hasKey('noBoolKey');
58+
const hasKey = appSettings.hasKey('noBoolKey');
5959
// will return false if there is no value for "noBoolKey"
6060

6161
TKUnit.assert(!hasKey, 'There is a key: ' + noBoolKey);
@@ -90,7 +90,7 @@ export var testClear = function () {
9090
export var testFlush = function () {
9191
appSettings.setString(stringKey, 'String value');
9292

93-
var flushed = appSettings.flush();
93+
const flushed = appSettings.flush();
9494
// will return boolean indicating whether flush to disk was successful
9595

9696
TKUnit.assert(flushed, 'Flush failed: ' + flushed);
@@ -102,7 +102,7 @@ export var testAllKeys = function () {
102102
appSettings.setBoolean(boolKey, true);
103103
appSettings.setNumber(numberKey, 22);
104104

105-
var allKeys = appSettings.getAllKeys();
105+
const allKeys = appSettings.getAllKeys();
106106
TKUnit.assert(allKeys.indexOf(stringKey) !== -1, `${stringKey} is missing from .allKeys()`);
107107
TKUnit.assert(allKeys.indexOf(boolKey) !== -1, `${boolKey} is missing from .allKeys()`);
108108
TKUnit.assert(allKeys.indexOf(numberKey) !== -1, `${numberKey} is missing from .allKeys()`);

‎apps/automated/src/application/application-tests.android.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import * as TKUnit from '../tk-unit';
55
export * from './application-tests-common';
66

77
// >> application-app-android
8-
let androidApp = Application.android;
8+
const androidApp = Application.android;
99
// << application-app-android
1010

1111
// >> application-app-android-context
12-
let context = Application.android.context;
12+
const context = Application.android.context;
1313
//// get the Files (Documents) folder (directory)
14-
let dir = context.getFilesDir();
14+
const dir = context.getFilesDir();
1515
// << application-app-android-context
1616

1717
// >> application-app-android-current

‎apps/automated/src/application/application-tests.ios.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export * from './application-tests-common';
77
//// Add the notification observer
88
if (Application.ios) {
99
var observer = Application.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification, function onReceiveCallback(notification: NSNotification) {
10-
var percent = UIDevice.currentDevice.batteryLevel * 100;
11-
var message = 'Battery: ' + percent + '%';
10+
const percent = UIDevice.currentDevice.batteryLevel * 100;
11+
const message = 'Battery: ' + percent + '%';
1212
////console.log(message);
1313
});
1414
}

‎apps/automated/src/color/color-tests-common.ts‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// >> color-require
22
import * as colorModule from '@nativescript/core/color';
3-
var Color = colorModule.Color;
3+
const Color = colorModule.Color;
44
// << color-require
55
import * as TKUnit from '../tk-unit';
66

77
export var test_Hex_Color = function () {
88
// >> color-hex
99
// Creates the red color
10-
var color = new Color('#FF0000');
10+
const color = new Color('#FF0000');
1111
// << color-hex
1212
TKUnit.assertEqual(color.a, 255, 'Color.a not properly parsed');
1313
TKUnit.assertEqual(color.r, 255, 'Color.r not properly parsed');
@@ -20,7 +20,7 @@ export var test_Hex_Color = function () {
2020
export var test_Hex_rgba_Color = function () {
2121
// >> color-hex-rgba
2222
// Creates the red color
23-
var color = new Color('#FF0000FF');
23+
const color = new Color('#FF0000FF');
2424
// << color-hex-rgba
2525
TKUnit.assertEqual(color.a, 255, 'Color.a not properly parsed');
2626
TKUnit.assertEqual(color.r, 255, 'Color.r not properly parsed');
@@ -33,7 +33,7 @@ export var test_Hex_rgba_Color = function () {
3333
export var test_ShortHex_Color = function () {
3434
// >> color-hex-short
3535
// Creates the color #FF8800
36-
var color = new Color('#F80');
36+
const color = new Color('#F80');
3737
// << color-hex-short
3838
TKUnit.assertEqual(color.a, 255, 'Color.a not properly parsed');
3939
TKUnit.assertEqual(color.r, 255, 'Color.r not properly parsed');
@@ -46,7 +46,7 @@ export var test_ShortHex_Color = function () {
4646
export var test_ShortHex_rgba_Color = function () {
4747
// >> color-hex-short-rgba
4848
// Creates the color #FF8800
49-
var color = new Color('#F80F');
49+
const color = new Color('#F80F');
5050
// << color-hex-short-rgba
5151
TKUnit.assertEqual(color.a, 255, 'Color.a not properly parsed');
5252
TKUnit.assertEqual(color.r, 255, 'Color.r not properly parsed');
@@ -59,7 +59,7 @@ export var test_ShortHex_rgba_Color = function () {
5959
export var test_Argb_Color = function () {
6060
// >> color-rgb
6161
// Creates the color with 100 alpha, 255 red, 100 green, 100 blue
62-
var color = new Color(100, 255, 100, 100);
62+
const color = new Color(100, 255, 100, 100);
6363
// << color-rgb
6464
TKUnit.assertEqual(color.a, 100, 'Color.a not properly parsed');
6565
TKUnit.assertEqual(color.r, 255, 'Color.r not properly parsed');
@@ -72,7 +72,7 @@ export var test_Argb_Color = function () {
7272
export var test_ArgbInt_Color = function () {
7373
// >> color-rgb-single
7474
// Creates the color with 100 alpha, 100 red, 100 green, 100 blue
75-
var color = new Color(0x64646464);
75+
const color = new Color(0x64646464);
7676
// << color-rgb-single
7777
TKUnit.assertEqual(color.a, 100, 'Color.a not properly parsed');
7878
TKUnit.assertEqual(color.r, 100, 'Color.r not properly parsed');
@@ -87,7 +87,7 @@ export var test_rgb_Color_CSS = function () {
8787
// ### Creating a Color from four RGB values
8888
// ``` JavaScript
8989
// Creates the color with 255 red, 100 green, 100 blue
90-
var color = new Color('rgb(255, 100, 100)');
90+
const color = new Color('rgb(255, 100, 100)');
9191
// ```
9292
// </snippet>
9393
TKUnit.assertEqual(color.a, 255, 'Color.a not properly parsed');
@@ -99,13 +99,13 @@ export var test_rgb_Color_CSS = function () {
9999
};
100100

101101
export var test_rgb_Color_CSS_lvl4 = function () {
102-
var alpha = 0.5;
103-
var expected = 0x80;
102+
const alpha = 0.5;
103+
const expected = 0x80;
104104
// <snippet module="color" title="color">
105105
// ### Creating a Color from four RGB values
106106
// ``` JavaScript
107107
// Creates the color with 255 red, 100 green, 100 blue
108-
var color = new Color(`rgb(255 100 100 / ${alpha})`);
108+
const color = new Color(`rgb(255 100 100 / ${alpha})`);
109109
// ```
110110
// </snippet>
111111
TKUnit.assertEqual(color.a, expected, 'Color.a not properly parsed');
@@ -117,13 +117,13 @@ export var test_rgb_Color_CSS_lvl4 = function () {
117117
};
118118

119119
export var test_rgba_Color_CSS = function () {
120-
var alpha = 0.5;
121-
var expected = 0x80;
120+
const alpha = 0.5;
121+
const expected = 0x80;
122122
// <snippet module="color" title="color">
123123
// ### Creating a Color from four RGB values
124124
// ``` JavaScript
125125
// Creates the color with 255 red, 100 green, 100 blue and 0 alpha
126-
var color = new Color(`rgba(255, 100, 100, ${alpha})`);
126+
const color = new Color(`rgba(255, 100, 100, ${alpha})`);
127127
// ```
128128
// </snippet>
129129
TKUnit.assertEqual(color.a, expected, 'Color.a not properly parsed');
@@ -135,7 +135,7 @@ export var test_rgba_Color_CSS = function () {
135135
};
136136

137137
export var test_Color_isValid = function () {
138-
var color = new Color('#FF0000');
138+
const color = new Color('#FF0000');
139139

140140
TKUnit.assertEqual(Color.isValid(color), true, 'Failed to validate color instance');
141141
TKUnit.assertEqual(Color.isValid('#FFF'), true, 'Failed to validate 3-digit hex color');

‎apps/automated/src/connectivity/connectivity-tests.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as connectivity from '@nativescript/core/connectivity';
44

55
export var test_DummyTestForSnippetOnly0 = function () {
66
// >> connectivity-type
7-
var connectionType = connectivity.getConnectionType();
7+
const connectionType = connectivity.getConnectionType();
88
switch (connectionType) {
99
case connectivity.connectionType.none:
1010
//console.log("No connection");

‎apps/automated/src/console/console-tests.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export var test_DummyTestForSnippetOnly2 = function () {
2424

2525
export var test_DummyTestForSnippetOnly3 = function () {
2626
// >> console-dir
27-
var obj = { name: 'John', age: 34 };
27+
const obj = { name: 'John', age: 34 };
2828
console.dir(obj);
2929
// << console-dir
3030
};

‎apps/automated/src/data/observable-array-tests.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,21 +736,21 @@ export const test_reduce_isDefined = function () {
736736

737737
export const test_reduce_without_initial_value = function () {
738738
const sa = [1, 2, 3];
739-
let array: ObservableArray<number> = new ObservableArray(sa);
739+
const array: ObservableArray<number> = new ObservableArray(sa);
740740
const result = array.reduce((a, b) => a + b);
741741
TKUnit.assertEqual(result, 6, 'ObservableArray reduce function broken when initialValue is missing');
742742
};
743743

744744
export const test_reduce_with_initial_value = function () {
745745
const sa = [1, 2, 3];
746-
let array: ObservableArray<number> = new ObservableArray(sa);
746+
const array: ObservableArray<number> = new ObservableArray(sa);
747747
const result = array.reduce((a, b) => a + b, 5);
748748
TKUnit.assertEqual(result, 11, 'ObservableArray reduce function broken when Initial Value is passed.');
749749
};
750750

751751
export const test_reduce_with_zero_as_initial_value = function () {
752752
const sa = [{ prop: 1 }, { prop: 2 }, { prop: 3 }];
753-
let array: ObservableArray<any> = new ObservableArray(sa);
753+
const array: ObservableArray<any> = new ObservableArray(sa);
754754
const result = array.reduce((a, b) => a + b.prop, 0);
755755
TKUnit.assertEqual(result, 6, 'ObservableArray reduce function broken when Initial Value is zero.');
756756
};
@@ -761,21 +761,21 @@ export const test_reduceRight_isDefined = function () {
761761

762762
export const test_reduceRight_without_initial_value = function () {
763763
const sa = [1, 2, 3];
764-
let array: ObservableArray<number> = new ObservableArray(sa);
764+
const array: ObservableArray<number> = new ObservableArray(sa);
765765
const result = array.reduceRight((a, b) => a + b);
766766
TKUnit.assertEqual(result, 6, 'ObservableArray reduceRight function broken when initialValue is missing');
767767
};
768768

769769
export const test_reduceRight_with_initial_value = function () {
770770
const sa = [1, 2, 3];
771-
let array: ObservableArray<number> = new ObservableArray(sa);
771+
const array: ObservableArray<number> = new ObservableArray(sa);
772772
const result = array.reduceRight((a, b) => a + b, 5);
773773
TKUnit.assertEqual(result, 11, 'ObservableArray reduceRight function broken when Initial Value is passed.');
774774
};
775775

776776
export const test_reduceRight_with_zero_as_initial_value = function () {
777777
const sa = [{ prop: 1 }, { prop: 2 }, { prop: 3 }];
778-
let array: ObservableArray<any> = new ObservableArray(sa);
778+
const array: ObservableArray<any> = new ObservableArray(sa);
779779
const result = array.reduceRight((a, b) => a + b.prop, 0);
780780
TKUnit.assertEqual(result, 6, 'ObservableArray reduceRight function broken when Initial Value is zero.');
781781
};

0 commit comments

Comments
 (0)