<commit_before>HTMLHint.addRule({
    id: 'containers-accessibility',
    description: 'div with class container should have role of tabPanel and attr binding of id and aria-labeledby',
    init: function (parser, reporter) {
        var self = this;
        var isContainer = function (element, attributes) {
            return (element === "div" && HTMLHint.utils.hasClass(attributes, "container"));
        };

        var bindingContains = function (bindings, requestedBind) {
            return !bindings.includes('attr') || !bindings.includes(requestedBind);
        };
        parser.addListener('tagstart', function (event) {
            var tagName = event.tagName.toLowerCase();

            if (isContainer(tagName, event.attrs)) {
                var roleAttr = HTMLHint.utils.getAttributeValue(event.attrs, "role");
                var bindingsAttr = HTMLHint.utils.getAttributeValue(event.attrs, "data-bind");
                if (roleAttr !== 'tabpanel') {
                    reporter.error('div with class container should have role "tabpanel"', event.line, event.col, self, event.raw);
                }

                if (bindingContains(bindingsAttr, 'id') || bindingContains(bindingsAttr, 'tabpanel_')) {
                    reporter.error('div with class container should have attr binding of id that starts with "tabpanel_"', event.line, event.col, self, event.raw);
                }

                if (bindingContains(bindingsAttr, 'aria-labeledby') || bindingContains(bindingsAttr, 'tab_')) {
                    reporter.error('div with class container should have attr binding of aria-labeledby to an id that starts with "tab_"', event.line, event.col, self, event.raw);
                }
            }
        });

    }
});
<commit_msg>refract and rename functions. not finished<commit_after>HTMLHint.addRule({
    id: 'containers-accessibility',
    description: 'div with class container should have role of tabPanel and attr binding of id and aria-labeledby',
    init: function (parser, reporter) {
        var self = this;
        var isContainer = function (element, attributes) {
            return (element === "div" && HTMLHint.utils.hasClass(attributes, "container"));
        };

        var trimAll = function (val) {
            if (typeof val !== 'string') {
                return;
            }
            return val().replace(/ /g, '');
        }

        var isContainerWithoutAttrBinding = function (bindings) {
            return !bindings.includes('attr');
        };

        var isContainerWithoutAriaLabeledbyBinding = function (bindings, requestedBind) {
            var ariaLabelBinding = trimAll(HTMLHint.resources.containersAccessibility.ariaLabelBinding);
            return isContainerWithoutAttrBinding() || !bindings.includes(ariaLabelBinding);
        };

        var isContainerWithoutIdBinding = function (bindings, requestedBind) {
           var idBinding = trimAll(HTMLHint.resources.containersAccessibility.idBinding);
            return isContainerWithoutAttrBinding() || !bindings.includes(idBinding);
        }
        parser.addListener('tagstart', function (event) {
            var tagName = event.tagName.toLowerCase();

            if (isContainer(tagName, event.attrs)) {
                var roleAttr = HTMLHint.utils.getAttributeValue(event.attrs, "role");
                var dataBindings = HTMLHint.utils.getAttributeValue(event.attrs, "data-bind");
                if (roleAttr !== 'tabpanel') {
                    reporter.error('div with class container should have role "tabpanel"', event.line, event.col, self, event.raw);
                }

                if (bindingContains(dataBindings, 'tabpanel_')) {
                    reporter.error('div with class container should have attr binding of id that starts with "tabpanel_"', event.line, event.col, self, event.raw);
                }

                if (bindingContains(dataBindings, 'tab_')) {
                    reporter.error('div with class container should have attr binding of aria-labeledby to an id that starts with "tab_"', event.line, event.col, self, event.raw);
                }
            }
        });

    }
});

{'fraction_non_alphanumeric': 0.11010052656773577, 'fraction_numerical': 0.0, 'mean_word_length': 2.3920454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445249', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1039, 'n_words': 285}