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

Commit cdf0e2e

Browse files
committed
Adapt for input group changes
E006, E010, E015 removed E009, E011, E012 ported
1 parent 44fed15 commit cdf0e2e

File tree

2 files changed

+13
-84
lines changed

2 files changed

+13
-84
lines changed

src/bootlint.js

+7-40
Original file line numberDiff line numberDiff line change
@@ -731,46 +731,31 @@ var LocationIndex = _location.LocationIndex;
731731
addLinter('E009', function lintMissingInputGroupSizes($, reporter) {
732732
var selector = [
733733
'.input-group:not(.input-group-lg) .btn-lg',
734-
'.input-group:not(.input-group-lg) .input-lg',
734+
'.input-group:not(.input-group-lg) .form-control-lg',
735735
'.input-group:not(.input-group-sm) .btn-sm',
736-
'.input-group:not(.input-group-sm) .input-sm'
736+
'.input-group:not(.input-group-sm) .form-control-sm'
737737
].join(',');
738738
var badInputGroupSizing = $(selector);
739739
if (badInputGroupSizing.length) {
740740
reporter('Button and input sizing within `.input-group`s can cause issues. Instead, use input group sizing classes `.input-group-lg` or `.input-group-sm`', badInputGroupSizing);
741741
}
742742
});
743-
*/
744-
/*
745-
addLinter('E010', function lintMultipleFormControlsInInputGroup($, reporter) {
746-
var badInputGroups = $('.input-group').filter(function (i, inputGroup) {
747-
return $(inputGroup).find('.form-control').length > 1;
748-
});
749-
if (badInputGroups.length) {
750-
reporter('Input groups cannot contain multiple `.form-control`s', badInputGroups);
751-
}
752-
});
753-
*/
754-
/*
755743
addLinter('E011', function lintFormGroupMixedWithInputGroup($, reporter) {
756-
var badMixes = $('.input-group.form-group');
744+
var badMixes = $('.input-group.form-group, .input-group.row, .input-group.form-row');
757745
if (badMixes.length) {
758-
reporter('`.input-group` and `.form-group` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.form-group`', badMixes);
746+
reporter('`.input-group` and `.form-group`/`.row`/`.form-row` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.form-group`/`.row`/`.form-row`', badMixes);
759747
}
760748
});
761-
*/
762-
/*
763749
addLinter('E012', function lintGridClassMixedWithInputGroup($, reporter) {
764750
var selector = COL_CLASSES.map(function (colClass) {
765751
return '.input-group' + colClass;
766752
}).join(',');
767753
768754
var badMixes = $(selector);
769755
if (badMixes.length) {
770-
reporter('`.input-group` and `.col-*-*` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.col-*-*`', badMixes);
756+
reporter('`.input-group` and `.col*` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.col*`', badMixes);
771757
}
772758
});
773-
*/
774759
/*
775760
addLinter('E013', function lintRowChildrenAreCols($, reporter) {
776761
var ALLOWED_CHILDREN = COL_CLASSES.concat(['script', '.clearfix', '.bs-customizer-input']);
@@ -797,22 +782,6 @@ var LocationIndex = _location.LocationIndex;
797782
});
798783
*/
799784
/*
800-
addLinter('E015', function lintInputGroupsWithMultipleAddOnsPerSide($, reporter) {
801-
var addOnClasses = ['.input-group-addon', '.input-group-btn'];
802-
var combos = [];
803-
addOnClasses.forEach(function (first) {
804-
addOnClasses.forEach(function (second) {
805-
combos.push('.input-group>' + first + '+' + second);
806-
});
807-
});
808-
var selector = combos.join(',');
809-
var multipleAddOns = $(selector);
810-
if (multipleAddOns.length) {
811-
reporter('Having multiple add-ons on a single side of an input group is not supported', multipleAddOns);
812-
}
813-
});
814-
*/
815-
/*
816785
addLinter('E016', function lintBtnToggle($, reporter) {
817786
var badBtnToggle = $('.btn.dropdown-toggle ~ .btn');
818787
if (badBtnToggle.length) {
@@ -1168,17 +1137,15 @@ var LocationIndex = _location.LocationIndex;
11681137
}
11691138
});
11701139
*/
1171-
/*
11721140
addLinter('E044', function lintInputGroupAddonChildren($, reporter) {
11731141
var badInputGroups = $('.input-group').filter(function () {
11741142
var inputGroup = $(this);
1175-
return !inputGroup.children('.form-control').length || !inputGroup.children('.input-group-addon, .input-group-btn').length;
1143+
return !inputGroup.children('.form-control').length || !inputGroup.children('.input-group-prepend, .input-group-append').length;
11761144
});
11771145
if (badInputGroups.length) {
1178-
reporter('`.input-group` must have a `.form-control` and either an `.input-group-addon` or an `.input-group-btn`.', badInputGroups);
1146+
reporter('`.input-group` must have a `.form-control` and either an `.input-group-prepend` or `.input-group-append`.', badInputGroups);
11791147
}
11801148
});
1181-
*/
11821149
/*
11831150
addLinter('E045', function lintImgResponsiveOnNonImgs($, reporter) {
11841151
var imgResponsiveNotOnImg = $('.img-responsive:not(img)');

test/bootlint_test.js

+6-44
Original file line numberDiff line numberDiff line change
@@ -271,54 +271,37 @@ exports.bootlint = {
271271
test.done();
272272
},
273273
*/
274-
/*
275274
'btn/input sizing used without input-group-* size': function (test) {
276275
test.expect(1);
277276
test.deepEqual(lintHtml(utf8Fixture('input-group/missing-input-group-sizing.html')),
278277
['Button and input sizing within `.input-group`s can cause issues. Instead, use input group sizing classes `.input-group-lg` or `.input-group-sm`'],
279278
'should complain when an input/btn sizes are used within input-group.');
280279
test.done();
281280
},
282-
*/
283-
/*
284-
'input groups with multiple form controls': function (test) {
285-
test.expect(1);
286-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-form-controls.html')),
287-
['Input groups cannot contain multiple `.form-control`s'],
288-
'should complain when an input group contains multiple form controls.');
289-
test.done();
290-
},
291-
*/
292-
/*
293281
'mixing input groups with form groups': function (test) {
294282
test.expect(1);
295283
test.deepEqual(lintHtml(utf8Fixture('input-group/mixed-with-form-group.html')),
296-
['`.input-group` and `.form-group` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.form-group`'],
297-
'should complain when .input-group and .form-group are used on the same element.');
284+
['`.input-group` and `.form-group`/`.row`/`.form-row` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.form-group`/`.row`/`.form-row`'],
285+
'should complain when .input-group and .form-group/.row/.form-row are used on the same element.');
298286
test.done();
299287
},
300-
*/
301-
/*
302288
'mixing input groups with grid columns': function (test) {
303289
test.expect(1);
304290
test.deepEqual(lintHtml(utf8Fixture('input-group/mixed-with-grid-col.html')),
305-
['`.input-group` and `.col-*-*` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.col-*-*`'],
291+
['`.input-group` and `.col*` cannot be used directly on the same element. Instead, nest the `.input-group` within the `.col*`'],
306292
'should complain when an input group has a grid column class on it.');
307293
test.done();
308294
},
309-
*/
310-
/*
311295
'input groups missing controls and addons': function (test) {
312296
test.expect(2);
313297
test.deepEqual(lintHtml(utf8Fixture('input-group/missing-input-group-addon.html')),
314-
['`.input-group` must have a `.form-control` and either an `.input-group-addon` or an `.input-group-btn`.'],
298+
['`.input-group` must have a `.form-control` and either an `.input-group-prepend` or `.input-group-append`.'],
315299
'should complain when missing missing a `.form-control`');
316300
test.deepEqual(lintHtml(utf8Fixture('input-group/missing-form-control.html')),
317-
['`.input-group` must have a `.form-control` and either an `.input-group-addon` or an `.input-group-btn`.'],
318-
'should complain when missing missing a `.input-group-addon`');
301+
['`.input-group` must have a `.form-control` and either an `.input-group-prepend` or `.input-group-append`.'],
302+
'should complain when missing missing a `.input-group-prepend`');
319303
test.done();
320304
},
321-
*/
322305
/*
323306
'non-column children of rows': function (test) {
324307
test.expect(2);
@@ -332,27 +315,6 @@ exports.bootlint = {
332315
},
333316
*/
334317
/*
335-
'multiple columns on the same side of an input group': function (test) {
336-
test.expect(5);
337-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-add-on-left.html')),
338-
['Having multiple add-ons on a single side of an input group is not supported'],
339-
'should complain when multiple normal add-ons are on the left side of an input group.');
340-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-add-on-right.html')),
341-
['Having multiple add-ons on a single side of an input group is not supported'],
342-
'should complain when multiple normal add-ons are on the right side of an input group.');
343-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-btn-add-on-left.html')),
344-
['Having multiple add-ons on a single side of an input group is not supported'],
345-
'should complain when multiple button add-ons are on the left side of an input group.');
346-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-btn-add-on-right.html')),
347-
['Having multiple add-ons on a single side of an input group is not supported'],
348-
'should complain when multiple button add-ons are on the right side of an input group.');
349-
test.deepEqual(lintHtml(utf8Fixture('input-group/multiple-mixed-add-on-left.html')),
350-
['Having multiple add-ons on a single side of an input group is not supported'],
351-
'should complain when both a normal add-on and a button add-on are on the left side of an input group.');
352-
test.done();
353-
},
354-
*/
355-
/*
356318
'dropdown-toggle comes before btn': function (test) {
357319
test.expect(2);
358320
test.deepEqual(lintHtml(utf8Fixture('buttons/btn-toggle.html')),

0 commit comments

Comments
 (0)