Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #436 from davidmsibley/eslint-angular-module
Browse files Browse the repository at this point in the history
ESLint angular/module rules
  • Loading branch information
davidmsibley authored May 5, 2017
2 parents 0f00497 + 28628b6 commit b36b7b7
Show file tree
Hide file tree
Showing 34 changed files with 150 additions and 227 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@
],
"angular/controller-as": "off",

"angular/module-setter": "warn",
"angular/module-getter": "warn",
"max-len": "warn",
"promise/catch-or-return": "warn",
"promise/always-return": "warn",
Expand Down
6 changes: 1 addition & 5 deletions uw-frame-components/js/app-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
define(['angular'], function(angular) {
/* Keep in sync with docs/markdown/configuration.md*/

var config = angular.module('app-config', []);
config
return angular.module('app-config', [])
.value('APP_FLAGS', {
'showSearch': true,
'isWeb': false,
Expand Down Expand Up @@ -70,6 +68,4 @@ define(['angular'], function(angular) {
'description': 'This is just an example of a toggle. Look at your localStorage after you switch this on for the first time.',
},
]);

return config;
});
5 changes: 1 addition & 4 deletions uw-frame-components/js/frame-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
define(['angular'], function(angular) {
var config = angular.module('frame-config', []);
config
return angular.module('frame-config', [])
.constant('THEMES',
{'themeVersion': 7,
/* THOU SHALT INCREMENT THIS VERSION NUMBER IF THOU CHANGEST ANY OF THE THEMES BELOW */
Expand Down Expand Up @@ -1028,6 +1027,4 @@ define(['angular'], function(angular) {
'description': 'This flag disables announcement group filtering if you have it enabled (page refresh required)',
},
]);

return config;
});
7 changes: 1 addition & 6 deletions uw-frame-components/js/override.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
define(['angular'], function(angular) {
/* Keep in sync with docs/markdown/configuration.md*/

var config = angular.module('override', []);
config
// see configuration.md for howto
return angular.module('override', [])
.constant('OVERRIDE', {

});

return config;
});
2 changes: 1 addition & 1 deletion uw-frame-components/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
require(['./config'], function(config) {
// eslint-disable-next-line angular/module-getter
require.config(config);

require(['angular', 'my-app'], function(angular) {
angular.bootstrap(document, ['my-app']);
});
});

15 changes: 2 additions & 13 deletions uw-frame-components/my-app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@ define(['angular',
'portal/about/route',
'portal/widgets/routes',
], function(angular, $, portal, main, settings, notifications, features, about, widgets) {
/*
This module intentionally left empty. This file is intended to serve as an extension point
for My UW Madison 'App' developers that overlay angularjs-portal-frame.
For more information, see: https://github.com/UW-Madison-DoIT/my-app-seed
*/
var app = angular.module('my-app', ['portal']);

// Example route configuration
// TODO: Think of a more extensible approach such that frame and app can each manage their own routing without conflict
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
return angular.module('my-app', ['portal'])
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/settings', settings.betaSettings).
Expand All @@ -33,6 +24,4 @@ define(['angular',
when('/', main.main).
otherwise('/');
}]);

return app;
});
8 changes: 2 additions & 6 deletions uw-frame-components/portal/about/services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

define(['angular'], function(angular) {
var app = angular.module('portal.about.services', []);

app.factory('portalAboutService', ['$http', 'miscService', 'FRAME_URLS', function($http, miscService, FRAME_URLS) {
return angular.module('portal.about.services', [])
.factory('portalAboutService', ['$http', 'miscService', 'FRAME_URLS', function($http, miscService, FRAME_URLS) {
/**
* Gets frame information from generated about-frame.json
**/
Expand All @@ -29,7 +28,4 @@ define(['angular'], function(angular) {
getDetails: getDetails,
};
}]);

return app;
});

11 changes: 4 additions & 7 deletions uw-frame-components/portal/features/controllers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

define(['angular', 'require'], function(angular, require) {
var app = angular.module('portal.features.controllers', []);
angular.module('portal.features.controllers', [])


app.controller('PortalFeaturesController', ['miscService', '$localStorage', '$sessionStorage', '$scope', '$document', 'FEATURES',
.controller('PortalFeaturesController', ['miscService', '$localStorage', '$sessionStorage', '$scope', '$document', 'FEATURES',
'$mdDialog', 'portalFeaturesService', '$sanitize', 'MISC_URLS',
function(miscService, $localStorage, $sessionStorage, $scope, $document, FEATURES, $mdDialog, portalFeaturesService, $sanitize, MISC_URLS) {
$scope.features = [];
Expand All @@ -17,9 +16,9 @@ define(['angular', 'require'], function(angular, require) {
}
});
}
}]);
}])

app.controller('PortalPopupController', ['$localStorage', '$sessionStorage', '$rootScope', '$scope', '$document', 'FEATURES',
.controller('PortalPopupController', ['$localStorage', '$sessionStorage', '$rootScope', '$scope', '$document', 'FEATURES',
'filterFilter', '$filter', '$mdDialog', 'portalFeaturesService', 'miscService', '$sanitize',
function($localStorage, $sessionStorage, $rootScope, $scope, $document, FEATURES, filterFilter, $filter, $mdDialog, portalFeaturesService, miscService, $sanitize) {
// scope functions ---------------------------------------------------------
Expand Down Expand Up @@ -147,6 +146,4 @@ define(['angular', 'require'], function(angular, require) {
// run function -------------------------------------------------------------
init();
}]);

return app;
});
7 changes: 2 additions & 5 deletions uw-frame-components/portal/features/directives.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

define(['angular', 'require'], function(angular, require) {
var app = angular.module('portal.features.directives', []);

app.directive('buckyAnnouncement', function() {
return angular.module('portal.features.directives', [])
.directive('buckyAnnouncement', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/announcement.html'),
Expand All @@ -14,6 +13,4 @@ define(['angular', 'require'], function(angular, require) {
},
};
});

return app;
});
7 changes: 2 additions & 5 deletions uw-frame-components/portal/features/services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

define(['angular'], function(angular) {
var app = angular.module('portal.features.services', []);

app.factory('portalFeaturesService', ['$http',
return angular.module('portal.features.services', [])
.factory('portalFeaturesService', ['$http',
'$q',
'miscService',
'keyValueService',
Expand Down Expand Up @@ -296,6 +295,4 @@ define(['angular'], function(angular) {
getUnseenPopups: getUnseenPopups,
};
}]);

return app;
});
12 changes: 5 additions & 7 deletions uw-frame-components/portal/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
angular.module('angulartics.google.analytics', []);
}

var app = angular.module('portal', [
return angular.module('portal', [
'app-config',
'override',
'frame-config',
Expand Down Expand Up @@ -90,9 +90,9 @@ define([
'ui.sortable',
'angulartics',
'angulartics.google.analytics',
]);
])

app.config(['gravatarServiceProvider', '$analyticsProvider', '$mdThemingProvider', 'THEMES', function(gravatarServiceProvider, $analyticsProvider, $mdThemingProvider, THEMES) {
.config(['gravatarServiceProvider', '$analyticsProvider', '$mdThemingProvider', 'THEMES', function(gravatarServiceProvider, $analyticsProvider, $mdThemingProvider, THEMES) {
gravatarServiceProvider.defaults = {
'default': 'https://yt3.ggpht.com/-xE0EQR3Ngt8/AAAAAAAAAAI/AAAAAAAAAAA/zTofDHA3-s4/s100-c-k-no/photo.jpg',
};
Expand Down Expand Up @@ -156,9 +156,9 @@ define([
}
cur = null;
}
}]);
}])

app.run(function($location,
.run(function($location,
$log,
$http,
$rootScope,
Expand Down Expand Up @@ -401,6 +401,4 @@ define([
};
init();
});

return app;
});
18 changes: 8 additions & 10 deletions uw-frame-components/portal/main/controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

define(['angular', 'require'], function(angular, require) {
var app = angular.module('portal.main.controllers', []);
return angular.module('portal.main.controllers', [])

app.controller('PortalMainController', ['$localStorage', '$sessionStorage', '$scope', '$rootScope', '$document', '$location', 'NAMES', 'MISC_URLS', 'APP_FLAGS', 'THEMES', 'miscService', function($localStorage, $sessionStorage, $scope, $rootScope, $document, $location, NAMES, MISC_URLS, APP_FLAGS, THEMES, miscService) {
.controller('PortalMainController', ['$localStorage', '$sessionStorage', '$scope', '$rootScope', '$document', '$location', 'NAMES', 'MISC_URLS', 'APP_FLAGS', 'THEMES', 'miscService', function($localStorage, $sessionStorage, $scope, $rootScope, $document, $location, NAMES, MISC_URLS, APP_FLAGS, THEMES, miscService) {
var defaults = {
layoutMode: 'list', // other option is 'widgets
};
Expand Down Expand Up @@ -72,10 +72,10 @@ define(['angular', 'require'], function(angular, require) {

// run init
init();
}]);
}])

/* Username */
app.controller('SessionCheckController', ['$scope', 'mainService', 'NAMES', 'FOOTER_URLS', '$rootScope', function($scope, mainService, NAMES, FOOTER_URLS, $rootScope) {
.controller('SessionCheckController', ['$scope', 'mainService', 'NAMES', 'FOOTER_URLS', '$rootScope', function($scope, mainService, NAMES, FOOTER_URLS, $rootScope) {
var vm = this;
vm.user = [];
vm.firstLetter = '';
Expand All @@ -98,10 +98,10 @@ define(['angular', 'require'], function(angular, require) {
}
}
});
}]);
}])

/* Header */
app.controller('PortalHeaderController', ['$rootScope', '$scope', '$location', 'NAMES', 'APP_FLAGS', 'MISC_URLS', 'notificationsService', function($rootScope, $scope, $location, NAMES, APP_FLAGS, MISC_URLS, notificationsService) {
.controller('PortalHeaderController', ['$rootScope', '$scope', '$location', 'NAMES', 'APP_FLAGS', 'MISC_URLS', 'notificationsService', function($rootScope, $scope, $location, NAMES, APP_FLAGS, MISC_URLS, notificationsService) {
var vm = this;
vm.navbarCollapsed = true;
vm.showLogout = true;
Expand All @@ -119,12 +119,10 @@ define(['angular', 'require'], function(angular, require) {
$scope.showSearch = false;
vm.navbarCollapsed = !vm.navbarCollapsed;
};
}]);
}])

/* Footer */
app.controller('PortalFooterController', ['$scope', function($scope) {
.controller('PortalFooterController', ['$scope', function($scope) {
$scope.date = new Date();
}]);

return app;
});
26 changes: 12 additions & 14 deletions uw-frame-components/portal/main/directives.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
'use strict';

define(['angular', 'require'], function(angular, require) {
var app = angular.module('portal.main.directives', []);
return angular.module('portal.main.directives', [])

app.directive('uwBody', function() {
.directive('uwBody', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/body.html'),
controller: 'PortalMainController',
};
});
})

app.directive('portalHeader', function() {
.directive('portalHeader', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/header.html'),
};
});
})

app.directive('sideBarMenu', function() {
.directive('sideBarMenu', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/sidebar-left.html'),
};
});
})

app.directive('username', function() {
.directive('username', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/username.html'),
};
});
})

app.directive('siteFooter', function() {
.directive('siteFooter', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/footer.html'),
};
});
})

app.directive('featuresModalTemplate', function() {
.directive('featuresModalTemplate', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/features-dialog-template.html'),
};
});

return app;
});
6 changes: 2 additions & 4 deletions uw-frame-components/portal/main/services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

define(['angular'], function(angular) {
var app = angular.module('portal.main.services', []);
return angular.module('portal.main.services', [])

app.factory('mainService', ['$http', '$log', '$sessionStorage', 'miscService', 'SERVICE_LOC', 'APP_FLAGS', function($http, $log, $sessionStorage, miscService, SERVICE_LOC, APP_FLAGS) {
.factory('mainService', ['$http', '$log', '$sessionStorage', 'miscService', 'SERVICE_LOC', 'APP_FLAGS', function($http, $log, $sessionStorage, miscService, SERVICE_LOC, APP_FLAGS) {
var prom = $http.get(SERVICE_LOC.sessionInfo, {cache: true});
var userPromise;

Expand Down Expand Up @@ -38,6 +38,4 @@ define(['angular'], function(angular) {
getUser: getUser,
};
}]);

return app;
});
6 changes: 2 additions & 4 deletions uw-frame-components/portal/misc/controllers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

define(['angular'], function(angular) {
var app = angular.module('portal.misc.controllers', []);
return angular.module('portal.misc.controllers', [])

/* AddToHomeController */
app.controller('AddToHomeController', ['$scope', '$timeout', 'PortalAddToHomeService',
.controller('AddToHomeController', ['$scope', '$timeout', 'PortalAddToHomeService',
function($scope, $timeout, PortalAddToHomeService) {
$scope.addToHome = function() {
if(!$scope.inHome && PortalAddToHomeService.canAddToHome($scope.fname)) {
Expand Down Expand Up @@ -55,6 +55,4 @@ define(['angular'], function(angular) {

init();
}]);

return app;
});
Loading

0 comments on commit b36b7b7

Please sign in to comment.