Injected dependencies should be written one per line.
Rule based on Angular 1.x
The following patterns are considered problems;
/*eslint angular/one-dependency-per-line: 2*/
// 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
The following patterns are not considered problems;
/*eslint angular/one-dependency-per-line: 2*/
// 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) {
}
This rule was introduced in eslint-plugin-angular 0.14.0