UNPKG

938 BJavaScriptView Raw
1/**
2 * use `$document` instead of `document`
3 *
4 * Instead of the default document object, you should prefer the AngularJS wrapper service $document.
5 *
6 * @styleguideReference {johnpapa} `y180` Angular $ Wrapper Services - $document and $window
7 * @version 0.1.0
8 * @category angularWrapper
9 * @sinceAngularVersion 1.x
10 */
11'use strict';
12
13module.exports = {
14 meta: {
15 docs: {
16 url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/document-service.md'
17 },
18 schema: []
19 },
20 create: function(context) {
21 return {
22 MemberExpression: function(node) {
23 if (node.object.name === 'document' || (node.object.name === 'window' && node.property.name === 'document')) {
24 context.report(node, 'You should use the $document service instead of the default document object', {});
25 }
26 }
27 };
28 }
29};