More lint tweaking (#3164)

1. Add no space in paren rule
2. fix spec/eslintrc.json so it allow for inheriting from root rc.

Because the spce rc specified reccomended, it "turned off" all of the
rule tweaks in the root.  This fixes that.
This commit is contained in:
Arthur Cinader
2016-12-02 16:11:54 -08:00
committed by Florent Vilmart
parent b9afccd338
commit a270632570
19 changed files with 51 additions and 56 deletions

View File

@@ -17,6 +17,7 @@
"indent": ["error", 2], "indent": ["error", 2],
"linebreak-style": ["error", "unix"], "linebreak-style": ["error", "unix"],
"no-trailing-spaces": 2, "no-trailing-spaces": 2,
"eol-last": 2 "eol-last": 2,
"space-in-parens": ["error", "never"]
} }
} }

View File

@@ -1,8 +1,5 @@
{ {
"extends": "eslint:recommended",
"env": { "env": {
"node": true,
"es6": true,
"jasmine": true "jasmine": true
}, },
"globals": { "globals": {
@@ -29,9 +26,6 @@
"arrayContains": true "arrayContains": true
}, },
"rules": { "rules": {
"no-console": [0], "no-console": [0]
"indent": ["error", 2],
"no-trailing-spaces": 2,
"eol-last": 2
} }
} }

View File

@@ -460,7 +460,7 @@ describe("Email Verification Token Expiration: ", () => {
user.set('email', 'user@parse.com'); user.set('email', 'user@parse.com');
return new Promise((resolve) => { return new Promise((resolve) => {
// wait for half a sec to get a new expiration time // wait for half a sec to get a new expiration time
setTimeout( () => resolve(user.save()), 500 ); setTimeout(() => resolve(user.save()), 500);
}); });
}) })
.then(() => { .then(() => {

View File

@@ -816,7 +816,7 @@ describe('miscellaneous', function() {
it('should return the updated fields on PUT', done => { it('should return the updated fields on PUT', done => {
let obj = new Parse.Object('GameScore'); let obj = new Parse.Object('GameScore');
obj.save({a:'hello', c: 1, d: ['1'], e:['1'], f:['1','2']}).then(( ) => { obj.save({a:'hello', c: 1, d: ['1'], e:['1'], f:['1','2']}).then(() => {
var headers = { var headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-Parse-Application-Id': 'test', 'X-Parse-Application-Id': 'test',

View File

@@ -26,7 +26,7 @@ describe('Hooks', () => {
}); });
it("should have no triggers registered", (done) => { it("should have no triggers registered", (done) => {
Parse.Hooks.getTriggers().then( (res) => { Parse.Hooks.getTriggers().then((res) => {
expect(res.constructor).toBe(Array.prototype.constructor); expect(res.constructor).toBe(Array.prototype.constructor);
done(); done();
}, (err) => { }, (err) => {
@@ -143,11 +143,11 @@ describe('Hooks', () => {
}); });
it("should fail trying to create two times the same function", (done) => { it("should fail trying to create two times the same function", (done) => {
Parse.Hooks.createFunction("my_new_function", "http://url.com").then( () => { Parse.Hooks.createFunction("my_new_function", "http://url.com").then(() => {
return Parse.Hooks.createFunction("my_new_function", "http://url.com") return Parse.Hooks.createFunction("my_new_function", "http://url.com")
}, () => { }, () => {
fail("should create a new function"); fail("should create a new function");
}).then( () => { }).then(() => {
fail("should not be able to create the same function"); fail("should not be able to create the same function");
}, (err) => { }, (err) => {
expect(err).not.toBe(undefined); expect(err).not.toBe(undefined);
@@ -166,11 +166,11 @@ describe('Hooks', () => {
}); });
it("should fail trying to create two times the same trigger", (done) => { it("should fail trying to create two times the same trigger", (done) => {
Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com").then( () => { Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com").then(() => {
return Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com") return Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com")
}, () => { }, () => {
fail("should create a new trigger"); fail("should create a new trigger");
}).then( () => { }).then(() => {
fail("should not be able to create the same trigger"); fail("should not be able to create the same trigger");
}, (err) => { }, (err) => {
expect(err).not.toBe(undefined); expect(err).not.toBe(undefined);
@@ -189,7 +189,7 @@ describe('Hooks', () => {
}); });
it("should fail trying to update a function that don't exist", (done) => { it("should fail trying to update a function that don't exist", (done) => {
Parse.Hooks.updateFunction("A_COOL_FUNCTION", "http://url.com").then( () => { Parse.Hooks.updateFunction("A_COOL_FUNCTION", "http://url.com").then(() => {
fail("Should not succeed") fail("Should not succeed")
}, (err) => { }, (err) => {
expect(err).not.toBe(undefined); expect(err).not.toBe(undefined);
@@ -214,7 +214,7 @@ describe('Hooks', () => {
}); });
it("should fail trying to update a trigger that don't exist", (done) => { it("should fail trying to update a trigger that don't exist", (done) => {
Parse.Hooks.updateTrigger("AClassName","beforeSave", "http://url.com").then( () => { Parse.Hooks.updateTrigger("AClassName","beforeSave", "http://url.com").then(() => {
fail("Should not succeed") fail("Should not succeed")
}, (err) => { }, (err) => {
expect(err).not.toBe(undefined); expect(err).not.toBe(undefined);
@@ -240,7 +240,7 @@ describe('Hooks', () => {
it("should fail trying to create a malformed function", (done) => { it("should fail trying to create a malformed function", (done) => {
Parse.Hooks.createFunction("MyFunction").then( (res) => { Parse.Hooks.createFunction("MyFunction").then((res) => {
fail(res); fail(res);
}, (err) => { }, (err) => {
expect(err).not.toBe(undefined); expect(err).not.toBe(undefined);

View File

@@ -1842,10 +1842,10 @@ describe('Parse.Object testing', () => {
"_nested": "key" "_nested": "key"
} }
}); });
object.save().then( res => { object.save().then(res => {
ok(res); ok(res);
return res.fetch(); return res.fetch();
}).then( res => { }).then(res => {
const foo = res.get("foo"); const foo = res.get("foo");
expect(foo["_bar"]).toEqual("_"); expect(foo["_bar"]).toEqual("_");
expect(foo["baz_bar"]).toEqual(1); expect(foo["baz_bar"]).toEqual(1);
@@ -1853,7 +1853,7 @@ describe('Parse.Object testing', () => {
expect(foo["_0"]).toEqual("underscore_zero"); expect(foo["_0"]).toEqual("underscore_zero");
expect(foo["_more"]["_nested"]).toEqual("key"); expect(foo["_more"]["_nested"]).toEqual("key");
done(); done();
}).fail( err => { }).fail(err => {
jfail(err); jfail(err);
fail("should not fail"); fail("should not fail");
done(); done();

View File

@@ -816,7 +816,7 @@ describe('Parse.Query testing', () => {
var makeBoxedNumber = function(i) { var makeBoxedNumber = function(i) {
return new BoxedNumber({ number: i }); return new BoxedNumber({ number: i });
}; };
Parse.Object.saveAll([3, 1, 2].map(makeBoxedNumber)).then( function() { Parse.Object.saveAll([3, 1, 2].map(makeBoxedNumber)).then(function() {
var query = new Parse.Query(BoxedNumber); var query = new Parse.Query(BoxedNumber);
query.descending("number"); query.descending("number");
query.find(expectSuccess({ query.find(expectSuccess({
@@ -2435,7 +2435,7 @@ describe('Parse.Query testing', () => {
var user = new Parse.User(); var user = new Parse.User();
user.set("username", "foo"); user.set("username", "foo");
user.set("password", "bar"); user.set("password", "bar");
return user.save().then( (user) => { return user.save().then((user) => {
var objIdQuery = new Parse.Query("_User").equalTo("objectId", user.id); var objIdQuery = new Parse.Query("_User").equalTo("objectId", user.id);
var blockedUserQuery = user.relation("blockedUsers").query(); var blockedUserQuery = user.relation("blockedUsers").query();

View File

@@ -98,10 +98,10 @@ describe('Parse Role testing', () => {
var user, var user,
auth, auth,
getAllRolesSpy; getAllRolesSpy;
createTestUser().then( (newUser) => { createTestUser().then((newUser) => {
user = newUser; user = newUser;
return createAllRoles(user); return createAllRoles(user);
}).then ( (roles) => { }).then ((roles) => {
var rootRoleObj = roleObjs[rootRole]; var rootRoleObj = roleObjs[rootRole];
roles.forEach(function(role, i) { roles.forEach(function(role, i) {
// Add all roles to the RootRole // Add all roles to the RootRole
@@ -115,12 +115,12 @@ describe('Parse Role testing', () => {
}); });
return Parse.Object.saveAll(roles, { useMasterKey: true }); return Parse.Object.saveAll(roles, { useMasterKey: true });
}).then( () => { }).then(() => {
auth = new Auth({config: new Config("test"), isMaster: true, user: user}); auth = new Auth({config: new Config("test"), isMaster: true, user: user});
getAllRolesSpy = spyOn(auth, "_getAllRolesNamesForRoleIds").and.callThrough(); getAllRolesSpy = spyOn(auth, "_getAllRolesNamesForRoleIds").and.callThrough();
return auth._loadRoles(); return auth._loadRoles();
}).then ( (roles) => { }).then ((roles) => {
expect(roles.length).toEqual(4); expect(roles.length).toEqual(4);
allRoles.forEach(function(name) { allRoles.forEach(function(name) {
@@ -135,7 +135,7 @@ describe('Parse Role testing', () => {
// 1 call for the 2nd layer // 1 call for the 2nd layer
expect(getAllRolesSpy.calls.count()).toEqual(2); expect(getAllRolesSpy.calls.count()).toEqual(2);
done() done()
}).catch( () => { }).catch(() => {
fail("should succeed"); fail("should succeed");
done(); done();
}); });
@@ -145,26 +145,26 @@ describe('Parse Role testing', () => {
it("should recursively load roles", (done) => { it("should recursively load roles", (done) => {
var rolesNames = ["FooRole", "BarRole", "BazRole"]; var rolesNames = ["FooRole", "BarRole", "BazRole"];
var roleIds = {}; var roleIds = {};
createTestUser().then( (user) => { createTestUser().then((user) => {
// Put the user on the 1st role // Put the user on the 1st role
return createRole(rolesNames[0], null, user).then( (aRole) => { return createRole(rolesNames[0], null, user).then((aRole) => {
roleIds[aRole.get("name")] = aRole.id; roleIds[aRole.get("name")] = aRole.id;
// set the 1st role as a sibling of the second // set the 1st role as a sibling of the second
// user will should have 2 role now // user will should have 2 role now
return createRole(rolesNames[1], aRole, null); return createRole(rolesNames[1], aRole, null);
}).then( (anotherRole) => { }).then((anotherRole) => {
roleIds[anotherRole.get("name")] = anotherRole.id; roleIds[anotherRole.get("name")] = anotherRole.id;
// set this role as a sibling of the last // set this role as a sibling of the last
// the user should now have 3 roles // the user should now have 3 roles
return createRole(rolesNames[2], anotherRole, null); return createRole(rolesNames[2], anotherRole, null);
}).then( (lastRole) => { }).then((lastRole) => {
roleIds[lastRole.get("name")] = lastRole.id; roleIds[lastRole.get("name")] = lastRole.id;
var auth = new Auth({ config: new Config("test"), isMaster: true, user: user }); var auth = new Auth({ config: new Config("test"), isMaster: true, user: user });
return auth._loadRoles(); return auth._loadRoles();
}) })
}).then( (roles) => { }).then((roles) => {
expect(roles.length).toEqual(3); expect(roles.length).toEqual(3);
rolesNames.forEach( (name) => { rolesNames.forEach((name) => {
expect(roles.indexOf('role:'+name)).not.toBe(-1); expect(roles.indexOf('role:'+name)).not.toBe(-1);
}); });
done(); done();

View File

@@ -20,7 +20,7 @@ function createProduct() {
} }
describe("test validate_receipt endpoint", () => { describe("test validate_receipt endpoint", () => {
beforeEach( done => { beforeEach(done => {
createProduct().then(done).fail(function(){ createProduct().then(done).fail(function(){
done(); done();
}); });

View File

@@ -1283,13 +1283,13 @@ describe('schemas', () => {
}) })
}).then(() => { }).then(() => {
return Parse.User.logIn('admin', 'admin'); return Parse.User.logIn('admin', 'admin');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then((results) => { }).then((results) => {
expect(results.length).toBe(1); expect(results.length).toBe(1);
done(); done();
}).catch( (err) => { }).catch((err) => {
jfail(err); jfail(err);
done(); done();
}) })
@@ -1346,13 +1346,13 @@ describe('schemas', () => {
}); });
}).then(() => { }).then(() => {
return Parse.User.logIn('admin', 'admin'); return Parse.User.logIn('admin', 'admin');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then((results) => { }).then((results) => {
expect(results.length).toBe(1); expect(results.length).toBe(1);
done(); done();
}).catch( (err) => { }).catch((err) => {
jfail(err); jfail(err);
done(); done();
}) })
@@ -1404,7 +1404,7 @@ describe('schemas', () => {
}); });
}).then(() => { }).then(() => {
return Parse.User.logIn('admin', 'admin'); return Parse.User.logIn('admin', 'admin');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then((results) => { }).then((results) => {
@@ -1470,13 +1470,13 @@ describe('schemas', () => {
}); });
}).then(() => { }).then(() => {
return Parse.User.logIn('admin', 'admin'); return Parse.User.logIn('admin', 'admin');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then((results) => { }).then((results) => {
expect(results.length).toBe(1); expect(results.length).toBe(1);
done(); done();
}).catch( (err) => { }).catch((err) => {
jfail(err); jfail(err);
done(); done();
}) })
@@ -1523,7 +1523,7 @@ describe('schemas', () => {
}) })
}).then(() => { }).then(() => {
return Parse.User.logIn('admin', 'admin'); return Parse.User.logIn('admin', 'admin');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then(() => { }).then(() => {
@@ -1534,7 +1534,7 @@ describe('schemas', () => {
return Promise.resolve(); return Promise.resolve();
}).then(() => { }).then(() => {
return Parse.User.logIn('user2', 'user2'); return Parse.User.logIn('user2', 'user2');
}).then( () => { }).then(() => {
let query = new Parse.Query('AClass'); let query = new Parse.Query('AClass');
return query.find(); return query.find();
}).then(() => { }).then(() => {

View File

@@ -258,7 +258,7 @@ const buildWhereClause = ({ schema, query, index }) => {
let allowNull = false; let allowNull = false;
values.push(fieldName); values.push(fieldName);
fieldValue.$in.forEach((listElem, listIndex) => { fieldValue.$in.forEach((listElem, listIndex) => {
if (listElem === null ) { if (listElem === null) {
allowNull = true; allowNull = true;
} else { } else {
values.push(listElem); values.push(listElem);

View File

@@ -131,7 +131,7 @@ export class Config {
throw 'passwordPolicy.validatorPattern must be a RegExp.'; throw 'passwordPolicy.validatorPattern must be a RegExp.';
} }
if(passwordPolicy.validatorCallback && typeof passwordPolicy.validatorCallback !== 'function' ) { if(passwordPolicy.validatorCallback && typeof passwordPolicy.validatorCallback !== 'function') {
throw 'passwordPolicy.validatorCallback must be a function.'; throw 'passwordPolicy.validatorCallback must be a function.';
} }

View File

@@ -49,7 +49,7 @@ export class AdaptableController {
} }
// Makes sure the prototype matches // Makes sure the prototype matches
let mismatches = Object.getOwnPropertyNames(Type.prototype).reduce( (obj, key) => { let mismatches = Object.getOwnPropertyNames(Type.prototype).reduce((obj, key) => {
const adapterType = typeof adapter[key]; const adapterType = typeof adapter[key];
const expectedType = typeof Type.prototype[key]; const expectedType = typeof Type.prototype[key];
if (adapterType !== expectedType) { if (adapterType !== expectedType) {

View File

@@ -305,7 +305,7 @@ class ParseServer {
//This causes tests to spew some useless warnings, so disable in test //This causes tests to spew some useless warnings, so disable in test
if (!process.env.TESTING) { if (!process.env.TESTING) {
process.on('uncaughtException', (err) => { process.on('uncaughtException', (err) => {
if ( err.code === "EADDRINUSE" ) { // user-friendly message for this common error if (err.code === "EADDRINUSE") { // user-friendly message for this common error
/* eslint-disable no-console */ /* eslint-disable no-console */
console.error(`Unable to listen on port ${err.port}. The port is already in use.`); console.error(`Unable to listen on port ${err.port}. The port is already in use.`);
/* eslint-enable no-console */ /* eslint-enable no-console */

View File

@@ -4,7 +4,7 @@ import * as middleware from "../middlewares";
export class HooksRouter extends PromiseRouter { export class HooksRouter extends PromiseRouter {
createHook(aHook, config) { createHook(aHook, config) {
return config.hooksController.createHook(aHook).then( (hook) => ({response: hook})); return config.hooksController.createHook(aHook).then((hook) => ({response: hook}));
} }
updateHook(aHook, config) { updateHook(aHook, config) {
@@ -18,7 +18,7 @@ export class HooksRouter extends PromiseRouter {
handleGetFunctions(req) { handleGetFunctions(req) {
var hooksController = req.config.hooksController; var hooksController = req.config.hooksController;
if (req.params.functionName) { if (req.params.functionName) {
return hooksController.getFunction(req.params.functionName).then( (foundFunction) => { return hooksController.getFunction(req.params.functionName).then((foundFunction) => {
if (!foundFunction) { if (!foundFunction) {
throw new Parse.Error(143, `no function named: ${req.params.functionName} is defined`); throw new Parse.Error(143, `no function named: ${req.params.functionName} is defined`);
} }

View File

@@ -88,13 +88,13 @@ export class IAPValidationRouter extends PromiseRouter {
return Promise.resolve({response: appStoreError(error.status) }); return Promise.resolve({response: appStoreError(error.status) });
} }
return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then( () => { return validateWithAppStore(IAP_PRODUCTION_URL, receipt).then(() => {
return successCallback(); return successCallback();
}, (error) => { }, (error) => {
if (error.status == 21007) { if (error.status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( () => { return validateWithAppStore(IAP_SANDBOX_URL, receipt).then(() => {
return successCallback(); return successCallback();
}, (error) => { }, (error) => {
return errorCallback(error); return errorCallback(error);

View File

@@ -24,7 +24,7 @@ export class PublicAPIRouter extends PromiseRouter {
} }
let userController = config.userController; let userController = config.userController;
return userController.verifyEmail(username, token).then( () => { return userController.verifyEmail(username, token).then(() => {
let params = qs.stringify({username}); let params = qs.stringify({username});
return Promise.resolve({ return Promise.resolve({
status: 302, status: 302,
@@ -71,7 +71,7 @@ export class PublicAPIRouter extends PromiseRouter {
return this.invalidLink(req); return this.invalidLink(req);
} }
return config.userController.checkResetTokenValidity(username, token).then( () => { return config.userController.checkResetTokenValidity(username, token).then(() => {
let params = qs.stringify({token, id: config.applicationId, username, app: config.appName, }); let params = qs.stringify({token, id: config.applicationId, username, app: config.appName, });
return Promise.resolve({ return Promise.resolve({
status: 302, status: 302,

View File

@@ -118,7 +118,7 @@ OAuth.nonce = function(){
var text = ""; var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 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)); text += possible.charAt(Math.floor(Math.random() * possible.length));
return text; return text;

View File

@@ -25,7 +25,7 @@ function validateAuthData(authData, params) {
function vkOAuth2Request(params) { function vkOAuth2Request(params) {
var promise = new Parse.Promise(); var promise = new Parse.Promise();
return promise.then(function(){ return promise.then(function(){
if (!params || !params.appIds || !params.appIds.length || !params.appSecret || !params.appSecret.length ) { if (!params || !params.appIds || !params.appIds.length || !params.appSecret || !params.appSecret.length) {
logger.error('Vk Auth', 'Vk auth is not configured. Missing appIds or appSecret.'); logger.error('Vk Auth', 'Vk auth is not configured. Missing appIds or appSecret.');
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Vk auth is not configured. Missing appIds or appSecret.'); throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Vk auth is not configured. Missing appIds or appSecret.');
} }