bstoney bstoney - 4 years ago 100
AngularJS Question

Resharper rule "Function Parameter" does not accept angularjs service name

In my angularjs app all my service names start with an uppercase character. I would like to be able the allow service parameters to match the the service name, however the JavaScript "Function Parameter" name rule in Resharper does not allow parameters that start with an uppercase character.

Is it possible to configure or change the JavaScript "Function Parameter" name rule in Resharper to allow service names that start with an uppercase character?Or is there some other way to to avoid this warning?

The

BudgetingService
parameter in the following code is flagged as a warning by Resharper with the message: "Name 'BudgetingService' does not match rule 'Function Parameter'. Suggested name is 'budgetingService'."

app.controller('BudgetingController',
['$scope', '$rootScope', '$window', 'BudgetingService',
function ($scope, $rootScope, $window, BudgetingService) {
// ...
}]);

Answer Source

Not the answer you are looking for, but there is a reason for that. the only time variables in javascript should be ConstantCamelCase is when they are classes/constructors.

if anything the actual service you create should be budgetingService, not BudgetingService

just lowercase the name it's not work the fight you're trying to put up

app.controller('BudgetingController',
  ['$scope', '$rootScope', '$window', 'BudgetingService',
    function ($scope, $rootScope, $window, budgetingService) {
        budgetingService.whatever()
        // ...
    }
  ]);

if you REALLY want to have it uppercase, redeclare it after injecting

app.controller('BudgetingController',
  ['$scope', '$rootScope', '$window', 'BudgetingService',
    function ($scope, $rootScope, $window, budgetingService) {
        var BudgetingService = budgetingService;
        // ...
    }
  ]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download