Skip to content

Commit 43f1551

Browse files
committed
Solve doc for no-service
1 parent 9fcf835 commit 43f1551

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

docs/no-services.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,45 @@ The following patterns are **not** considered problems with default config;
3434
// ...
3535
});
3636

37-
The following patterns are considered problems when configured `["$http","$q"]`:
37+
The following patterns are considered problems when configured `["http","q"]`:
3838

39-
/*eslint angular/no-services: [2,["$http","$q"]]*/
39+
/*eslint angular/no-services: [2,["http","q"]]*/
4040

4141
// invalid
4242
app.directive('helloWorld', function($q) {
4343
// ...
4444
}); // error: REST API calls should be implemented in a specific service ($q in directive)
4545

46-
The following patterns are **not** considered problems when configured `["$http","$q"]`:
46+
The following patterns are **not** considered problems when configured `["http","q"]`:
4747

48-
/*eslint angular/no-services: [2,["$http","$q"]]*/
48+
/*eslint angular/no-services: [2,["http","q"]]*/
4949

5050
// valid
5151
app.directive('helloWorld', function($resource) {
5252
// ...
5353
});
5454

55-
The following patterns are considered problems when configured `["$http","$q"]` and `["directive"]`:
55+
The following patterns are considered problems when configured `["http","q"]` and `["directive"]`:
5656

57-
/*eslint angular/no-services: [2,["$http","$q"],["directive"]]*/
57+
/*eslint angular/no-services: [2,["http","q"],["directive"]]*/
5858

5959
// invalid
6060
app.directive('MyController', function($http) {
6161
// ...
6262
}); // error: REST API calls should be implemented in a specific service ($http in directive)
6363

64-
The following patterns are **not** considered problems when configured `["$http","$q"]` and `["directive"]`:
64+
The following patterns are **not** considered problems when configured `["http","q"]` and `["directive"]`:
6565

66-
/*eslint angular/no-services: [2,["$http","$q"],["directive"]]*/
66+
/*eslint angular/no-services: [2,["http","q"],["directive"]]*/
6767

6868
// valid
6969
app.controller('MyController', function($http) {
7070
// ...
7171
});
7272

73-
The following patterns are considered problems when configured `{"directive":["$http","$q"],"controller":["$resource"]}`:
73+
The following patterns are considered problems when configured `{"directive":["http","q"],"controller":["resource"]}`:
7474

75-
/*eslint angular/no-services: [2,{"directive":["$http","$q"],"controller":["$resource"]}]*/
75+
/*eslint angular/no-services: [2,{"directive":["http","q"],"controller":["resource"]}]*/
7676

7777
// invalid
7878
app.controller('MyController', function($resource, $log) {
@@ -84,9 +84,9 @@ The following patterns are considered problems when configured `{"directive":["$
8484
// ...
8585
}); // error: REST API calls should be implemented in a specific service ($http in directive)
8686

87-
The following patterns are **not** considered problems when configured `{"directive":["$http","$q"],"controller":["$resource"]}`:
87+
The following patterns are **not** considered problems when configured `{"directive":["http","q"],"controller":["resource"]}`:
8888

89-
/*eslint angular/no-services: [2,{"directive":["$http","$q"],"controller":["$resource"]}]*/
89+
/*eslint angular/no-services: [2,{"directive":["http","q"],"controller":["resource"]}]*/
9090

9191
// valid
9292
app.controller('MyController', function($http, $q, $log) {

examples/no-services.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ app.controller('MyController', function(myService) {
33
// ...
44
});
55

6+
67
// example - valid: false, errorMessage: "REST API calls should be implemented in a specific service ($http in controller)"
78
app.controller('MyController', function($http) {
89
// ...
@@ -13,43 +14,43 @@ app.directive('helloWorld', function($resource) {
1314
// ...
1415
});
1516

16-
// example - valid: true, options: [["$http","$q"]]
17+
// example - valid: true, options: [["http","q"]]
1718
app.directive('helloWorld', function($resource) {
1819
// ...
1920
});
2021

21-
// example - valid: false, options: [["$http","$q"]], errorMessage: "REST API calls should be implemented in a specific service ($q in directive)"
22+
// example - valid: false, options: [["http","q"]], errorMessage: "REST API calls should be implemented in a specific service ($q in directive)"
2223
app.directive('helloWorld', function($q) {
2324
// ...
2425
});
2526

26-
// example - valid: true, options: [["$http","$q"],["directive"]]
27+
// example - valid: true, options: [["http","q"],["directive"]]
2728
app.controller('MyController', function($http) {
2829
// ...
2930
});
3031

31-
// example - valid: false, options: [["$http","$q"],["directive"]], errorMessage: "REST API calls should be implemented in a specific service ($http in directive)"
32+
// example - valid: false, options: [["http","q"],["directive"]], errorMessage: "REST API calls should be implemented in a specific service ($http in directive)"
3233
app.directive('MyController', function($http) {
3334
// ...
3435
});
3536

3637

37-
// example - valid: true, options: [{"directive":["$http","$q"],"controller":["$resource"]}]
38+
// example - valid: true, options: [{"directive":["http","q"],"controller":["resource"]}]
3839
app.controller('MyController', function($http, $q, $log) {
3940
// ...
4041
});
4142

42-
// example - valid: true, options: [{"directive":["$http","$q"],"controller":["$resource"]}]
43+
// example - valid: true, options: [{"directive":["http","q"],"controller":["resource"]}]
4344
app.directive('helloWorld', function($resource, $log) {
4445
// ...
4546
});
4647

47-
// example - valid: false, options: [{"directive":["$http","$q"],"controller":["$resource"]}], errorMessage: "REST API calls should be implemented in a specific service ($resource in controller)"
48+
// example - valid: false, options: [{"directive":["http","q"],"controller":["resource"]}], errorMessage: "REST API calls should be implemented in a specific service ($resource in controller)"
4849
app.controller('MyController', function($resource, $log) {
4950
// ...
5051
});
5152

52-
// example - valid: false, options: [{"directive":["$http","$q"],"controller":["$resource"]}], errorMessage: "REST API calls should be implemented in a specific service ($http in directive)"
53+
// example - valid: false, options: [{"directive":["http","q"],"controller":["resource"]}], errorMessage: "REST API calls should be implemented in a specific service ($http in directive)"
5354
app.directive('helloWorld', function($http, $log) {
5455
// ...
5556
});

rules/no-services.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
}
3939

4040
if (context.options[0] === undefined) {
41-
badServices = ['/\$http/', '/\$resource/', 'Restangular', '/\$q/', '/\$filter/'];
41+
badServices = [/\$http/, /\$resource/, /Restangular/, /\$q/, /\$filter/];
4242
}
4343

4444
if (isArray(context.options[0])) {
@@ -65,6 +65,7 @@ module.exports = {
6565
}
6666

6767
function isSetBedService(serviceName, angularObjectName) {
68+
console.log(badServices)
6869
if (map) {
6970
return map[angularObjectName].find(object => utils.convertPrefixToRegex(object).test(serviceName));
7071
}

0 commit comments

Comments
 (0)