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

Explicitly ignore containers within navbar for E004 #255

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bootlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ var LocationIndex = _location.LocationIndex;
}
});
addLinter("E004", function lintNestedContainers($, reporter) {
var nestedContainers = $('.container, .container-fluid').children('.container, .container-fluid');
var nestedContainers = $('.container, .container-fluid').filter(function () {
return $(this).find('.navbar').length === 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to .not(':has(.navbar)').

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this time I'd been fighting cheerio with a .find(':not(.navbar)') check. I'll make the change.

}).find('.container, .container-fluid');
if (nestedContainers.length) {
reporter("Containers (`.container` and `.container-fluid`) are not nestable", nestedContainers);
}
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/containers/nested-fixed-fluid.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<div class="container-fluid"></div>
</div>

<div class="container">
<div class="navbar">
<div class="container-fluid"></div>
</div>
</div>

<div id="qunit"></div>
<ol id="bootlint">
<li data-lint="Containers (`.container` and `.container-fluid`) are not nestable"></li>
Expand Down