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

Commit c09effd

Browse files
committed
Cards (formerly panels)
Port E023, E024, E025, and E026
1 parent 0258293 commit c09effd

7 files changed

+77
-78
lines changed

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
@@ -460,27 +460,25 @@ exports.bootlint = {
460460
test.done();
461461
},
462462
*/
463-
/*
464-
'panel structure': function (test) {
463+
'card structure': function (test) {
465464
test.expect(5);
466-
test.deepEqual(lintHtml(utf8Fixture('panels/panels.html')),
465+
test.deepEqual(lintHtml(utf8Fixture('cards/cards.html')),
467466
[],
468-
'should not complain when panel is structured correctly.');
469-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-body-missing-parent.html')),
470-
['`.panel-body` must have a `.panel` or `.panel-collapse` parent'],
471-
'should complain when .panel-body is missing .panel or .panel-collapse parent');
472-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-footer-missing-parent.html')),
473-
['`.panel-footer` must have a `.panel` or `.panel-collapse` parent'],
474-
'should complain when .panel-footer is missing .panel parent');
475-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-title-missing-parent.html')),
476-
['`.panel-title` must have a `.panel-heading` parent'],
477-
'should complain when .panel-title is missing .panel-heading parent');
478-
test.deepEqual(lintHtml(utf8Fixture('panels/panel-heading-missing-parent.html')),
479-
['`.panel-heading` must have a `.panel` parent'],
480-
'should complain when .panel-heading is missing .panel parent');
467+
'should not complain when card is structured correctly.');
468+
test.deepEqual(lintHtml(utf8Fixture('cards/card-body-missing-ancestor.html')),
469+
['`.card-body` must have `.card` or have it as an ancestor.'],
470+
'should complain when .card-body is missing .card ancestor');
471+
test.deepEqual(lintHtml(utf8Fixture('cards/card-footer-missing-ancestor.html')),
472+
['`.card-footer` must have a `.card` ancestor.'],
473+
'should complain when .card-footer is missing .card ancestor');
474+
test.deepEqual(lintHtml(utf8Fixture('cards/card-title-missing-ancestor.html')),
475+
['`.card-title` must have a `.card` ancestor.'],
476+
'should complain when .card-title is missing .card ancestor');
477+
test.deepEqual(lintHtml(utf8Fixture('cards/card-header-missing-ancestor.html')),
478+
['`.card-header` must have a `.card` ancestor.'],
479+
'should complain when .card-header is missing .card ancestor');
481480
test.done();
482481
},
483-
*/
484482
'columns outside of rows and form groups': function (test) {
485483
test.expect(3);
486484
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

+29-28
Original file line numberDiff line numberDiff line change
@@ -18,73 +18,74 @@
1818
</head>
1919
<body>
2020

21-
<!-- Basic Panel -->
22-
<div class="panel">
23-
<div class="panel-heading">
24-
<h1 class="panel-title">Title</h1>
21+
22+
<!-- Basic Card -->
23+
<div class="card">
24+
<div class="card-header">
25+
<h1 class="card-title">Title</h1>
2526
</div>
26-
<div class="panel-body">
27+
<div class="card-body">
2728
<p>Something</p>
2829
</div>
29-
<div class="panel-footer">
30+
<div class="card-footer">
3031
<p>Footer</p>
3132
</div>
3233
</div>
3334

34-
<!-- Panel accordion example -->
35-
<div class="panel-group" id="accordion">
36-
<div class="panel panel-default">
37-
<div class="panel-heading">
38-
<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">
3940
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
4041
Collapsible Group Item #1
4142
</a>
4243
</h4>
4344
</div>
44-
<div id="collapseOne" class="panel-collapse collapse in">
45-
<div class="panel-body">
45+
<div id="collapseOne" class="collapse in">
46+
<div class="card-body">
4647
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.
4748
</div>
4849
</div>
4950
</div>
50-
<div class="panel panel-default">
51-
<div class="panel-heading">
52-
<h4 class="panel-title">
51+
<div class="card">
52+
<div class="card-header">
53+
<h4 class="card-title">
5354
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
5455
Collapsible Group Item #2
5556
</a>
5657
</h4>
5758
</div>
58-
<div id="collapseTwo" class="panel-collapse collapse">
59-
<div class="panel-body">
59+
<div id="collapseTwo" class="collapse">
60+
<div class="card-body">
6061
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.
6162
</div>
6263
</div>
6364
</div>
64-
<div class="panel panel-default">
65-
<div class="panel-heading">
66-
<h4 class="panel-title">
65+
<div class="card">
66+
<div class="card-header">
67+
<h4 class="card-title">
6768
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
6869
Collapsible Group Item #3
6970
</a>
7071
</h4>
7172
</div>
72-
<div id="collapseThree" class="panel-collapse collapse">
73-
<div class="panel-body">
73+
<div id="collapseThree" class="collapse">
74+
<div class="card-body">
7475
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.
7576
</div>
7677
</div>
7778
</div>
78-
<div class="panel panel-default">
79-
<div class="panel-heading">
80-
<h4 class="panel-title">
79+
<div class="card">
80+
<div class="card-header">
81+
<h4 class="card-title">
8182
<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
8283
Collapsible Group Item #3
8384
</a>
8485
</h4>
8586
</div>
86-
<div id="collapseFour" class="panel-collapse collapse">
87-
<div class="panel-footer">Footer</div>
87+
<div id="collapseFour" class="collapse">
88+
<div class="card-footer">Footer</div>
8889
</div>
8990
</div>
9091
</div>

0 commit comments

Comments
 (0)