I'm working on an angular app and am having issues with jslint complaining about an unused parameter. As you may know, controllers in angular require "$scope" to be passed as the first parameter in your controller definition. In my specific case, I prefer not to use the $scope object, but instead use the "this" keyword. I can make the code work using either $scope or this, but for other reasons that I don't think are relevant, I need to use "this" and not "$scope". If you must know why, I'll be happy to provide a link that helps explain why I'm making this judgement call.
I found this article that explains how you can turn off this warning for all unused parameters.
https://jslinterrors.com/unused-a
This works, but it's not ideal because then I can't see if there are other unused parameters besides the one I already know about (and am ok with).
I'm aware that you can turn the unparam warning on,then turn it back off again, but this still does not solve my problem because it's the rest of the code block that I want to allow jslint to check for, just not this specific variable ($scope). I have a ton of these types of files that, unfortunately, all share similar issues. Here is my code:
/*globals angular, console, document */
(function() {
'use strict';
/**
* @ngdoc function
* @name app.controller:UserLogoutController
* @description
* Loggs out the current active user
*
*/
/*jslint unparam: true */
angular.module('myAppName')
.controller('UserLogoutController', ['$scope', 'userService', 'appConfig',
function ($scope, userService, config) {
this.logout = function() {
//logout logic goes here
};
}
]);
/*jslint unparam: false */
angular.module('myAppName')
.directive('logoutbtn', function() {
return {
restrict: 'E',
replace: true,
templateUrl: './user/userLogout.html',
controller: 'UserLogoutController',
controllerAs: 'logout'
};
});
}());
This is as close as I've been able to get to what I'm looking for. For what it's worth, I've also tried adding $scope to the globals section at the top and that doesn't suppress the warning either. What I'd like to be able to do is something like this
/*jslint unparam: "$scope" */
or
/*jslint unparam: [$scope] */
So that jslint only ignores only this one unused parameter, but still warns about any other unused parameters. Any advice you can give would be great. Let me know if you need more detail on any of this, I'd be happy to provide. Thanks in advance!!!