eslint-plugin-angular
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -36,3 +36,3 @@ (function(){ | ||
'ng_angularelement': 1, | ||
'ng_controller_name': 0, | ||
'ng_controller_name': [2, /[A-Z].*Controller$/], | ||
'ng_definedundefined': 2, | ||
@@ -39,0 +39,0 @@ 'ng_di': [2, 'function'], |
{ | ||
"name": "eslint-plugin-angular", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "ESLint rules for AngularJS projects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,10 @@ [![Build Status](https://travis-ci.org/Gillespie59/eslint-plugin-angular.svg?branch=master)](https://travis-ci.org/Gillespie59/eslint-plugin-angular) | ||
``` | ||
3. You can also configure these rules in your `.eslintrc`. All rules defined in this plugin have to be prefixed by 'angular/' | ||
```yaml | ||
plugins: | ||
- angular | ||
rules: | ||
- angular/ng_controller_name: 0 | ||
``` | ||
@@ -33,3 +40,3 @@ # Rules | ||
| ng_angularelement | The angular.element method should be used of the $ or jQuery object (if you are using jQuery of course). If the jQuery library is imported, angular.element will be a wrapper around the jQuery object. | 'ng_angularelement': 1 | | ||
| ng_controller_name | All your controllers should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. ("ng_controller_name": [2, "ng"]) [Y123](https://github.com/johnpapa/angularjs-styleguide#style-y123), [Y124](https://github.com/johnpapa/angularjs-styleguide#style-y124)| 'ng_controller_name': 0 | | ||
| ng_controller_name | All your controllers should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp. ("ng_controller_name": [2, "ng"]) [Y123](https://github.com/johnpapa/angularjs-styleguide#style-y123), [Y124](https://github.com/johnpapa/angularjs-styleguide#style-y124)| 'ng_controller_name': [2, /[A-Z].*Controller$/] | | ||
| ng_definedundefined | You should use the angular.isUndefined or angular.isDefined methods instead of using the keyword undefined. We check also the use of !angular.isUndefined and !angular.isDefined (should prefer the reverse function)| 'ng_definedundefined': 2 | | ||
@@ -36,0 +43,0 @@ | ng_di | All your DI should use the same syntax : the Array or function syntaxes ("ng_di": [2, "function or array"])| 'ng_di': [2, 'function'] | |
@@ -21,5 +21,4 @@ module.exports = function(context) { | ||
var callee = node.callee; | ||
if (callee.type === 'MemberExpression' && callee.object.name === 'angular' && angularObjectList.indexOf(callee.property.name) >= 0) { | ||
if (callee.type === 'MemberExpression' && angularObjectList.indexOf(callee.property.name) >= 0) { | ||
if(syntax === 'function' && (!utils.isFunctionType(node.arguments[1]) && !utils.isIdentifierType(node.arguments[1]))){ | ||
@@ -26,0 +25,0 @@ report(node, syntax); |
@@ -23,2 +23,5 @@ //------------------------------------------------------------------------------ | ||
args: [1, undefined] | ||
}, { | ||
code: 'angular.controller("EslintController", function(){});', | ||
args: [1, /[A-Z].*Controller$/] | ||
}], | ||
@@ -40,4 +43,14 @@ invalid: [ | ||
errors: [{ message: 'The Controller controller should follow this pattern: /^eslint/'}] | ||
}, | ||
{ | ||
code: 'angular.controller("customers", function(){});', | ||
args: [1, /[A-Z].*Controller$/], | ||
errors: [{ message: 'The customers controller should follow this pattern: /[A-Z].*Controller$/'}] | ||
}, | ||
{ | ||
code: 'angular.controller("customersController", function(){});', | ||
args: [1, /[A-Z].*Controller$/], | ||
errors: [{ message: 'The customersController controller should follow this pattern: /[A-Z].*Controller$/'}] | ||
} | ||
] | ||
}); |
@@ -44,2 +44,11 @@ //------------------------------------------------------------------------------ | ||
}); | ||
valid.push({ | ||
code: 'vm.navRoutes = states.filter(x).sort(y);', | ||
args: [1, 'function'] | ||
}, { | ||
code: 'vm.navRoutes = states.filter(x).sort(y);', | ||
args: [1, 'array'] | ||
}) | ||
//------------------------------------------------------------------------------ | ||
@@ -49,2 +58,4 @@ // Tests | ||
var eslintTester = new ESLintTester(eslint); | ||
@@ -51,0 +62,0 @@ eslintTester.addRuleTest('rules/ng_di', { |
81746
1515
85