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

Commit 63a44b5

Browse files
committed
Cards (formerly panels)
Port E023, E024, E025, and E026
1 parent 65d8daf commit 63a44b5

8 files changed

+228
-102
lines changed

dist/browser/bootlint.js

+152-24
Large diffs are not rendered by default.

src/bootlint.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -878,38 +878,38 @@ var LocationIndex = _location.LocationIndex;
878878
}
879879
});
880880
*/
881-
/*
882-
addLinter('E023', function lintPanelBodyWithoutPanel($, reporter) {
883-
var badPanelBody = $('.panel-body').parent(':not(.panel, .panel-collapse)');
884-
if (badPanelBody.length) {
885-
reporter('`.panel-body` must have a `.panel` or `.panel-collapse` parent', badPanelBody);
881+
addLinter('E023', function lintCardBodyWithoutCard($, reporter) {
882+
var badCardBody = $('.card-body').filter(function () {
883+
return $(this).closest('.card').length !== 1;
884+
});
885+
if (badCardBody.length) {
886+
reporter('`.card-body` must have `.card` or have it as an ancestor.', badCardBody);
886887
}
887888
});
888-
*/
889-
/*
890-
addLinter('E024', function lintPanelHeadingWithoutPanel($, reporter) {
891-
var badPanelHeading = $('.panel-heading').parent(':not(.panel)');
892-
if (badPanelHeading.length) {
893-
reporter('`.panel-heading` must have a `.panel` parent', badPanelHeading);
889+
addLinter('E024', function lintCardHeaderWithoutCard($, reporter) {
890+
var badCardHeader = $('.card-header').filter(function () {
891+
return $(this).parents('.card').length !== 1;
892+
});
893+
if (badCardHeader.length) {
894+
reporter('`.card-header` must have a `.card` ancestor.', badCardHeader);
894895
}
895896
});
896-
*/
897-
/*
898-
addLinter('E025', function lintPanelFooterWithoutPanel($, reporter) {
899-
var badPanelFooter = $('.panel-footer').parent(':not(.panel, .panel-collapse)');
900-
if (badPanelFooter.length) {
901-
reporter('`.panel-footer` must have a `.panel` or `.panel-collapse` parent', badPanelFooter);
897+
addLinter('E025', function lintCardFooterWithoutCard($, reporter) {
898+
var badCardFooter = $('.card-footer').filter(function () {
899+
return $(this).parents('.card').length !== 1;
900+
});
901+
if (badCardFooter.length) {
902+
reporter('`.card-footer` must have a `.card` ancestor.', badCardFooter);
902903
}
903904
});
904-
*/
905-
/*
906-
addLinter('E026', function lintPanelTitleWithoutPanelHeading($, reporter) {
907-
var badPanelTitle = $('.panel-title').parent(':not(.panel-heading)');
908-
if (badPanelTitle.length) {
909-
reporter('`.panel-title` must have a `.panel-heading` parent', badPanelTitle);
905+
addLinter('E026', function lintCardTitleWithoutCard($, reporter) {
906+
var badCardTitle = $('.card-title').filter(function () {
907+
return $(this).parents('.card').length !== 1;
908+
});
909+
if (badCardTitle.length) {
910+
reporter('`.card-title` must have a `.card` ancestor.', badCardTitle);
910911
}
911912
});
912-
*/
913913
/*
914914
addLinter('E027', function lintTableResponsive($, reporter) {
915915
var badStructure = $('.table.table-responsive, table.table-responsive');

test/bootlint_test.js

+15-17
Original file line numberDiff line numberDiff line change
@@ -457,27 +457,25 @@ exports.bootlint = {
457457
test.done();
458458
},
459459
*/
460-
/*
461-
'panel structure': function (test) {
460+
'card structure': function (test) {
462461
test.expect(5);
463-
test.deepEqual(lintHtml(utf8Fixture('panels/panels.html')),
462+
test.deepEqual(lintHtml(utf8Fixture('cards/cards.html')),
464463
[],
465-
'should not complain when panel is structured correctly.');
466-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-body-missing-parent.html')),
467-
['`.panel-body` must have a `.panel` or `.panel-collapse` parent'],
468-
'should complain when .panel-body is missing .panel or .panel-collapse parent');
469-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-footer-missing-parent.html')),
470-
['`.panel-footer` must have a `.panel` or `.panel-collapse` parent'],
471-
'should complain when .panel-footer is missing .panel parent');
472-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-title-missing-parent.html')),
473-
['`.panel-title` must have a `.panel-heading` parent'],
474-
'should complain when .panel-title is missing .panel-heading parent');
475-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-heading-missing-parent.html')),
476-
['`.panel-heading` must have a `.panel` parent'],
477-
'should complain when .panel-heading is missing .panel parent');
464+
'should not complain when card is structured correctly.');
465+
test.deepEqual(lintHtml(utf8Fixture('cards/card-body-missing-ancestor.html')),
466+
['`.card-body` must have `.card` or have it as an ancestor.'],
467+
'should complain when .card-body is missing .card ancestor');
468+
test.deepEqual(lintHtml(utf8Fixture('cards/card-footer-missing-ancestor.html')),
469+
['`.card-footer` must have a `.card` ancestor.'],
470+
'should complain when .card-footer is missing .card ancestor');
471+
test.deepEqual(lintHtml(utf8Fixture('cards/card-title-missing-ancestor.html')),
472+
['`.card-title` must have a `.card` ancestor.'],
473+
'should complain when .card-title is missing .card ancestor');
474+
test.deepEqual(lintHtml(utf8Fixture('cards/card-header-missing-ancestor.html')),
475+
['`.card-header` must have a `.card` ancestor.'],
476+
'should complain when .card-header is missing .card ancestor');
478477
test.done();
479478
},
480-
*/
481479
'columns outside of rows and form groups': function (test) {
482480
test.expect(3);
483481
test.deepEqual(lintHtml(utf8Fixture('grid/cols-within-row.html')),

test/_old_fixtures/panels/panel-body-missing-parent.html test/fixtures/cards/card-body-missing-ancestor.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<body>
2020

2121
<div>
22-
<div class="panel-body">
22+
<div class="card-body">
2323
<p>Something</p>
2424
</div>
2525
</div>
2626

2727
<div id="qunit"></div>
2828
<ol id="bootlint">
29-
<li data-lint="`.panel-body` must have a `.panel` or `.panel-collapse` parent"> </li>
29+
<li data-lint="`.card-body` must have `.card` or have it as an ancestor."> </li>
3030
</ol>
3131
</body>
3232
</html>

test/_old_fixtures/panels/panel-heading-missing-parent.html test/fixtures/cards/card-footer-missing-ancestor.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<body>
2020

2121
<div>
22-
<div class="panel-heading">
22+
<div class="card-footer">
2323
<p>Something</p>
2424
</div>
2525
</div>
2626

2727
<div id="qunit"></div>
2828
<ol id="bootlint">
29-
<li data-lint="`.panel-heading` must have a `.panel` parent"></li>
29+
<li data-lint="`.card-footer` must have a `.card` ancestor."></li>
3030
</ol>
3131
</body>
3232
</html>

test/_old_fixtures/panels/panel-footer-missing-parent.html test/fixtures/cards/card-header-missing-ancestor.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<body>
2020

2121
<div>
22-
<div class="panel-footer">
22+
<div class="card-header">
2323
<p>Something</p>
2424
</div>
2525
</div>
2626

2727
<div id="qunit"></div>
2828
<ol id="bootlint">
29-
<li data-lint="`.panel-footer` must have a `.panel` or `.panel-collapse` parent"></li>
29+
<li data-lint="`.card-header` must have a `.card` ancestor."></li>
3030
</ol>
3131
</body>
3232
</html>

test/_old_fixtures/panels/panel-title-missing-parent.html test/fixtures/cards/card-title-missing-ancestor.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
</head>
1919
<body>
2020

21-
<div class="panel">
22-
<h2 class="panel-title">Panel title</h2>
21+
<div>
22+
<h2 class="card-title">Card title</h2>
2323
</div>
2424

2525
<div id="qunit"></div>
2626
<ol id="bootlint">
27-
<li data-lint="`.panel-title` must have a `.panel-heading` parent"></li>
27+
<li data-lint="`.card-title` must have a `.card` ancestor."></li>
2828
</ol>
2929
</body>
3030
</html>

test/_old_fixtures/panels/panels.html test/fixtures/cards/cards.html

+28-28
Original file line numberDiff line numberDiff line change
@@ -19,73 +19,73 @@
1919
<body>
2020

2121

22-
<!-- Basic Panel -->
23-
<div class="panel">
24-
<div class="panel-heading">
25-
<h1 class="panel-title">Title</h1>
22+
<!-- Basic Card -->
23+
<div class="card">
24+
<div class="card-header">
25+
<h1 class="card-title">Title</h1>
2626
</div>
27-
<div class="panel-body">
27+
<div class="card-body">
2828
<p>Something</p>
2929
</div>
30-
<div class="panel-footer">
30+
<div class="card-footer">
3131
<p>Footer</p>
3232
</div>
3333
</div>
3434

35-
<!-- Panel accordion example -->
36-
<div class="panel-group" id="accordion">
37-
<div class="panel panel-default">
38-
<div class="panel-heading">
39-
<h4 class="panel-title">
35+
<!-- Card accordion example -->
36+
<div class="accordion" id="accordion">
37+
<div class="card">
38+
<div class="card-header">
39+
<h4 class="card-title">
4040
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
4141
Collapsible Group Item #1
4242
</a>
4343
</h4>
4444
</div>
45-
<div id="collapseOne" class="panel-collapse collapse in">
46-
<div class="panel-body">
45+
<div id="collapseOne" class="collapse in">
46+
<div class="card-body">
4747
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
4848
</div>
4949
</div>
5050
</div>
51-
<div class="panel panel-default">
52-
<div class="panel-heading">
53-
<h4 class="panel-title">
51+
<div class="card">
52+
<div class="card-header">
53+
<h4 class="card-title">
5454
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
5555
Collapsible Group Item #2
5656
</a>
5757
</h4>
5858
</div>
59-
<div id="collapseTwo" class="panel-collapse collapse">
60-
<div class="panel-body">
59+
<div id="collapseTwo" class="collapse">
60+
<div class="card-body">
6161
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
6262
</div>
6363
</div>
6464
</div>
65-
<div class="panel panel-default">
66-
<div class="panel-heading">
67-
<h4 class="panel-title">
65+
<div class="card">
66+
<div class="card-header">
67+
<h4 class="card-title">
6868
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
6969
Collapsible Group Item #3
7070
</a>
7171
</h4>
7272
</div>
73-
<div id="collapseThree" class="panel-collapse collapse">
74-
<div class="panel-body">
73+
<div id="collapseThree" class="collapse">
74+
<div class="card-body">
7575
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
7676
</div>
7777
</div>
7878
</div>
79-
<div class="panel panel-default">
80-
<div class="panel-heading">
81-
<h4 class="panel-title">
79+
<div class="card">
80+
<div class="card-header">
81+
<h4 class="card-title">
8282
<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
8383
Collapsible Group Item #3
8484
</a>
8585
</h4>
8686
</div>
87-
<div id="collapseFour" class="panel-collapse collapse">
88-
<div class="panel-footer">Footer</div>
87+
<div id="collapseFour" class="collapse">
88+
<div class="card-footer">Footer</div>
8989
</div>
9090
</div>
9191
</div>

0 commit comments

Comments
 (0)