зеркало из https://github.com/twbs/bootlint.git
Complain about .navbar-{left,right} outside of .navbar; fixes #223
This commit is contained in:
Родитель
fd0bfad391
Коммит
bd83f574c8
|
@ -797,6 +797,14 @@ var LocationIndex = _location.LocationIndex;
|
|||
reporter('`.media-left` and `.media-right` should not be used outside of `.media` objects.', mediaPullsOutsideMedia);
|
||||
}
|
||||
});
|
||||
addLinter("E039", function lintNavbarPulls($, reporter) {
|
||||
var navbarPullsOutsideNavbars = $('.navbar-left, .navbar-right').filter(function () {
|
||||
return !($(this).parent().closest('.navbar').length);
|
||||
});
|
||||
if (navbarPullsOutsideNavbars.length) {
|
||||
reporter('`.navbar-left` and `.navbar-right` should not be used outside of navbars.', navbarPullsOutsideNavbars);
|
||||
}
|
||||
});
|
||||
addLinter("W009", function lintEmptySpacerCols($, reporter) {
|
||||
var selector = COL_CLASSES.map(function (colClass) {
|
||||
return colClass + ':not(col):not(:last-child)';
|
||||
|
|
|
@ -715,5 +715,26 @@ exports.bootlint = {
|
|||
'should complain about media pulls on .media itself.'
|
||||
);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'navbar pulls outside of navbars': function (test) {
|
||||
test.expect(4);
|
||||
test.deepEqual(lintHtml(utf8Fixture('navbar/navbar-left-bad.html')),
|
||||
['`.navbar-left` and `.navbar-right` should not be used outside of navbars.'],
|
||||
'should complain about .navbar-left outside of .navbar.'
|
||||
);
|
||||
test.deepEqual(lintHtml(utf8Fixture('navbar/navbar-right-bad.html')),
|
||||
['`.navbar-left` and `.navbar-right` should not be used outside of navbars.'],
|
||||
'should complain about .navbar-right outside of .navbar.'
|
||||
);
|
||||
test.deepEqual(lintHtml(utf8Fixture('navbar/navbar-left-right-on-navbar.html')),
|
||||
['`.navbar-left` and `.navbar-right` should not be used outside of navbars.'],
|
||||
'should complain about .navbar-left/right directly on a .navbar.'
|
||||
);
|
||||
test.deepEqual(lintHtml(utf8Fixture('navbar/navbar-left-right-valid.html')),
|
||||
[],
|
||||
'should not complain about .navbar-left or .navbar-right inside of .navbar.'
|
||||
);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Test</title>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../../lib/jquery.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../lib/qunit.css">
|
||||
<script src="../../lib/qunit.js"></script>
|
||||
<script src="../../../dist/browser/bootlint.js"></script>
|
||||
<script src="../generic-qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p class="navbar-left">Misplaced outside navbar</p>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint">
|
||||
<li data-lint="`.navbar-left` and `.navbar-right` should not be used outside of navbars."></li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Test</title>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../../lib/jquery.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../lib/qunit.css">
|
||||
<script src="../../lib/qunit.js"></script>
|
||||
<script src="../../../dist/browser/bootlint.js"></script>
|
||||
<script src="../generic-qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default navbar-left">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Brand</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<nav class="navbar navbar-default navbar-right">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Brand</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint">
|
||||
<li data-lint="`.navbar-left` and `.navbar-right` should not be used outside of navbars."></li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Test</title>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../../lib/jquery.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../lib/qunit.css">
|
||||
<script src="../../lib/qunit.js"></script>
|
||||
<script src="../../../dist/browser/bootlint.js"></script>
|
||||
<script src="../generic-qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Brand</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Link</a></li>
|
||||
</ul>
|
||||
<form class="navbar-form navbar-left">
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
<form class="navbar-form navbar-right">
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint"></ol>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Test</title>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="../../lib/jquery.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../lib/qunit.css">
|
||||
<script src="../../lib/qunit.js"></script>
|
||||
<script src="../../../dist/browser/bootlint.js"></script>
|
||||
<script src="../generic-qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p class="navbar-right">Misplaced outside navbar</p>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint">
|
||||
<li data-lint="`.navbar-left` and `.navbar-right` should not be used outside of navbars."></li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче