зеркало из https://github.com/twbs/bootlint.git
warn about .form-control-feedback with incorrect parent; fixes #41
This commit is contained in:
Родитель
4df4169899
Коммит
ff0934cb5a
|
@ -502,6 +502,12 @@ var cheerio = require('cheerio');
|
|||
return "`.table-responsive` is supposed to be used on the table's parent wrapper <div>, not on the table itself";
|
||||
}
|
||||
};
|
||||
exports.lintFormControlFeedbackWithoutHasFeedback = function ($) {
|
||||
var parentsMissingClasses = $('*:not(.form-group.has-feedback)>.form-control-feedback');
|
||||
if (parentsMissingClasses.length) {
|
||||
return "`.form-control-feedback` must have a `.form-group.has-feedback` parent";
|
||||
}
|
||||
};
|
||||
exports.lintRedundantColumnClasses = function ($) {
|
||||
var columns = $(COL_CLASSES.join(','));
|
||||
var errs = [];
|
||||
|
@ -583,6 +589,7 @@ var cheerio = require('cheerio');
|
|||
errs.push(this.lintPanelTitleWithoutPanelHeading($));
|
||||
errs.push(this.lintPanelFooterWithoutPanel($));
|
||||
errs.push(this.lintTableResponsive($));
|
||||
errs.push(this.lintFormControlFeedbackWithoutHasFeedback($));
|
||||
errs = errs.concat(this.lintInputGroupFormControlTypes($));
|
||||
errs = errs.concat(this.lintInlineCheckboxes($));
|
||||
errs = errs.concat(this.lintInlineRadios($));
|
||||
|
|
|
@ -394,5 +394,18 @@ exports['bootlint'] = {
|
|||
'should complain when there are redundant grid column classes.'
|
||||
);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'.form-control-feedback without a .has-feedback parent': function (test) {
|
||||
test.expect(2);
|
||||
test.deepEqual(bootlint.lintHtml(utf8Fixture('feedback/form-control-valid.html')),
|
||||
[],
|
||||
'should not complain when .form-control-feedback has a correct parent.'
|
||||
);
|
||||
test.deepEqual(bootlint.lintHtml(utf8Fixture('feedback/form-control-bad.html')),
|
||||
["`.form-control-feedback` must have a `.form-group.has-feedback` parent"],
|
||||
'should complain when .form-control-feedback\'s parent isn\'t a .form-group.has-feedback.'
|
||||
);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<!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>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="inputSuccess2">Input with success</label>
|
||||
<input type="text" class="form-control" id="inputSuccess2">
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback"></span>
|
||||
</div>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint">
|
||||
<li data-lint="`.form-control-feedback` must have a `.form-group.has-feedback` parent"></li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
<!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>
|
||||
<div class="form-group has-success has-feedback">
|
||||
<label class="control-label" for="inputSuccess2">Input with success</label>
|
||||
<input type="text" class="form-control" id="inputSuccess2">
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback"></span>
|
||||
</div>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<ol id="bootlint"></ol>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче