Skip to content

Commit

Permalink
Allow parameterless functions for array di (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
tilmanschweitzer committed Jan 11, 2016
1 parent e9a982d commit 6303e88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rules/di.js
Expand Up @@ -31,7 +31,7 @@ module.exports = function(context) {
if (utils.isFunctionType(fn) && fn.params.length !== param.elements.length - 1) {
context.report(fn, 'The signature of the method is incorrect', {});
}
} else {
} else if (!(utils.isFunctionType(param) && param.params.length === 0)) {
report(node, syntax);
}
} else if (syntax === '$inject') {
Expand Down
10 changes: 8 additions & 2 deletions test/di.js
Expand Up @@ -20,6 +20,9 @@ angularObjectList.forEach(function(object) {
valid.push({
code: 'angular.' + object + '(function() {});',
options: ['function']
}, {
code: 'angular.' + object + '(function() {});',
options: ['array']
}, {
code: 'angular.' + object + '([function() {}]);',
options: ['array']
Expand Down Expand Up @@ -47,7 +50,7 @@ angularObjectList.forEach(function(object) {
});

invalid.push({
code: 'angular.' + object + '(function() {});',
code: 'angular.' + object + '(function(myService) {});',
options: ['array'],
errors: [{message: 'You should use the array syntax for DI'}]
}, {
Expand Down Expand Up @@ -85,6 +88,9 @@ angularNamedObjectList.forEach(function(object) {
valid.push({
code: 'angular.' + object + '("name", function() {});',
options: ['function']
}, {
code: 'angular.' + object + '("name", function() {});',
options: ['array']
}, {
code: 'angular.' + object + '("name", [function() {}]);',
options: ['array']
Expand All @@ -109,7 +115,7 @@ angularNamedObjectList.forEach(function(object) {
});

invalid.push({
code: 'angular.' + object + '("name", function() {});',
code: 'angular.' + object + '("name", function(myService) {});',
options: ['array'],
errors: [{message: 'You should use the array syntax for DI'}]
}, {
Expand Down

0 comments on commit 6303e88

Please sign in to comment.