Skip to content

Commit 0c12e2a

Browse files
committed
Run grunt.
[ci skip]
1 parent cb467d4 commit 0c12e2a

File tree

7 files changed

+376
-20
lines changed

7 files changed

+376
-20
lines changed

dist/cli.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,28 @@ function cli(api) {
330330
function readConfigData(config) {
331331
var data = readConfigFile(config),
332332
json,
333+
optionName,
334+
optionValue,
335+
args,
333336
options = {};
334337
if (data) {
335338
if (data.charAt(0) === "{") {
336339
try {
337340
json = JSON.parse(data);
338341
data = "";
339-
for (var optionName in json) {
342+
for (optionName in json) {
340343
if (json.hasOwnProperty(optionName)) {
341-
data += "--" + optionName + "=" + json[optionName].join();
344+
optionValue = json[optionName];
345+
if (Array.isArray(optionValue)) {
346+
optionValue = optionValue.join(",");
347+
}
348+
data += "--" + optionName + "=" + optionValue;
342349
}
343350
}
344351
} catch (e) {}
345352
}
346-
options = processArguments(data.split(/[\s\n\r]+/m));
353+
args = data.replace(/\s+/g,"").split(/(?=--)/);
354+
options = processArguments(args);
347355
}
348356

349357
return options;

dist/csslint-node.js

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,48 @@ CSSLint.addRule({
15041504

15051505
});
15061506

1507+
/*
1508+
* Rule: IE6-9 supports up to 31 stylesheet import.
1509+
* Reference:
1510+
* http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx
1511+
*/
1512+
1513+
CSSLint.addRule({
1514+
1515+
//rule information
1516+
id: "import-ie-limit",
1517+
name: "@import limit on IE6-IE9",
1518+
desc: "IE6-9 supports up to 31 @import per stylesheet",
1519+
browsers: "IE6, IE7, IE8, IE9",
1520+
1521+
//initialization
1522+
init: function(parser, reporter){
1523+
"use strict";
1524+
var rule = this,
1525+
MAX_IMPORT_COUNT = 31,
1526+
count = 0;
1527+
1528+
function startPage(){
1529+
count = 0;
1530+
}
1531+
1532+
parser.addListener("startpage", startPage);
1533+
1534+
parser.addListener("import", function(){
1535+
count++;
1536+
});
1537+
1538+
parser.addListener("endstylesheet", function() {
1539+
if (count > MAX_IMPORT_COUNT) {
1540+
reporter.rollupError(
1541+
"Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
1542+
rule
1543+
);
1544+
}
1545+
});
1546+
}
1547+
1548+
});
15071549
/*
15081550
* Rule: Don't use @import, use <link> instead.
15091551
*/
@@ -2343,11 +2385,13 @@ CSSLint.addRule({
23432385
//initialization
23442386
init: function(parser, reporter) {
23452387
"use strict";
2388+
23462389
var rule = this;
23472390

23482391
parser.addListener("startrule", function(event) {
23492392

23502393
var selectors = event.selectors,
2394+
selectorContainsClassOrId = false,
23512395
selector,
23522396
part,
23532397
modifier,
@@ -2360,8 +2404,19 @@ CSSLint.addRule({
23602404
if (part.type === parser.SELECTOR_PART_TYPE) {
23612405
for (k=0; k < part.modifiers.length; k++) {
23622406
modifier = part.modifiers[k];
2363-
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
2364-
reporter.report(rule.desc, part.line, part.col, rule);
2407+
2408+
if (modifier.type === "class" || modifier.type === "id") {
2409+
selectorContainsClassOrId = true;
2410+
break;
2411+
}
2412+
}
2413+
2414+
if (!selectorContainsClassOrId) {
2415+
for (k=0; k < part.modifiers.length; k++) {
2416+
modifier = part.modifiers[k];
2417+
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
2418+
reporter.report(rule.desc, part.line, part.col, rule);
2419+
}
23652420
}
23662421
}
23672422
}

dist/csslint-rhino.js

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8197,6 +8197,48 @@ CSSLint.addRule({
81978197

81988198
});
81998199

8200+
/*
8201+
* Rule: IE6-9 supports up to 31 stylesheet import.
8202+
* Reference:
8203+
* http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx
8204+
*/
8205+
8206+
CSSLint.addRule({
8207+
8208+
//rule information
8209+
id: "import-ie-limit",
8210+
name: "@import limit on IE6-IE9",
8211+
desc: "IE6-9 supports up to 31 @import per stylesheet",
8212+
browsers: "IE6, IE7, IE8, IE9",
8213+
8214+
//initialization
8215+
init: function(parser, reporter){
8216+
"use strict";
8217+
var rule = this,
8218+
MAX_IMPORT_COUNT = 31,
8219+
count = 0;
8220+
8221+
function startPage(){
8222+
count = 0;
8223+
}
8224+
8225+
parser.addListener("startpage", startPage);
8226+
8227+
parser.addListener("import", function(){
8228+
count++;
8229+
});
8230+
8231+
parser.addListener("endstylesheet", function() {
8232+
if (count > MAX_IMPORT_COUNT) {
8233+
reporter.rollupError(
8234+
"Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
8235+
rule
8236+
);
8237+
}
8238+
});
8239+
}
8240+
8241+
});
82008242
/*
82018243
* Rule: Don't use @import, use <link> instead.
82028244
*/
@@ -9036,11 +9078,13 @@ CSSLint.addRule({
90369078
//initialization
90379079
init: function(parser, reporter) {
90389080
"use strict";
9081+
90399082
var rule = this;
90409083

90419084
parser.addListener("startrule", function(event) {
90429085

90439086
var selectors = event.selectors,
9087+
selectorContainsClassOrId = false,
90449088
selector,
90459089
part,
90469090
modifier,
@@ -9053,8 +9097,19 @@ CSSLint.addRule({
90539097
if (part.type === parser.SELECTOR_PART_TYPE) {
90549098
for (k=0; k < part.modifiers.length; k++) {
90559099
modifier = part.modifiers[k];
9056-
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
9057-
reporter.report(rule.desc, part.line, part.col, rule);
9100+
9101+
if (modifier.type === "class" || modifier.type === "id") {
9102+
selectorContainsClassOrId = true;
9103+
break;
9104+
}
9105+
}
9106+
9107+
if (!selectorContainsClassOrId) {
9108+
for (k=0; k < part.modifiers.length; k++) {
9109+
modifier = part.modifiers[k];
9110+
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
9111+
reporter.report(rule.desc, part.line, part.col, rule);
9112+
}
90589113
}
90599114
}
90609115
}
@@ -10055,20 +10110,28 @@ function cli(api) {
1005510110
function readConfigData(config) {
1005610111
var data = readConfigFile(config),
1005710112
json,
10113+
optionName,
10114+
optionValue,
10115+
args,
1005810116
options = {};
1005910117
if (data) {
1006010118
if (data.charAt(0) === "{") {
1006110119
try {
1006210120
json = JSON.parse(data);
1006310121
data = "";
10064-
for (var optionName in json) {
10122+
for (optionName in json) {
1006510123
if (json.hasOwnProperty(optionName)) {
10066-
data += "--" + optionName + "=" + json[optionName].join();
10124+
optionValue = json[optionName];
10125+
if (Array.isArray(optionValue)) {
10126+
optionValue = optionValue.join(",");
10127+
}
10128+
data += "--" + optionName + "=" + optionValue;
1006710129
}
1006810130
}
1006910131
} catch (e) {}
1007010132
}
10071-
options = processArguments(data.split(/[\s\n\r]+/m));
10133+
args = data.replace(/\s+/g,"").split(/(?=--)/);
10134+
options = processArguments(args);
1007210135
}
1007310136

1007410137
return options;

dist/csslint-tests.js

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,54 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
24132413

24142414
})();
24152415

2416+
(function(){
2417+
"use strict";
2418+
var Assert = YUITest.Assert,
2419+
IMPORT_STATEMENT = "@import url('foo.css');",
2420+
MAX_IMPORT_LIMIT = 31,
2421+
withinLimitCss = "",
2422+
exceedLimitCss = "",
2423+
greatlyExceedLimitCss = "",
2424+
i;
2425+
2426+
// Build CSS strings to be used in tests
2427+
withinLimitCss = IMPORT_STATEMENT;
2428+
2429+
for (i = 0; i < MAX_IMPORT_LIMIT + 1; i++) {
2430+
exceedLimitCss += IMPORT_STATEMENT;
2431+
}
2432+
2433+
for (i = 0; i < MAX_IMPORT_LIMIT + 100; i++) {
2434+
greatlyExceedLimitCss += IMPORT_STATEMENT;
2435+
}
2436+
2437+
YUITest.TestRunner.add(new YUITest.TestCase({
2438+
2439+
name: "Import IE Limit Rule Error",
2440+
2441+
"Using @import <= 31 times should not result in error": function(){
2442+
2443+
var result = CSSLint.verify(withinLimitCss, { "import-ie-limit": 1 });
2444+
Assert.areEqual(0, result.messages.length);
2445+
},
2446+
2447+
"Using @import > 31 times should result in error": function(){
2448+
var result = CSSLint.verify(exceedLimitCss, { "import-ie-limit": 1 });
2449+
Assert.areEqual(1, result.messages.length);
2450+
Assert.areEqual("error", result.messages[0].type);
2451+
Assert.areEqual("Too many @import rules (32). IE6-9 supports up to 31 import per stylesheet.", result.messages[0].message);
2452+
},
2453+
2454+
"Using @import > 31 times repeatedly should result in a single error": function(){
2455+
var result = CSSLint.verify(greatlyExceedLimitCss, { "import-ie-limit": 1 });
2456+
Assert.areEqual(1, result.messages.length);
2457+
Assert.areEqual("error", result.messages[0].type);
2458+
Assert.areEqual("Too many @import rules (131). IE6-9 supports up to 31 import per stylesheet.", result.messages[0].message);
2459+
}
2460+
}));
2461+
2462+
})();
2463+
24162464
(function() {
24172465
"use strict";
24182466
var Assert = YUITest.Assert;
@@ -3109,8 +3157,17 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
31093157
"Using a qualified attribute selector should not result in a warning": function() {
31103158
var result = CSSLint.verify("input[type=text] { font-size: 10px; } ", {"unqualified-attributes": 1 });
31113159
Assert.areEqual(0, result.messages.length);
3112-
}
3160+
},
31133161

3162+
"Using an attribute selector qualified by a class should not result in a warning": function(){
3163+
var result = CSSLint.verify(".fancy[type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
3164+
Assert.areEqual(0, result.messages.length);
3165+
},
3166+
3167+
"Using an attribute selector qualified by an ID should not result in a warning": function(){
3168+
var result = CSSLint.verify("#fancy[type=text] { font-size: 10px; }", {"unqualified-attributes": 1 });
3169+
Assert.areEqual(0, result.messages.length);
3170+
}
31143171

31153172
}));
31163173

dist/csslint-worker.js

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8193,6 +8193,48 @@ CSSLint.addRule({
81938193

81948194
});
81958195

8196+
/*
8197+
* Rule: IE6-9 supports up to 31 stylesheet import.
8198+
* Reference:
8199+
* http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx
8200+
*/
8201+
8202+
CSSLint.addRule({
8203+
8204+
//rule information
8205+
id: "import-ie-limit",
8206+
name: "@import limit on IE6-IE9",
8207+
desc: "IE6-9 supports up to 31 @import per stylesheet",
8208+
browsers: "IE6, IE7, IE8, IE9",
8209+
8210+
//initialization
8211+
init: function(parser, reporter){
8212+
"use strict";
8213+
var rule = this,
8214+
MAX_IMPORT_COUNT = 31,
8215+
count = 0;
8216+
8217+
function startPage(){
8218+
count = 0;
8219+
}
8220+
8221+
parser.addListener("startpage", startPage);
8222+
8223+
parser.addListener("import", function(){
8224+
count++;
8225+
});
8226+
8227+
parser.addListener("endstylesheet", function() {
8228+
if (count > MAX_IMPORT_COUNT) {
8229+
reporter.rollupError(
8230+
"Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
8231+
rule
8232+
);
8233+
}
8234+
});
8235+
}
8236+
8237+
});
81968238
/*
81978239
* Rule: Don't use @import, use <link> instead.
81988240
*/
@@ -9032,11 +9074,13 @@ CSSLint.addRule({
90329074
//initialization
90339075
init: function(parser, reporter) {
90349076
"use strict";
9077+
90359078
var rule = this;
90369079

90379080
parser.addListener("startrule", function(event) {
90389081

90399082
var selectors = event.selectors,
9083+
selectorContainsClassOrId = false,
90409084
selector,
90419085
part,
90429086
modifier,
@@ -9049,8 +9093,19 @@ CSSLint.addRule({
90499093
if (part.type === parser.SELECTOR_PART_TYPE) {
90509094
for (k=0; k < part.modifiers.length; k++) {
90519095
modifier = part.modifiers[k];
9052-
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
9053-
reporter.report(rule.desc, part.line, part.col, rule);
9096+
9097+
if (modifier.type === "class" || modifier.type === "id") {
9098+
selectorContainsClassOrId = true;
9099+
break;
9100+
}
9101+
}
9102+
9103+
if (!selectorContainsClassOrId) {
9104+
for (k=0; k < part.modifiers.length; k++) {
9105+
modifier = part.modifiers[k];
9106+
if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
9107+
reporter.report(rule.desc, part.line, part.col, rule);
9108+
}
90549109
}
90559110
}
90569111
}

0 commit comments

Comments
 (0)