Add lint rule space-infix-ops (#3237)

Disallows: 1+1.  Must be 1 + 1.
This commit is contained in:
Arthur Cinader
2017-01-11 12:31:40 -08:00
committed by GitHub
parent 56bb505df2
commit 4cb6e7d209
45 changed files with 145 additions and 144 deletions

View File

@@ -36,7 +36,7 @@ OAuth.prototype.send = function(method, path, params, body){
OAuth.prototype.buildRequest = function(method, path, params, body) {
if (path.indexOf("/") != 0) {
path = "/"+path;
path = "/" + path;
}
if (params && Object.keys(params).length > 0) {
path += "?" + OAuth.buildParameterString(params);
@@ -118,7 +118,7 @@ OAuth.nonce = function(){
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for(var i=0; i < 30; i++)
for(var i = 0; i < 30; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
@@ -162,7 +162,7 @@ OAuth.signRequest = function(request, oauth_parameters, consumer_secret, auth_to
oauth_parameters.oauth_nonce = OAuth.nonce();
}
if (!oauth_parameters.oauth_timestamp) {
oauth_parameters.oauth_timestamp = Math.floor(new Date().getTime()/1000);
oauth_parameters.oauth_timestamp = Math.floor(new Date().getTime() / 1000);
}
if (!oauth_parameters.oauth_signature_method) {
oauth_parameters.oauth_signature_method = OAuth.signatureMethod;
@@ -172,7 +172,7 @@ OAuth.signRequest = function(request, oauth_parameters, consumer_secret, auth_to
}
if(!auth_token_secret){
auth_token_secret="";
auth_token_secret = "";
}
// Force GET method if unset
if (!request.method) {
@@ -193,7 +193,7 @@ OAuth.signRequest = function(request, oauth_parameters, consumer_secret, auth_to
var parameterString = OAuth.buildParameterString(signatureParams);
// Build the signature string
var url = "https://"+request.host+""+request.path;
var url = "https://" + request.host + "" + request.path;
var signatureString = OAuth.buildSignatureString(request.method, url, parameterString);
// Hash the signature string
@@ -210,7 +210,7 @@ OAuth.signRequest = function(request, oauth_parameters, consumer_secret, auth_to
// Set the authorization header
var authHeader = Object.keys(oauth_parameters).sort().map(function(key){
var value = oauth_parameters[key];
return key+'="'+value+'"';
return key + '="' + value + '"';
}).join(", ")
request.headers.Authorization = 'OAuth ' + authHeader;

View File

@@ -27,7 +27,7 @@ function request(path, access_token) {
host: 'api.github.com',
path: '/' + path,
headers: {
'Authorization': 'bearer '+access_token,
'Authorization': 'bearer ' + access_token,
'User-Agent': 'parse-server'
}
}, function(res) {

View File

@@ -3,7 +3,7 @@ var https = require('https');
var Parse = require('parse/node').Parse;
function validateIdToken(id, token) {
return request("tokeninfo?id_token="+token)
return request("tokeninfo?id_token=" + token)
.then((response) => {
if (response && (response.sub == id || response.user_id == id)) {
return;
@@ -15,7 +15,7 @@ function validateIdToken(id, token) {
}
function validateAuthToken(id, token) {
return request("tokeninfo?access_token="+token)
return request("tokeninfo?access_token=" + token)
.then((response) => {
if (response && (response.sub == id || response.user_id == id)) {
return;

View File

@@ -4,7 +4,7 @@ var Parse = require('parse/node').Parse;
// Returns a promise that fulfills iff this user id is valid.
function validateAuthData(authData) {
return request("users/self/?access_token="+authData.access_token)
return request("users/self/?access_token=" + authData.access_token)
.then((response) => {
if (response && response.data && response.data.id == authData.id) {
return;

View File

@@ -27,7 +27,7 @@ function request(path, access_token) {
host: 'api.meetup.com',
path: '/2/' + path,
headers: {
'Authorization': 'bearer '+access_token
'Authorization': 'bearer ' + access_token
}
}, function(res) {
var data = '';

View File

@@ -26,12 +26,12 @@ function graphRequest(path) {
data += chunk;
});
res.on('end', function () {
var starPos=data.indexOf("(");
var endPos=data.indexOf(")");
if(starPos==-1||endPos==-1){
var starPos = data.indexOf("(");
var endPos = data.indexOf(")");
if(starPos == -1 || endPos == -1){
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'qq auth is invalid for this user.');
}
data=data.substring(starPos+1,endPos-1);
data = data.substring(starPos + 1,endPos - 1);
data = JSON.parse(data);
resolve(data);
});

View File

@@ -41,7 +41,7 @@ function request(path, access_token) {
host: 'api.spotify.com',
path: '/v1/' + path,
headers: {
'Authorization': 'Bearer '+access_token
'Authorization': 'Bearer ' + access_token
}
}, function(res) {
var data = '';

View File

@@ -12,7 +12,7 @@ function validateAuthData(authData, options) {
client.auth_token_secret = authData.auth_token_secret;
return client.get("/1.1/account/verify_credentials.json").then((data) => {
if (data && data.id_str == ''+authData.id) {
if (data && data.id_str == '' + authData.id) {
return;
}
throw new Parse.Error(

View File

@@ -4,7 +4,7 @@ var Parse = require('parse/node').Parse;
// Returns a promise that fulfills iff this user id is valid.
function validateAuthData(authData) {
return graphRequest('auth?access_token=' + authData.access_token +'&openid=' +authData.id).then(function (data) {
return graphRequest('auth?access_token=' + authData.access_token + '&openid=' + authData.id).then(function (data) {
if (data.errcode == 0) {
return;
}

View File

@@ -109,7 +109,7 @@ const transformKeyValueForUpdate = (className, restKey, restValue, parseFormatSc
}
const transformInteriorValue = restValue => {
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.includes('$')|| key.includes('.'))) {
if (restValue !== null && typeof restValue === 'object' && Object.keys(restValue).some(key => key.includes('$') || key.includes('.'))) {
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
}
// Handle atomic values

View File

@@ -11,7 +11,7 @@ const logger = require('../../../logger');
const debug = function(){
let args = [...arguments];
args = ['PG: '+arguments[0]].concat(args.slice(1, args.length));
args = ['PG: ' + arguments[0]].concat(args.slice(1, args.length));
const log = logger.getLogger();
log.debug.apply(log, args);
}
@@ -196,8 +196,8 @@ const buildWhereClause = ({ schema, query, index }) => {
}
return `'${cmpt}'`;
});
let name = components.slice(0, components.length-1).join('->');
name+='->>'+components[components.length-1];
let name = components.slice(0, components.length - 1).join('->');
name += '->>' + components[components.length - 1];
patterns.push(`${name} = '${fieldValue}'`);
} else if (typeof fieldValue === 'string') {
patterns.push(`$${index}:name = $${index + 1}`);
@@ -277,7 +277,7 @@ const buildWhereClause = ({ schema, query, index }) => {
if (baseArray.length > 0) {
const not = notIn ? ' NOT ' : '';
if (isArrayField) {
patterns.push(`${not} array_contains($${index}:name, $${index+1})`);
patterns.push(`${not} array_contains($${index}:name, $${index + 1})`);
values.push(fieldName, JSON.stringify(baseArray));
index += 2;
} else {
@@ -305,9 +305,9 @@ const buildWhereClause = ({ schema, query, index }) => {
}
if (Array.isArray(fieldValue.$all) && isArrayField) {
patterns.push(`array_contains_all($${index}:name, $${index+1}::jsonb)`);
patterns.push(`array_contains_all($${index}:name, $${index + 1}::jsonb)`);
values.push(fieldName, JSON.stringify(fieldValue.$all));
index+=2;
index += 2;
}
if (typeof fieldValue.$exists !== 'undefined') {
@@ -323,9 +323,9 @@ const buildWhereClause = ({ schema, query, index }) => {
if (fieldValue.$nearSphere) {
const point = fieldValue.$nearSphere;
const distance = fieldValue.$maxDistance;
const distanceInKM = distance*6371*1000;
patterns.push(`ST_distance_sphere($${index}:name::geometry, POINT($${index+1}, $${index+2})::geometry) <= $${index+3}`);
sorts.push(`ST_distance_sphere($${index}:name::geometry, POINT($${index+1}, $${index+2})::geometry) ASC`)
const distanceInKM = distance * 6371 * 1000;
patterns.push(`ST_distance_sphere($${index}:name::geometry, POINT($${index + 1}, $${index + 2})::geometry) <= $${index + 3}`);
sorts.push(`ST_distance_sphere($${index}:name::geometry, POINT($${index + 1}, $${index + 2})::geometry) ASC`)
values.push(fieldName, point.longitude, point.latitude, distanceInKM);
index += 4;
}
@@ -337,7 +337,7 @@ const buildWhereClause = ({ schema, query, index }) => {
const right = box[1].longitude;
const top = box[1].latitude;
patterns.push(`$${index}:name::point <@ $${index+1}::box`);
patterns.push(`$${index}:name::point <@ $${index + 1}::box`);
values.push(fieldName, `((${left}, ${bottom}), (${right}, ${top}))`);
index += 2;
}
@@ -357,7 +357,7 @@ const buildWhereClause = ({ schema, query, index }) => {
regex = processRegexPattern(regex);
patterns.push(`$${index}:name ${operator} '$${index+1}:raw'`);
patterns.push(`$${index}:name ${operator} '$${index + 1}:raw'`);
values.push(fieldName, regex);
index += 2;
}
@@ -490,11 +490,11 @@ export class PostgresStorageAdapter {
}
valuesArray.push(fieldName);
valuesArray.push(parseTypeToPostgresType(parseType));
patternsArray.push(`$${index}:name $${index+1}:raw`);
patternsArray.push(`$${index}:name $${index + 1}:raw`);
if (fieldName === 'objectId') {
patternsArray.push(`PRIMARY KEY ($${index}:name)`)
}
index = index+2;
index = index + 2;
});
const qs = `CREATE TABLE IF NOT EXISTS $1:name (${patternsArray.join(',')})`;
const values = [className, ...valuesArray];
@@ -618,7 +618,7 @@ export class PostgresStorageAdapter {
const values = [className, ...fieldNames];
const columns = fieldNames.map((name, idx) => {
return `$${idx+2}:name`;
return `$${idx + 2}:name`;
}).join(',');
const doBatch = (t) => {
@@ -699,8 +699,8 @@ export class PostgresStorageAdapter {
}
}
if (fieldName === '_account_lockout_expires_at'||
fieldName === '_perishable_token_expires_at'||
if (fieldName === '_account_lockout_expires_at' ||
fieldName === '_perishable_token_expires_at' ||
fieldName === '_password_changed_at') {
if (object[fieldName]) {
valuesArray.push(object[fieldName].iso);
@@ -762,7 +762,7 @@ export class PostgresStorageAdapter {
const value = geoPoints[key];
valuesArray.push(value.longitude, value.latitude);
const l = valuesArray.length + columnsArray.length;
return `POINT($${l}, $${l+1})`;
return `POINT($${l}, $${l + 1})`;
});
const columnsPattern = columnsArray.map((col, index) => `$${index + 2}:name`).join(',');
@@ -848,11 +848,11 @@ export class PostgresStorageAdapter {
}
const lastKey = `$${index}:name`;
const fieldNameIndex = index;
index+=1;
index += 1;
values.push(fieldName);
const update = Object.keys(fieldValue).reduce((lastKey, key) => {
const str = generate(lastKey, `$${index}::text`, `$${index+1}::jsonb`)
index+=2;
const str = generate(lastKey, `$${index}::text`, `$${index + 1}::jsonb`)
index += 2;
let value = fieldValue[key];
if (value) {
if (value.__op === 'Delete') {
@@ -997,7 +997,7 @@ export class PostgresStorageAdapter {
if (hasLimit) {
values.push(limit);
}
const skipPattern = hasSkip ? `OFFSET $${values.length+1}` : '';
const skipPattern = hasSkip ? `OFFSET $${values.length + 1}` : '';
if (hasSkip) {
values.push(skip);
}
@@ -1024,7 +1024,7 @@ export class PostgresStorageAdapter {
return key.length > 0;
});
columns = keys.map((key, index) => {
return `$${index+values.length+1}:name`;
return `$${index + values.length + 1}:name`;
}).join(',');
values = values.concat(keys);
}