Skip to content

Commit d574fe8

Browse files
committed
Merge pull request #185 from Gillespie59/development
0.9.0
2 parents fc3cc9c + 29c604c commit d574fe8

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ We provide also three samples :
9595
| 'ng_module_name': 0 | When you create a new module, its name should start with the parameter you can define in your config object. The second parameter can be a Regexp wrapped in quotes. You can not prefix your modules by "ng" (reserved keyword for AngularJS modules) ("ng_module_name": [2, "ng"]) [Y127](https://github.com/johnpapa/angular-styleguide#style-y127)|
9696
| 'ng_module_setter':2 | Declare modules without a variable using the setter syntax.[Y021](https://github.com/johnpapa/angular-styleguide#style-y021) |
9797
| 'ng_no_angular_mock':0 | All methods defined in the angular.mock object are also available in the object window. So you can remove angular.mock from your code
98+
| 'ng_no_controller': 0 | According to the Component-First pattern, we should avoid the use of AngularJS controller. |
9899
| 'ng_no_cookiestore':2 | In Angular 1.4, the $cookieStore service is now deprected. Please use the $cookies service instead|
99100
| 'ng_no_digest': 2 | DEPRECATED! The scope's $digest() method shouldn't be used. You should prefer the $apply method. |
100101
| 'ng_no_jquery_angularelement': 2 | You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element|

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'ng_module_name': require('./rules/ng_module_name'),
2727
'ng_module_setter': require('./rules/ng_module_setter'),
2828
'ng_no_angular_mock': require('./rules/ng_no_angular_mock'),
29+
'ng_no_controller': require('./rules/ng_no_controller'),
2930
'ng_no_cookiestore': require('./rules/ng_no_cookiestore'),
3031
'ng_no_digest': require('./rules/ng_no_digest'),
3132
'ng_no_jquery_angularelement': require('./rules/ng_no_jquery_angularelement'),
@@ -70,6 +71,7 @@
7071
'ng_module_name': 0,
7172
'ng_module_setter': 2,
7273
'ng_no_angular_mock': 0,
74+
'ng_no_controller': 0,
7375
'ng_no_cookiestore': 2,
7476
'ng_no_digest': 0,
7577
'ng_no_jquery_angularelement': 2,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-angular",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "ESLint rules for AngularJS projects",
55
"main": "index.js",
66
"repository": {

rules/ng_no_controller.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = function(context) {
2+
3+
'use strict';
4+
var utils = require('./utils/utils');
5+
6+
return {
7+
8+
'CallExpression': function(node) {
9+
if(utils.isAngularControllerDeclaration(node)) {
10+
context.report(node, 'Based on the Component-First Pattern, you should avoid the use of controllers', {});
11+
}
12+
}
13+
};
14+
};
15+
16+
module.exports.schema = [
17+
// JSON Schema for rule options goes here
18+
];

test/ng_no_controller.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//------------------------------------------------------------------------------
2+
// Requirements
3+
//------------------------------------------------------------------------------
4+
5+
var rule = require('../rules/ng_no_controller'),
6+
RuleTester = require("eslint").RuleTester;
7+
8+
//------------------------------------------------------------------------------
9+
// Tests
10+
//------------------------------------------------------------------------------
11+
12+
var eslintTester = new RuleTester();
13+
eslintTester.run('ng_no_controller', rule, {
14+
valid: [
15+
'app.controller("")',
16+
'app.service("", function(){})'
17+
],
18+
invalid: [
19+
{ code: 'app.controller("", function(){})', errors: [{ message: 'Based on the Component-First Pattern, you should avoid the use of controllers'}] },
20+
{ code: 'angular.module("").controller("", function(){})', errors: [{ message: 'Based on the Component-First Pattern, you should avoid the use of controllers'}] }
21+
]
22+
});

0 commit comments

Comments
 (0)