JavaScript

JavaScript

Made by DeepSource

Specify a consistent function style for components JS-0547

Anti-pattern
Minor
angularjs

Anonymous or named functions inside AngularJS components. The first parameter sets which type of function is required and can be 'named' or 'anonymous'. The second parameter is an optional list of angular object names.

Rule based on Angular 1.x

Bad Practice

// invalid
angular.module('myModule').factory('myService', myServiceFn);
function myServiceFn() {
    // ...
} // error: Use anonymous functions instead of named function

Recommended

// valid
angular.module('myModule').factory('myService', function () {
    // ...
});