Skip to content

Commit 08af717

Browse files
committed
issue #149 $cookieStore deprecated$cookieStore deprecated
1 parent c71605a commit 08af717

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ We provide also three samples :
9393
| '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)|
9494
| 'ng_module_setter':2 | Declare modules without a variable using the setter syntax.[Y021](https://github.com/johnpapa/angular-styleguide#style-y021) |
9595
| '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
96+
| 'ng_no_cookiestore':2 | In Angular 1.4, the $cookieStore service is now deprected. Please use the $cookies service instead|
9697
| 'ng_no_digest': 2 | The scope's $digest() method shouldn't be used. You should prefer the $apply method. |
9798
| 'ng_no_jquery_angularelement': 2 | You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element|
9899
| 'ng_no_private_call': 2 | All scope's properties/methods starting with $$ are used internally by AngularJS. You should not use them directly. |

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'ng_module_name': require('./rules/ng_module_name'),
2424
'ng_module_setter': require('./rules/ng_module_setter'),
2525
'ng_no_angular_mock': require('./rules/ng_no_angular_mock'),
26+
'ng_no_cookiestore': require('./rules/ng_no_cookiestore'),
2627
'ng_no_digest': require('./rules/ng_no_digest'),
2728
'ng_no_jquery_angularelement': require('./rules/ng_no_jquery_angularelement'),
2829
'ng_no_private_call': require('./rules/ng_no_private_call'),
@@ -61,6 +62,7 @@
6162
'ng_module_name': 0,
6263
'ng_module_setter': 2,
6364
'ng_no_angular_mock': 0,
65+
'ng_no_cookiestore': 2,
6466
'ng_no_digest': 2,
6567
'ng_no_jquery_angularelement': 2,
6668
'ng_no_private_call': 2,

rules/ng_no_cookiestore.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = function(context) {
2+
3+
'use strict';
4+
5+
return {
6+
7+
'MemberExpression': function(node) {
8+
if(node.object && node.object.name === '$cookieStore'){
9+
context.report(node, 'Since Angular 1.4, the $cookieStore service is depreacted. Please use now the $cookies service.', {});
10+
}
11+
12+
}
13+
};
14+
15+
};

test/ng_no_cookiestore.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//------------------------------------------------------------------------------
2+
// Requirements
3+
//------------------------------------------------------------------------------
4+
5+
var eslint = require('../node_modules/eslint/lib/eslint'),
6+
ESLintTester = require('eslint-tester');
7+
8+
//------------------------------------------------------------------------------
9+
// Tests
10+
//------------------------------------------------------------------------------
11+
12+
var eslintTester = new ESLintTester(eslint);
13+
eslintTester.addRuleTest('rules/ng_no_cookiestore', {
14+
valid: [
15+
'$cookies();'
16+
],
17+
invalid: [{
18+
code: '$cookieStore.get("");',
19+
errors: [{ message: 'Since Angular 1.4, the $cookieStore service is depreacted. Please use now the $cookies service.'}]
20+
}, {
21+
code: '$cookieStore.put("", "");',
22+
errors: [{ message: 'Since Angular 1.4, the $cookieStore service is depreacted. Please use now the $cookies service.'}]
23+
}
24+
]
25+
});

0 commit comments

Comments
 (0)