diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 098c60b14f..0000000000 --- a/.eslintrc +++ /dev/null @@ -1,37 +0,0 @@ -{ - rules: { - indent: [2, 2, {"SwitchCase": 1}], - no-multi-spaces: 2, - no-underscore-dangle: 0, - no-use-before-define: [1, "nofunc"], - no-unused-expressions: 0, - no-empty-class: 0, - object-curly-spacing: [2, "always"], - quotes: [1, "single"], - space-in-parens: [2, "never"] - }, - env: { - node: true - }, - globals: { - angular: true, - $: true, - jQuery: true, - moment: true, - window: true, - document: true, - Modernizr: true, - __TESTING__: true, - beforeEach: true, - expect: true, - describe: true, - it: true, - element: true, - by: true, - browser: true, - inject: true, - register: true, - sinon: true, - _: false - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..f03e9c512d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,72 @@ +module.exports = { + extends: [ + 'airbnb/legacy' + ], + rules: { + camelcase: 0, + 'comma-dangle': [2, 'never'], + 'comma-spacing': [2, { before: false, after: true }], + 'consistent-return': 0, + curly: 0, + 'default-case': 0, + eqeqeq: [2, 'smart'], + 'func-names': 0, + 'guard-for-in': 2, + indent: [2, 2, { SwitchCase: 1 }], + 'key-spacing': [2, { beforeColon: false, afterColon: true }], + 'keyword-spacing': [2, { before: true, after: true }], + 'max-len': 0, + 'new-cap': [2, { newIsCapExceptions: ['acl.memoryBackend', 'acl'] }], + 'no-bitwise': 0, + 'no-caller': 2, + 'no-else-return': 0, + 'no-empty-class': 0, + 'no-multi-spaces': 2, + 'no-param-reassign': 0, + 'no-shadow': 0, + 'no-spaced-func': 2, + 'no-throw-literal': 2, + 'no-trailing-spaces': 2, + 'no-undef': 2, + 'no-unneeded-ternary': 2, + 'no-unreachable': 2, + 'no-underscore-dangle': 0, + 'no-unused-expressions': 0, + 'no-unused-vars': 0, + 'no-use-before-define': [1, 'nofunc'], + 'no-var': 0, + 'object-curly-spacing': [2, 'always'], + 'one-var': [0, 'never'], + 'one-var-declaration-per-line': [2, 'always'], + 'padded-blocks': 0, + 'space-before-function-paren': 0, + 'space-in-parens': [2, 'never'], + 'spaced-comment': [2, 'always'], + strict: 0, + 'quote-props': 0, + quotes: [1, 'single'], + 'wrap-iife': [2, 'outside'], + 'vars-on-top': 0 + }, + env: { + node: true, + browser: true, + jasmine: true, + mocha: true, + jquery: true + }, + globals: { + angular: true, + by: true, + browser: true, + element: true, + inject: true, + io: true, + moment: true, + Modernizr: true, + Promise: true, + __TESTING__: true, + _: false, + ApplicationConfiguration: true + } +}; diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 2466369095..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,27 +0,0 @@ -{ - "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment. - "mocha": true, // Enable globals available when code is running inside of the Mocha tests. - "jasmine": true, // Enable globals available when code is running inside of the Jasmine tests. - "browser": true, // Standard browser globals e.g. `window`, `document`. - "esnext": true, // Allow ES.next specific features such as `const` and `let`. - "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.). - "curly": false, // Require {} for every new block or scope. - "eqeqeq": true, // Require triple equals i.e. `===`. - "latedef": "nofunc", // Prohibit variable use before definition. - "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`. - "undef": true, // Require all non-global variables be declared before they are used. - "unused": false, // Warn unused variables. - "strict": true, // Require `use strict` pragma in every file. - "globals": { // Globals variables. - "angular": true, - "io": true, - "ApplicationConfiguration": true - }, - "predef": [ // Extra globals. - "inject", - "by", - "browser", - "element" - ], - "devel": true // Allow development statements e.g. `console.log();`. -} diff --git a/config/assets/production.js b/config/assets/production.js index 79cfe745ba..9d82cb8b5e 100644 --- a/config/assets/production.js +++ b/config/assets/production.js @@ -6,7 +6,7 @@ module.exports = { css: [ // bower:css 'public/lib/bootstrap/dist/css/bootstrap.min.css', - 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css', + 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css' // endbower ], js: [ diff --git a/config/config.js b/config/config.js index b19c3a2e25..6ff51e810b 100644 --- a/config/config.js +++ b/config/config.js @@ -33,7 +33,9 @@ var getGlobbedPaths = function (globPatterns, excludes) { files = files.map(function (file) { if (_.isArray(excludes)) { for (var i in excludes) { - file = file.replace(excludes[i], ''); + if (excludes.hasOwnProperty(i)) { + file = file.replace(excludes[i], ''); + } } } else { file = file.replace(excludes, ''); diff --git a/config/env/cloud-foundry.js b/config/env/cloud-foundry.js index 6f7750bf00..6833ab8717 100644 --- a/config/env/cloud-foundry.js +++ b/config/env/cloud-foundry.js @@ -74,9 +74,9 @@ module.exports = { } }, seedDB: { - seed: process.env.MONGO_SEED === 'true' ? true : false, + seed: process.env.MONGO_SEED === 'true', options: { - logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true, + logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false', seedUser: { username: process.env.MONGO_SEED_USER_USERNAME || 'user', provider: 'local', diff --git a/config/env/default.js b/config/env/default.js index 735dd0adb2..b19e5e7da3 100644 --- a/config/env/default.js +++ b/config/env/default.js @@ -47,7 +47,7 @@ module.exports = { profileUpload: { dest: './modules/users/client/img/profile/uploads/', // Profile upload destination path limits: { - fileSize: 1*1024*1024 // Max file size in bytes (1 MB) + fileSize: 1 * 1024 * 1024 // Max file size in bytes (1 MB) } } } diff --git a/config/env/development.js b/config/env/development.js index 0c74753e8d..1e9ac2b44e 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -19,16 +19,16 @@ module.exports = { options: { // Stream defaults to process.stdout // Uncomment/comment to toggle the logging to a log on the file system - //stream: { + // stream: { // directoryPath: process.cwd(), // fileName: 'access.log', // rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage - // active: false, // activate to use rotating logs + // active: false, // activate to use rotating logs // fileName: 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used // frequency: 'daily', // verbose: false // } - //} + // } } }, app: { @@ -77,9 +77,9 @@ module.exports = { }, livereload: true, seedDB: { - seed: process.env.MONGO_SEED === 'true' ? true : false, + seed: process.env.MONGO_SEED === 'true', options: { - logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true, + logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false', seedUser: { username: process.env.MONGO_SEED_USER_USERNAME || 'user', provider: 'local', diff --git a/config/env/local.example.js b/config/env/local.example.js index ebf5b2788a..7a8641ff59 100644 --- a/config/env/local.example.js +++ b/config/env/local.example.js @@ -5,7 +5,7 @@ // Use it for your API keys, passwords, etc. // WARNING: When using this example for multiple NODE_ENV's concurrently, make sure you update the 'db' settings appropriately. -// You do not want to accidentally overwrite/lose any data. For instance, if you create a file for 'test' and don't change the +// You do not want to accidentally overwrite/lose any data. For instance, if you create a file for 'test' and don't change the // database name in the setting below, running the tests will drop all the data from the specified database. // // You may end up with a list of files, that will be used with their corresponding NODE_ENV: diff --git a/config/env/production.js b/config/env/production.js index b878ce988b..581944ee80 100644 --- a/config/env/production.js +++ b/config/env/production.js @@ -29,10 +29,10 @@ module.exports = { directoryPath: process.env.LOG_DIR_PATH || process.cwd(), fileName: process.env.LOG_FILE || 'access.log', rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage - active: process.env.LOG_ROTATING_ACTIVE === 'true' ? true : false, // activate to use rotating logs + active: process.env.LOG_ROTATING_ACTIVE === 'true', // activate to use rotating logs fileName: process.env.LOG_ROTATING_FILE || 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used frequency: process.env.LOG_ROTATING_FREQUENCY || 'daily', - verbose: process.env.LOG_ROTATING_VERBOSE === 'true' ? true : false + verbose: process.env.LOG_ROTATING_VERBOSE === 'true' } } } @@ -79,9 +79,9 @@ module.exports = { } }, seedDB: { - seed: process.env.MONGO_SEED === 'true' ? true : false, + seed: process.env.MONGO_SEED === 'true', options: { - logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true, + logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false', seedUser: { username: process.env.MONGO_SEED_USER_USERNAME || 'user', provider: 'local', diff --git a/config/env/test.js b/config/env/test.js index 8ea1cfc77f..7f1bf25b60 100644 --- a/config/env/test.js +++ b/config/env/test.js @@ -23,7 +23,7 @@ module.exports = { directoryPath: process.cwd(), fileName: 'access.log', rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage - active: false, // activate to use rotating logs + active: false, // activate to use rotating logs fileName: 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used frequency: 'daily', verbose: false @@ -77,9 +77,9 @@ module.exports = { } }, seedDB: { - seed: process.env.MONGO_SEED === 'true' ? true : false, + seed: process.env.MONGO_SEED === 'true', options: { - logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true, + logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false', seedUser: { username: process.env.MONGO_SEED_USER_USERNAME || 'user', provider: 'local', diff --git a/config/lib/seed.js b/config/lib/seed.js index cc8f92db99..eca4188844 100644 --- a/config/lib/seed.js +++ b/config/lib/seed.js @@ -120,8 +120,8 @@ module.exports.start = function start(options) { seedOptions.logResults = options.logResults; } - if (_.has(options, 'seedUser')) { - seedOptions.seedUser = options.seedUser; + if (_.has(options, 'seedUser')) { + seedOptions.seedUser = options.seedUser; } if (_.has(options, 'seedAdmin')) { @@ -134,7 +134,7 @@ module.exports.start = function start(options) { var adminAccount = new User(seedOptions.seedAdmin); var userAccount = new User(seedOptions.seedUser); - //If production only seed admin if it does not exist + // If production only seed admin if it does not exist if (process.env.NODE_ENV === 'production') { User.generateRandomPassphrase() .then(seedTheUser(adminAccount)) diff --git a/gruntfile.js b/gruntfile.js index 2a18d9a5e0..eb5c3d6752 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -34,7 +34,7 @@ module.exports = function (grunt) { }, serverJS: { files: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS), - tasks: ['jshint'], + tasks: ['eslint'], options: { livereload: true } @@ -47,7 +47,7 @@ module.exports = function (grunt) { }, clientJS: { files: defaultAssets.client.js, - tasks: ['jshint'], + tasks: ['eslint'], options: { livereload: true } @@ -91,17 +91,6 @@ module.exports = function (grunt) { logConcurrentOutput: true } }, - jshint: { - all: { - src: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e), - options: { - jshintrc: true, - node: true, - mocha: true, - jasmine: true - } - } - }, eslint: { options: {}, target: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e) @@ -190,7 +179,7 @@ module.exports = function (grunt) { coverage: true, require: 'test.js', coverageFolder: 'coverage/server', - reportFormats: ['cobertura','lcovonly'], + reportFormats: ['cobertura', 'lcovonly'], check: { lines: 40, statements: 40 @@ -297,7 +286,7 @@ module.exports = function (grunt) { }); // Lint CSS and JavaScript files. - grunt.registerTask('lint', ['sass', 'less', 'jshint', 'eslint', 'csslint']); + grunt.registerTask('lint', ['sass', 'less', 'eslint', 'csslint']); // Lint project files and minify them into two production files. grunt.registerTask('build', ['env:dev', 'lint', 'ngAnnotate', 'uglify', 'cssmin']); diff --git a/gulpfile.js b/gulpfile.js index 567217c347..1b4abc8afa 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -69,24 +69,24 @@ gulp.task('watch', function () { // Add watch rules gulp.watch(defaultAssets.server.views).on('change', plugins.livereload.changed); - gulp.watch(defaultAssets.server.allJS, ['jshint']).on('change', plugins.livereload.changed); - gulp.watch(defaultAssets.client.js, ['jshint']).on('change', plugins.livereload.changed); + gulp.watch(defaultAssets.server.allJS, ['eslint']).on('change', plugins.livereload.changed); + gulp.watch(defaultAssets.client.js, ['eslint']).on('change', plugins.livereload.changed); gulp.watch(defaultAssets.client.css, ['csslint']).on('change', plugins.livereload.changed); gulp.watch(defaultAssets.client.sass, ['sass', 'csslint']).on('change', plugins.livereload.changed); gulp.watch(defaultAssets.client.less, ['less', 'csslint']).on('change', plugins.livereload.changed); if (process.env.NODE_ENV === 'production') { - gulp.watch(defaultAssets.server.gulpConfig, ['templatecache', 'jshint']); - gulp.watch(defaultAssets.client.views, ['templatecache', 'jshint']).on('change', plugins.livereload.changed); + gulp.watch(defaultAssets.server.gulpConfig, ['templatecache', 'eslint']); + gulp.watch(defaultAssets.client.views, ['templatecache']).on('change', plugins.livereload.changed); } else { - gulp.watch(defaultAssets.server.gulpConfig, ['jshint']); + gulp.watch(defaultAssets.server.gulpConfig, ['eslint']); gulp.watch(defaultAssets.client.views).on('change', plugins.livereload.changed); } if (process.env.NODE_ENV === 'test') { // Add Server Test file rules gulp.watch([testAssets.tests.server, defaultAssets.server.allJS], ['test:server']).on('change', function (file) { - var runOnlyChangedTestFile = argv.onlyChanged ? true : false; + var runOnlyChangedTestFile = !!argv.onlyChanged; // check if we should only run a changed test file if (runOnlyChangedTestFile) { @@ -125,23 +125,6 @@ gulp.task('csslint', function (done) { })); }); -// JS linting task -gulp.task('jshint', function () { - var assets = _.union( - defaultAssets.server.gulpConfig, - defaultAssets.server.allJS, - defaultAssets.client.js, - testAssets.tests.server, - testAssets.tests.client, - testAssets.tests.e2e - ); - - return gulp.src(assets) - .pipe(plugins.jshint()) - .pipe(plugins.jshint.reporter('default')) - .pipe(plugins.jshint.reporter('fail')); -}); - // ESLint JS linting task gulp.task('eslint', function () { var assets = _.union( @@ -339,7 +322,7 @@ gulp.task('dropdb', function (done) { mongoose.connect(function (db) { db.connection.db.dropDatabase(function (err) { - if(err) { + if (err) { console.log(err); } else { console.log('Successfully dropped db: ', db.connection.db.databaseName); @@ -376,7 +359,7 @@ gulp.task('protractor', ['webdriver_update'], function () { // Lint CSS and JavaScript files. gulp.task('lint', function (done) { - runSequence('less', 'sass', ['csslint', 'eslint', 'jshint'], done); + runSequence('less', 'sass', ['csslint', 'eslint'], done); }); // Lint project files and minify them into two production files. @@ -394,7 +377,7 @@ gulp.task('test:server', function (done) { }); // Watch all server files for changes & run server tests (test:server) task on changes -// optional arguments: +// optional arguments: // --onlyChanged - optional argument for specifying that only the tests in a changed Server Test file will be run // example usage: gulp test:server:watch --onlyChanged gulp.task('test:server:watch', function (done) { diff --git a/karma.conf.js b/karma.conf.js index 1a14d10eb6..c47045263f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -35,7 +35,7 @@ module.exports = function (karmaConfig) { cacheIdFromPath: function (filepath) { return filepath; - }, + } }, // List of files / patterns to load in the browser @@ -47,7 +47,7 @@ module.exports = function (karmaConfig) { // Configure the coverage reporter coverageReporter: { - dir : 'coverage/client', + dir: 'coverage/client', reporters: [ // Reporters not supporting the `file` property { type: 'html', subdir: 'report-html' }, diff --git a/modules/articles/client/articles.client.module.js b/modules/articles/client/articles.client.module.js index 85ff0c3fb1..0e7dcb9cbb 100644 --- a/modules/articles/client/articles.client.module.js +++ b/modules/articles/client/articles.client.module.js @@ -4,4 +4,4 @@ app.registerModule('articles', ['core']);// The core module is required for special route handling; see /core/client/config/core.client.routes app.registerModule('articles.services'); app.registerModule('articles.routes', ['ui.router', 'articles.services']); -})(ApplicationConfiguration); +}(ApplicationConfiguration)); diff --git a/modules/articles/client/config/articles.client.config.js b/modules/articles/client/config/articles.client.config.js index 1f8853e494..4437735020 100644 --- a/modules/articles/client/config/articles.client.config.js +++ b/modules/articles/client/config/articles.client.config.js @@ -28,4 +28,4 @@ roles: ['user'] }); } -})(); +}()); diff --git a/modules/articles/client/config/articles.client.routes.js b/modules/articles/client/config/articles.client.routes.js index b7671b1180..1ed46de06c 100644 --- a/modules/articles/client/config/articles.client.routes.js +++ b/modules/articles/client/config/articles.client.routes.js @@ -33,7 +33,7 @@ }, data: { roles: ['user', 'admin'], - pageTitle : 'Articles Create' + pageTitle: 'Articles Create' } }) .state('articles.edit', { @@ -57,7 +57,7 @@ resolve: { articleResolve: getArticle }, - data:{ + data: { pageTitle: 'Article {{ articleResolve.title }}' } }); @@ -76,4 +76,4 @@ function newArticle(ArticlesService) { return new ArticlesService(); } -})(); +}()); diff --git a/modules/articles/client/controllers/articles.client.controller.js b/modules/articles/client/controllers/articles.client.controller.js index 398379988e..641eb60083 100644 --- a/modules/articles/client/controllers/articles.client.controller.js +++ b/modules/articles/client/controllers/articles.client.controller.js @@ -49,4 +49,4 @@ } } } -})(); +}()); diff --git a/modules/articles/client/controllers/list-articles.client.controller.js b/modules/articles/client/controllers/list-articles.client.controller.js index 4b593ae9f9..24f80b39f8 100644 --- a/modules/articles/client/controllers/list-articles.client.controller.js +++ b/modules/articles/client/controllers/list-articles.client.controller.js @@ -12,4 +12,4 @@ vm.articles = ArticlesService.query(); } -})(); +}()); diff --git a/modules/articles/client/services/articles.client.service.js b/modules/articles/client/services/articles.client.service.js index 420d271448..3dc4c7f534 100644 --- a/modules/articles/client/services/articles.client.service.js +++ b/modules/articles/client/services/articles.client.service.js @@ -16,4 +16,4 @@ } }); } -})(); +}()); diff --git a/modules/articles/server/controllers/articles.server.controller.js b/modules/articles/server/controllers/articles.server.controller.js index a3a87c95e2..18d6a3b959 100644 --- a/modules/articles/server/controllers/articles.server.controller.js +++ b/modules/articles/server/controllers/articles.server.controller.js @@ -35,7 +35,7 @@ exports.read = function (req, res) { // Add a custom field to the Article, for determining if the current User is the "owner". // NOTE: This field is NOT persisted to the database, since it doesn't exist in the Article model. - article.isCurrentUserOwner = req.user && article.user && article.user._id.toString() === req.user._id.toString() ? true : false; + article.isCurrentUserOwner = !!(req.user && article.user && article.user._id.toString() === req.user._id.toString()); res.json(article); }; diff --git a/modules/articles/tests/client/articles.client.controller.tests.js b/modules/articles/tests/client/articles.client.controller.tests.js index d9107e6856..df6ae9a69e 100644 --- a/modules/articles/tests/client/articles.client.controller.tests.js +++ b/modules/articles/tests/client/articles.client.controller.tests.js @@ -64,7 +64,7 @@ articleResolve: {} }); - //Spy on state go + // Spy on state go spyOn($state, 'go'); })); @@ -143,12 +143,12 @@ describe('vm.remove()', function () { beforeEach(function () { - //Setup articles + // Setup articles $scope.vm.article = mockArticle; }); it('should delete the article and redirect to articles', function () { - //Return true on confirm message + // Return true on confirm message spyOn(window, 'confirm').and.returnValue(true); $httpBackend.expectDELETE(/api\/articles\/([0-9a-fA-F]{24})$/).respond(204); @@ -160,7 +160,7 @@ }); it('should should not delete the article and not redirect', function () { - //Return false on confirm message + // Return false on confirm message spyOn(window, 'confirm').and.returnValue(false); $scope.vm.remove(); @@ -169,4 +169,4 @@ }); }); }); -})(); +}()); diff --git a/modules/articles/tests/client/articles.client.routes.tests.js b/modules/articles/tests/client/articles.client.routes.tests.js index c850a2541e..851bcc1ddb 100644 --- a/modules/articles/tests/client/articles.client.routes.tests.js +++ b/modules/articles/tests/client/articles.client.routes.tests.js @@ -6,7 +6,7 @@ var $scope, ArticlesService; - //We can start by loading the main application module + // We can start by loading the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). @@ -73,7 +73,7 @@ content: 'MEAN rocks!' }); - //Initialize Controller + // Initialize Controller ArticlesController = $controller('ArticlesController as vm', { $scope: $scope, articleResolve: mockArticle @@ -120,7 +120,7 @@ // create mock article mockArticle = new ArticlesService(); - //Initialize Controller + // Initialize Controller ArticlesController = $controller('ArticlesController as vm', { $scope: $scope, articleResolve: mockArticle @@ -170,7 +170,7 @@ content: 'MEAN rocks!' }); - //Initialize Controller + // Initialize Controller ArticlesController = $controller('ArticlesController as vm', { $scope: $scope, articleResolve: mockArticle @@ -226,4 +226,4 @@ }); }); -})(); +}()); diff --git a/modules/articles/tests/client/list-articles.client.controller.tests.js b/modules/articles/tests/client/list-articles.client.controller.tests.js index 9f93f9fa2c..ee654f4707 100644 --- a/modules/articles/tests/client/list-articles.client.controller.tests.js +++ b/modules/articles/tests/client/list-articles.client.controller.tests.js @@ -63,7 +63,7 @@ $scope: $scope }); - //Spy on state go + // Spy on state go spyOn($state, 'go'); })); @@ -89,4 +89,4 @@ })); }); }); -})(); +}()); diff --git a/modules/articles/tests/server/article.server.model.tests.js b/modules/articles/tests/server/article.server.model.tests.js index d6d265bde1..fb37701704 100644 --- a/modules/articles/tests/server/article.server.model.tests.js +++ b/modules/articles/tests/server/article.server.model.tests.js @@ -11,7 +11,8 @@ var should = require('should'), /** * Globals */ -var user, article; +var user, + article; /** * Unit tests diff --git a/modules/articles/tests/server/article.server.routes.tests.js b/modules/articles/tests/server/article.server.routes.tests.js index 1dcf5da3bc..b6f29ac538 100644 --- a/modules/articles/tests/server/article.server.routes.tests.js +++ b/modules/articles/tests/server/article.server.routes.tests.js @@ -11,7 +11,11 @@ var should = require('should'), /** * Globals */ -var app, agent, credentials, user, article; +var app, + agent, + credentials, + user, + article; /** * Article routes tests diff --git a/modules/chat/client/chat.client.module.js b/modules/chat/client/chat.client.module.js index e9a138d8fe..1a1c932ff3 100644 --- a/modules/chat/client/chat.client.module.js +++ b/modules/chat/client/chat.client.module.js @@ -3,4 +3,4 @@ app.registerModule('chat', ['core']); app.registerModule('chat.routes', ['ui.router']); -})(ApplicationConfiguration); +}(ApplicationConfiguration)); diff --git a/modules/chat/client/config/chat.client.config.js b/modules/chat/client/config/chat.client.config.js index d0efbebe1a..c6a3542d2b 100644 --- a/modules/chat/client/config/chat.client.config.js +++ b/modules/chat/client/config/chat.client.config.js @@ -14,4 +14,4 @@ state: 'chat' }); } -})(); +}()); diff --git a/modules/chat/client/config/chat.client.routes.js b/modules/chat/client/config/chat.client.routes.js index fc86903123..4ec07d8bc9 100644 --- a/modules/chat/client/config/chat.client.routes.js +++ b/modules/chat/client/config/chat.client.routes.js @@ -20,4 +20,4 @@ } }); } -})(); +}()); diff --git a/modules/chat/client/controllers/chat.client.controller.js b/modules/chat/client/controllers/chat.client.controller.js index 85c060fec2..52df51cc31 100644 --- a/modules/chat/client/controllers/chat.client.controller.js +++ b/modules/chat/client/controllers/chat.client.controller.js @@ -52,4 +52,4 @@ vm.messageText = ''; } } -})(); +}()); diff --git a/modules/chat/tests/client/chat.client.controller.tests.js b/modules/chat/tests/client/chat.client.controller.tests.js index 354f0e39ac..50139f689b 100644 --- a/modules/chat/tests/client/chat.client.controller.tests.js +++ b/modules/chat/tests/client/chat.client.controller.tests.js @@ -5,7 +5,7 @@ 'use strict'; describe('ChatController', function () { - //Initialize global variables + // Initialize global variables var $scope, Socket, ChatController, @@ -91,4 +91,4 @@ }); }); }); -})(); +}()); diff --git a/modules/chat/tests/client/chat.client.routes.tests.js b/modules/chat/tests/client/chat.client.routes.tests.js index 4e72f4f960..bbd447eee1 100644 --- a/modules/chat/tests/client/chat.client.routes.tests.js +++ b/modules/chat/tests/client/chat.client.routes.tests.js @@ -6,7 +6,7 @@ var $scope, Authentication; - //We can start by loading the main application module + // We can start by loading the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). @@ -60,4 +60,4 @@ }); }); -})(); +}()); diff --git a/modules/core/client/app/config.js b/modules/core/client/app/config.js index 07a9cd7ce2..6c38c50907 100644 --- a/modules/core/client/app/config.js +++ b/modules/core/client/app/config.js @@ -20,4 +20,4 @@ var ApplicationConfiguration = (function () { applicationModuleVendorDependencies: applicationModuleVendorDependencies, registerModule: registerModule }; -})(); +}()); diff --git a/modules/core/client/app/init.js b/modules/core/client/app/init.js index e06e7f65e9..8d54b1cad6 100644 --- a/modules/core/client/app/init.js +++ b/modules/core/client/app/init.js @@ -1,6 +1,6 @@ 'use strict'; -//Start by defining the main module and adding the module dependencies +// Start by defining the main module and adding the module dependencies angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies); // Setting HTML5 Location Mode @@ -45,7 +45,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro // Store previous state function storePreviousState(state, params) { - // only store this state if it shouldn't be ignored + // only store this state if it shouldn't be ignored if (!state.data || !state.data.ignoreState) { $state.previous = { state: state, @@ -56,9 +56,9 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro } }); -//Then define the init function for starting up the application +// Then define the init function for starting up the application angular.element(document).ready(function () { - //Fixing facebook bug with redirect + // Fixing facebook bug with redirect if (window.location.hash && window.location.hash === '#_=_') { if (window.history && history.pushState) { window.history.pushState('', document.title, window.location.pathname); @@ -75,6 +75,6 @@ angular.element(document).ready(function () { } } - //Then init the app + // Then init the app angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]); }); diff --git a/modules/core/client/config/core.client.menus.js b/modules/core/client/config/core.client.menus.js index 1e52689b85..7cb277fc25 100644 --- a/modules/core/client/config/core.client.menus.js +++ b/modules/core/client/config/core.client.menus.js @@ -42,4 +42,4 @@ } -})(); +}()); diff --git a/modules/core/client/config/core.client.routes.js b/modules/core/client/config/core.client.routes.js index 49714cb628..432acc8cb8 100644 --- a/modules/core/client/config/core.client.routes.js +++ b/modules/core/client/config/core.client.routes.js @@ -9,7 +9,7 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider', var hasTrailingSlash = path.length > 1 && path[path.length - 1] === '/'; if (hasTrailingSlash) { - //if last character is a slash, return the same url without the slash + // if last character is a slash, return the same url without the slash var newPath = path.substr(0, path.length - 1); $location.replace().path(newPath); } diff --git a/modules/core/client/directives/page-title.client.directives.js b/modules/core/client/directives/page-title.client.directives.js index 2eea805a65..a58b13a03f 100644 --- a/modules/core/client/directives/page-title.client.directives.js +++ b/modules/core/client/directives/page-title.client.directives.js @@ -37,4 +37,4 @@ } } } -})(); +}()); diff --git a/modules/core/client/directives/show-errors.client.directives.js b/modules/core/client/directives/show-errors.client.directives.js index 937df8ea9d..c9473a837a 100644 --- a/modules/core/client/directives/show-errors.client.directives.js +++ b/modules/core/client/directives/show-errors.client.directives.js @@ -7,7 +7,12 @@ angular.module('core') .directive('showErrors', ['$timeout', '$interpolate', function ($timeout, $interpolate) { var linkFn = function (scope, el, attrs, formCtrl) { - var inputEl, inputName, inputNgEl, options, showSuccess, toggleClasses, + var inputEl, + inputName, + inputNgEl, + options, + showSuccess, + toggleClasses, initCheck = false, showValidationMessages = false, blurred = false; @@ -19,7 +24,7 @@ angular.module('core') inputName = $interpolate(inputNgEl.attr('name') || '')(scope); if (!inputName) { - throw 'show-errors element has no child input elements with a \'name\' attribute class'; + throw new Error('show-errors element has no child input elements with a \'name\' attribute class'); } var reset = function () { @@ -65,7 +70,7 @@ angular.module('core') compile: function (elem, attrs) { if (attrs.showErrors.indexOf('skipFormGroupCheck') === -1) { if (!(elem.hasClass('form-group') || elem.hasClass('input-group'))) { - throw 'show-errors element does not have the \'form-group\' or \'input-group\' class'; + throw new Error('show-errors element does not have the \'form-group\' or \'input-group\' class'); } } return linkFn; diff --git a/modules/core/client/services/menus.client.service.js b/modules/core/client/services/menus.client.service.js index 7d18f0cc10..64e6dd568d 100644 --- a/modules/core/client/services/menus.client.service.js +++ b/modules/core/client/services/menus.client.service.js @@ -1,6 +1,6 @@ 'use strict'; -//Menu service used for managing menus +// Menu service used for managing menus angular.module('core').service('Menus', [ function () { // Define a set of default roles @@ -14,13 +14,17 @@ angular.module('core').service('Menus', [ if (!!~this.roles.indexOf('*')) { return true; } else { - if(!user) { + if (!user) { return false; } for (var userRoleIndex in user.roles) { - for (var roleIndex in this.roles) { - if (this.roles[roleIndex] === user.roles[userRoleIndex]) { - return true; + if (user.roles.hasOwnProperty(userRoleIndex)) { + for (var roleIndex in this.roles) { + if (this.roles.hasOwnProperty(roleIndex)) { + if (this.roles[roleIndex] === user.roles[userRoleIndex]) { + return true; + } + } } } } @@ -40,8 +44,6 @@ angular.module('core').service('Menus', [ } else { throw new Error('MenuId was not provided'); } - - return false; }; // Get the menu object by menu id @@ -99,7 +101,9 @@ angular.module('core').service('Menus', [ // Add submenu items if (options.items) { for (var i in options.items) { - this.addSubMenuItem(menuId, options.state, options.items[i]); + if (options.items.hasOwnProperty(i)) { + this.addSubMenuItem(menuId, options.state, options.items[i]); + } } } @@ -155,9 +159,13 @@ angular.module('core').service('Menus', [ // Search for menu item to remove for (var itemIndex in this.menus[menuId].items) { - for (var subitemIndex in this.menus[menuId].items[itemIndex].items) { - if (this.menus[menuId].items[itemIndex].items[subitemIndex].state === submenuItemState) { - this.menus[menuId].items[itemIndex].items.splice(subitemIndex, 1); + if (this.menus[menuId].items.hasOwnProperty(itemIndex)) { + for (var subitemIndex in this.menus[menuId].items[itemIndex].items) { + if (this.menus[menuId].items[itemIndex].items.hasOwnProperty(subitemIndex)) { + if (this.menus[menuId].items[itemIndex].items[subitemIndex].state === submenuItemState) { + this.menus[menuId].items[itemIndex].items.splice(subitemIndex, 1); + } + } } } } @@ -166,7 +174,7 @@ angular.module('core').service('Menus', [ return this.menus[menuId]; }; - //Adding the topbar menu + // Adding the topbar menu this.addMenu('topbar', { roles: ['*'] }); diff --git a/modules/core/tests/client/header.client.controller.tests.js b/modules/core/tests/client/header.client.controller.tests.js index 569e3c6e82..44c40e075a 100644 --- a/modules/core/tests/client/header.client.controller.tests.js +++ b/modules/core/tests/client/header.client.controller.tests.js @@ -2,7 +2,7 @@ (function () { describe('HeaderController', function () { - //Initialize global variables + // Initialize global variables var scope, HeaderController, $state, @@ -61,4 +61,4 @@ }); }); }); -})(); +}()); diff --git a/modules/core/tests/client/home.client.controller.tests.js b/modules/core/tests/client/home.client.controller.tests.js index b6db0cb919..abc8853db2 100644 --- a/modules/core/tests/client/home.client.controller.tests.js +++ b/modules/core/tests/client/home.client.controller.tests.js @@ -2,7 +2,7 @@ (function () { describe('HomeController', function () { - //Initialize global variables + // Initialize global variables var scope, HomeController; @@ -21,4 +21,4 @@ expect(scope.authentication).toBeTruthy(); }); }); -})(); +}()); diff --git a/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js b/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js index 2eecd4617a..33eb0b8c7b 100644 --- a/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js +++ b/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js @@ -2,7 +2,7 @@ (function() { describe('authInterceptor', function() { - //Initialize global variables + // Initialize global variables var authInterceptor, $q, $state, @@ -12,7 +12,7 @@ // Load the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); - //Load httpProvider + // Load httpProvider beforeEach(module(function($httpProvider) { httpProvider = $httpProvider; })); @@ -22,8 +22,8 @@ $q = _$q_; $state = _$state_; Authentication = _Authentication_; - spyOn($q,'reject'); - spyOn($state,'transitionTo'); + spyOn($q, 'reject'); + spyOn($state, 'transitionTo'); })); it('Auth Interceptor should be object', function() { @@ -63,4 +63,4 @@ }); }); }); -})(); +}()); diff --git a/modules/core/tests/client/menus.client.service.tests.js b/modules/core/tests/client/menus.client.service.tests.js index 4482a5df06..5fba104c02 100644 --- a/modules/core/tests/client/menus.client.service.tests.js +++ b/modules/core/tests/client/menus.client.service.tests.js @@ -2,7 +2,7 @@ (function() { describe('Menus', function() { - //Initialize global variables + // Initialize global variables var scope, Menus; @@ -405,21 +405,21 @@ expect(subItem2.position).toBe(0); }); }); - + describe('then removeSubMenuItem', function() { beforeEach(function() { Menus.validateMenuExistance = jasmine.createSpy(); menu = Menus.removeSubMenuItem(menuId, subItem1.state); }); - + it('should validate menu existance', function() { expect(Menus.validateMenuExistance).toHaveBeenCalledWith(menuId); }); - + it('should return menu object', function() { expect(menu).toBeDefined(); }); - + it('should remove sub menu item', function() { expect(menuItem1.items.length).toBe(1); expect(menuItem1.items[0].state).toEqual(subItem2.state); @@ -427,4 +427,4 @@ }); }); }); -})(); +}()); diff --git a/modules/core/tests/client/socket.io.client.service.tests.js b/modules/core/tests/client/socket.io.client.service.tests.js index ccf22053b1..02def5d065 100644 --- a/modules/core/tests/client/socket.io.client.service.tests.js +++ b/modules/core/tests/client/socket.io.client.service.tests.js @@ -40,4 +40,4 @@ }; $window.io = mock; -})(); +}()); diff --git a/modules/core/tests/server/core.server.config.tests.js b/modules/core/tests/server/core.server.config.tests.js index afc6e4f08d..310441dc72 100644 --- a/modules/core/tests/server/core.server.config.tests.js +++ b/modules/core/tests/server/core.server.config.tests.js @@ -17,7 +17,11 @@ var _ = require('lodash'), /** * Globals */ -var user1, admin1, userFromSeedConfig, adminFromSeedConfig, originalLogConfig; +var user1, + admin1, + userFromSeedConfig, + adminFromSeedConfig, + originalLogConfig; describe('Configuration Tests:', function () { @@ -308,7 +312,7 @@ describe('Configuration Tests:', function () { seed .start({ logResults: false }) .then(function () { - // we don't ever expect to make it here but we don't want to timeout + // we don't ever expect to make it here but we don't want to timeout User.remove(function(err) { should.not.exist(err); // force this test to fail since we should never be here @@ -461,7 +465,7 @@ describe('Configuration Tests:', function () { it('should use the default log format of "combined" when an invalid format was provided', function () { // manually set the config log format to be invalid config.log = { - format: '_some_invalid_format_' + format: '_some_invalid_format_' }; var format = logger.getFormat(); @@ -568,7 +572,7 @@ describe('Configuration Tests:', function () { var _dir = process.cwd() + '/temp-rotating-logs'; var _filename = 'unit-test-rotating-access-%DATE%.log'; - // enable rotating logs + // enable rotating logs config.log = { format: 'combined', options: { diff --git a/modules/users/client/config/users-admin.client.menus.js b/modules/users/client/config/users-admin.client.menus.js index 6e5e18c4e6..76d1b16ca0 100644 --- a/modules/users/client/config/users-admin.client.menus.js +++ b/modules/users/client/config/users-admin.client.menus.js @@ -14,4 +14,4 @@ state: 'admin.users' }); } -})(); +}()); diff --git a/modules/users/client/config/users-admin.client.routes.js b/modules/users/client/config/users-admin.client.routes.js index 04f0d57bb9..7f7db38f75 100644 --- a/modules/users/client/config/users-admin.client.routes.js +++ b/modules/users/client/config/users-admin.client.routes.js @@ -52,4 +52,4 @@ }).$promise; } } -})(); +}()); diff --git a/modules/users/client/config/users.client.routes.js b/modules/users/client/config/users.client.routes.js index a246a3cf77..6840de883f 100644 --- a/modules/users/client/config/users.client.routes.js +++ b/modules/users/client/config/users.client.routes.js @@ -125,4 +125,4 @@ } }); } -})(); +}()); diff --git a/modules/users/client/controllers/admin/list-users.client.controller.js b/modules/users/client/controllers/admin/list-users.client.controller.js index cd0fa74df6..a9fc9cbbbb 100644 --- a/modules/users/client/controllers/admin/list-users.client.controller.js +++ b/modules/users/client/controllers/admin/list-users.client.controller.js @@ -39,4 +39,4 @@ vm.figureOutItemsToDisplay(); } } -})(); +}()); diff --git a/modules/users/client/controllers/admin/user.client.controller.js b/modules/users/client/controllers/admin/user.client.controller.js index 95a5c7c7b9..7c0d491fbd 100644 --- a/modules/users/client/controllers/admin/user.client.controller.js +++ b/modules/users/client/controllers/admin/user.client.controller.js @@ -47,4 +47,4 @@ }); } } -})(); +}()); diff --git a/modules/users/client/controllers/authentication.client.controller.js b/modules/users/client/controllers/authentication.client.controller.js index ac13c46fda..e2f820cf82 100644 --- a/modules/users/client/controllers/authentication.client.controller.js +++ b/modules/users/client/controllers/authentication.client.controller.js @@ -74,4 +74,4 @@ $window.location.href = url; } } -})(); +}()); diff --git a/modules/users/client/controllers/password.client.controller.js b/modules/users/client/controllers/password.client.controller.js index 3656a4d063..4162d903fb 100644 --- a/modules/users/client/controllers/password.client.controller.js +++ b/modules/users/client/controllers/password.client.controller.js @@ -66,4 +66,4 @@ }); } } -})(); +}()); diff --git a/modules/users/client/controllers/settings/change-password.client.controller.js b/modules/users/client/controllers/settings/change-password.client.controller.js index d1cabc03fc..94ef2dda6e 100644 --- a/modules/users/client/controllers/settings/change-password.client.controller.js +++ b/modules/users/client/controllers/settings/change-password.client.controller.js @@ -34,4 +34,4 @@ }); } } -})(); +}()); diff --git a/modules/users/client/controllers/settings/change-profile-picture.client.controller.js b/modules/users/client/controllers/settings/change-profile-picture.client.controller.js index 6c5f75432d..5f5afd8931 100644 --- a/modules/users/client/controllers/settings/change-profile-picture.client.controller.js +++ b/modules/users/client/controllers/settings/change-profile-picture.client.controller.js @@ -83,4 +83,4 @@ vm.imageURL = vm.user.profileImageURL; } } -})(); +}()); diff --git a/modules/users/client/controllers/settings/edit-profile.client.controller.js b/modules/users/client/controllers/settings/edit-profile.client.controller.js index 0d6b2d7c1d..739146b09b 100644 --- a/modules/users/client/controllers/settings/edit-profile.client.controller.js +++ b/modules/users/client/controllers/settings/edit-profile.client.controller.js @@ -35,4 +35,4 @@ }); } } -})(); +}()); diff --git a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js index 5e5e3f2e06..f6411a43af 100644 --- a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js +++ b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js @@ -16,12 +16,8 @@ vm.removeUserSocialAccount = removeUserSocialAccount; // Check if there are additional accounts - function hasConnectedAdditionalSocialAccounts(provider) { - for (var i in vm.user.additionalProvidersData) { - return true; - } - - return false; + function hasConnectedAdditionalSocialAccounts() { + return ($scope.user.additionalProvidersData && Object.keys($scope.user.additionalProvidersData).length); } // Check if provider is already in use with current user @@ -46,4 +42,4 @@ }); } } -})(); +}()); diff --git a/modules/users/client/controllers/settings/settings.client.controller.js b/modules/users/client/controllers/settings/settings.client.controller.js index 7f637e1ff2..106cc071fa 100644 --- a/modules/users/client/controllers/settings/settings.client.controller.js +++ b/modules/users/client/controllers/settings/settings.client.controller.js @@ -12,4 +12,4 @@ vm.user = Authentication.user; } -})(); +}()); diff --git a/modules/users/client/directives/password-validator.client.directive.js b/modules/users/client/directives/password-validator.client.directive.js index 1825311e89..c81a8209b1 100644 --- a/modules/users/client/directives/password-validator.client.directive.js +++ b/modules/users/client/directives/password-validator.client.directive.js @@ -61,4 +61,4 @@ }; } } -})(); +}()); diff --git a/modules/users/client/directives/password-verify.client.directive.js b/modules/users/client/directives/password-verify.client.directive.js index ae594a71f6..2f2e9fe95b 100644 --- a/modules/users/client/directives/password-verify.client.directive.js +++ b/modules/users/client/directives/password-verify.client.directive.js @@ -28,10 +28,10 @@ if (value) { ngModel.$validators.passwordVerify = function (password) { var origin = scope.passwordVerify; - return (origin !== password) ? false : true; + return (origin === password); }; } }); } } -})(); +}()); diff --git a/modules/users/client/directives/users.client.directive.js b/modules/users/client/directives/users.client.directive.js index a48202e56f..836f0c20b4 100644 --- a/modules/users/client/directives/users.client.directive.js +++ b/modules/users/client/directives/users.client.directive.js @@ -21,4 +21,4 @@ element.css('text-transform', 'lowercase'); } } -})(); +}()); diff --git a/modules/users/client/services/authentication.client.service.js b/modules/users/client/services/authentication.client.service.js index b36d5ef0ee..9e6b83d663 100644 --- a/modules/users/client/services/authentication.client.service.js +++ b/modules/users/client/services/authentication.client.service.js @@ -16,4 +16,4 @@ return auth; } -})(); +}()); diff --git a/modules/users/client/services/password-validator.client.service.js b/modules/users/client/services/password-validator.client.service.js index ac0f4bce8e..d163558697 100644 --- a/modules/users/client/services/password-validator.client.service.js +++ b/modules/users/client/services/password-validator.client.service.js @@ -30,4 +30,4 @@ } } -})(); +}()); diff --git a/modules/users/client/services/users.client.service.js b/modules/users/client/services/users.client.service.js index 17d1947dce..8037afbf3f 100644 --- a/modules/users/client/services/users.client.service.js +++ b/modules/users/client/services/users.client.service.js @@ -16,8 +16,7 @@ }); } - - //TODO this should be Users service + // TODO this should be Users service angular .module('users.admin.services') .factory('AdminService', AdminService); @@ -33,4 +32,4 @@ } }); } -})(); +}()); diff --git a/modules/users/client/users.client.module.js b/modules/users/client/users.client.module.js index e4a39a52ab..6fdf361104 100644 --- a/modules/users/client/users.client.module.js +++ b/modules/users/client/users.client.module.js @@ -7,4 +7,4 @@ app.registerModule('users.admin.services'); app.registerModule('users.routes', ['ui.router']); app.registerModule('users.admin.routes', ['ui.router', 'users.admin.services']); -})(ApplicationConfiguration); +}(ApplicationConfiguration)); diff --git a/modules/users/server/controllers/admin.server.controller.js b/modules/users/server/controllers/admin.server.controller.js index c4e7bf9d5d..46fc41d4b9 100644 --- a/modules/users/server/controllers/admin.server.controller.js +++ b/modules/users/server/controllers/admin.server.controller.js @@ -21,7 +21,7 @@ exports.read = function (req, res) { exports.update = function (req, res) { var user = req.model; - //For security purposes only merge these parameters + // For security purposes only merge these parameters user.firstName = req.body.firstName; user.lastName = req.body.lastName; user.displayName = user.firstName + ' ' + user.lastName; diff --git a/modules/users/server/controllers/users/users.profile.server.controller.js b/modules/users/server/controllers/users/users.profile.server.controller.js index 51677303e2..8dbd740a9e 100644 --- a/modules/users/server/controllers/users/users.profile.server.controller.js +++ b/modules/users/server/controllers/users/users.profile.server.controller.js @@ -57,13 +57,13 @@ exports.changeProfilePicture = function (req, res) { var user = req.user; var upload = multer(config.uploads.profileUpload).single('newProfilePicture'); var profileUploadFileFilter = require(path.resolve('./config/lib/multer')).profileUploadFileFilter; - + // Filtering to upload only images upload.fileFilter = profileUploadFileFilter; if (user) { upload(req, res, function (uploadError) { - if(uploadError) { + if (uploadError) { return res.status(400).send({ message: 'Error occurred while uploading profile picture' }); diff --git a/modules/users/server/models/user.server.model.js b/modules/users/server/models/user.server.model.js index c92647a6ae..f00e9500e2 100644 --- a/modules/users/server/models/user.server.model.js +++ b/modules/users/server/models/user.server.model.js @@ -186,7 +186,7 @@ UserSchema.statics.generateRandomPassphrase = function () { numbers: true, symbols: false, uppercase: true, - excludeSimilarCharacters: true, + excludeSimilarCharacters: true }); // check if we need to remove any repeating characters diff --git a/modules/users/tests/client/users-admin.client.routes.tests.js b/modules/users/tests/client/users-admin.client.routes.tests.js index 0a3f5ce8c2..e462f66349 100644 --- a/modules/users/tests/client/users-admin.client.routes.tests.js +++ b/modules/users/tests/client/users-admin.client.routes.tests.js @@ -6,7 +6,7 @@ var $scope, Authentication; - //We can start by loading the main application module + // We can start by loading the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). @@ -98,4 +98,4 @@ }); }); -})(); +}()); diff --git a/modules/users/tests/client/users.client.routes.tests.js b/modules/users/tests/client/users.client.routes.tests.js index 0861de02e3..daf21c2c59 100644 --- a/modules/users/tests/client/users.client.routes.tests.js +++ b/modules/users/tests/client/users.client.routes.tests.js @@ -6,7 +6,7 @@ var $scope, Authentication; - //We can start by loading the main application module + // We can start by loading the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). @@ -316,4 +316,4 @@ }); }); -})(); +}()); diff --git a/modules/users/tests/e2e/users.e2e.tests.js b/modules/users/tests/e2e/users.e2e.tests.js index 51be35ccc2..aab8cc6fcc 100644 --- a/modules/users/tests/e2e/users.e2e.tests.js +++ b/modules/users/tests/e2e/users.e2e.tests.js @@ -299,9 +299,9 @@ describe('Users E2E Tests:', function () { describe('Signin Validation', function () { it('Should report missing credentials', function () { - //Make sure user is signed out first + // Make sure user is signed out first signout(); - //Sign in + // Sign in browser.get('http://localhost:3001/authentication/signin'); // Click Submit button element(by.css('button[type="submit"]')).click(); @@ -312,9 +312,9 @@ describe('Users E2E Tests:', function () { }); it('Verify that the user is logged in', function() { - //Make sure user is signed out first + // Make sure user is signed out first signout(); - //Sign in + // Sign in browser.get('http://localhost:3001/authentication/signin'); // Enter UserName element(by.model('vm.credentials.username')).sendKeys(user1.username); @@ -327,7 +327,7 @@ describe('Users E2E Tests:', function () { }); - describe ('Change Password Settings Validation', function () { + describe('Change Password Settings Validation', function () { it('Should report missing passwords', function () { browser.get('http://localhost:3001/settings/password'); diff --git a/modules/users/tests/server/user.server.model.tests.js b/modules/users/tests/server/user.server.model.tests.js index a059bf2d8b..07f01766aa 100644 --- a/modules/users/tests/server/user.server.model.tests.js +++ b/modules/users/tests/server/user.server.model.tests.js @@ -10,7 +10,9 @@ var should = require('should'), /** * Globals */ -var user1, user2, user3; +var user1, + user2, + user3; /** * Unit tests diff --git a/modules/users/tests/server/user.server.routes.tests.js b/modules/users/tests/server/user.server.routes.tests.js index 5d57c65e3b..2d59d4d3a7 100644 --- a/modules/users/tests/server/user.server.routes.tests.js +++ b/modules/users/tests/server/user.server.routes.tests.js @@ -10,7 +10,12 @@ var should = require('should'), /** * Globals */ -var app, agent, credentials, user, _user, admin; +var app, + agent, + credentials, + user, + _user, + admin; /** * User routes tests @@ -254,7 +259,7 @@ describe('User CRUD tests', function () { } agent.delete('/api/users/' + user._id) - //.send(userUpdate) + // .send(userUpdate) .expect(200) .end(function (userInfoErr, userInfoRes) { if (userInfoErr) { @@ -631,7 +636,7 @@ describe('User CRUD tests', function () { var userUpdate = { firstName: 'user_update_first', - lastName: 'user_update_last', + lastName: 'user_update_last' }; agent.put('/api/users') @@ -811,7 +816,7 @@ describe('User CRUD tests', function () { var userUpdate = { firstName: 'user_update_first', - lastName: 'user_update_last', + lastName: 'user_update_last' }; agent.put('/api/users') diff --git a/package.json b/package.json index 1276ac0286..ca32a53fe8 100644 --- a/package.json +++ b/package.json @@ -68,17 +68,18 @@ }, "devDependencies": { "coveralls": "~2.11.6", + "eslint": "~2.2.0", + "eslint-config-airbnb": "~6.0.2", "grunt-concurrent": "~2.0.0", "grunt-contrib-copy": "~0.8.0", "grunt-contrib-csslint": "~0.4.0", "grunt-contrib-cssmin": "~0.12.3", - "grunt-contrib-jshint": "~0.11.2", "grunt-contrib-less": "~1.0.1", "grunt-contrib-sass": "~0.9.2", "grunt-contrib-uglify": "~0.9.1", "grunt-contrib-watch": "~0.6.1", "grunt-env": "~0.4.4", - "grunt-eslint": "~17.3.1", + "grunt-eslint": "~18.0.0", "grunt-karma": "~0.12.1", "grunt-mocha-istanbul": "~2.4.0", "grunt-mocha-test": "~0.12.7", @@ -95,7 +96,6 @@ "gulp-cssmin": "~0.1.7", "gulp-eslint": "~2.0.0", "gulp-imagemin": "~2.4.0", - "gulp-jshint": "~2.0.0", "gulp-less": "~3.0.5", "gulp-livereload": "~3.8.1", "gulp-load-plugins": "~1.2.0", @@ -109,7 +109,6 @@ "gulp-util": "~3.0.7", "imagemin-pngquant": "~4.2.0", "istanbul": "~0.4.2", - "jshint": "~2.9.1", "karma": "~0.13.21", "karma-chrome-launcher": "~0.2.2", "karma-coverage": "~0.5.3", diff --git a/scripts/reset-password.js b/scripts/reset-password.js index b88cd2fd17..6316a94613 100755 --- a/scripts/reset-password.js +++ b/scripts/reset-password.js @@ -81,7 +81,14 @@ mg.connect(function (db) { if (processedCount === 0) { console.log(chalk.yellow('No users were found.')); } else { - var alert = (!errorCount) ? chalk.green : ((successCount / processedCount) < 0.8) ? chalk.red : chalk.yellow; + var alert; + if (!errorCount) { + alert = chalk.green; + } else if ((successCount / processedCount) < 0.8) { + alert = chalk.red; + } else { + alert = chalk.yellow; + } console.log(alert('Sent ' + successCount + ' of ' + processedCount + ' emails successfully.')); } diff --git a/test.js b/test.js index daf3386e1f..e44bf389ae 100644 --- a/test.js +++ b/test.js @@ -3,7 +3,6 @@ /** * Module dependencies. */ -var app; var path = require('path'); var app = require(path.resolve('./config/lib/app'));