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

Commit 6ef40e9

Browse files
iamphillcvrebert
authored andcommitted
Form group should not have form-inline/horizontal class
Fixes #42 Closes #139
1 parent f94885c commit 6ef40e9

File tree

5 files changed

+112
-12
lines changed

5 files changed

+112
-12
lines changed

dist/browser/bootlint.js

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9545,35 +9545,35 @@ SemVer.prototype.comparePre = function(other) {
95459545

95469546
// preminor will bump the version up to the next minor release, and immediately
95479547
// down to pre-release. premajor and prepatch work the same way.
9548-
SemVer.prototype.inc = function(release) {
9548+
SemVer.prototype.inc = function(release, identifier) {
95499549
switch (release) {
95509550
case 'premajor':
95519551
this.prerelease.length = 0;
95529552
this.patch = 0;
95539553
this.minor = 0;
95549554
this.major++;
9555-
this.inc('pre');
9555+
this.inc('pre', identifier);
95569556
break;
95579557
case 'preminor':
95589558
this.prerelease.length = 0;
95599559
this.patch = 0;
95609560
this.minor++;
9561-
this.inc('pre');
9561+
this.inc('pre', identifier);
95629562
break;
95639563
case 'prepatch':
95649564
// If this is already a prerelease, it will bump to the next version
95659565
// drop any prereleases that might already exist, since they are not
95669566
// relevant at this point.
95679567
this.prerelease.length = 0;
9568-
this.inc('patch');
9569-
this.inc('pre');
9568+
this.inc('patch', identifier);
9569+
this.inc('pre', identifier);
95709570
break;
95719571
// If the input is a non-prerelease version, this acts the same as
95729572
// prepatch.
95739573
case 'prerelease':
95749574
if (this.prerelease.length === 0)
9575-
this.inc('patch');
9576-
this.inc('pre');
9575+
this.inc('patch', identifier);
9576+
this.inc('pre', identifier);
95779577
break;
95789578

95799579
case 'major':
@@ -9607,7 +9607,7 @@ SemVer.prototype.inc = function(release) {
96079607
this.prerelease = [];
96089608
break;
96099609
// This probably shouldn't be used publicly.
9610-
// 1.0.0 "pre" would become 1.0.0 which is the wrong direction.
9610+
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
96119611
case 'pre':
96129612
if (this.prerelease.length === 0)
96139613
this.prerelease = [0];
@@ -9622,6 +9622,15 @@ SemVer.prototype.inc = function(release) {
96229622
if (i === -1) // didn't increment anything
96239623
this.prerelease.push(0);
96249624
}
9625+
if (identifier) {
9626+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
9627+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
9628+
if (this.prerelease[0] === identifier) {
9629+
if (isNaN(this.prerelease[1]))
9630+
this.prerelease = [identifier, 0];
9631+
} else
9632+
this.prerelease = [identifier, 0];
9633+
}
96259634
break;
96269635

96279636
default:
@@ -9632,9 +9641,14 @@ SemVer.prototype.inc = function(release) {
96329641
};
96339642

96349643
exports.inc = inc;
9635-
function inc(version, release, loose) {
9644+
function inc(version, release, loose, identifier) {
9645+
if (typeof(loose) === 'string') {
9646+
identifier = loose;
9647+
loose = undefined;
9648+
}
9649+
96369650
try {
9637-
return new SemVer(version, loose).inc(release).version;
9651+
return new SemVer(version, loose).inc(release, identifier).version;
96389652
} catch (er) {
96399653
return null;
96409654
}
@@ -10896,7 +10910,7 @@ var semver = require('semver');
1089610910
}
1089710911
});
1089810912
addLinter("E027", function lintTableResponsive($, reporter) {
10899-
var badStructure = $('.table.table-responsive,table.table-responsive');
10913+
var badStructure = $('.table.table-responsive, table.table-responsive');
1090010914
if (badStructure.length) {
1090110915
reporter("`.table-responsive` is supposed to be used on the table's parent wrapper <div>, not on the table itself", badStructure);
1090210916
}
@@ -11003,6 +11017,12 @@ var semver = require('semver');
1100311017
reporter(".modal-title must be a child of .modal-header", elements);
1100411018
}
1100511019
});
11020+
addLinter("E035", function lintFormGroupWithFormClass($, reporter) {
11021+
var badFormGroups = $('.form-group.form-inline, .form-group.form-horizontal');
11022+
if (badFormGroups.length) {
11023+
reporter('Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal', badFormGroups);
11024+
}
11025+
});
1100611026

1100711027
exports._lint = function ($, reporter, disabledIdList) {
1100811028
var disabledIdSet = {};

src/bootlint.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ var semver = require('semver');
588588
}
589589
});
590590
addLinter("E027", function lintTableResponsive($, reporter) {
591-
var badStructure = $('.table.table-responsive,table.table-responsive');
591+
var badStructure = $('.table.table-responsive, table.table-responsive');
592592
if (badStructure.length) {
593593
reporter("`.table-responsive` is supposed to be used on the table's parent wrapper <div>, not on the table itself", badStructure);
594594
}
@@ -695,6 +695,12 @@ var semver = require('semver');
695695
reporter(".modal-title must be a child of .modal-header", elements);
696696
}
697697
});
698+
addLinter("E035", function lintFormGroupWithFormClass($, reporter) {
699+
var badFormGroups = $('.form-group.form-inline, .form-group.form-horizontal');
700+
if (badFormGroups.length) {
701+
reporter('Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal', badFormGroups);
702+
}
703+
});
698704

699705
exports._lint = function ($, reporter, disabledIdList) {
700706
var disabledIdSet = {};

test/bootlint_test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,5 +506,17 @@ exports.bootlint = {
506506
'should complain when modal title is not within modal header.'
507507
);
508508
test.done();
509+
},
510+
'test form group validity': function (test) {
511+
test.expect(2);
512+
test.deepEqual(lintHtml(utf8Fixture('form/form-inline-group.html')),
513+
["Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal"],
514+
'should complain about form-group having .form-inline'
515+
);
516+
test.deepEqual(lintHtml(utf8Fixture('form/form-horizontal-group.html')),
517+
["Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal"],
518+
'should complain about form-group having .form-horizontal'
519+
);
520+
test.done();
509521
}
510522
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<form role="form">
21+
<div class="form-group form-horizontal">
22+
<label>Label</label>
23+
<input type="text" class="form-control" />
24+
</div>
25+
</form>
26+
<div id="qunit"></div>
27+
<ol id="bootlint">
28+
<li data-lint="Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal"></li>
29+
</ol>
30+
</body>
31+
</html>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<title>Test</title>
8+
<!--[if lt IE 9]>
9+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
10+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
11+
<![endif]-->
12+
<script src="../../lib/jquery.min.js"></script>
13+
14+
<link rel="stylesheet" href="../../lib/qunit.css">
15+
<script src="../../lib/qunit.js"></script>
16+
<script src="../../../dist/browser/bootlint.js"></script>
17+
<script src="../generic-qunit.js"></script>
18+
</head>
19+
<body>
20+
<form role="form">
21+
<div class="form-group form-inline">
22+
<label>Label</label>
23+
<input type="text" class="form-control" />
24+
</div>
25+
</form>
26+
<div id="qunit"></div>
27+
<ol id="bootlint">
28+
<li data-lint="Neither .form-inline nor .form-horizontal should be used directly on a `.form-group`. Instead, nest the .form-group within the .form-inline or .form-horizontal"></li>
29+
</ol>
30+
</body>
31+
</html>

0 commit comments

Comments
 (0)