CallExpression: function()

in rules/service-name.js [92:131]


            CallExpression: function(node) {
                var config = getConfig(context.options);
                var prefix = getPrefixFromOptions(context.options);
                var convertedPrefix; // convert string from JSON .eslintrc to regex
                var isService;

                if (prefix === undefined) {
                    return;
                }

                convertedPrefix = utils.convertPrefixToRegex(prefix);

                if (config.oldBehavior) {
                    isService = utils.isAngularServiceDeclarationDeprecated(node);
                } else {
                    isService = utils.isAngularServiceDeclaration(node);
                }

                if (isService) {
                    var name = node.arguments[0].value;

                    if (name !== undefined && name.indexOf('$') === 0) {
                        context.report(node, 'The {{service}} service should not start with "$". This is reserved for AngularJS services', {
                            service: name
                        });
                    } else if (name !== undefined && !convertedPrefix.test(name)) {
                        if (typeof prefix === 'string' && !utils.isStringRegexp(prefix)) {
                            context.report(node, 'The {{service}} service should be prefixed by {{prefix}}', {
                                service: name,
                                prefix: prefix
                            });
                        } else {
                            context.report(node, 'The {{service}} service should follow this pattern: {{prefix}}', {
                                service: name,
                                prefix: prefix.toString()
                            });
                        }
                    }
                }
            }