Permalink
Browse files

Adds liniting into the workflow (#3082)

* initial linting of src

* fix indent to 2 spaces

* Removes unnecessary rules

* ignore spec folder for now

* Spec linting

* Fix spec indent

* nits

* nits

* no no-empty rule
  • Loading branch information...
1 parent 6e2fba4 commit 8c2c76dd269f5aaf71439acb7a42a971a6560e49 @flovilmart flovilmart committed on GitHub Nov 24, 2016
Showing with 3,480 additions and 3,509 deletions.
  1. +2 −0 .eslintignore
  2. +20 −0 .eslintrc.json
  3. +1 −0 .travis.yml
  4. +4 −0 package.json
  5. +35 −0 spec/.eslintrc.json
  6. +11 −11 spec/AccountLockoutPolicy.spec.js
  7. +11 −11 spec/AdaptableController.spec.js
  8. +6 −6 spec/Analytics.spec.js
  9. +3 −4 spec/Auth.spec.js
  10. +5 −5 spec/CacheController.spec.js
  11. +20 −20 spec/ClientSDK.spec.js
  12. +186 −187 spec/CloudCode.spec.js
  13. +152 −152 spec/CloudCodeLogger.spec.js
  14. +33 −33 spec/EmailVerificationToken.spec.js
  15. +1 −1 spec/EnableSingleSchemaCache.spec.js
  16. +1 −1 spec/EventEmitterPubSub.spec.js
  17. +9 −9 spec/HTTPRequest.spec.js
  18. +1 −1 spec/InMemoryCache.spec.js
  19. +1 −3 spec/InMemoryCacheAdapter.spec.js
  20. +29 −29 spec/InstallationsRouter.spec.js
  21. +5 −5 spec/Logger.spec.js
  22. +3 −3 spec/LoggerController.spec.js
  23. +97 −97 spec/Middlewares.spec.js
  24. +16 −16 spec/MockEmailAdapterWithOptions.js
  25. +1 −1 spec/MongoTransform.spec.js
  26. +17 −17 spec/OAuth.spec.js
  27. +28 −28 spec/Parse.Push.spec.js
  28. +4 −4 spec/ParseACL.spec.js
  29. +121 −123 spec/ParseAPI.spec.js
  30. +1 −1 spec/ParseCloudCodePublisher.spec.js
  31. +6 −6 spec/ParseFile.spec.js
  32. +11 −11 spec/ParseGeoPoint.spec.js
  33. +2 −3 spec/ParseGlobalConfig.spec.js
  34. +376 −376 spec/ParseHooks.spec.js
  35. +10 −12 spec/ParseInstallation.spec.js
  36. +9 −10 spec/ParseLiveQueryServer.spec.js
  37. +25 −30 spec/ParseObject.spec.js
  38. +4 −4 spec/ParsePubSub.spec.js
  39. +199 −201 spec/ParseQuery.spec.js
  40. +84 −88 spec/ParseRelation.spec.js
  41. +40 −40 spec/ParseRole.spec.js
  42. +28 −29 spec/ParseServerRESTController.spec.js
  43. +112 −111 spec/ParseUser.spec.js
  44. +21 −22 spec/PasswordPolicy.spec.js
  45. +102 −108 spec/PointerPermissions.spec.js
  46. +4 −4 spec/PromiseRouter.spec.js
  47. +8 −8 spec/PublicAPI.spec.js
  48. +47 −47 spec/PurchaseValidation.spec.js
  49. +258 −258 spec/PushController.spec.js
  50. +2 −2 spec/RedisPubSub.spec.js
  51. +13 −15 spec/RestCreate.spec.js
  52. +11 −13 spec/RestQuery.spec.js
  53. +20 −20 spec/RevocableSessionsUpgrade.spec.js
  54. +35 −36 spec/Schema.spec.js
  55. +1 −1 spec/SessionTokenCache.spec.js
  56. +2 −2 spec/TwitterAuth.spec.js
  57. +0 −1 spec/Uniqueness.spec.js
  58. +37 −37 spec/ValidationAndPasswordsReset.spec.js
  59. +20 −21 spec/WinstonLoggerAdapter.spec.js
  60. +10 −11 spec/helper.js
  61. +27 −27 spec/index.spec.js
  62. +24 −24 spec/parsers.spec.js
  63. +115 −115 spec/schemas.spec.js
  64. +4 −5 src/AccountLockout.js
  65. +1 −0 src/Adapters/Analytics/AnalyticsAdapter.js
  66. +1 −0 src/Adapters/Cache/CacheAdapter.js
  67. +1 −1 src/Adapters/Cache/InMemoryCacheAdapter.js
  68. +5 −6 src/Adapters/Cache/NullCacheAdapter.js
  69. +13 −13 src/Adapters/Cache/RedisCacheAdapter.js
  70. +1 −1 src/Adapters/Email/MailAdapter.js
  71. +1 −0 src/Adapters/Files/FilesAdapter.js
  72. +1 −1 src/Adapters/Files/GridStoreAdapter.js
  73. +1 −0 src/Adapters/Logger/LoggerAdapter.js
  74. +3 −3 src/Adapters/Logger/WinstonLogger.js
  75. +3 −10 src/Adapters/Logger/WinstonLoggerAdapter.js
  76. +1 −0 src/Adapters/Push/PushAdapter.js
  77. +1 −1 src/Adapters/Storage/Mongo/MongoCollection.js
  78. +21 −20 src/Adapters/Storage/Mongo/MongoSchemaCollection.js
  79. +8 −6 src/Adapters/Storage/Mongo/MongoStorageAdapter.js
  80. +14 −12 src/Adapters/Storage/Mongo/MongoTransform.js
  81. +118 −119 src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
  82. +5 −6 src/Auth.js
  83. +9 −9 src/Controllers/AdaptableController.js
  84. +2 −2 src/Controllers/AnalyticsController.js
  85. +51 −69 src/Controllers/DatabaseController.js
  86. +1 −2 src/Controllers/FilesController.js
  87. +5 −6 src/Controllers/HooksController.js
  88. +0 −1 src/Controllers/LiveQueryController.js
  89. +0 −1 src/Controllers/LoggerController.js
  90. +3 −5 src/Controllers/PushController.js
  91. +2 −3 src/Controllers/SchemaCache.js
  92. +107 −104 src/Controllers/SchemaController.js
  93. +7 −9 src/Controllers/UserController.js
  94. +1 −2 src/LiveQuery/Client.js
  95. +35 −35 src/LiveQuery/ParseLiveQueryServer.js
  96. +1 −1 src/LiveQuery/ParseWebSocketServer.js
  97. +93 −92 src/LiveQuery/QueryTools.js
  98. +2 −2 src/LiveQuery/RequestSchema.js
  99. +0 −1 src/LiveQuery/Subscription.js
  100. +22 −23 src/ParseServer.js
  101. +4 −4 src/ParseServerRESTController.js
  102. +7 −10 src/PromiseRouter.js
  103. +33 −35 src/RestQuery.js
  104. +30 −31 src/RestWrite.js
  105. +1 −1 src/Routers/ClassesRouter.js
  106. +1 −1 src/Routers/CloudCodeRouter.js
  107. +3 −3 src/Routers/FeaturesRouter.js
  108. +6 −10 src/Routers/FilesRouter.js
  109. +16 −17 src/Routers/FunctionsRouter.js
  110. +1 −1 src/Routers/GlobalConfigRouter.js
  111. +3 −3 src/Routers/HooksRouter.js
  112. +9 −9 src/Routers/IAPValidationRouter.js
  113. +5 −6 src/Routers/PublicAPIRouter.js
  114. +0 −2 src/Routers/RolesRouter.js
  115. +1 −2 src/Routers/SchemasRouter.js
  116. +4 −4 src/Routers/SessionsRouter.js
  117. +5 −6 src/Routers/UsersRouter.js
  118. +6 −7 src/StatusHandler.js
  119. +7 −7 src/TestUtils.js
  120. +63 −65 src/authDataManager/OAuth1Client.js
  121. +1 −1 src/authDataManager/facebook.js
  122. +1 −1 src/authDataManager/github.js
  123. +1 −1 src/authDataManager/google.js
  124. +2 −2 src/authDataManager/index.js
  125. +1 −1 src/authDataManager/instagram.js
  126. +1 −1 src/authDataManager/janraincapture.js
  127. +1 −1 src/authDataManager/janrainengage.js
  128. +1 −1 src/authDataManager/linkedin.js
  129. +1 −1 src/authDataManager/meetup.js
  130. +2 −2 src/authDataManager/qq.js
  131. +1 −1 src/authDataManager/spotify.js
  132. +1 −1 src/authDataManager/twitter.js
  133. +1 −1 src/authDataManager/vkontakte.js
  134. +2 −2 src/authDataManager/wechat.js
  135. +3 −3 src/authDataManager/weibo.js
  136. +1 −1 src/batch.js
  137. +5 −11 src/cli/definitions/parse-live-query-server.js
  138. +6 −10 src/cli/definitions/parse-server.js
  139. +6 −7 src/cli/parse-server.js
  140. +15 −13 src/cli/utils/commander.js
  141. +1 −1 src/cli/utils/parsers.js
  142. +2 −1 src/cli/utils/runner.js
  143. +3 −3 src/cloud-code/HTTPResponse.js
  144. +2 −2 src/defaults.js
  145. +12 −12 src/middlewares.js
  146. +1 −1 src/password.js
  147. +2 −2 src/rest.js
  148. +31 −32 src/triggers.js
  149. +137 −137 src/vendor/mongodbUrl.js
View
@@ -0,0 +1,2 @@
+lib/*
+coverage/*
View
@@ -0,0 +1,20 @@
+{
+ "root": true,
+ "extends": "eslint:recommended",
+ "env": {
+ "node": true,
+ "es6": true
+ },
+ "parser": "babel-eslint",
+ "plugins": [
+ "flowtype"
+ ],
+ "parserOptions": {
+ "ecmaVersion": 6,
+ "sourceType": "module"
+ },
+ "rules": {
+ "indent": ["error", 2],
+ "linebreak-style": ["error", "unix"]
+ }
+}
View
@@ -15,6 +15,7 @@ before_script:
- psql -c 'create database parse_server_postgres_adapter_test_database;' -U postgres
- psql -c 'CREATE EXTENSION postgis;' -U postgres -d parse_server_postgres_adapter_test_database
- psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d parse_server_postgres_adapter_test_database
+ - npm run lint
env:
global:
- COVERAGE_OPTION='./node_modules/.bin/istanbul cover'
View
@@ -46,6 +46,7 @@
"devDependencies": {
"babel-cli": "6.18.0",
"babel-core": "6.18.2",
+ "babel-eslint": "^7.1.1",
"babel-plugin-syntax-flow": "6.13.0",
"babel-plugin-transform-flow-strip-types": "6.18.0",
"babel-preset-es2015": "6.14.0",
@@ -54,6 +55,8 @@
"bcrypt-nodejs": "0.0.3",
"cross-env": "3.1.3",
"deep-diff": "0.3.4",
+ "eslint": "^3.10.2",
+ "eslint-plugin-flowtype": "^2.25.0",
"gaze": "1.1.1",
"istanbul": "1.0.0-alpha.1",
"jasmine": "2.5.2",
@@ -64,6 +67,7 @@
},
"scripts": {
"dev": "npm run build && node bin/dev",
+ "lint": "eslint ./",
"build": "babel src/ -d lib/",
"test": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 NODE_ENV=test TESTING=1 $COVERAGE_OPTION jasmine",
"test:win": "npm run pretest && cross-env NODE_ENV=test TESTING=1 node ./node_modules/jasmine/bin/jasmine.js && npm run posttest",
View
@@ -0,0 +1,35 @@
+{
+ "extends": "eslint:recommended",
+ "env": {
+ "node": true,
+ "es6": true,
+ "jasmine": true
+ },
+ "globals": {
+ "Parse": true,
+ "reconfigureServer": true,
+ "createTestUser": true,
+ "jfail": true,
+ "ok": true,
+ "strictEqual": true,
+ "TestObject": true,
+ "Item": true,
+ "Container": true,
+ "equal": true,
+ "notEqual": true,
+ "it_exclude_dbs": true,
+ "describe_only_db": true,
+ "on_db": true,
+ "defaultConfiguration": true,
+ "expectSuccess": true,
+ "range": true,
+ "expectError": true,
+ "jequal": true,
+ "create": true,
+ "arrayContains": true
+ },
+ "rules": {
+ "no-console": [0],
+ "indent": ["error", 2]
+ }
+}
@@ -5,7 +5,7 @@ const Config = require("../src/Config");
var loginWithWrongCredentialsShouldFail = function(username, password) {
return new Promise((resolve, reject) => {
Parse.User.logIn(username, password)
- .then(user => reject('login should have failed'))
+ .then(() => reject('login should have failed'))
.catch(err => {
if (err.message === 'Invalid username/password.') {
resolve();
@@ -20,7 +20,7 @@ var isAccountLockoutError = function(username, password, duration, waitTime) {
return new Promise((resolve, reject) => {
setTimeout(() => {
Parse.User.logIn(username, password)
- .then(user => reject('login should have failed'))
+ .then(() => reject('login should have failed'))
.catch(err => {
if (err.message === 'Your account is locked due to multiple failed login attempts. Please try again after ' + duration + ' minute(s)') {
resolve();
@@ -45,7 +45,7 @@ describe("Account Lockout Policy: ", () => {
user.setPassword('password');
return user.signUp(null);
})
- .then(user => {
+ .then(() => {
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 1');
})
.then(() => {
@@ -71,7 +71,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('set duration to an invalid number test failed');
done();
})
@@ -95,7 +95,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('set threshold to an invalid number test failed');
done();
})
@@ -119,7 +119,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('threshold value < 1 is invalid test failed');
done();
})
@@ -143,7 +143,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('threshold value > 999 is invalid test failed');
done();
})
@@ -167,7 +167,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('duration value < 1 is invalid test failed');
done();
})
@@ -191,7 +191,7 @@ describe("Account Lockout Policy: ", () => {
publicServerURL: "https://my.public.server.com/1"
})
.then(() => {
- var config = new Config('test');
+ new Config('test');
fail('duration value > 99999 is invalid test failed');
done();
})
@@ -230,7 +230,7 @@ describe("Account Lockout Policy: ", () => {
return isAccountLockoutError('username2', 'wrong password', 1, 1);
})
.then(() => {
- done();
+ done();
})
.catch(err => {
fail('lock account after failed login attempts test failed: ' + JSON.stringify(err));
@@ -301,7 +301,7 @@ describe("Account Lockout Policy: ", () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
Parse.User.logIn('username4', 'correct password')
- .then(user => resolve())
+ .then(() => resolve())
.catch(err => reject(err));
}, 3001);
});
@@ -31,7 +31,7 @@ describe("AdaptableController", ()=>{
});
it("should fail setting the wrong adapter to the controller", (done) => {
- function WrongAdapter() {};
+ function WrongAdapter() {}
var adapter = new FilesAdapter();
var controller = new FilesController(adapter);
var otherAdapter = new WrongAdapter();
@@ -42,7 +42,7 @@ describe("AdaptableController", ()=>{
});
it("should fail to instantiate a controller with wrong adapter", (done) => {
- function WrongAdapter() {};
+ function WrongAdapter() {}
var adapter = new WrongAdapter();
expect(() => {
new FilesController(adapter);
@@ -59,10 +59,10 @@ describe("AdaptableController", ()=>{
it("should accept an object adapter", (done) => {
var adapter = {
- createFile: function(config, filename, data) { },
- deleteFile: function(config, filename) { },
- getFileData: function(config, filename) { },
- getFileLocation: function(config, filename) { },
+ createFile: function() { },
+ deleteFile: function() { },
+ getFileData: function() { },
+ getFileLocation: function() { },
}
expect(() => {
new FilesController(adapter);
@@ -71,11 +71,11 @@ describe("AdaptableController", ()=>{
});
it("should accept an object adapter", (done) => {
- function AGoodAdapter() {};
- AGoodAdapter.prototype.createFile = function(config, filename, data) { };
- AGoodAdapter.prototype.deleteFile = function(config, filename) { };
- AGoodAdapter.prototype.getFileData = function(config, filename) { };
- AGoodAdapter.prototype.getFileLocation = function(config, filename) { };
+ function AGoodAdapter() {}
+ AGoodAdapter.prototype.createFile = function() { };
+ AGoodAdapter.prototype.deleteFile = function() { };
+ AGoodAdapter.prototype.getFileData = function() { };
+ AGoodAdapter.prototype.getFileLocation = function() { };
var adapter = new AGoodAdapter();
expect(() => {
@@ -1,6 +1,6 @@
const analyticsAdapter = {
- appOpened: function(parameters, req) {},
- trackEvent: function(eventName, parameters, req) {}
+ appOpened: function() {},
+ trackEvent: function() {}
}
describe('AnalyticsController', () => {
@@ -9,7 +9,7 @@ describe('AnalyticsController', () => {
spyOn(analyticsAdapter, 'trackEvent').and.callThrough();
reconfigureServer({
analyticsAdapter
- }).then(() => {
+ }).then(() => {
return Parse.Analytics.track('MyEvent', {
key: 'value',
count: '0'
@@ -26,7 +26,7 @@ describe('AnalyticsController', () => {
}
});
done();
- }, (err) => {
+ }, (err) => {
fail(JSON.stringify(err));
done();
})
@@ -37,7 +37,7 @@ describe('AnalyticsController', () => {
spyOn(analyticsAdapter, 'appOpened').and.callThrough();
reconfigureServer({
analyticsAdapter
- }).then(() => {
+ }).then(() => {
return Parse.Analytics.track('AppOpened', {
key: 'value',
count: '0'
@@ -53,7 +53,7 @@ describe('AnalyticsController', () => {
}
});
done();
- }, (err) => {
+ }, (err) => {
fail(JSON.stringify(err));
done();
})
View
@@ -4,7 +4,6 @@ describe('Auth', () => {
describe('getUserRoles', () => {
var auth;
var config;
- var cacheController;
var currentRoles = null;
var currentUserId = 'userId';
@@ -51,8 +50,8 @@ describe('Auth', () => {
expect(roles).toEqual(currentRoles);
return auth.getUserRoles()
})
- .then((roles) => auth.getUserRoles())
- .then((roles) => auth.getUserRoles())
+ .then(() => auth.getUserRoles())
+ .then(() => auth.getUserRoles())
.then((roles) => {
// Should only call the cache adapter once.
expect(config.cacheController.role.get.calls.count()).toEqual(1);
@@ -79,7 +78,7 @@ describe('Auth', () => {
.then(() => done());
});
- it('should properly handle bcrypt upgrade', (done) => {
+ it('should properly handle bcrypt upgrade', (done) => {
var bcryptOriginal = require('bcrypt-nodejs');
var bcryptNew = require('bcryptjs');
bcryptOriginal.hash('my1Long:password', null, null, function(err, res) {
@@ -62,13 +62,13 @@ describe('CacheController', function() {
it('should handle cache rejections', (done) => {
- FakeCacheAdapter.get = () => Promise.reject();
+ FakeCacheAdapter.get = () => Promise.reject();
- var cache = new CacheController(FakeCacheAdapter, FakeAppID);
+ var cache = new CacheController(FakeCacheAdapter, FakeAppID);
- cache.get('foo').then(done, () => {
- fail('Promise should not be rejected.');
- });
+ cache.get('foo').then(done, () => {
+ fail('Promise should not be rejected.');
+ });
});
});
@@ -1,27 +1,27 @@
var ClientSDK = require('../src/ClientSDK');
-describe('ClientSDK', () => {
- it('should properly parse the SDK versions', () => {
- let clientSDKFromVersion = ClientSDK.fromString;
- expect(clientSDKFromVersion('i1.1.1')).toEqual({
- sdk: 'i',
- version: '1.1.1'
- });
- expect(clientSDKFromVersion('i1')).toEqual({
- sdk: 'i',
- version: '1'
- });
- expect(clientSDKFromVersion('apple-tv1.13.0')).toEqual({
- sdk: 'apple-tv',
- version: '1.13.0'
- });
- expect(clientSDKFromVersion('js1.9.0')).toEqual({
- sdk: 'js',
- version: '1.9.0'
- });
+describe('ClientSDK', () => {
+ it('should properly parse the SDK versions', () => {
+ let clientSDKFromVersion = ClientSDK.fromString;
+ expect(clientSDKFromVersion('i1.1.1')).toEqual({
+ sdk: 'i',
+ version: '1.1.1'
+ });
+ expect(clientSDKFromVersion('i1')).toEqual({
+ sdk: 'i',
+ version: '1'
+ });
+ expect(clientSDKFromVersion('apple-tv1.13.0')).toEqual({
+ sdk: 'apple-tv',
+ version: '1.13.0'
+ });
+ expect(clientSDKFromVersion('js1.9.0')).toEqual({
+ sdk: 'js',
+ version: '1.9.0'
+ });
});
- it('should properly sastisfy', () => {
+ it('should properly sastisfy', () => {
expect(ClientSDK.compatible({
js: '>=1.9.0'
})("js1.9.0")).toBe(true);
Oops, something went wrong.

0 comments on commit 8c2c76d

Please sign in to comment.