Skip to content

Commit e3e105a

Browse files
authored
Add no-var to eslint (#710)
I used `eslint --fix` for this. The only real change was in the promiseUtils.js file
1 parent 629a550 commit e3e105a

40 files changed

+483
-479
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"no-multiple-empty-lines": 1,
2323
"prefer-const": "error",
2424
"space-infix-ops": "error",
25-
"no-useless-escape": "off"
25+
"no-useless-escape": "off",
26+
"no-var": "error"
2627
}
2728
}

integration/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var express = require('express');
2-
var ParseServer = require('parse-server').ParseServer;
3-
var app = express();
1+
const express = require('express');
2+
const ParseServer = require('parse-server').ParseServer;
3+
const app = express();
44

55
// Specify the connection string for your mongodb database
66
// and the location to your Parse cloud code
7-
var api = new ParseServer({
7+
const api = new ParseServer({
88
databaseURI: 'mongodb://localhost:27017/integration',
99
appId: 'integration',
1010
masterKey: 'notsosecret',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"release": "./build_releases.sh && npm publish",
7474
"test": "PARSE_BUILD=node jest",
7575
"lint": "eslint --cache src/ integration/",
76+
"lint:fix": "eslint --fix --cache src/ integration/",
7677
"preintegration": "npm run build",
7778
"watch": "PARSE_BUILD=${PARSE_BUILD:=node} gulp watch",
7879
"integration": "TESTING=1 jasmine --config=jasmine.json",

src/Analytics.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function track(
6262
throw new TypeError('A name for the custom event must be provided');
6363
}
6464

65-
for (var key in dimensions) {
65+
for (const key in dimensions) {
6666
if (typeof key !== 'string' || typeof dimensions[key] !== 'string') {
6767
throw new TypeError(
6868
'track() dimensions expects keys and values of type "string".'
@@ -74,10 +74,10 @@ export function track(
7474
.track(name, dimensions);
7575
}
7676

77-
var DefaultController = {
77+
const DefaultController = {
7878
track(name, dimensions) {
79-
var path = 'events/' + name;
80-
var RESTController = CoreManager.getRESTController();
79+
const path = 'events/' + name;
80+
const RESTController = CoreManager.getRESTController();
8181
return RESTController.request('POST', path, { dimensions: dimensions });
8282
}
8383
};

src/Cloud.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function run(
4848
throw new TypeError('Cloud function name must be a string.');
4949
}
5050

51-
var requestOptions = {};
51+
const requestOptions = {};
5252
if (options.useMasterKey) {
5353
requestOptions.useMasterKey = options.useMasterKey;
5454
}
@@ -104,15 +104,15 @@ export function startJob(
104104
* @return {Parse.Object} Status of Job.
105105
*/
106106
export function getJobStatus(jobStatusId: string): Promise {
107-
var query = new ParseQuery('_JobStatus');
107+
const query = new ParseQuery('_JobStatus');
108108
return query.get(jobStatusId, { useMasterKey: true });
109109
}
110110

111111
const DefaultController = {
112112
run(name, data, options) {
113-
var RESTController = CoreManager.getRESTController();
113+
const RESTController = CoreManager.getRESTController();
114114

115-
var payload = encode(data, true);
115+
const payload = encode(data, true);
116116

117117
const request = RESTController.request(
118118
'POST',
@@ -139,7 +139,7 @@ const DefaultController = {
139139
},
140140

141141
getJobsData(options) {
142-
var RESTController = CoreManager.getRESTController();
142+
const RESTController = CoreManager.getRESTController();
143143

144144
return RESTController.request(
145145
'GET',
@@ -150,9 +150,9 @@ const DefaultController = {
150150
},
151151

152152
startJob(name, data, options) {
153-
var RESTController = CoreManager.getRESTController();
153+
const RESTController = CoreManager.getRESTController();
154154

155-
var payload = encode(data, true);
155+
const payload = encode(data, true);
156156

157157
return RESTController.request(
158158
'POST',

src/CoreManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ type Config = {
156156
HooksController?: HooksController,
157157
};
158158

159-
var config: Config & { [key: string]: mixed } = {
159+
const config: Config & { [key: string]: mixed } = {
160160
// Defaults
161161
IS_NODE: (typeof process !== 'undefined' &&
162162
!!process.versions &&

src/FacebookUtils.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import parseDate from './parseDate';
1313
import ParseUser from './ParseUser';
1414

15-
var initialized = false;
16-
var requestedPermissions;
17-
var initOptions;
18-
var provider = {
15+
let initialized = false;
16+
let requestedPermissions;
17+
let initOptions;
18+
const provider = {
1919
authenticate(options) {
2020
if (typeof FB === 'undefined') {
2121
options.error(this, 'Facebook SDK not found.');
@@ -42,19 +42,19 @@ var provider = {
4242

4343
restoreAuthentication(authData) {
4444
if (authData) {
45-
var expiration = parseDate(authData.expiration_date);
46-
var expiresIn = expiration ?
45+
const expiration = parseDate(authData.expiration_date);
46+
const expiresIn = expiration ?
4747
(expiration.getTime() - new Date().getTime()) / 1000 :
4848
0;
4949

50-
var authResponse = {
50+
const authResponse = {
5151
userID: authData.id,
5252
accessToken: authData.access_token,
5353
expiresIn: expiresIn
5454
};
55-
var newOptions = {};
55+
const newOptions = {};
5656
if (initOptions) {
57-
for (var key in initOptions) {
57+
for (const key in initOptions) {
5858
newOptions[key] = initOptions[key];
5959
}
6060
}
@@ -67,7 +67,7 @@ var provider = {
6767
// Most of the time, the users will match -- it's only in cases where
6868
// the FB SDK knows of a different user than the one being restored
6969
// from a Parse User that logged in with username/password.
70-
var existingResponse = FB.getAuthResponse();
70+
const existingResponse = FB.getAuthResponse();
7171
if (existingResponse &&
7272
existingResponse.userID !== authResponse.userID) {
7373
FB.logout();
@@ -93,7 +93,7 @@ var provider = {
9393
* @static
9494
* @hideconstructor
9595
*/
96-
var FacebookUtils = {
96+
const FacebookUtils = {
9797
/**
9898
* Initializes Parse Facebook integration. Call this function after you
9999
* have loaded the Facebook Javascript SDK with the same parameters
@@ -120,12 +120,12 @@ var FacebookUtils = {
120120
}
121121
initOptions = {};
122122
if (options) {
123-
for (var key in options) {
123+
for (const key in options) {
124124
initOptions[key] = options[key];
125125
}
126126
}
127127
if (initOptions.status && typeof console !== 'undefined') {
128-
var warn = console.warn || console.log || function() {}; // eslint-disable-line no-console
128+
const warn = console.warn || console.log || function() {}; // eslint-disable-line no-console
129129
warn.call(console, 'The "status" flag passed into' +
130130
' FB.init, when set to true, can interfere with Parse Facebook' +
131131
' integration, so it has been suppressed. Please call' +
@@ -177,9 +177,9 @@ var FacebookUtils = {
177177
requestedPermissions = permissions;
178178
return ParseUser._logInWith('facebook', options);
179179
} else {
180-
var newOptions = {};
180+
const newOptions = {};
181181
if (options) {
182-
for (var key in options) {
182+
for (const key in options) {
183183
newOptions[key] = options[key];
184184
}
185185
}
@@ -216,9 +216,9 @@ var FacebookUtils = {
216216
requestedPermissions = permissions;
217217
return user._linkWith('facebook', options);
218218
} else {
219-
var newOptions = {};
219+
const newOptions = {};
220220
if (options) {
221-
for (var key in options) {
221+
for (const key in options) {
222222
newOptions[key] = options[key];
223223
}
224224
}

src/InstallationController.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import Storage from './Storage';
1313

14-
var iidCache = null;
14+
let iidCache = null;
1515

1616
function hexOctet() {
1717
return Math.floor(
@@ -29,12 +29,12 @@ function generateId() {
2929
);
3030
}
3131

32-
var InstallationController = {
32+
const InstallationController = {
3333
currentInstallationId(): Promise {
3434
if (typeof iidCache === 'string') {
3535
return Promise.resolve(iidCache);
3636
}
37-
var path = Storage.generatePath('installationId');
37+
const path = Storage.generatePath('installationId');
3838
return Storage.getItemAsync(path).then((iid) => {
3939
if (!iid) {
4040
iid = generateId();

src/LocalDatastoreController.default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const LocalDatastoreController = {
3131
},
3232

3333
clear() {
34-
for (var key in memMap) {
34+
for (const key in memMap) {
3535
if (memMap.hasOwnProperty(key)) {
3636
delete memMap[key];
3737
}

src/OfflineQuery.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var equalObjects = require('./equals').default;
2-
var decode = require('./decode').default;
3-
var ParseError = require('./ParseError').default;
4-
var ParsePolygon = require('./ParsePolygon').default;
5-
var ParseGeoPoint = require('./ParseGeoPoint').default;
1+
const equalObjects = require('./equals').default;
2+
const decode = require('./decode').default;
3+
const ParseError = require('./ParseError').default;
4+
const ParsePolygon = require('./ParsePolygon').default;
5+
const ParseGeoPoint = require('./ParseGeoPoint').default;
66

77
/**
88
* contains -- Determines if an object is contained in a list with special handling for Parse pointers.
@@ -49,7 +49,7 @@ function matchesQuery(className, object, objects, query) {
4949
q = query.toJSON().where;
5050
}
5151
obj.className = className;
52-
for (var field in q) {
52+
for (const field in q) {
5353
if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
5454
return false;
5555
}
@@ -78,12 +78,12 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
7878
}
7979
if (key.indexOf('.') >= 0) {
8080
// Key references a subobject
81-
var keyComponents = key.split('.');
82-
var subObjectKey = keyComponents[0];
83-
var keyRemainder = keyComponents.slice(1).join('.');
81+
const keyComponents = key.split('.');
82+
const subObjectKey = keyComponents[0];
83+
const keyRemainder = keyComponents.slice(1).join('.');
8484
return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
8585
}
86-
var i;
86+
let i;
8787
if (key === '$or') {
8888
for (i = 0; i < constraints.length; i++) {
8989
if (matchesQuery(className, object, objects, constraints[i])) {
@@ -122,7 +122,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
122122
}
123123
return object[key] === constraints;
124124
}
125-
var compareTo;
125+
let compareTo;
126126
if (constraints.__type) {
127127
if (constraints.__type === 'Pointer') {
128128
return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
@@ -132,7 +132,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
132132
return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
133133
}
134134
// More complex cases
135-
for (var condition in constraints) {
135+
for (const condition in constraints) {
136136
compareTo = constraints[condition];
137137
if (compareTo.__type) {
138138
compareTo = decode(compareTo);
@@ -202,9 +202,9 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
202202
return compareTo.test(object[key]);
203203
}
204204
// JS doesn't support perl-style escaping
205-
var expString = '';
206-
var escapeEnd = -2;
207-
var escapeStart = compareTo.indexOf('\\Q');
205+
let expString = '';
206+
let escapeEnd = -2;
207+
let escapeStart = compareTo.indexOf('\\Q');
208208
while (escapeStart > -1) {
209209
// Add the unescaped portion
210210
expString += compareTo.substring(escapeEnd + 2, escapeStart);
@@ -219,30 +219,32 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
219219
let modifiers = constraints.$options || '';
220220
modifiers = modifiers.replace('x', '').replace('s', '')
221221
// Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
222-
var exp = new RegExp(expString, modifiers);
222+
const exp = new RegExp(expString, modifiers);
223223
if (!exp.test(object[key])) {
224224
return false;
225225
}
226226
break;
227227
}
228-
case '$nearSphere':
228+
case '$nearSphere': {
229229
if (!compareTo || !object[key]) {
230230
return false;
231231
}
232-
var distance = compareTo.radiansTo(object[key]);
233-
var max = constraints.$maxDistance || Infinity;
232+
const distance = compareTo.radiansTo(object[key]);
233+
const max = constraints.$maxDistance || Infinity;
234234
return distance <= max;
235-
case '$within':
235+
}
236+
case '$within': {
236237
if (!compareTo || !object[key]) {
237238
return false;
238239
}
239-
var southWest = compareTo.$box[0];
240-
var northEast = compareTo.$box[1];
240+
const southWest = compareTo.$box[0];
241+
const northEast = compareTo.$box[1];
241242
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
242243
// Invalid box, crosses the date line
243244
return false;
244245
}
245246
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
247+
}
246248
case '$options':
247249
// Not a query type, but a way to add options to $regex. Ignore and
248250
// avoid the default
@@ -346,7 +348,7 @@ function validateQuery(query: any) {
346348
});
347349
}
348350

349-
var OfflineQuery = {
351+
const OfflineQuery = {
350352
matchesQuery: matchesQuery,
351353
validateQuery: validateQuery,
352354
};

src/Parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import RESTController from './RESTController';
2121
* @class
2222
* @hideconstructor
2323
*/
24-
var Parse = {
24+
const Parse = {
2525
/**
2626
* Call this method first to set up your authentication tokens for Parse.
2727
* You can get your keys from the Data Browser on parse.com.

0 commit comments

Comments
 (0)