Skip to content

Commit 4cb6e7d

Browse files
author
Arthur Cinader
authored
Add lint rule space-infix-ops (#3237)
Disallows: 1+1. Must be 1 + 1.
1 parent 56bb505 commit 4cb6e7d

Some content is hidden

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

45 files changed

+145
-144
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"eol-last": 2,
2121
"space-in-parens": ["error", "never"],
2222
"no-multiple-empty-lines": 1,
23-
"prefer-const": "error"
23+
"prefer-const": "error",
24+
"space-infix-ops": "error"
2425
}
2526
}

spec/AuthenticationAdapters.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var path = require('path');
66

77
describe('AuthenticationProviers', function() {
88
["facebook", "github", "instagram", "google", "linkedin", "meetup", "twitter", "janrainengage", "janraincapture", "vkontakte"].map(function(providerName){
9-
it("Should validate structure of "+providerName, (done) => {
10-
var provider = require("../src/Adapters/Auth/"+providerName);
9+
it("Should validate structure of " + providerName, (done) => {
10+
var provider = require("../src/Adapters/Auth/" + providerName);
1111
jequal(typeof provider.validateAuthData, "function");
1212
jequal(typeof provider.validateAppId, "function");
1313
jequal(provider.validateAuthData({}, {}).constructor, Promise.prototype.constructor);

spec/CloudCode.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ describe('afterFind hooks', () => {
13611361
Parse.Cloud.afterFind('MyObject', (req, res) => {
13621362
const filteredResults = [];
13631363
for(let i = 0 ; i < req.objects.length ; i++){
1364-
if(req.objects[i].get("secretField")==="SSID1") {
1364+
if(req.objects[i].get("secretField") === "SSID1") {
13651365
filteredResults.push(req.objects[i]);
13661366
}
13671367
}

spec/HTTPRequest.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var httpRequest = require("../src/cloud-code/httpRequest"),
66
express = require("express");
77

88
var port = 13371;
9-
var httpRequestServer = "http://localhost:"+port;
9+
var httpRequestServer = "http://localhost:" + port;
1010

1111
var app = express();
1212
app.use(bodyParser.json({ 'type': '*/*' }));
@@ -39,7 +39,7 @@ app.listen(13371);
3939
describe("httpRequest", () => {
4040
it("should do /hello", (done) => {
4141
httpRequest({
42-
url: httpRequestServer+"/hello"
42+
url: httpRequestServer + "/hello"
4343
}).then(function(httpResponse){
4444
expect(httpResponse.status).toBe(200);
4545
expect(httpResponse.buffer).toEqual(new Buffer('{"response":"OK"}'));
@@ -55,7 +55,7 @@ describe("httpRequest", () => {
5555
it("should do /hello with callback and promises", (done) => {
5656
var calls = 0;
5757
httpRequest({
58-
url: httpRequestServer+"/hello",
58+
url: httpRequestServer + "/hello",
5959
success: function() { calls++; },
6060
error: function() { calls++; }
6161
}).then(function(httpResponse){
@@ -74,7 +74,7 @@ describe("httpRequest", () => {
7474
it("should do not follow redirects by default", (done) => {
7575

7676
httpRequest({
77-
url: httpRequestServer+"/301"
77+
url: httpRequestServer + "/301"
7878
}).then(function(httpResponse){
7979
expect(httpResponse.status).toBe(301);
8080
done();
@@ -87,7 +87,7 @@ describe("httpRequest", () => {
8787
it("should follow redirects when set", (done) => {
8888

8989
httpRequest({
90-
url: httpRequestServer+"/301",
90+
url: httpRequestServer + "/301",
9191
followRedirects: true
9292
}).then(function(httpResponse){
9393
expect(httpResponse.status).toBe(200);
@@ -104,7 +104,7 @@ describe("httpRequest", () => {
104104
it("should fail on 404", (done) => {
105105
var calls = 0;
106106
httpRequest({
107-
url: httpRequestServer+"/404",
107+
url: httpRequestServer + "/404",
108108
success: function() {
109109
calls++;
110110
fail("should not succeed");
@@ -124,7 +124,7 @@ describe("httpRequest", () => {
124124

125125
it("should fail on 404", (done) => {
126126
httpRequest({
127-
url: httpRequestServer+"/404",
127+
url: httpRequestServer + "/404",
128128
}).then(function(){
129129
fail("should not succeed");
130130
done();
@@ -141,7 +141,7 @@ describe("httpRequest", () => {
141141
var calls = 0;
142142
httpRequest({
143143
method: "POST",
144-
url: httpRequestServer+"/echo",
144+
url: httpRequestServer + "/echo",
145145
body: {
146146
foo: "bar"
147147
},
@@ -218,7 +218,7 @@ describe("httpRequest", () => {
218218

219219
it("should params object to query string", (done) => {
220220
httpRequest({
221-
url: httpRequestServer+"/qs",
221+
url: httpRequestServer + "/qs",
222222
params: {
223223
foo: "bar"
224224
}
@@ -234,7 +234,7 @@ describe("httpRequest", () => {
234234

235235
it("should params string to query string", (done) => {
236236
httpRequest({
237-
url: httpRequestServer+"/qs",
237+
url: httpRequestServer + "/qs",
238238
params: "foo=bar&foo2=bar2"
239239
}).then(function(httpResponse){
240240
expect(httpResponse.status).toBe(200);

spec/Logger.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Logger', () => {
5252
logging.logger.info('hi', {key: 'value'});
5353
expect(process.stdout.write).toHaveBeenCalled();
5454
var firstLog = process.stdout.write.calls.first().args[0];
55-
expect(firstLog).toEqual(JSON.stringify({key: 'value', level: 'info', message: 'hi' })+'\n');
55+
expect(firstLog).toEqual(JSON.stringify({key: 'value', level: 'info', message: 'hi' }) + '\n');
5656
return reconfigureServer({
5757
jsonLogs: false
5858
});

spec/OAuth1.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('OAuth', function() {
6464
var req = oauthClient.buildRequest(method, path, {"query": "param"});
6565

6666
jequal(req.host, options.host);
67-
jequal(req.path, "/"+path+"?query=param");
67+
jequal(req.path, "/" + path + "?query=param");
6868
jequal(req.method, "GET");
6969
jequal(req.headers['Content-Type'], 'application/x-www-form-urlencoded');
7070
jequal(req.headers['Authorization'], 'OAuth oauth_consumer_key="hello", oauth_nonce="AAAAAAAAAAAAAAAAA", oauth_signature="wNkyEkDE%2F0JZ2idmqyrgHdvC0rs%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="123450000", oauth_token="token", oauth_version="1.0"')

spec/Parse.Push.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Parse.Push', () => {
1010
const promises = installations.map((installation) => {
1111
if (installation.deviceType == "ios") {
1212
expect(installation.badge).toEqual(badge);
13-
expect(installation.originalBadge+1).toEqual(installation.badge);
13+
expect(installation.originalBadge + 1).toEqual(installation.badge);
1414
} else {
1515
expect(installation.badge).toBeUndefined();
1616
}
@@ -39,8 +39,8 @@ describe('Parse.Push', () => {
3939
var installations = [];
4040
while(installations.length != 10) {
4141
var installation = new Parse.Object("_Installation");
42-
installation.set("installationId", "installation_"+installations.length);
43-
installation.set("deviceToken","device_token_"+installations.length)
42+
installation.set("installationId", "installation_" + installations.length);
43+
installation.set("deviceToken","device_token_" + installations.length)
4444
installation.set("badge", installations.length);
4545
installation.set("originalBadge", installations.length);
4646
installation.set("deviceType", "ios");

spec/ParseAPI.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ describe('miscellaneous', function() {
825825
};
826826
request.put({
827827
headers: headers,
828-
url: 'http://localhost:8378/1/classes/GameScore/'+obj.id,
828+
url: 'http://localhost:8378/1/classes/GameScore/' + obj.id,
829829
body: JSON.stringify({
830830
a: 'b',
831831
c: {"__op":"Increment","amount":2},
@@ -1241,7 +1241,7 @@ describe('miscellaneous', function() {
12411241
amount: amount
12421242
}
12431243
},
1244-
url: 'http://localhost:8378/1/classes/AnObject/'+object.id
1244+
url: 'http://localhost:8378/1/classes/AnObject/' + object.id
12451245
})
12461246
return new Promise((resolve, reject) => {
12471247
request.put(options, (err, res, body) => {

spec/ParseHooks.spec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var express = require("express");
77
var bodyParser = require('body-parser');
88

99
var port = 12345;
10-
var hookServerURL = "http://localhost:"+port;
10+
var hookServerURL = "http://localhost:" + port;
1111
const AppCache = require('../src/cache').AppCache;
1212

1313
var app = express();
@@ -129,7 +129,7 @@ describe('Hooks', () => {
129129
});
130130

131131
it("should fail to register hooks without Master Key", (done) => {
132-
request.post(Parse.serverURL+"/hooks/functions", {
132+
request.post(Parse.serverURL + "/hooks/functions", {
133133
headers: {
134134
"X-Parse-Application-Id": Parse.applicationId,
135135
"X-Parse-REST-API-Key": Parse.restKey,
@@ -254,7 +254,7 @@ describe('Hooks', () => {
254254
});
255255

256256
it("should fail trying to create a malformed function (REST)", (done) => {
257-
request.post(Parse.serverURL+"/hooks/functions", {
257+
request.post(Parse.serverURL + "/hooks/functions", {
258258
headers: {
259259
"X-Parse-Application-Id": Parse.applicationId,
260260
"X-Parse-Master-Key": Parse.masterKey,
@@ -272,18 +272,18 @@ describe('Hooks', () => {
272272
it("should create hooks and properly preload them", (done) => {
273273

274274
var promises = [];
275-
for (var i = 0; i<5; i++) {
276-
promises.push(Parse.Hooks.createTrigger("MyClass"+i, "beforeSave", "http://url.com/beforeSave/"+i));
277-
promises.push(Parse.Hooks.createFunction("AFunction"+i, "http://url.com/function"+i));
275+
for (var i = 0; i < 5; i++) {
276+
promises.push(Parse.Hooks.createTrigger("MyClass" + i, "beforeSave", "http://url.com/beforeSave/" + i));
277+
promises.push(Parse.Hooks.createFunction("AFunction" + i, "http://url.com/function" + i));
278278
}
279279

280280
Parse.Promise.when(promises).then(function(){
281-
for (var i=0; i<5; i++) {
281+
for (var i = 0; i < 5; i++) {
282282
// Delete everything from memory, as the server just started
283-
triggers.removeTrigger("beforeSave", "MyClass"+i, Parse.applicationId);
284-
triggers.removeFunction("AFunction"+i, Parse.applicationId);
285-
expect(triggers.getTrigger("MyClass"+i, "beforeSave", Parse.applicationId)).toBeUndefined();
286-
expect(triggers.getFunction("AFunction"+i, Parse.applicationId)).toBeUndefined();
283+
triggers.removeTrigger("beforeSave", "MyClass" + i, Parse.applicationId);
284+
triggers.removeFunction("AFunction" + i, Parse.applicationId);
285+
expect(triggers.getTrigger("MyClass" + i, "beforeSave", Parse.applicationId)).toBeUndefined();
286+
expect(triggers.getFunction("AFunction" + i, Parse.applicationId)).toBeUndefined();
287287
}
288288
const hooksController = new HooksController(Parse.applicationId, AppCache.get('test').databaseController);
289289
return hooksController.load()
@@ -292,9 +292,9 @@ describe('Hooks', () => {
292292
fail('Should properly create all hooks');
293293
done();
294294
}).then(function() {
295-
for (var i=0; i<5; i++) {
296-
expect(triggers.getTrigger("MyClass"+i, "beforeSave", Parse.applicationId)).not.toBeUndefined();
297-
expect(triggers.getFunction("AFunction"+i, Parse.applicationId)).not.toBeUndefined();
295+
for (var i = 0; i < 5; i++) {
296+
expect(triggers.getTrigger("MyClass" + i, "beforeSave", Parse.applicationId)).not.toBeUndefined();
297+
expect(triggers.getFunction("AFunction" + i, Parse.applicationId)).not.toBeUndefined();
298298
}
299299
done();
300300
}, (err) => {
@@ -310,7 +310,7 @@ describe('Hooks', () => {
310310
res.json({success:"OK!"});
311311
});
312312

313-
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL+"/SomeFunction").then(function(){
313+
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL + "/SomeFunction").then(function(){
314314
return Parse.Cloud.run("SOME_TEST_FUNCTION")
315315
}, (err) => {
316316
jfail(err);
@@ -332,7 +332,7 @@ describe('Hooks', () => {
332332
res.json({error: {code: 1337, error: "hacking that one!"}});
333333
});
334334
// The function is deleted as the DB is dropped between calls
335-
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL+"/SomeFunctionError").then(function(){
335+
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL + "/SomeFunctionError").then(function(){
336336
return Parse.Cloud.run("SOME_TEST_FUNCTION")
337337
}, (err) => {
338338
jfail(err);
@@ -362,7 +362,7 @@ describe('Hooks', () => {
362362
}
363363
});
364364

365-
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL+"/ExpectingKey").then(function(){
365+
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL + "/ExpectingKey").then(function(){
366366
return Parse.Cloud.run("SOME_TEST_FUNCTION")
367367
}, (err) => {
368368
jfail(err);
@@ -389,7 +389,7 @@ describe('Hooks', () => {
389389
}
390390
});
391391

392-
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL+"/ExpectingKeyAlso").then(function(){
392+
Parse.Hooks.createFunction("SOME_TEST_FUNCTION", hookServerURL + "/ExpectingKeyAlso").then(function(){
393393
return Parse.Cloud.run("SOME_TEST_FUNCTION")
394394
}, (err) => {
395395
jfail(err);
@@ -422,7 +422,7 @@ describe('Hooks', () => {
422422
res.json({success: object});
423423
});
424424
// The function is delete as the DB is dropped between calls
425-
Parse.Hooks.createTrigger("SomeRandomObject", "beforeSave" ,hookServerURL+"/BeforeSaveSome").then(function(){
425+
Parse.Hooks.createTrigger("SomeRandomObject", "beforeSave" ,hookServerURL + "/BeforeSaveSome").then(function(){
426426
const obj = new Parse.Object("SomeRandomObject");
427427
return obj.save();
428428
}).then(function(res) {
@@ -444,7 +444,7 @@ describe('Hooks', () => {
444444
object.set('hello', "world");
445445
res.json({success: object});
446446
});
447-
Parse.Hooks.createTrigger("SomeRandomObject2", "beforeSave" ,hookServerURL+"/BeforeSaveSome2").then(function(){
447+
Parse.Hooks.createTrigger("SomeRandomObject2", "beforeSave" ,hookServerURL + "/BeforeSaveSome2").then(function(){
448448
const obj = new Parse.Object("SomeRandomObject2");
449449
return obj.save();
450450
}).then(function(res) {
@@ -471,7 +471,7 @@ describe('Hooks', () => {
471471
})
472472
});
473473
// The function is delete as the DB is dropped between calls
474-
Parse.Hooks.createTrigger("SomeRandomObject", "afterSave" ,hookServerURL+"/AfterSaveSome").then(function(){
474+
Parse.Hooks.createTrigger("SomeRandomObject", "afterSave" ,hookServerURL + "/AfterSaveSome").then(function(){
475475
const obj = new Parse.Object("SomeRandomObject");
476476
return obj.save();
477477
}).then(function() {

spec/ParseObject.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ describe('Parse.Object testing', () => {
13901390
}
13911391
equal(itemsAgain.length, numItems, "Should get the array back");
13921392
itemsAgain.forEach(function(item, i) {
1393-
var newValue = i*2;
1393+
var newValue = i * 2;
13941394
item.set("x", newValue);
13951395
});
13961396
return Parse.Object.saveAll(itemsAgain);
@@ -1400,7 +1400,7 @@ describe('Parse.Object testing', () => {
14001400
equal(fetchedItemsAgain.length, numItems,
14011401
"Number of items fetched should not change");
14021402
fetchedItemsAgain.forEach(function(item, i) {
1403-
equal(item.get("x"), i*2);
1403+
equal(item.get("x"), i * 2);
14041404
});
14051405
done();
14061406
});
@@ -1457,7 +1457,7 @@ describe('Parse.Object testing', () => {
14571457
}
14581458
equal(itemsAgain.length, numItems, "Should get the array back");
14591459
itemsAgain.forEach(function(item, i) {
1460-
var newValue = i*2;
1460+
var newValue = i * 2;
14611461
item.set("x", newValue);
14621462
});
14631463
return Parse.Object.saveAll(itemsAgain);
@@ -1467,7 +1467,7 @@ describe('Parse.Object testing', () => {
14671467
equal(fetchedItemsAgain.length, numItems,
14681468
"Number of items fetched should not change");
14691469
fetchedItemsAgain.forEach(function(item, i) {
1470-
equal(item.get("x"), i*2);
1470+
equal(item.get("x"), i * 2);
14711471
});
14721472
done();
14731473
},
@@ -1581,7 +1581,7 @@ describe('Parse.Object testing', () => {
15811581
return;
15821582
}
15831583
itemsAgain.forEach(function(item, i) {
1584-
item.set("x", i*2);
1584+
item.set("x", i * 2);
15851585
});
15861586
return Parse.Object.saveAll(itemsAgain);
15871587
}).then(function() {
@@ -1619,7 +1619,7 @@ describe('Parse.Object testing', () => {
16191619
return;
16201620
}
16211621
itemsAgain.forEach(function(item, i) {
1622-
item.set("x", i*2);
1622+
item.set("x", i * 2);
16231623
});
16241624
return Parse.Object.saveAll(itemsAgain);
16251625
}).then(function() {

spec/ParseQuery.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,8 @@ describe('Parse.Query testing', () => {
16521652
}
16531653
Parse.Object.saveAll(objects).then(() => {
16541654
const object = new Parse.Object("AContainer");
1655-
for (var i=0; i<objects.length; i++) {
1656-
if (i%2 == 0) {
1655+
for (var i = 0; i < objects.length; i++) {
1656+
if (i % 2 == 0) {
16571657
objects[i].id = 'randomThing'
16581658
} else {
16591659
total += objects[i].get('key');
@@ -2401,7 +2401,7 @@ describe('Parse.Query testing', () => {
24012401
it('query match on array with multiple objects', (done) => {
24022402
var target1 = {__type: 'Pointer', className: 'TestObject', objectId: 'abc'};
24032403
var target2 = {__type: 'Pointer', className: 'TestObject', objectId: '123'};
2404-
var obj= new Parse.Object('TestObject');
2404+
var obj = new Parse.Object('TestObject');
24052405
obj.set('someObjs', [target1, target2]);
24062406
obj.save().then(() => {
24072407
var query = new Parse.Query('TestObject');

spec/ParseRole.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('Parse Role testing', () => {
124124
expect(roles.length).toEqual(4);
125125

126126
allRoles.forEach(function(name) {
127-
expect(roles.indexOf("role:"+name)).not.toBe(-1);
127+
expect(roles.indexOf("role:" + name)).not.toBe(-1);
128128
});
129129

130130
// 1 Query for the initial setup
@@ -165,7 +165,7 @@ describe('Parse Role testing', () => {
165165
}).then((roles) => {
166166
expect(roles.length).toEqual(3);
167167
rolesNames.forEach((name) => {
168-
expect(roles.indexOf('role:'+name)).not.toBe(-1);
168+
expect(roles.indexOf('role:' + name)).not.toBe(-1);
169169
});
170170
done();
171171
}, function(){

0 commit comments

Comments
 (0)