Skip to content

Commit

Permalink
Add no-var to eslint (#710)
Browse files Browse the repository at this point in the history
I used `eslint --fix` for this.

The only real change was in the promiseUtils.js file
  • Loading branch information
dplewis authored Dec 27, 2018
1 parent 629a550 commit e3e105a
Show file tree
Hide file tree
Showing 40 changed files with 483 additions and 479 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"no-multiple-empty-lines": 1,
"prefer-const": "error",
"space-infix-ops": "error",
"no-useless-escape": "off"
"no-useless-escape": "off",
"no-var": "error"
}
}
8 changes: 4 additions & 4 deletions integration/server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
const express = require('express');
const ParseServer = require('parse-server').ParseServer;
const app = express();

// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
const api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/integration',
appId: 'integration',
masterKey: 'notsosecret',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"release": "./build_releases.sh && npm publish",
"test": "PARSE_BUILD=node jest",
"lint": "eslint --cache src/ integration/",
"lint:fix": "eslint --fix --cache src/ integration/",
"preintegration": "npm run build",
"watch": "PARSE_BUILD=${PARSE_BUILD:=node} gulp watch",
"integration": "TESTING=1 jasmine --config=jasmine.json",
Expand Down
8 changes: 4 additions & 4 deletions src/Analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function track(
throw new TypeError('A name for the custom event must be provided');
}

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

var DefaultController = {
const DefaultController = {
track(name, dimensions) {
var path = 'events/' + name;
var RESTController = CoreManager.getRESTController();
const path = 'events/' + name;
const RESTController = CoreManager.getRESTController();
return RESTController.request('POST', path, { dimensions: dimensions });
}
};
Expand Down
14 changes: 7 additions & 7 deletions src/Cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function run(
throw new TypeError('Cloud function name must be a string.');
}

var requestOptions = {};
const requestOptions = {};
if (options.useMasterKey) {
requestOptions.useMasterKey = options.useMasterKey;
}
Expand Down Expand Up @@ -104,15 +104,15 @@ export function startJob(
* @return {Parse.Object} Status of Job.
*/
export function getJobStatus(jobStatusId: string): Promise {
var query = new ParseQuery('_JobStatus');
const query = new ParseQuery('_JobStatus');
return query.get(jobStatusId, { useMasterKey: true });
}

const DefaultController = {
run(name, data, options) {
var RESTController = CoreManager.getRESTController();
const RESTController = CoreManager.getRESTController();

var payload = encode(data, true);
const payload = encode(data, true);

const request = RESTController.request(
'POST',
Expand All @@ -139,7 +139,7 @@ const DefaultController = {
},

getJobsData(options) {
var RESTController = CoreManager.getRESTController();
const RESTController = CoreManager.getRESTController();

return RESTController.request(
'GET',
Expand All @@ -150,9 +150,9 @@ const DefaultController = {
},

startJob(name, data, options) {
var RESTController = CoreManager.getRESTController();
const RESTController = CoreManager.getRESTController();

var payload = encode(data, true);
const payload = encode(data, true);

return RESTController.request(
'POST',
Expand Down
2 changes: 1 addition & 1 deletion src/CoreManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type Config = {
HooksController?: HooksController,
};

var config: Config & { [key: string]: mixed } = {
const config: Config & { [key: string]: mixed } = {
// Defaults
IS_NODE: (typeof process !== 'undefined' &&
!!process.versions &&
Expand Down
34 changes: 17 additions & 17 deletions src/FacebookUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import parseDate from './parseDate';
import ParseUser from './ParseUser';

var initialized = false;
var requestedPermissions;
var initOptions;
var provider = {
let initialized = false;
let requestedPermissions;
let initOptions;
const provider = {
authenticate(options) {
if (typeof FB === 'undefined') {
options.error(this, 'Facebook SDK not found.');
Expand All @@ -42,19 +42,19 @@ var provider = {

restoreAuthentication(authData) {
if (authData) {
var expiration = parseDate(authData.expiration_date);
var expiresIn = expiration ?
const expiration = parseDate(authData.expiration_date);
const expiresIn = expiration ?
(expiration.getTime() - new Date().getTime()) / 1000 :
0;

var authResponse = {
const authResponse = {
userID: authData.id,
accessToken: authData.access_token,
expiresIn: expiresIn
};
var newOptions = {};
const newOptions = {};
if (initOptions) {
for (var key in initOptions) {
for (const key in initOptions) {
newOptions[key] = initOptions[key];
}
}
Expand All @@ -67,7 +67,7 @@ var provider = {
// Most of the time, the users will match -- it's only in cases where
// the FB SDK knows of a different user than the one being restored
// from a Parse User that logged in with username/password.
var existingResponse = FB.getAuthResponse();
const existingResponse = FB.getAuthResponse();
if (existingResponse &&
existingResponse.userID !== authResponse.userID) {
FB.logout();
Expand All @@ -93,7 +93,7 @@ var provider = {
* @static
* @hideconstructor
*/
var FacebookUtils = {
const FacebookUtils = {
/**
* Initializes Parse Facebook integration. Call this function after you
* have loaded the Facebook Javascript SDK with the same parameters
Expand All @@ -120,12 +120,12 @@ var FacebookUtils = {
}
initOptions = {};
if (options) {
for (var key in options) {
for (const key in options) {
initOptions[key] = options[key];
}
}
if (initOptions.status && typeof console !== 'undefined') {
var warn = console.warn || console.log || function() {}; // eslint-disable-line no-console
const warn = console.warn || console.log || function() {}; // eslint-disable-line no-console
warn.call(console, 'The "status" flag passed into' +
' FB.init, when set to true, can interfere with Parse Facebook' +
' integration, so it has been suppressed. Please call' +
Expand Down Expand Up @@ -177,9 +177,9 @@ var FacebookUtils = {
requestedPermissions = permissions;
return ParseUser._logInWith('facebook', options);
} else {
var newOptions = {};
const newOptions = {};
if (options) {
for (var key in options) {
for (const key in options) {
newOptions[key] = options[key];
}
}
Expand Down Expand Up @@ -216,9 +216,9 @@ var FacebookUtils = {
requestedPermissions = permissions;
return user._linkWith('facebook', options);
} else {
var newOptions = {};
const newOptions = {};
if (options) {
for (var key in options) {
for (const key in options) {
newOptions[key] = options[key];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/InstallationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import Storage from './Storage';

var iidCache = null;
let iidCache = null;

function hexOctet() {
return Math.floor(
Expand All @@ -29,12 +29,12 @@ function generateId() {
);
}

var InstallationController = {
const InstallationController = {
currentInstallationId(): Promise {
if (typeof iidCache === 'string') {
return Promise.resolve(iidCache);
}
var path = Storage.generatePath('installationId');
const path = Storage.generatePath('installationId');
return Storage.getItemAsync(path).then((iid) => {
if (!iid) {
iid = generateId();
Expand Down
2 changes: 1 addition & 1 deletion src/LocalDatastoreController.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const LocalDatastoreController = {
},

clear() {
for (var key in memMap) {
for (const key in memMap) {
if (memMap.hasOwnProperty(key)) {
delete memMap[key];
}
Expand Down
48 changes: 25 additions & 23 deletions src/OfflineQuery.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var equalObjects = require('./equals').default;
var decode = require('./decode').default;
var ParseError = require('./ParseError').default;
var ParsePolygon = require('./ParsePolygon').default;
var ParseGeoPoint = require('./ParseGeoPoint').default;
const equalObjects = require('./equals').default;
const decode = require('./decode').default;
const ParseError = require('./ParseError').default;
const ParsePolygon = require('./ParsePolygon').default;
const ParseGeoPoint = require('./ParseGeoPoint').default;

/**
* contains -- Determines if an object is contained in a list with special handling for Parse pointers.
Expand Down Expand Up @@ -49,7 +49,7 @@ function matchesQuery(className, object, objects, query) {
q = query.toJSON().where;
}
obj.className = className;
for (var field in q) {
for (const field in q) {
if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
return false;
}
Expand Down Expand Up @@ -78,12 +78,12 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
}
if (key.indexOf('.') >= 0) {
// Key references a subobject
var keyComponents = key.split('.');
var subObjectKey = keyComponents[0];
var keyRemainder = keyComponents.slice(1).join('.');
const keyComponents = key.split('.');
const subObjectKey = keyComponents[0];
const keyRemainder = keyComponents.slice(1).join('.');
return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
}
var i;
let i;
if (key === '$or') {
for (i = 0; i < constraints.length; i++) {
if (matchesQuery(className, object, objects, constraints[i])) {
Expand Down Expand Up @@ -122,7 +122,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
}
return object[key] === constraints;
}
var compareTo;
let compareTo;
if (constraints.__type) {
if (constraints.__type === 'Pointer') {
return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
Expand All @@ -132,7 +132,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
}
// More complex cases
for (var condition in constraints) {
for (const condition in constraints) {
compareTo = constraints[condition];
if (compareTo.__type) {
compareTo = decode(compareTo);
Expand Down Expand Up @@ -202,9 +202,9 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
return compareTo.test(object[key]);
}
// JS doesn't support perl-style escaping
var expString = '';
var escapeEnd = -2;
var escapeStart = compareTo.indexOf('\\Q');
let expString = '';
let escapeEnd = -2;
let escapeStart = compareTo.indexOf('\\Q');
while (escapeStart > -1) {
// Add the unescaped portion
expString += compareTo.substring(escapeEnd + 2, escapeStart);
Expand All @@ -219,30 +219,32 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
let modifiers = constraints.$options || '';
modifiers = modifiers.replace('x', '').replace('s', '')
// Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
var exp = new RegExp(expString, modifiers);
const exp = new RegExp(expString, modifiers);
if (!exp.test(object[key])) {
return false;
}
break;
}
case '$nearSphere':
case '$nearSphere': {
if (!compareTo || !object[key]) {
return false;
}
var distance = compareTo.radiansTo(object[key]);
var max = constraints.$maxDistance || Infinity;
const distance = compareTo.radiansTo(object[key]);
const max = constraints.$maxDistance || Infinity;
return distance <= max;
case '$within':
}
case '$within': {
if (!compareTo || !object[key]) {
return false;
}
var southWest = compareTo.$box[0];
var northEast = compareTo.$box[1];
const southWest = compareTo.$box[0];
const northEast = compareTo.$box[1];
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
// Invalid box, crosses the date line
return false;
}
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
}
case '$options':
// Not a query type, but a way to add options to $regex. Ignore and
// avoid the default
Expand Down Expand Up @@ -346,7 +348,7 @@ function validateQuery(query: any) {
});
}

var OfflineQuery = {
const OfflineQuery = {
matchesQuery: matchesQuery,
validateQuery: validateQuery,
};
Expand Down
2 changes: 1 addition & 1 deletion src/Parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import RESTController from './RESTController';
* @class
* @hideconstructor
*/
var Parse = {
const Parse = {
/**
* Call this method first to set up your authentication tokens for Parse.
* You can get your keys from the Data Browser on parse.com.
Expand Down
Loading

0 comments on commit e3e105a

Please sign in to comment.