all files / eslint-plugin-angular/rules/ document-service.js

100% Statements 5/5
100% Branches 5/5
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                      11×   11×                
/**
 * use `$document` instead of `document`
 *
 * Instead of the default document object, you should prefer the AngularJS wrapper service $document.
 *
 * @styleguideReference {johnpapa} `y180` Angular $ Wrapper Services - $document and $window
 * @version 0.1.0
 * @category angularWrapper
 */
'use strict';
 
module.exports = function(context) {
    return {
        MemberExpression: function(node) {
            if (node.object.name === 'document' || (node.object.name === 'window' && node.property.name === 'document')) {
                context.report(node, 'You should use the $document service instead of the default document object', {});
            }
        }
    };
};
 
module.exports.schema = [
    // JSON Schema for rule options goes here
];