Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 8e06ef6

Browse files
committed
More specific selectors in Bootstrap 3 detection
1 parent 0258293 commit 8e06ef6

File tree

1 file changed

+318
-0
lines changed

1 file changed

+318
-0
lines changed

src/bootlint.js

+318
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,324 @@ var LocationIndex = _location.LocationIndex;
609609
}
610610
});
611611
*/
612+
addLinter('W018', function bs3ClassUsed($, reporter) {
613+
var bs3Selectors = [
614+
'td.active, th.active, tr.info',
615+
'.affix',
616+
'.alert-dismissable',
617+
'.blockquote-reverse',
618+
'.tooltip.bottom, .popover.bottom',
619+
'.bottom-left',
620+
'.bottom-right',
621+
'.btn-default',
622+
'.btn-group-justified',
623+
'.btn-group-xs',
624+
'.btn-xs',
625+
'.thumbnail .caption',
626+
'.caret',
627+
'.carousel-control',
628+
'.center-block',
629+
'.checkbox label',
630+
'.checkbox-inline label',
631+
'.col-lg-offset-0',
632+
'.col-lg-offset-1',
633+
'.col-lg-offset-2',
634+
'.col-lg-offset-3',
635+
'.col-lg-offset-4',
636+
'.col-lg-offset-5',
637+
'.col-lg-offset-6',
638+
'.col-lg-offset-7',
639+
'.col-lg-offset-8',
640+
'.col-lg-offset-9',
641+
'.col-lg-offset-10',
642+
'.col-lg-offset-11',
643+
'.col-lg-offset-12',
644+
'.col-lg-pull-0',
645+
'.col-lg-pull-1',
646+
'.col-lg-pull-2',
647+
'.col-lg-pull-3',
648+
'.col-lg-pull-4',
649+
'.col-lg-pull-5',
650+
'.col-lg-pull-6',
651+
'.col-lg-pull-7',
652+
'.col-lg-pull-8',
653+
'.col-lg-pull-9',
654+
'.col-lg-pull-10',
655+
'.col-lg-pull-11',
656+
'.col-lg-pull-12',
657+
'.col-lg-push-0',
658+
'.col-lg-push-1',
659+
'.col-lg-push-2',
660+
'.col-lg-push-3',
661+
'.col-lg-push-4',
662+
'.col-lg-push-5',
663+
'.col-lg-push-6',
664+
'.col-lg-push-7',
665+
'.col-lg-push-8',
666+
'.col-lg-push-9',
667+
'.col-lg-push-10',
668+
'.col-lg-push-11',
669+
'.col-lg-push-12',
670+
'.col-md-offset-0',
671+
'.col-md-offset-1',
672+
'.col-md-offset-2',
673+
'.col-md-offset-3',
674+
'.col-md-offset-4',
675+
'.col-md-offset-5',
676+
'.col-md-offset-6',
677+
'.col-md-offset-7',
678+
'.col-md-offset-8',
679+
'.col-md-offset-9',
680+
'.col-md-offset-10',
681+
'.col-md-offset-11',
682+
'.col-md-offset-12',
683+
'.col-md-pull-0',
684+
'.col-md-pull-1',
685+
'.col-md-pull-2',
686+
'.col-md-pull-3',
687+
'.col-md-pull-4',
688+
'.col-md-pull-5',
689+
'.col-md-pull-6',
690+
'.col-md-pull-7',
691+
'.col-md-pull-8',
692+
'.col-md-pull-9',
693+
'.col-md-pull-10',
694+
'.col-md-pull-11',
695+
'.col-md-pull-12',
696+
'.col-md-push-0',
697+
'.col-md-push-1',
698+
'.col-md-push-2',
699+
'.col-md-push-3',
700+
'.col-md-push-4',
701+
'.col-md-push-5',
702+
'.col-md-push-6',
703+
'.col-md-push-7',
704+
'.col-md-push-8',
705+
'.col-md-push-9',
706+
'.col-md-push-10',
707+
'.col-md-push-11',
708+
'.col-md-push-12',
709+
'.col-sm-offset-0',
710+
'.col-sm-offset-1',
711+
'.col-sm-offset-2',
712+
'.col-sm-offset-3',
713+
'.col-sm-offset-4',
714+
'.col-sm-offset-5',
715+
'.col-sm-offset-6',
716+
'.col-sm-offset-7',
717+
'.col-sm-offset-8',
718+
'.col-sm-offset-9',
719+
'.col-sm-offset-10',
720+
'.col-sm-offset-11',
721+
'.col-sm-offset-12',
722+
'.col-sm-pull-0',
723+
'.col-sm-pull-1',
724+
'.col-sm-pull-2',
725+
'.col-sm-pull-3',
726+
'.col-sm-pull-4',
727+
'.col-sm-pull-5',
728+
'.col-sm-pull-6',
729+
'.col-sm-pull-7',
730+
'.col-sm-pull-8',
731+
'.col-sm-pull-9',
732+
'.col-sm-pull-10',
733+
'.col-sm-pull-11',
734+
'.col-sm-pull-12',
735+
'.col-sm-push-0',
736+
'.col-sm-push-1',
737+
'.col-sm-push-2',
738+
'.col-sm-push-3',
739+
'.col-sm-push-4',
740+
'.col-sm-push-5',
741+
'.col-sm-push-6',
742+
'.col-sm-push-7',
743+
'.col-sm-push-8',
744+
'.col-sm-push-9',
745+
'.col-sm-push-10',
746+
'.col-sm-push-11',
747+
'.col-sm-push-12',
748+
'.col-xs-1',
749+
'.col-xs-2',
750+
'.col-xs-3',
751+
'.col-xs-4',
752+
'.col-xs-5',
753+
'.col-xs-6',
754+
'.col-xs-7',
755+
'.col-xs-8',
756+
'.col-xs-9',
757+
'.col-xs-10',
758+
'.col-xs-11',
759+
'.col-xs-12',
760+
'.col-xs-offset-0',
761+
'.col-xs-offset-1',
762+
'.col-xs-offset-2',
763+
'.col-xs-offset-3',
764+
'.col-xs-offset-4',
765+
'.col-xs-offset-5',
766+
'.col-xs-offset-6',
767+
'.col-xs-offset-7',
768+
'.col-xs-offset-8',
769+
'.col-xs-offset-9',
770+
'.col-xs-offset-10',
771+
'.col-xs-offset-11',
772+
'.col-xs-offset-12',
773+
'.col-xs-pull-0',
774+
'.col-xs-pull-1',
775+
'.col-xs-pull-2',
776+
'.col-xs-pull-3',
777+
'.col-xs-pull-4',
778+
'.col-xs-pull-5',
779+
'.col-xs-pull-6',
780+
'.col-xs-pull-7',
781+
'.col-xs-pull-8',
782+
'.col-xs-pull-9',
783+
'.col-xs-pull-10',
784+
'.col-xs-pull-11',
785+
'.col-xs-pull-12',
786+
'.col-xs-push-0',
787+
'.col-xs-push-1',
788+
'.col-xs-push-2',
789+
'.col-xs-push-3',
790+
'.col-xs-push-4',
791+
'.col-xs-push-5',
792+
'.col-xs-push-6',
793+
'.col-xs-push-7',
794+
'.col-xs-push-8',
795+
'.col-xs-push-9',
796+
'.col-xs-push-10',
797+
'.col-xs-push-11',
798+
'.col-xs-push-12',
799+
'.control-label',
800+
'td.danger, th.danger, tr.danger',
801+
'.dl-horizontal',
802+
'.dropdown-backdrop',
803+
'.dropdown-menu-left',
804+
'.form-control-static',
805+
'.form-group-lg',
806+
'.form-group-sm',
807+
'.form-horizontal',
808+
'.has-error',
809+
'.has-success',
810+
'.has-warning',
811+
'.help-block',
812+
'.hidden',
813+
'.hidden-lg',
814+
'.hidden-md',
815+
'.hidden-print',
816+
'.hidden-sm',
817+
'.hidden-xs',
818+
'.hide',
819+
'.icon-bar',
820+
'.icon-next',
821+
'.icon-prev',
822+
'.img-circle',
823+
'.img-responsive',
824+
'.img-rounded',
825+
'.fade.in, .collapse.in, .navbar-collapse.in, .modal.in, .modal-backdrop.in, .tooltip.in',
826+
'td.info, th.info, tr.info',
827+
'.input-lg',
828+
'.input-sm',
829+
'.carousel-inner > .item',
830+
'.label',
831+
'.label-danger',
832+
'.label-default',
833+
'.label-info',
834+
'.label-primary',
835+
'.label-success',
836+
'.label-warning',
837+
'.tooltip.left, .popover.left, .item.left',
838+
'.list-group-item-heading',
839+
'.list-group-item-text',
840+
'.media-bottom',
841+
'.media-heading',
842+
'.media-left',
843+
'.media-list',
844+
'.media-middle',
845+
'.media-object',
846+
'.media-right',
847+
'.navbar-btn',
848+
'.navbar-default',
849+
'.navbar-fixed-bottom',
850+
'.navbar-fixed-top',
851+
'.navbar-form',
852+
'.navbar-header',
853+
'.navbar-inverse',
854+
'.navbar-left',
855+
'.navbar-link',
856+
'.navbar-right',
857+
'.navbar-static-top',
858+
'.navbar-toggle',
859+
'.nav-divider',
860+
'.nav-stacked',
861+
'.nav-tabs-justified',
862+
'.item.next',
863+
'.btn-group.open',
864+
'.page-header',
865+
'.pager',
866+
'.panel',
867+
'.panel-body',
868+
'.panel-collapse',
869+
'.panel-danger',
870+
'.panel-default',
871+
'.panel-footer',
872+
'.panel-group',
873+
'.panel-heading',
874+
'.panel-info',
875+
'.panel-primary',
876+
'.panel-success',
877+
'.panel-title',
878+
'.panel-warning',
879+
'.popover-content',
880+
'.popover-title',
881+
'.item.prev, .carousel-inner > .prev',
882+
'.pager .previous',
883+
'.progress-bar-danger',
884+
'.progress-bar-info',
885+
'.progress-bar-success',
886+
'.progress-bar-warning',
887+
'.progress-striped',
888+
'.pull-left',
889+
'.pull-right',
890+
'.radio label',
891+
'.radio-inline label',
892+
'.row-no-gutters',
893+
'td.success, th.success, tr.success',
894+
'.table-condensed',
895+
'.thumbnail',
896+
'.tooltip-arrow',
897+
'.tooltip.top, .popover.top',
898+
'.tooltip.top-left',
899+
'.tooltip.top-right',
900+
'.visible-lg',
901+
'.visible-lg-block',
902+
'.visible-lg-inline',
903+
'.visible-lg-inline-block',
904+
'.visible-md',
905+
'.visible-md-block',
906+
'.visible-md-inline',
907+
'.visible-md-inline-block',
908+
'.visible-print',
909+
'.visible-print-block',
910+
'.visible-print-inline',
911+
'.visible-print-inline-block',
912+
'.visible-sm',
913+
'.visible-sm-block',
914+
'.visible-sm-inline',
915+
'.visible-sm-inline-block',
916+
'.visible-xs',
917+
'.visible-xs-block',
918+
'.visible-xs-inline',
919+
'.visible-xs-inline-block',
920+
'td.warning, th.warning, tr.warning',
921+
'.well',
922+
'.well-lg',
923+
'.well-sm'
924+
];
925+
var bs3Usage = $(bs3Selectors.join(', '));
926+
if (bs3Usage.length) {
927+
reporter('Found usage of CSS classes possibly indicative of Bootstrap 3 and not newer versions.', bs3Usage);
928+
}
929+
});
612930
addLinter('E001', (function () {
613931
var MISSING_DOCTYPE = 'Document is missing a DOCTYPE declaration';
614932
var NON_HTML5_DOCTYPE = 'Document declares a non-HTML5 DOCTYPE';

0 commit comments

Comments
 (0)