Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bootlint.js « src - github.com/twbs/bootlint.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 13990d3b94289b14e6891d7d9a77f21788e7f342 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
/*
 * Bootlint - an HTML linter for Bootstrap projects
 * https://github.com/twbs/bootlint
 * Copyright (c) 2014-2019 The Bootlint Authors
 * Licensed under the MIT License.
 */

var cheerio = require('cheerio');
var parseUrl = require('url').parse;
var semver = require('semver');
var voidElements = require('void-elements');
var _location = require('./location');

var LocationIndex = _location.LocationIndex;

(function (exports) {
    'use strict';
    var NUM_COLS = 12;
    var COL_REGEX = /\bcol(?:-(sm|md|lg|xl))?(?:-(auto|\d{1,2}))?\b/;
    var COL_REGEX_G = /\bcol(?:-(sm|md|lg|xl))?(?:-(auto|\d{1,2}))?\b/g;
    var COL_CLASSES = [];
    var SCREENS = ['', 'sm', 'md', 'lg', 'xl'];
    SCREENS.forEach(function (screen) {
        for (var n = -1; n <= NUM_COLS; n++) {
            COL_CLASSES.push('.col' + (screen && '-' + screen) + (n < 0 ? '' : '-' + (n || 'auto')));
        }
    });
    var SCREEN2NUM = {
        '': 0,
        'sm': 1,
        'md': 2,
        'lg': 3,
        'xl': 4
    };
    var NUM2SCREEN = ['', 'sm', 'md', 'lg', 'xl'];
    var IN_NODE_JS = Boolean(cheerio.load);
    var MIN_JQUERY_VERSION = '1.9.1'; // as of Bootstrap v3.3.0
    var CURRENT_BOOTSTRAP_VERSION = '3.4.1';
    var BOOTSTRAP_VERSION_4 = '4.0.0';
    var PLUGINS = [
        'affix',
        'alert',
        'button',
        'carousel',
        'collapse',
        'dropdown',
        'modal',
        'popover',
        'scrollspy',
        'tab',
        'tooltip'
    ];
    var BOOTSTRAP_FILES = [
        'link[rel="stylesheet"][href$="/bootstrap.css"]',
        'link[rel="stylesheet"][href="bootstrap.css"]',
        'link[rel="stylesheet"][href$="/bootstrap.min.css"]',
        'link[rel="stylesheet"][href="bootstrap.min.css"]',
        'script[src$="/bootstrap.js"]',
        'script[src="bootstrap.js"]',
        'script[src$="/bootstrap.min.js"]',
        'script[src="bootstrap.min.js"]'
    ].join(',');
    var WIKI_URL = 'https://github.com/twbs/bootlint/wiki/';

    function compareNums(a, b) {
        return a - b;
    }

    function isDoctype(node) {
        return node.type === 'directive' && node.name === '!doctype';
    }

    var tagNameOf = IN_NODE_JS ?
        function (element) {
            return element.name.toUpperCase();
        } :
        function (element) {
            /* istanbul ignore next */
            return element.tagName.toUpperCase();
        };

    function filenameFromUrl(url) {
        var filename = url.replace(/[#?].*$/, ''); // strip querystring & fragment ID
        var lastSlash = filename.lastIndexOf('/');
        if (lastSlash !== -1) {
            filename = filename.slice(lastSlash + 1);
        }
        return filename;
    }

    function withoutClass(classes, klass) {
        return classes.replace(new RegExp('\\b' + klass + '\\b', 'g'), '');
    }

    function columnClassKey(colClass) {
        return SCREEN2NUM[COL_REGEX.exec(colClass)[1]];
    }

    function compareColumnClasses(a, b) {
        return columnClassKey(a) - columnClassKey(b);
    }

    /**
     * Moves any grid column classes to the end of the class string and sorts the grid classes by ascending screen size.
     * @param {string} classes The "class" attribute of a DOM node
     * @returns {string} The processed "class" attribute value
     */
    function sortedColumnClasses(classes) {
        // extract column classes
        var colClasses = [];
        while (true) {
            var match = COL_REGEX.exec(classes);
            if (!match) {
                break;
            }
            var colClass = match[0];
            colClasses.push(colClass);
            classes = withoutClass(classes, colClass);
        }

        colClasses.sort(compareColumnClasses);
        return classes + ' ' + colClasses.join(' ');
    }

    /**
     * @param {string} classes The "class" attribute of a DOM node
     * @returns {Object.<string, integer[]>} Object mapping grid column widths (1 thru 12) to sorted arrays of screen size numbers (see SCREEN2NUM)
     *      Widths not used in the classes will not have an entry in the object.
     */
    function width2screensFor(classes) {
        var width = null;
        var width2screens = {};
        while (true) {
            var match = COL_REGEX_G.exec(classes);
            if (!match || !match[1] && !match[2]) {
                break;
            }
            var screen = match[1] || '';
            width = match[2] || ''; // can also be 'auto'
            var screens = width2screens[width];
            if (!screens) {
                screens = width2screens[width] = [];
            }
            screens.push(SCREEN2NUM[screen]);
        }

        for (width in width2screens) {
            if (Object.prototype.hasOwnProperty.call(width2screens, 'width')) {
                width2screens[width].sort(compareNums);
            }
        }

        return width2screens;
    }

    /**
     * Given a sorted array of integers, this finds all contiguous runs where each item is incremented by 1 from the next.
     * For example:
     *      [0, 2, 3, 5] has one such run: [2, 3]
     *      [0, 2, 3, 4, 6, 8, 9, 11] has two such runs: [2, 3, 4], [8, 9]
     *      [0, 2, 4] has no runs.
     * @param {integer[]} list Sorted array of integers
     * @returns {Array.<Array.<integer>>} Array of pairs of start and end values of runs
     */
    function incrementingRunsFrom(list) {
        list = list.concat([Infinity]);// use Infinity to ensure any nontrivial (length >= 2) run ends before the end of the loop
        var runs = [];
        var start = null;
        var prev = null;
        for (var i = 0; i < list.length; i++) {
            var current = list[i];
            if (start === null) {
                // first element starts a trivial run
                start = current;
            } else if (prev + 1 !== current) {
                // run ended
                if (start !== prev) {
                    // run is nontrivial
                    runs.push([start, prev]);
                }
                // start new run
                start = current;
            }
            // else: the run continues

            prev = current;
        }
        return runs;
    }

    /**
     * @returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
     */
    function getBrowserWindowObject() {
        var theWindow = null;
        try {
            /* eslint-disable no-undef, block-scoped-var */
            theWindow = window;
            /* eslint-enable no-undef, block-scoped-var */
        } catch (e) {
            // deliberately do nothing
            // empty
        }

        return theWindow;
    }

    function versionsIn(strings) {
        return strings.map(function (str) {
            var match = str.match(/^\d+\.\d+\.\d+$/);
            return match ? match[0] : null;
        }).filter(function (match) {
            return match !== null;
        });
    }

    function versionInLinkedElement($, element) {
        var elem = $(element);
        var urlAttr = tagNameOf(element) === 'LINK' ? 'href' : 'src';
        var pathSegments = parseUrl(elem.attr(urlAttr)).pathname.split('/');
        var versions = versionsIn(pathSegments);
        if (!versions.length) {
            return null;
        }
        var version = versions[versions.length - 1];
        return version;
    }

    function jqueryPluginVersions(jQuery) {
        /* istanbul ignore next */
        return PLUGINS.map(function (pluginName) {
            var plugin = jQuery.fn[pluginName];
            if (!plugin) {
                return undefined;
            }
            var constructor = plugin.Constructor;
            if (!constructor) {
                return undefined;
            }
            return constructor.VERSION;
        }).filter(function (version) {
            return typeof version !== 'undefined';
        }).sort(semver.compare);
    }

    function bootstrapScriptsIn($) {
        var longhands = $('script[src*="bootstrap.js"]').filter(function (i, script) {
            var url = $(script).attr('src');
            var filename = filenameFromUrl(url);
            return filename === 'bootstrap.js';
        });
        var minifieds = $('script[src*="bootstrap.min.js"]').filter(function (i, script) {
            var url = $(script).attr('src');
            var filename = filenameFromUrl(url);
            return filename === 'bootstrap.min.js';
        });

        return {
            longhands: longhands,
            minifieds: minifieds
        };
    }

    /**
     * @param {integer} id Unique string ID for this type of lint error. Of the form "E###" (e.g. "E123").
     * @param {string} message Human-readable string describing the error
     * @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
     * @class
     */
    function LintError(id, message, elements) {
        this.id = id;
        this.url = WIKI_URL + id;
        this.message = message;
        this.elements = elements || cheerio('');
    }
    exports.LintError = LintError;

    /**
     * @param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123").
     * @param {string} message Human-readable string describing the warning
     * @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
     * @class
     */
    function LintWarning(id, message, elements) {
        this.id = id;
        this.url = WIKI_URL + id;
        this.message = message;
        this.elements = elements || cheerio('');
    }
    exports.LintWarning = LintWarning;

    var allLinters = {};
    function addLinter(id, linter) {
        if (allLinters[id]) {
            /* istanbul ignore next */
            throw new Error('Linter already registered with ID: ' + id);
        }

        var Problem = null;
        if (id[0] === 'E') {
            Problem = LintError;
        } else if (id[0] === 'W') {
            Problem = LintWarning;
        } else {
            /* istanbul ignore next */
            throw new Error('Invalid linter ID: ' + id);
        }

        function linterWrapper($, reporter) {
            function specializedReporter(message, elements) {
                reporter(new Problem(id, message, elements));
            }

            linter($, specializedReporter);
        }

        linterWrapper.id = id;
        allLinters[id] = linterWrapper;
    }

    addLinter('W001', function lintMetaCharsetUtf8($, reporter) {
        var meta = $('head>meta[charset]');
        var charset = meta.attr('charset');
        if (!charset) {
            meta = $([
                'head>meta[http-equiv="Content-Type"][content="text/html; charset=utf-8"]',
                'head>meta[http-equiv="content-type"][content="text/html; charset=utf-8"]',
                'head>meta[http-equiv="Content-Type"][content="text/html; charset=UTF-8"]',
                'head>meta[http-equiv="content-type"][content="text/html; charset=UTF-8"]'
            ].join(','));
            if (!meta.length) {
                reporter('`<head>` is missing UTF-8 charset `<meta>` tag');
            }
        } else if (charset.toLowerCase() !== 'utf-8') {
            reporter('charset `<meta>` tag is specifying a legacy, non-UTF-8 charset', meta);
        }
    });
    /*
    addLinter('W003', function lintViewport($, reporter) {
        var meta = $('head>meta[name="viewport"][content]');
        if (!meta.length) {
            reporter('`<head>` is missing viewport `<meta>` tag that enables responsiveness');
        }
    });
    */
    /*
    addLinter('W005', function lintJquery($, reporter) {
        var OLD_JQUERY = 'Found what might be an outdated version of jQuery; Bootstrap requires jQuery v' + MIN_JQUERY_VERSION + ' or higher';
        var NO_JQUERY_BUT_BS_JS = 'Unable to locate jQuery, which is required for Bootstrap\'s JavaScript plugins to work';
        var NO_JQUERY_NOR_BS_JS = 'Unable to locate jQuery, which is required for Bootstrap\'s JavaScript plugins to work; however, you might not be using Bootstrap\'s JavaScript';
        var bsScripts = bootstrapScriptsIn($);
        var hasBsJs = Boolean(bsScripts.minifieds.length || bsScripts.longhands.length);
        var theWindow = null;
        try {
            // eslint-disable no-undef, block-scoped-var
            theWindow = window;
            // eslint-enable no-undef, block-scoped-var
        } catch (e) {
            // deliberately do nothing
            // empty
        }
        // istanbul ignore if
        if (theWindow) {
            // check browser global jQuery
            var globaljQuery = theWindow.$ || theWindow.jQuery;
            if (globaljQuery) {
                var globalVersion = null;
                try {
                    globalVersion = globaljQuery.fn.jquery.split(' ')[0];
                } catch (e) {
                    // skip; not actually jQuery?
                    // empty
                }
                if (globalVersion) {
                    // pad out short version numbers (e.g. '1.7')
                    while (globalVersion.match(/\./g).length < 2) {
                        globalVersion += '.0';
                    }

                    var upToDate = null;
                    try {
                        upToDate = semver.gte(globalVersion, MIN_JQUERY_VERSION, true);
                    } catch (e) {
                        // invalid version number
                        // empty
                    }
                    if (upToDate === false) {
                        reporter(OLD_JQUERY);
                    }
                    if (upToDate !== null) {
                        return;
                    }
                }
            }
        }

        // check for jQuery <script>s
        var jqueries = $([
            'script[src*="jquery"]',
            'script[src*="jQuery"]'
        ].join(','));
        if (!jqueries.length) {
            reporter(hasBsJs ? NO_JQUERY_BUT_BS_JS : NO_JQUERY_NOR_BS_JS);
            return;
        }
        jqueries.each(function () {
            var script = $(this);
            var pathSegments = parseUrl(script.attr('src')).pathname.split('/');
            var filename = pathSegments[pathSegments.length - 1];
            if (!/^j[qQ]uery(\.min)?\.js$/.test(filename)) {
                return;
            }
            var versions = versionsIn(pathSegments);
            if (!versions.length) {
                return;
            }
            var version = versions[versions.length - 1];
            if (!semver.gte(version, MIN_JQUERY_VERSION, true)) {
                reporter(OLD_JQUERY, script);
            }
        });
    });
    */
    /*
    addLinter('W006', function lintTooltipsOnDisabledElems($, reporter) {
        var selector = [
            '[disabled][data-toggle="tooltip"]',
            '.disabled[data-toggle="tooltip"]',
            '[disabled][data-toggle="popover"]',
            '.disabled[data-toggle="popover"]'
        ].join(',');
        var disabledWithTooltips = $(selector);
        if (disabledWithTooltips.length) {
            reporter(
                'Tooltips and popovers on disabled elements cannot be triggered by user interaction unless the element becomes enabled.' +
                ' To have tooltips and popovers be triggerable by the user even when their associated element is disabled,' +
                ' put the disabled element inside a wrapper `<div>` and apply the tooltip or popover to the wrapper `<div>` instead.',
                disabledWithTooltips
            );
        }
    });
    */
    /*
    addLinter('W007', function lintBtnType($, reporter) {
        var badBtnType = $('button:not([type="submit"], [type="reset"], [type="button"])');
        if (badBtnType.length) {
            reporter('Found one or more `<button>`s missing a `type` attribute.', badBtnType);
        }
    });
    */
    /*
    addLinter('W008', function lintTooltipsInBtnGroups($, reporter) {
        var nonBodyContainers = $('.btn-group [data-toggle="tooltip"]:not([data-container="body"]), .btn-group [data-toggle="popover"]:not([data-container="body"])');
        if (nonBodyContainers.length) {
            reporter('Tooltips and popovers within button groups should have their `container` set to `\'body\'`. Found tooltips/popovers that might lack this setting.', nonBodyContainers);
        }
    });
    */
    addLinter('W009', function lintEmptySpacerCols($, reporter) {
        var selector = COL_CLASSES.map(function (colClass) {
            return colClass + ':not(:last-child)';
        }).join(',');
        var columns = $(selector);
        columns.each(function (_index, col) {
            var column = $(col);
            var isVoidElement = voidElements[col.tagName.toLowerCase()];
            // can't just use :empty because :empty excludes nodes with all-whitespace text content
            var hasText = Boolean(column.text().trim().length);
            var hasChildren = Boolean(column.children(':first-child').length);
            if (hasChildren || hasText || isVoidElement) {
                return;
            }

            reporter('Using empty spacer columns isn\'t necessary with Bootstrap\'s grid.', column);
        });
    });
    /*
    addLinter('W012', function lintNavbarContainers($, reporter) {
        var navBars = $('.navbar');
        var containers = [
            '.container',
            '.container-fluid'
        ].join(',');
        navBars.each(function () {
            var navBar = $(this);
            var hasContainerChildren = Boolean(navBar.children(containers).length);

            if (!hasContainerChildren) {
                reporter('`.navbar`\'s first child element should always be either `.container` or `.container-fluid`', navBar);
            }
        });
    });
    */
    /*
    addLinter('W013', function lintOutdatedBootstrap($, reporter) {
        var OUTDATED_BOOTSTRAP = 'Bootstrap version might be outdated. Latest version is at least ' + CURRENT_BOOTSTRAP_VERSION + ' ; saw what appears to be usage of Bootstrap ';
        var theWindow = getBrowserWindowObject();
        var globaljQuery = theWindow && (theWindow.$ || theWindow.jQuery);
        // istanbul ignore if
        if (globaljQuery) {
            var versions = jqueryPluginVersions(globaljQuery);
            if (versions.length) {
                var minVersion = versions[0];
                if (semver.lt(minVersion, CURRENT_BOOTSTRAP_VERSION, true)) {
                    reporter(OUTDATED_BOOTSTRAP + minVersion);
                    return;
                }
            }
        }
        // check for Bootstrap <link>s and <script>s
        var bootstraps = $(BOOTSTRAP_FILES);
        bootstraps.each(function () {
            var version = versionInLinkedElement($, this);
            if (version === null) {
                return;
            }
            if (semver.lt(version, CURRENT_BOOTSTRAP_VERSION, true)) {
                reporter(OUTDATED_BOOTSTRAP + version, $(this));
            }
        });
    });
    */
    addLinter('W014', function lintCarouselControls($, reporter) {
        var controls = $('.carousel-indicators > li, .carousel-control-next, .carousel-control-prev');
        controls.each(function (_index, cont) {
            var control = $(cont);
            var target = control.attr('href') || control.attr('data-target');
            var carousel = $(target);

            if (!carousel.length || carousel.is(':not(.carousel)')) {
                reporter('Carousel controls and indicators should use `href` or `data-target` to reference an element with class `.carousel`.', control);
            }
        });
    });
    /*
    addLinter('W016', function lintDisabledClassOnButton($, reporter) {
        var btnsWithDisabledClass = $('button.btn.disabled, input.btn.disabled');
        if (btnsWithDisabledClass.length) {
            reporter('Using the `.disabled` class on a `<button>` or `<input>` only changes the appearance of the element. It doesn\'t prevent the user from interacting with the element (for example, clicking on it or focusing it). If you want to truly disable the element, use the `disabled` attribute instead.', btnsWithDisabledClass);
        }
    });
    */
    /*
    addLinter('W017', function lintInputsMissingTypeAttr($, reporter) {
        var inputsMissingTypeAttr = $('input:not([type])');
        if (inputsMissingTypeAttr.length) {
            reporter('Found one or more `<input>`s missing a `type` attribute.', inputsMissingTypeAttr);
        }
    });
    */
    addLinter('E001', (function () {
        var MISSING_DOCTYPE = 'Document is missing a DOCTYPE declaration';
        var NON_HTML5_DOCTYPE = 'Document declares a non-HTML5 DOCTYPE';
        if (IN_NODE_JS) {
            return function lintDoctype($, reporter) {
                var doctype = $(':root')[0];
                while (doctype && !isDoctype(doctype)) {
                    doctype = doctype.prev;
                }
                if (!doctype) {
                    reporter(MISSING_DOCTYPE);
                    return;
                }
                var doctypeId = doctype.data.toLowerCase();
                if (doctypeId !== '!doctype html' && doctypeId !== '!doctype html system "about:legacy-compat"') {
                    reporter(NON_HTML5_DOCTYPE);
                }
            };
        }

        /* istanbul ignore next */
        return function lintDoctype($, reporter) {
            /* eslint-disable no-undef, block-scoped-var */
            var doc = window.document;
            /* eslint-enable un-undef, block-scoped-var */
            if (doc.doctype === null) {
                reporter(MISSING_DOCTYPE);
            } else if (doc.doctype.publicId) {
                reporter(NON_HTML5_DOCTYPE);
            } else if (doc.doctype.systemId && doc.doctype.systemId !== 'about:legacy-compat') {
                reporter(NON_HTML5_DOCTYPE);
            }
        };
    })());
    addLinter('E003', function lintContainers($, reporter) {
        var notAnyColClass = COL_CLASSES.map(function (colClass) {
            return ':not(' + colClass + ')';
        }).join('');
        var selector = '*' + notAnyColClass + '>.row';
        var rowsOutsideColumns = $(selector);
        var rowsOutsideColumnsAndContainers = rowsOutsideColumns.filter(function () {
            var parent = $(this).parent();
            while (parent.length) {
                if (parent.is('.container, .container-fluid, .modal-body')) {
                    return false;
                }
                parent = $(parent).parent();
            }
            return true;
        });
        if (rowsOutsideColumnsAndContainers.length) {
            reporter('Found one or more `.row`s that were not children of a grid column or descendants of a `.container` or `.container-fluid` or `.modal-body`', rowsOutsideColumnsAndContainers);
        }
    });
    addLinter('E005', function lintRowAndColOnSameElem($, reporter) {
        var selector = COL_CLASSES.map(function (col) {
            return '.row' + col;
        }).join(',');

        var rowCols = $(selector);
        if (rowCols.length) {
            reporter('Found both `.row` and `.col*` used on the same element', rowCols);
        }
    });
    /*
    addLinter('E007', function lintBootstrapJs($, reporter) {
        var scripts = bootstrapScriptsIn($);
        if (scripts.longhands.length && scripts.minifieds.length) {
            reporter('Only one copy of Bootstrap\'s JS should be included; currently the webpage includes both bootstrap.js and bootstrap.min.js', scripts.longhands.add(scripts.minifieds));
        }
    });
    */
    addLinter('E009', function lintMissingInputGroupSizes($, reporter) {
        var selector = [
            '.input-group:not(.input-group-lg) .btn-lg',
            '.input-group:not(.input-group-lg) .form-control-lg',
            '.input-group:not(.input-group-sm) .btn-sm',
            '.input-group:not(.input-group-sm) .form-control-sm'
        ].join(',');
        var badInputGroupSizing = $(selector);
        if (badInputGroupSizing.length) {
            reporter('Button and input sizing within `.input-group`s can cause issues. Instead, use input group sizing classes `.input-group-lg` or `.input-group-sm`', badInputGroupSizing);
        }
    });
    addLinter('E011', function lintFormGroupMixedWithInputGroup($, reporter) {
        var badMixes = $('.input-group.form-group, .input-group.row, .input-group.form-row');
        if (badMixes.length) {
            reporter('`.input-group` and `.form-group`/`.row`/`.form-row` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.form-group`/`.row`/`.form-row`', badMixes);
        }
    });
    addLinter('E012', function lintGridClassMixedWithInputGroup($, reporter) {
        var selector = COL_CLASSES.map(function (colClass) {
            return '.input-group' + colClass;
        }).join(',');

        var badMixes = $(selector);
        if (badMixes.length) {
            reporter('`.input-group` and `.col*` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.col*`', badMixes);
        }
    });
    addLinter('E013', function lintRowChildrenAreCols($, reporter) {
        var ALLOWED_CHILDREN = COL_CLASSES.concat(['script', '.clearfix']);
        var disallowedChildren = ALLOWED_CHILDREN.map(function (colClass) {
            return ':not(' + colClass + ')';
        }).join('');
        var selector = '.row>*' + disallowedChildren + ',.form-row>*' + disallowedChildren;

        var nonColRowChildren = $(selector);
        if (nonColRowChildren.length) {
            reporter('Only columns (`.col*`) or `.clearfix` may be children of `.row`s or `.form-row`s', nonColRowChildren);
        }
    });
    addLinter('E014', function lintColParentsAreRowsOrFormGroups($, reporter) {
        var selector = COL_CLASSES.map(function (colClass) {
            return '*:not(.row):not(.form-row)>' + colClass + ':not(col):not(th):not(td)';
        }).join(',');

        var colsOutsideRowsAndFormGroups = $(selector);
        if (colsOutsideRowsAndFormGroups.length) {
            reporter('Columns (`.col*`) can only be children of `.row`s or `.form-row`s', colsOutsideRowsAndFormGroups);
        }
    });
    /*
    addLinter('E016', function lintBtnToggle($, reporter) {
        var badBtnToggle = $('.btn.dropdown-toggle ~ .btn');
        if (badBtnToggle.length) {
            reporter('`.btn.dropdown-toggle` must be the last button in a button group.', badBtnToggle);
        }
    });
    */
    /*
    addLinter('E017', function lintBlockCheckboxes($, reporter) {
        var badCheckboxes = $('.checkbox').filter(function (i, div) {
            return $(div).filter(':has(>label>input[type="checkbox"])').length <= 0;
        });
        if (badCheckboxes.length) {
            reporter('Incorrect markup used with the `.checkbox` class. The correct markup structure is `.checkbox>label>input[type="checkbox"]`', badCheckboxes);
        }
    });
    */
    /*
    addLinter('E018', function lintBlockRadios($, reporter) {
        var badRadios = $('.radio').filter(function (i, div) {
            return $(div).filter(':has(>label>input[type="radio"])').length <= 0;
        });
        if (badRadios.length) {
            reporter('Incorrect markup used with the `.radio` class. The correct markup structure is `.radio>label>input[type="radio"]`', badRadios);
        }
    });
    */
    /*
    addLinter('E019', function lintInlineCheckboxes($, reporter) {
        var wrongElems = $('.checkbox-inline:not(label)');
        if (wrongElems.length) {
            reporter('`.checkbox-inline` should only be used on `<label>` elements', wrongElems);
        }
        var badStructures = $('.checkbox-inline').filter(function (i, label) {
            return $(label).children('input[type="checkbox"]').length <= 0;
        });
        if (badStructures.length) {
            reporter('Incorrect markup used with the `.checkbox-inline` class. The correct markup structure is `label.checkbox-inline>input[type="checkbox"]`', badStructures);
        }
    });
    */
    /*
    addLinter('E020', function lintInlineRadios($, reporter) {
        var wrongElems = $('.radio-inline:not(label)');
        if (wrongElems.length) {
            reporter('`.radio-inline` should only be used on `<label>` elements', wrongElems);
        }
        var badStructures = $('.radio-inline').filter(function (i, label) {
            return $(label).children('input[type="radio"]').length <= 0;
        });
        if (badStructures.length) {
            reporter('Incorrect markup used with the `.radio-inline` class. The correct markup structure is `label.radio-inline>input[type="radio"]`', badStructures);
        }
    });
    */
    /*
    addLinter('E021', function lintButtonsCheckedActive($, reporter) {
        var selector = [
            '[data-toggle="buttons"]>label:not(.active)>input[type="checkbox"][checked]',
            '[data-toggle="buttons"]>label.active>input[type="checkbox"]:not([checked])',
            '[data-toggle="buttons"]>label:not(.active)>input[type="radio"][checked]',
            '[data-toggle="buttons"]>label.active>input[type="radio"]:not([checked])'
        ].join(',');
        var mismatchedButtonInputs = $(selector);
        if (mismatchedButtonInputs.length) {
            reporter('`.active` class used without the `checked` attribute (or vice-versa) in a button group using the button.js plugin', mismatchedButtonInputs);
        }
    });
    */
    addLinter('E022', function lintModalsWithinOtherComponents($, reporter) {
        var selector = [
            '.table .modal',
            '.navbar .modal'
        ].join(',');
        var badNestings = $(selector);
        if (badNestings.length) {
            reporter('Modal markup should not be placed within other components, so as to avoid the component\'s styles interfering with the modal\'s appearance or functionality', badNestings);
        }
    });
    addLinter('E023', function lintCardBodyWithoutCard($, reporter) {
        var badCardBody = $('.card-body').filter(function () {
            return $(this).closest('.card').length !== 1;
        });
        if (badCardBody.length) {
            reporter('`.card-body` must have `.card` or have it as an ancestor.', badCardBody);
        }
    });
    addLinter('E024', function lintCardHeaderWithoutCard($, reporter) {
        var badCardHeader = $('.card-header').filter(function () {
            return $(this).parents('.card').length !== 1;
        });
        if (badCardHeader.length) {
            reporter('`.card-header` must have a `.card` ancestor.', badCardHeader);
        }
    });
    addLinter('E025', function lintCardFooterWithoutCard($, reporter) {
        var badCardFooter = $('.card-footer').filter(function () {
            return $(this).parents('.card').length !== 1;
        });
        if (badCardFooter.length) {
            reporter('`.card-footer` must have a `.card` ancestor.', badCardFooter);
        }
    });
    addLinter('E026', function lintCardTitleWithoutCard($, reporter) {
        var badCardTitle = $('.card-title').filter(function () {
            return $(this).parents('.card').length !== 1;
        });
        if (badCardTitle.length) {
            reporter('`.card-title` must have a `.card` ancestor.', badCardTitle);
        }
    });
    addLinter('E027', function lintTableResponsive($, reporter) {

        var tableSelectors = ['.table', 'table'];
        var badStructureSelectors = [];

        for (var i = 0; i < tableSelectors.length; i++) {
            for (var j = 0; j < NUM2SCREEN.length; j++) {
                badStructureSelectors.push(tableSelectors[i] + '.table-responsive-' + NUM2SCREEN[j]);
            }
        }

        var badStructure = $(badStructureSelectors.join(','));
        if (badStructure.length) {
            reporter('`.table-responsive*` is supposed to be used on the table\'s parent wrapper `<div>`, not on the table itself', badStructure);
        }
    });
    /*
    addLinter('E028', function lintFormControlFeedbackWithoutHasFeedback($, reporter) {
        var ancestorsMissingClasses = $('.form-control-feedback').filter(function () {
            return $(this).closest('.form-group.has-feedback').length !== 1;
        });
        if (ancestorsMissingClasses.length) {
            reporter('`.form-control-feedback` must have a `.form-group.has-feedback` ancestor', ancestorsMissingClasses);
        }
    });
    */
    addLinter('E029', function lintRedundantColumnClasses($, reporter) {
        var columns = $(COL_CLASSES.join(','));
        columns.each(function (_index, col) {
            var column = $(col);
            var classes = column.attr('class');
            var simplifiedClasses = classes;
            var width2screens = width2screensFor(classes);
            var isRedundant = false;
            for (var width in width2screens) {
                if (Object.prototype.hasOwnProperty.call(width2screens, width)) {
                    var screens = width2screens[width];
                    var runs = incrementingRunsFrom(screens);
                    if (!runs.length) {
                        continue;
                    }

                    isRedundant = true;

                    for (var i = 0; i < runs.length; i++) {
                        var run = runs[i];
                        var min = run[0];
                        var max = run[1];

                        // remove redundant classes
                        for (var screenNum = min + 1; screenNum <= max; screenNum++) {
                            var colClass = 'col' + (NUM2SCREEN[screenNum] && '-' + NUM2SCREEN[screenNum]) + (width && '-' + width);
                            simplifiedClasses = withoutClass(simplifiedClasses, colClass);
                        }
                    }
                }
            }
            if (!isRedundant) {
                return;
            }

            simplifiedClasses = sortedColumnClasses(simplifiedClasses);
            simplifiedClasses = simplifiedClasses.replace(/ {2,}/g, ' ').trim();
            var oldClass = '`class="' + classes + '"`';
            var newClass = '`class="' + simplifiedClasses + '"`';
            reporter(
                'Since grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes (unless overridden by grid classes targeting larger screens), ' +
                oldClass + ' is redundant and can be simplified to ' + newClass,
                column
            );
        });
    });
    addLinter('E032', function lintModalStructure($, reporter) {
        var elements;

        elements = $('.modal-dialog').parent(':not(.modal)');
        if (elements.length) {
            reporter('`.modal-dialog` must be a child of `.modal`', elements);
        }

        elements = $('.modal-content').parent(':not(.modal-dialog)');
        if (elements.length) {
            reporter('`.modal-content` must be a child of `.modal-dialog`', elements);
        }

        elements = $('.modal-header').parent(':not(.modal-content)');
        if (elements.length) {
            reporter('`.modal-header` must be a child of `.modal-content`', elements);
        }

        elements = $('.modal-body').parent(':not(.modal-content)');
        if (elements.length) {
            reporter('`.modal-body` must be a child of `.modal-content`', elements);
        }

        elements = $('.modal-footer').parent(':not(.modal-content)');
        if (elements.length) {
            reporter('`.modal-footer` must be a child of `.modal-content`', elements);
        }

        elements = $('.modal-title').parent(':not(.modal-header)');
        if (elements.length) {
            reporter('`.modal-title` must be a child of `.modal-header`', elements);
        }
    });
    /*
    addLinter('E033', function lintAlertMissingDismissible($, reporter) {
        var alertsMissingDismissible = $('.alert:not(.alert-dismissible):has([data-dismiss="alert"])');
        if (alertsMissingDismissible.length) {
            reporter('`.alert` with dismiss button must have class `.alert-dismissible`', alertsMissingDismissible);
        }
    });
    */
    /*
    addLinter('E034', function lintAlertDismissStructure($, reporter) {
        var nonFirstChildCloses = $('.alert>.close:not(:first-child)');
        var closesPrecededByText = $('.alert>.close').filter(function () {
            var firstNode = $(this).parent().contents().eq(0);
            var firstNodeIsText = IN_NODE_JS ? firstNode[0].type === 'text' : firstNode[0].nodeType === 3;
            return Boolean(firstNodeIsText && firstNode.text().trim());
        });
        var problematicCloses = nonFirstChildCloses.add(closesPrecededByText);
        if (problematicCloses.length) {
            reporter('`.close` button for `.alert` must be the first element in the `.alert`', problematicCloses);
        }
    });
    */
    /*
    addLinter('E035', function lintFormGroupWithFormClass($, reporter) {
        var badFormGroups = $('.form-group.form-inline, .form-group.form-horizontal');
        if (badFormGroups.length) {
            reporter('Neither `.form-inline` nor `.form-horizontal` should be used directly on a `.form-group`. Instead, nest the `.form-group` within the `.form-inline` or `.form-horizontal`', badFormGroups);
        }
    });
    */
    addLinter('E037', function lintColZeros($, reporter) {
        var selector = SCREENS.map(function (screen) {
            return '.col' + (screen && '-' + screen) + '-0';
        }).join(',');
        var elements = $(selector);
        if (elements.length) {
            reporter('Column widths must be positive integers (and <= 12 by default). Found usage(s) of invalid nonexistent `.col*-0` classes.', elements);
        }
    });
    /*
    addLinter('E039', function lintNavbarPulls($, reporter) {
        var navbarPullsOutsideNavbars = $('.navbar-left, .navbar-right').filter(function () {
            return !$(this).parent().closest('.navbar').length;
        });
        if (navbarPullsOutsideNavbars.length) {
            reporter('`.navbar-left` and `.navbar-right` should not be used outside of navbars.', navbarPullsOutsideNavbars);
        }
    });
    */
    addLinter('E041', function lintCarouselStructure($, reporter) {
        var carouselsWithWrongInners = $('.carousel').filter(function () {
            return $(this).children('.carousel-inner').length !== 1;
        });
        if (carouselsWithWrongInners.length) {
            reporter('`.carousel` must have exactly one `.carousel-inner` child.', carouselsWithWrongInners);
        }

        var innersWithWrongActiveItems = $('.carousel-inner').filter(function () {
            return $(this).children('.item.active').length !== 1;
        });
        if (innersWithWrongActiveItems.length) {
            reporter('`.carousel-inner` must have exactly one `.item.active` child.', innersWithWrongActiveItems);
        }
    });
    /*
    addLinter('E042', function lintFormControlOnWrongControl($, reporter) {
        var formControlsOnWrongTags = $('.form-control:not(input,textarea,select)');
        if (formControlsOnWrongTags.length) {
            reporter('`.form-control` should only be used on `<input>`s, `<textarea>`s, and `<select>`s.', formControlsOnWrongTags);
        }

        var formControlsOnWrongTypes = $('input.form-control:not(' + [
            'color',
            'email',
            'number',
            'password',
            'search',
            'tel',
            'text',
            'url',
            'date',
            'month',
            'week',
            'time'
        ].map(function (type) {
            return '[type="' + type + '"]';
        }).join(',') + ')');
        if (formControlsOnWrongTypes.length) {
            reporter('`.form-control` cannot be used on non-textual `<input>`s, such as those whose `type` is: `file`, `checkbox`, `radio`, `range`, `button`', formControlsOnWrongTypes);
        }
    });
    */
    /*
    addLinter('E043', function lintNavbarNavAnchorButtons($, reporter) {
        var navbarNavAnchorBtns = $('.navbar-nav a.btn, .navbar-nav a.navbar-btn');
        if (navbarNavAnchorBtns.length) {
            reporter('Button classes (`.btn`, `.btn-*`, `.navbar-btn`) cannot be used on `<a>`s within `.navbar-nav`s.', navbarNavAnchorBtns);
        }
    });
    */
    addLinter('E044', function lintInputGroupAddonChildren($, reporter) {
        var badInputGroups = $('.input-group').filter(function () {
            var inputGroup = $(this);
            return !inputGroup.children('.form-control, .custom-select, .custom-file').length || !inputGroup.children('.input-group-prepend, .input-group-append').length;
        });
        if (badInputGroups.length) {
            reporter('`.input-group` must have at least one `.form-control`/`.custom-select`/`.custom-file` child and also at least one `.input-group-prepend`/`.input-group-append` child.', badInputGroups);
        }
    });
    addLinter('E045', function lintImgResponsiveOnNonImgs($, reporter) {
        var imgResponsiveNotOnImg = $('.img-fluid:not(img)');
        if (imgResponsiveNotOnImg.length) {
            reporter('`.img-fluid` should only be used on `<img>`s', imgResponsiveNotOnImg);
        }
    });
    addLinter('E046', function lintModalTabIndex($, reporter) {
        var modalsWithoutTabindex = $('.modal:not([tabindex])');
        if (modalsWithoutTabindex.length) {
            reporter('`.modal` elements must have a `tabindex` attribute.', modalsWithoutTabindex);
        }
    });
    /*
    addLinter('E047', function lintBtnElements($, reporter) {
        var btns = $('.btn:not(a,button,input,label)');
        if (btns.length) {
            reporter('`.btn` should only be used on `<a>`, `<button>`, `<input>`, or `<label>` elements.', btns);
        }
    });
    */
    addLinter('E048', function lintModalRole($, reporter) {
        var modals = $('.modal:not([role="dialog"])');
        if (modals.length) {
            reporter('`.modal` must have a `role="dialog"` attribute.', modals);
        }
    });
    addLinter('E049', function lintModalDialogRole($, reporter) {
        var modalDialogs = $('.modal-dialog:not([role="document"])');
        if (modalDialogs.length) {
            reporter('`.modal-dialog` must have a `role="document"` attribute.', modalDialogs);
        }
    });
    /*
    addLinter('E050', function lintNestedFormGroups($, reporter) {
        var nestedFormGroups = $('.form-group > .form-group');
        if (nestedFormGroups.length) {
            reporter('`.form-group`s should not be nested.', nestedFormGroups);
        }
    });
    */
    addLinter('E051', function lintColumnsNoFloats($, reporter) {
        var pullSelector = COL_CLASSES.map(function (col) {
            return '.float-left' + col + ',.float-right' + col;
        }).join(',');
        var pulledCols = $(pullSelector);
        if (pulledCols.length) {
            reporter('`.float-right` and `.float-left` must not be used on `.col*` elements', pulledCols);
        }
        var styledSelector = COL_CLASSES.map(function (col) {
            return col + '[style]';
        }).join(',');
        var styledCols = $(styledSelector).filter(function (i, el) {
            //test for `float:*` in the style attribute
            return /float\s*:\s*[a-z]+/i.test($(el).attr('style'));
        });
        if (styledCols.length) {
            reporter('Manually added `float` styles must not be added on `.col*` elements', styledCols);
        }
    });
    addLinter('E052', function lintRowsNoFloats($, reporter) {
        var pulledRows = $('.row.float-right, .row.float-left');
        if (pulledRows.length) {
            reporter('`.float-right` and `.float-left` must not be used on `.row` elements', pulledRows);
        }
        var styledRows = $('.row[style]').filter(function (i, el) {
            //test for `float:*` in the style attribute
            return /float\s*:\s*[a-z]+/i.test($(el).attr('style'));
        });
        if (styledRows.length) {
            reporter('Manually added `float` styles must not be added on `.row` elements', styledRows);
        }
    });
    exports._lint = function ($, reporter, disabledIdList, html) {
        var locationIndex = IN_NODE_JS ? new LocationIndex(html) : null;
        var reporterWrapper = IN_NODE_JS ?
            function (problem) {
                if (problem.elements) {
                    problem.elements = problem.elements.each(function (i, element) {
                        if (typeof element.startIndex !== 'undefined') {
                            var location = locationIndex.locationOf(element.startIndex);
                            if (location) {
                                element.startLocation = location;
                            }
                        }
                    });
                }
                reporter(problem);
            } :
            reporter;

        var disabledIdSet = {};
        disabledIdList.forEach(function (disabledId) {
            disabledIdSet[disabledId] = true;
        });
        Object.keys(allLinters).sort().forEach(function (linterId) {
            if (!disabledIdSet[linterId]) {
                allLinters[linterId]($, reporterWrapper);
            }
        });
    };
    /**
     * @callback reporter
     * @param {LintWarning|LintError} problem A lint problem
     * @returns {undefined} Any return value is ignored.
     */

    if (IN_NODE_JS) {
        // cheerio; Node.js
        /**
         * Lints the given HTML.
         * @param {string} html The HTML to lint
         * @param {reporter} reporter Function to call with each lint problem
         * @param {string[]} disabledIds Array of string IDs of linters to disable
         * @returns {undefined} Nothing
         */
        exports.lintHtml = function (html, reporter, disabledIds) {
            var $ = cheerio.load(html, {withStartIndices: true});
            this._lint($, reporter, disabledIds, html);
        };
    } else {
        // jQuery; in-browser
        /* istanbul ignore next */
        (function () {
            var $ = cheerio;
            /**
             * Lints the HTML of the current document.
             * @param {reporter} reporter Function to call with each lint problem
             * @param {string[]} disabledIds Array of string IDs of linters to disable
             * @returns {undefined} Nothing
             */
            exports.lintCurrentDocument = function (reporter, disabledIds) {
                this._lint($, reporter, disabledIds);
            };
            /**
             * Lints the HTML of the current document.
             * If there are any lint warnings, one general notification message will be window.alert()-ed to the user.
             * Each warning will be output individually using console.warn().
             * @param {string[]} disabledIds Array of string IDs of linters to disable
             * @param {object} [alertOpts] Options object to configure alert()ing
             * @param {boolean} [alertOpts.hasProblems=true] Show one alert() when the first lint problem is found?
             * @param {boolean} [alertOpts.problemFree=true] Show one alert() at the end of linting if the page has no lint problems?
             * @returns {undefined} Nothing
             */
            exports.showLintReportForCurrentDocument = function (disabledIds, alertOpts) {
                alertOpts = alertOpts || {};
                var alertOnFirstProblem = alertOpts.hasProblems || typeof alertOpts.hasProblems === 'undefined';
                var alertIfNoProblems = alertOpts.problemFree || typeof alertOpts.problemFree === 'undefined';

                var seenLint = false;
                var errorCount = 0;
                var reporter = function (lint) {
                    var background = 'background: #' + (lint.id[0] === 'W' ? 'f0ad4e' : 'd9534f') + '; color: #ffffff;';
                    if (!seenLint) {
                        if (alertOnFirstProblem) {
                            /* eslint-disable no-alert, no-undef, block-scoped-var */
                            window.alert('bootlint found errors in this document! See the JavaScript console for details.');
                            /* eslint-enable no-alert, no-undef, block-scoped-var */
                        }
                        seenLint = true;
                    }

                    if (lint.elements.length) {
                        console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url, lint.elements);
                    } else {
                        console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url);
                    }
                    errorCount++;
                };
                this.lintCurrentDocument(reporter, disabledIds);

                if (errorCount > 0) {
                    console.info('bootlint: For details, look up the lint problem IDs in the Bootlint wiki: https://github.com/twbs/bootlint/wiki');
                } else if (alertIfNoProblems) {
                    /* eslint-disable no-alert, no-undef, block-scoped-var */
                    window.alert('bootlint found no errors in this document.');
                    /* eslint-enable no-alert, no-undef, block-scoped-var */
                }
            };
            /* eslint-disable no-undef, block-scoped-var */
            window.bootlint = exports;
            /* eslint-enable no-undef, block-scoped-var */
        })();
    }
})(typeof exports === 'object' && exports || this);