Require all DI parameters to be located in their own lineJS-0550
angularjs
Injected dependencies should be written one per line.
Rule based on Angular 1.x
Bad Practice
// invalid
app.controller('MyController', MyController);
function MyController($http, $q) {} // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', function($http, $q) {}); // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', ['$http','$q',
function($http,
$q) {
}]); // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', [
'$http',
'$q',
function($http, $q) {}]); // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', ['$http', '$q', MyController]);
function MyController($http,
$q) {} // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', [
'$http',
'$q',
MyController]);
function MyController($http, $q) {} // error: Do not use multiple dependencies in one line
// invalid
app.controller('MyController', ['$http', '$q', function($http, $q) {}]);
// error: Do not use multiple dependencies in one line, Do not use multiple dependencies in one line
Recommended
// valid
app.controller('MyController', MyController);
function MyController($http,
$q) {
}
// valid
app.controller('MyController', function($http,
$q) {
});
// valid
app.controller('MyController', [
'$http',
'$q',
function($http,
$q) {
}]);
// valid
app.controller('MyController', [
'$http',
'$q',
MyController]);
function MyController($http,
$q) {
}