Skip to content
Merged

0.9.0 #185

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ We provide also three samples :
| '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)|
| 'ng_module_setter':2 | Declare modules without a variable using the setter syntax.[Y021](https://github.com/johnpapa/angular-styleguide#style-y021) |
| '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
| 'ng_no_controller': 0 | According to the Component-First pattern, we should avoid the use of AngularJS controller. |
| 'ng_no_cookiestore':2 | In Angular 1.4, the $cookieStore service is now deprected. Please use the $cookies service instead|
| 'ng_no_digest': 2 | DEPRECATED! The scope's $digest() method shouldn't be used. You should prefer the $apply method. |
| 'ng_no_jquery_angularelement': 2 | You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element|
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'ng_module_name': require('./rules/ng_module_name'),
'ng_module_setter': require('./rules/ng_module_setter'),
'ng_no_angular_mock': require('./rules/ng_no_angular_mock'),
'ng_no_controller': require('./rules/ng_no_controller'),
'ng_no_cookiestore': require('./rules/ng_no_cookiestore'),
'ng_no_digest': require('./rules/ng_no_digest'),
'ng_no_jquery_angularelement': require('./rules/ng_no_jquery_angularelement'),
Expand Down Expand Up @@ -70,6 +71,7 @@
'ng_module_name': 0,
'ng_module_setter': 2,
'ng_no_angular_mock': 0,
'ng_no_controller': 0,
'ng_no_cookiestore': 2,
'ng_no_digest': 0,
'ng_no_jquery_angularelement': 2,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-angular",
"version": "0.8.1",
"version": "0.9.0",
"description": "ESLint rules for AngularJS projects",
"main": "index.js",
"repository": {
Expand Down
18 changes: 18 additions & 0 deletions rules/ng_no_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = function(context) {

'use strict';
var utils = require('./utils/utils');

return {

'CallExpression': function(node) {
if(utils.isAngularControllerDeclaration(node)) {
context.report(node, 'Based on the Component-First Pattern, you should avoid the use of controllers', {});
}
}
};
};

module.exports.schema = [
// JSON Schema for rule options goes here
];
22 changes: 22 additions & 0 deletions test/ng_no_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var rule = require('../rules/ng_no_controller'),
RuleTester = require("eslint").RuleTester;

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

var eslintTester = new RuleTester();
eslintTester.run('ng_no_controller', rule, {
valid: [
'app.controller("")',
'app.service("", function(){})'
],
invalid: [
{ code: 'app.controller("", function(){})', errors: [{ message: 'Based on the Component-First Pattern, you should avoid the use of controllers'}] },
{ code: 'angular.module("").controller("", function(){})', errors: [{ message: 'Based on the Component-First Pattern, you should avoid the use of controllers'}] }
]
});