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

Commit 551cafa

Browse files
committed
Support new modals
Removed W004, and E040. Ported E022, E032, E046, E048, and E049
1 parent d32eaa4 commit 551cafa

14 files changed

+451
-53
lines changed

src/bootlint.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,6 @@ var LocationIndex = _location.LocationIndex;
357357
});
358358
*/
359359
/*
360-
addLinter('W004', function lintRemoteModals($, reporter) {
361-
var remoteModalTriggers = $('[data-toggle="modal"][data-remote]');
362-
if (remoteModalTriggers.length) {
363-
reporter('Found one or more modals using the deprecated `remote` option', remoteModalTriggers);
364-
}
365-
});
366-
*/
367-
/*
368360
addLinter('W005', function lintJquery($, reporter) {
369361
var OLD_JQUERY = 'Found what might be an outdated version of jQuery; Bootstrap requires jQuery v' + MIN_JQUERY_VERSION + ' or higher';
370362
var NO_JQUERY_BUT_BS_JS = 'Unable to locate jQuery, which is required for Bootstrap\'s JavaScript plugins to work';
@@ -866,7 +858,6 @@ var LocationIndex = _location.LocationIndex;
866858
}
867859
});
868860
*/
869-
/*
870861
addLinter('E022', function lintModalsWithinOtherComponents($, reporter) {
871862
var selector = [
872863
'.table .modal',
@@ -877,7 +868,6 @@ var LocationIndex = _location.LocationIndex;
877868
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);
878869
}
879870
});
880-
*/
881871
/*
882872
addLinter('E023', function lintPanelBodyWithoutPanel($, reporter) {
883873
var badPanelBody = $('.panel-body').parent(':not(.panel, .panel-collapse)');
@@ -992,7 +982,6 @@ var LocationIndex = _location.LocationIndex;
992982
}
993983
});
994984
*/
995-
/*
996985
addLinter('E032', function lintModalStructure($, reporter) {
997986
var elements;
998987

@@ -1026,7 +1015,6 @@ var LocationIndex = _location.LocationIndex;
10261015
reporter('`.modal-title` must be a child of `.modal-header`', elements);
10271016
}
10281017
});
1029-
*/
10301018
/*
10311019
addLinter('E033', function lintAlertMissingDismissible($, reporter) {
10321020
var alertsMissingDismissible = $('.alert:not(.alert-dismissible):has([data-dismiss="alert"])');
@@ -1087,14 +1075,6 @@ var LocationIndex = _location.LocationIndex;
10871075
});
10881076
*/
10891077
/*
1090-
addLinter('E040', function lintModalHide($, reporter) {
1091-
var modalsWithHide = $('.modal.hide');
1092-
if (modalsWithHide.length) {
1093-
reporter('`.hide` should not be used on `.modal` in Bootstrap v3.', modalsWithHide);
1094-
}
1095-
});
1096-
*/
1097-
/*
10981078
addLinter('E041', function lintCarouselStructure($, reporter) {
10991079
var carouselsWithWrongInners = $('.carousel').filter(function () {
11001080
return $(this).children('.carousel-inner').length !== 1;
@@ -1166,14 +1146,12 @@ var LocationIndex = _location.LocationIndex;
11661146
}
11671147
});
11681148
*/
1169-
/*
11701149
addLinter('E046', function lintModalTabIndex($, reporter) {
11711150
var modalsWithoutTabindex = $('.modal:not([tabindex])');
11721151
if (modalsWithoutTabindex.length) {
11731152
reporter('`.modal` elements must have a `tabindex` attribute.', modalsWithoutTabindex);
11741153
}
11751154
});
1176-
*/
11771155
/*
11781156
addLinter('E047', function lintBtnElements($, reporter) {
11791157
var btns = $('.btn:not(a,button,input,label)');
@@ -1182,22 +1160,18 @@ var LocationIndex = _location.LocationIndex;
11821160
}
11831161
});
11841162
*/
1185-
/*
11861163
addLinter('E048', function lintModalRole($, reporter) {
11871164
var modals = $('.modal:not([role="dialog"])');
11881165
if (modals.length) {
11891166
reporter('`.modal` must have a `role="dialog"` attribute.', modals);
11901167
}
11911168
});
1192-
*/
1193-
/*
11941169
addLinter('E049', function lintModalDialogRole($, reporter) {
11951170
var modalDialogs = $('.modal-dialog:not([role="document"])');
11961171
if (modalDialogs.length) {
11971172
reporter('`.modal-dialog` must have a `role="document"` attribute.', modalDialogs);
11981173
}
11991174
});
1200-
*/
12011175
/*
12021176
addLinter('E050', function lintNestedFormGroups($, reporter) {
12031177
var nestedFormGroups = $('.form-group > .form-group');

test/bootlint_test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,6 @@ exports.bootlint = {
183183
test.done();
184184
},
185185
/*
186-
'remote modals': function (test) {
187-
test.expect(1);
188-
test.deepEqual(lintHtml(utf8Fixture('modal/remote.html')),
189-
['Found one or more modals using the deprecated `remote` option'],
190-
'should complain when remote modals are present.');
191-
test.done();
192-
},
193-
*/
194-
/*
195186
'jQuery': function (test) {
196187
test.expect(5);
197188
test.deepEqual(lintHtml(utf8Fixture('jquery/present.html')),
@@ -853,20 +844,6 @@ exports.bootlint = {
853844
},
854845
*/
855846
/*
856-
'modal with .hide class': function (test) {
857-
test.expect(2);
858-
test.deepEqual(lintHtml(utf8Fixture('modal/with-hide.html')),
859-
['`.hide` should not be used on `.modal` in Bootstrap v3.'],
860-
'should complain about a modal with the .hide class.'
861-
);
862-
test.deepEqual(lintHtml(utf8Fixture('modal/valid.html')),
863-
[],
864-
'should not complain about a modal without the .hide class.'
865-
);
866-
test.done();
867-
},
868-
*/
869-
/*
870847
'carousel structure': function (test) {
871848
test.expect(5);
872849
test.deepEqual(lintHtml(utf8Fixture('carousel/valid.html')),

test/_old_fixtures/modal/remote.html renamed to test/fixtures/modal/body-outside-content.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@
1717
<script src="../generic-qunit.js"></script>
1818
</head>
1919
<body>
20-
<button type="button" data-toggle="modal" data-remote="http://example.invalid/modal.html" data-target="#myModal">Launch modal</button>
20+
<div class="modal fade" tabindex="-1" role="dialog">
21+
<div class="modal-dialog" role="document">
22+
<!--Oops, forgot about the div.modal-content-->
23+
<div class="modal-body">
24+
<p>One fine body&hellip;</p>
25+
</div>
26+
</div>
27+
</div>
2128

2229
<div id="qunit"></div>
2330
<ol id="bootlint">
24-
<li data-lint="Found one or more modals using the deprecated `remote` option"></li>
31+
<li data-lint="`.modal-body` must be a child of `.modal-content`"></li>
2532
</ol>
2633
</body>
2734
</html>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<div class="modal fade" tabindex="-1" role="dialog">
21+
<!--Oops, forgot about the .modal-dialog-->
22+
<div class="modal-content">
23+
<div class="modal-header">
24+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
25+
<h4 class="modal-title">Modal title</h4>
26+
</div>
27+
<div class="modal-body">
28+
<p>One fine body&hellip;</p>
29+
</div>
30+
<div class="modal-footer">
31+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
32+
<button type="button" class="btn btn-primary">Save changes</button>
33+
</div>
34+
</div>
35+
</div>
36+
37+
<div id="qunit"></div>
38+
<ol id="bootlint">
39+
<li data-lint="`.modal-content` must be a child of `.modal-dialog`"></li>
40+
</ol>
41+
</body>
42+
</html>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<!--Oops, forgot the div.modal wrapper...-->
21+
<div class="modal-dialog" role="document">
22+
<div class="modal-content">
23+
<div class="modal-header">
24+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
25+
<h4 class="modal-title">Modal title</h4>
26+
</div>
27+
<div class="modal-body">
28+
<p>One fine body&hellip;</p>
29+
</div>
30+
<div class="modal-footer">
31+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
32+
<button type="button" class="btn btn-primary">Save changes</button>
33+
</div>
34+
</div>
35+
</div>
36+
37+
<div id="qunit"></div>
38+
<ol id="bootlint">
39+
<li data-lint="`.modal-dialog` must be a child of `.modal`"></li>
40+
</ol>
41+
</body>
42+
</html>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<div class="modal fade" tabindex="-1" role="dialog">
21+
<div class="modal-dialog" role="document">
22+
<div class="modal-content">
23+
<div class="modal-header">
24+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
25+
<h4 class="modal-title">Modal title</h4>
26+
</div>
27+
<div class="modal-body">
28+
<p>One fine body&hellip;</p>
29+
</div>
30+
</div>
31+
<!--Oops, forgot that the .modal-footer should go within the .modal-content-->
32+
<div class="modal-footer">
33+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
34+
<button type="button" class="btn btn-primary">Save changes</button>
35+
</div>
36+
</div>
37+
</div>
38+
39+
<div id="qunit"></div>
40+
<ol id="bootlint">
41+
<li data-lint="`.modal-footer` must be a child of `.modal-content`"></li>
42+
</ol>
43+
</body>
44+
</html>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<div class="modal fade" tabindex="-1" role="dialog">
21+
<div class="modal-dialog" role="document">
22+
<!--Oops, the .modal-header ought to be within the .modal-content-->
23+
<div class="modal-header">
24+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
25+
<h4 class="modal-title">Modal title</h4>
26+
</div>
27+
<div class="modal-content">
28+
<div class="modal-body">
29+
<p>One fine body&hellip;</p>
30+
</div>
31+
<div class="modal-footer">
32+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
33+
<button type="button" class="btn btn-primary">Save changes</button>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
38+
39+
<div id="qunit"></div>
40+
<ol id="bootlint">
41+
<li data-lint="`.modal-header` must be a child of `.modal-content`"></li>
42+
</ol>
43+
</body>
44+
</html>

test/_old_fixtures/modal/with-hide.html renamed to test/fixtures/modal/missing-role-dialog.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script src="../generic-qunit.js"></script>
1818
</head>
1919
<body>
20-
<div class="modal hide" tabindex="-1" role="dialog">
20+
<div class="modal fade" tabindex="-1">
2121
<div class="modal-dialog" role="document">
2222
<div class="modal-content">
2323
<div class="modal-header">
@@ -37,7 +37,7 @@ <h4 class="modal-title">Modal title</h4>
3737

3838
<div id="qunit"></div>
3939
<ol id="bootlint">
40-
<li data-lint="`.hide` should not be used on `.modal` in Bootstrap v3."></li>
40+
<li data-lint="`.modal` must have a `role=&quot;dialog&quot;` attribute."></li>
4141
</ol>
4242
</body>
4343
</html>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<div class="modal fade" tabindex="-1" role="dialog">
21+
<div class="modal-dialog">
22+
<div class="modal-content">
23+
<div class="modal-header">
24+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
25+
<h4 class="modal-title">Modal title</h4>
26+
</div>
27+
<div class="modal-body">
28+
<p>One fine body&hellip;</p>
29+
</div>
30+
<div class="modal-footer">
31+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
32+
<button type="button" class="btn btn-primary">Save changes</button>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
38+
<div id="qunit"></div>
39+
<ol id="bootlint">
40+
<li data-lint="`.modal-dialog` must have a `role=&quot;document&quot;` attribute."></li>
41+
</ol>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)