Skip to content

Latest commit

 

History

History
92 lines (65 loc) · 2.51 KB

one-dependency-per-line.md

File metadata and controls

92 lines (65 loc) · 2.51 KB

one-dependency-per-line - require all DI parameters to be located in their own line

Injected dependencies should be written one per line.

Examples

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) {
}

Version

This rule was introduced in eslint-plugin-angular 0.14.0

Links