How to use the codelyzer/angular/templates/basicTemplateAstVisitor.BasicTemplateAstVisitor function in codelyzer

To help you get started, we’ve selected a few codelyzer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intershop / intershop-pwa / tslint-rules / dist / ccpNoMarkupInContainersRule.js View on Github external
}
        var failures = element.attrs.map(function (attr) { return _this.validateAttr(attr); }).filter(function (x) { return !!x; });
        if (failures && failures.length) {
            this.addFailureFromStartToEnd(element.sourceSpan.start.offset, element.sourceSpan.end.offset, MESSAGE + " " + failures.join(' '));
        }
    };
    ContainerTemplateVisitor.prototype.validateAttr = function (attr) {
        if (attr.name === 'class' || attr.name === 'style') {
            return "Found '" + attr.name + "' with value '" + attr.value + "'.";
        }
        else {
            return;
        }
    };
    return ContainerTemplateVisitor;
}(basicTemplateAstVisitor_1.BasicTemplateAstVisitor));
var Rule = (function (_super) {
    __extends(Rule, _super);
    function Rule() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Rule.prototype.apply = function (sourceFile) {
        if (!sourceFile.fileName.match(/.*\/containers\/.*.ts/)) {
            return [];
        }
        var walker = new ngWalker_1.NgWalker(sourceFile, this.getOptions(), { templateVisitorCtrl: ContainerTemplateVisitor });
        walker.walk(sourceFile);
        var failures = walker.getFailures();
        if (failures && failures.length) {
            var errorToken_1 = tsquery_1.tsquery(sourceFile, 'ClassDeclaration > Identifier')[0];
            return this.applyWithFunction(sourceFile, function (ctx) {
                failures.forEach(function (f) { return ctx.addFailureAtNode(errorToken_1, f.getFailure()); });