Skip to content

Commit

Permalink
Add eslint rule "no-unused-vars" and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
simison committed Aug 10, 2016
1 parent 832cab8 commit fa04c41
Show file tree
Hide file tree
Showing 72 changed files with 210 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
'no-unreachable': 2,
'no-underscore-dangle': 0,
'no-unused-expressions': 0,
'no-unused-vars': 0,
'no-unused-vars': 2,
'no-use-before-define': [1, 'nofunc'],
'no-var': 0,
'object-curly-spacing': [2, 'always'],
Expand Down
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var validateEnvironmentVariable = function() {
/**
* Initialize global configuration files
*/
var initGlobalConfigFolders = function(config, assets) {
var initGlobalConfigFolders = function(config) {
// Appending files
config.folders = {
server: {},
Expand Down
6 changes: 3 additions & 3 deletions config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ module.exports.initSEO = function (app) {
* Configure Agenda "Cron" jobs
* @link https://www.npmjs.com/package/agenda
*/
module.exports.initAgenda = function (app, db) {
module.exports.initAgenda = function () {

// Don't launch Agenda on test environment
// @todo: make it possible to launch this manually with very small interwalls for testing
Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports.initAgenda = function (app, db) {
});

// Error reporting
agendaWorker.on('fail', function(err, job) {
agendaWorker.on('fail', function(err) {
console.error('Agenda job failed with error: %s', err.message || 'Unknown error');
});
};
Expand All @@ -265,7 +265,7 @@ module.exports.initModulesClientRoutes = function (app) {
/**
* Configure the modules ACL policies
*/
module.exports.initModulesServerPolicies = function (app) {
module.exports.initModulesServerPolicies = function () {
// Globbing policy files
config.files.server.policies.forEach(function (policyPath) {
require(path.resolve(policyPath)).invokeRolesPolicies();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
function() {
// User exists
},
function(error) {
function() {
vm.isConnected = true;
vm.error = 'User does not exist.';
}
Expand All @@ -62,7 +62,7 @@
function add() {
vm.isLoading = true;

vm.contact.$save(function(response) {
vm.contact.$save(function() {
vm.isLoading = false;
vm.isConnected = true;
vm.success = 'Done! We sent an email to your contact and he/she still needs to confirm it.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// First fetch contact object, just to make it sure it exists
vm.contact.$promise.then(
// Got contact
function(contact) {
function() {
vm.isLoading = false;
if (vm.contact.confirmed === true) {
vm.isConnected = true;
Expand All @@ -43,7 +43,7 @@
function confirmContact() {
vm.isLoading = true;
vm.contact.confirm = true;
vm.contact.$update(function(response) {
vm.contact.$update(function() {
vm.isLoading = false;
vm.isConnected = true;
vm.success = 'You two are now connected!';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
scope: {
contactToRemove: '=trContactRemove'
},
link: function(scope, element, attrs) {
link: function(scope, element) {

function openModal() {
$uibModal.open({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

describe('ContactAddController', function() {
// Initialize global variables
var $templateCache,
$httpBackend,
var $httpBackend,
Authentication,
UsersMini,
ContactByService,
Expand Down
9 changes: 3 additions & 6 deletions modules/contacts/tests/client/contacts.client.routes.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

describe('Contact Route Tests', function () {
// Initialize global variables
var $scope,
$httpBackend;
var $httpBackend;

// We can start by loading the main application module
beforeEach(module(AppConfig.appModuleName));
Expand All @@ -13,8 +12,6 @@
// This allows us to inject a service but then attach it to a variable
// with the same name as the service.
beforeEach(inject(function ($rootScope, _$httpBackend_) {
// Set a new global scope
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
}));

Expand Down Expand Up @@ -44,7 +41,7 @@
});

describe('Handle Trailing Slash', function () {
beforeEach(inject(function ($state, $rootScope, $templateCache, _Authentication_) {
beforeEach(inject(function ($state, $rootScope, $templateCache) {
// Test expected GET request
$templateCache.put('/modules/contacts/views/add-contact.client.view.html', '');
$httpBackend.when('GET', '/api/contact-by/123').respond(200, '');
Expand Down Expand Up @@ -90,7 +87,7 @@
});

describe('Handle Trailing Slash', function () {
beforeEach(inject(function ($state, $rootScope, $templateCache, _Authentication_) {
beforeEach(inject(function ($state, $rootScope, $templateCache) {
// Test expected GET request
$templateCache.put('/modules/contacts/views/confirm-contact.client.view.html', '');
$httpBackend.when('GET', '/api/contact/123').respond(200, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
// Load the main application module
beforeEach(module(AppConfig.appModuleName));

beforeEach(inject(function($templateCache, _$httpBackend_, _Authentication_, _$rootScope_, _messageCenterService_) {
beforeEach(inject(function(_$templateCache_, _$httpBackend_, _Authentication_, _$rootScope_, _messageCenterService_) {
$templateCache = _$templateCache_;
$httpBackend = _$httpBackend_;
Authentication = _Authentication_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Contact Model Unit Tests:', function() {
it('should be able to show an error when try to save without users', function(done) {
contact.users = '';

return contact.save(function(err, res) {
return contact.save(function(err) {
should.exist(err);
done();
});
Expand Down
24 changes: 14 additions & 10 deletions modules/contacts/tests/server/contact.server.routes.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ var app,
contact1,
contact2,
contact3,
contact1Id,
contact2Id,
contact3Id;
contact1Id;

/**
* Contact routes tests
Expand Down Expand Up @@ -126,22 +124,27 @@ describe('Contact CRUD tests', function() {

// Save user to the test db
user1.save(function(err, user1SaveRes) {
should.not.exist(err);
user1Id = user1SaveRes._id;
user2.save(function(err, user2SaveRes) {
should.not.exist(err);
user2Id = user2SaveRes._id;
user3.save(function(err, user3SaveRes) {
should.not.exist(err);
user3Id = user3SaveRes._id;
user4.save(function(err, user4SaveRes) {
should.not.exist(err);
user4Id = user4SaveRes._id;
contact1.users = [user1Id, user2Id]; // Connection A: Users 1+2, un-confirmed
contact2.users = [user2Id, user3Id]; // Connection B: Users 2+3, confirmed
contact3.users = [user1Id, user3Id]; // Connection C: Users 1+3, confirmed
contact1.save(function(err, contact1SaveRes) {
should.not.exist(err);
contact1Id = contact1SaveRes._id;
contact2.save(function(err, contact2SaveRes) {
contact2Id = contact2SaveRes._id;
contact3.save(function(err, contact3SaveRes) {
contact3Id = contact3SaveRes._id;
contact2.save(function(err) {
should.not.exist(err);
contact3.save(function(err) {
should.not.exist(err);
return done();
});
});
Expand Down Expand Up @@ -197,7 +200,7 @@ describe('Contact CRUD tests', function() {
agent.post('/api/auth/signin')
.send(credentials) // = user 1
.expect(200)
.end(function(signinErr, signinRes) {
.end(function(signinErr) {
done(signinErr);
});

Expand Down Expand Up @@ -321,7 +324,7 @@ describe('Contact CRUD tests', function() {
agent.post('/api/contact')
.send({ friendUserId: user2Id })
.expect(409)
.end(function(contactAddErr, contactAddRes) {
.end(function(contactAddErr) {
// Handle contact add error
if (contactAddErr) return done(contactAddErr);
return done();
Expand Down Expand Up @@ -353,7 +356,8 @@ describe('Contact CRUD tests', function() {
it('should be able to delete contact', function(done) {
agent.delete('/api/contact/' + contact1Id)
.expect(200)
.end(function(contactDelErr, contactDelRes) {
.end(function(contactDelErr) {

// Handle contact del error
if (contactDelErr) return done(contactDelErr);

Expand Down
1 change: 1 addition & 0 deletions modules/core/client/app/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

// Init the application configuration module for AngularJS application
// eslint-disable-next-line no-unused-vars
var AppConfig = (function () {
// Init module configuration options
var appEnv = window.env || 'production';
Expand Down
4 changes: 2 additions & 2 deletions modules/core/client/controllers/app.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
/**
* Before page change
*/
$scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
$scope.$on('$stateChangeStart', function(event, toState, toParams) {

// Redirect to login page if no user
if (toState.requiresAuth && !Authentication.user) {
Expand Down Expand Up @@ -117,7 +117,7 @@
/**
* After page change
*/
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
$scope.$on('$stateChangeSuccess', function(event, toState) {

// Set page title
vm.pageTitle = (toState.title) ? toState.title + ' - ' + $window.title : $window.title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
vm.isHidden = false;

// Changing footer styles/contents after navigation
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
$scope.$on('$stateChangeSuccess', function(event, toState) {

// Footer is transparent on these pages
vm.isTransparent = (angular.isDefined(toState.footerTransparent) && toState.footerTransparent === true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function activate() {

// Perform actions at page change
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
$scope.$on('$stateChangeSuccess', function(event, toState) {

// Collapsing the menu after navigation
vm.isCollapsed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
scope: {
trBoards: '='
},
link: function(scope, elem, attr) {
link: function(scope, elem) {

// If requested photo is missing or request is invalid, rely on this photo
var defaultPhoto = 'bokeh';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

// On ctrl+enter
if (iAttrs.trEditorOnCtrlEnter) {
ngModel.editor.subscribe('editableKeydownEnter', function (event, editable) {
ngModel.editor.subscribe('editableKeydownEnter', function (event) {
if (event.ctrlKey) {
event.preventDefault();
// Apply linked function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
' <p class="tr-flashcards-title" ng-bind="::flashTitle"></p>' +
' <p class="tr-flashcards-content" ng-bind="::flashContent"></p>' +
'</a>',
link: function(scope, iElement, iAttrs) {
link: function(scope) {

var flashcards = [{
title: 'Make sure your profile is complete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
.directive('trFocustip', trFocustipDirective);

/* @ngInject */
function trFocustipDirective($compile, $timeout) {
function trFocustipDirective($compile) {
return {
restrict: 'A',
replace: false,
scope: {
trFocustip: '='
},
link: function(scope, element, attrs, ctrl) {
link: function(scope, element) {

// Compiled template
// after() requires jQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/**
* When selecting autosuggested location
*/
function onSelect($item, $model, $label, $event) {
function onSelect($item, $model, $label) {
$timeout(function() {
$scope.value = $label;
});
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/directives/tr-time.client.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
trTime: '@',
trTimeTooltipPlacement: '@'
},
link: function(scope, el, attrs, ctrl) {
link: function(scope, element, attrs) {

if (!scope.trTime) {
$log.warn('No time passed for tr-time directive.');
Expand Down
3 changes: 1 addition & 2 deletions modules/core/client/services/location.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@
* @return String
*/
function shortTitle(geolocation) {
var title = '',
titlePostfix = null;
var title = '';

if (geolocation.text) {
title = geolocation.text;
Expand Down
11 changes: 4 additions & 7 deletions modules/core/tests/client/app.client.controller.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

describe('App Controller Tests', function () {
// Initialize global variables
var AppController,
$scope,
$window,
var $scope,
$state,
Authentication,
SettingsFactory,
Expand All @@ -17,15 +15,14 @@
// Load the main application module
beforeEach(module(AppConfig.appModuleName));

beforeEach(inject(function ($controller, $rootScope, _$window_, _$state_, _Authentication_, _SettingsFactory_, _Languages_) {
beforeEach(inject(function ($controller, $rootScope, _$state_, _Authentication_, _SettingsFactory_, _Languages_) {
$scope = $rootScope.$new();

// Point global variables to injected services
Authentication = _Authentication_;
SettingsFactory = _SettingsFactory_;
Languages = _Languages_;
$state = _$state_;
$window = _$window_;


// Mock logged in user
Expand All @@ -43,7 +40,7 @@

// Mock languages
Languages = {
get: function(type) {
get: function() {
return {};
}
};
Expand All @@ -53,7 +50,7 @@
spyOn($state, 'go');

// Initialize the App controller.
AppController = $controller('AppController as vm', {
$controller('AppController as vm', {
$scope: $scope,
SettingsFactory: SettingsFactory,
Languages: Languages
Expand Down
Loading

0 comments on commit fa04c41

Please sign in to comment.