Skip to content

Commit 927c1e6

Browse files
committed
More formatting tweaks to improve readability.
1 parent 97004cb commit 927c1e6

File tree

11 files changed

+914
-256
lines changed

11 files changed

+914
-256
lines changed

dist/csslint-tests.js

Lines changed: 457 additions & 128 deletions
Large diffs are not rendered by default.

tests/cli/assets/apiStub.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/* jshint node:true */
2+
23
"use strict";
34

45
var stub = {
5-
logbook: function (log) {
6+
logbook: function(log) {
67
this.logs.push(log);
78
},
8-
readLogs: function () {
9+
readLogs: function() {
910
return this.logs.slice();
1011
},
1112

12-
getFullPath: function (path) {
13+
getFullPath: function(path) {
1314
return path;
1415
},
15-
getFiles: function (dir) {
16+
getFiles: function(dir) {
1617
var filesobj = this.fakedFs[dir],
1718
fileix,
1819
out = [];
@@ -23,7 +24,7 @@ var stub = {
2324
}
2425
return out;
2526
},
26-
readFile: function (path) {
27+
readFile: function(path) {
2728
var spath = path.split("/"),
2829
spathLen = spath.length,
2930
i,
@@ -35,19 +36,19 @@ var stub = {
3536

3637
return out;
3738
},
38-
isDirectory: function (checkit) {
39+
isDirectory: function(checkit) {
3940
var result = this.fakedFs[checkit];
4041
return typeof result === "object";
4142
},
42-
print: function (msg) {
43+
print: function(msg) {
4344
this.logbook(msg);
4445
},
45-
quit: function (signal) {
46+
quit: function(signal) {
4647
this.logbook(signal);
4748
}
4849
};
4950

50-
module.exports = function (setup) {
51+
module.exports = function(setup) {
5152
var api,
5253
setix;
5354

tests/core/CSSLint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
name: "CSSLint object tests",
88

99
"Adjoining classes should not cause an error": function() {
10-
var result = CSSLint.verify(".foo.bar{}", { });
10+
var result = CSSLint.verify(".foo.bar{}", {});
1111
Assert.areEqual(0, result.messages.length);
1212
},
1313

1414
"@media (max-width:400px) should not cause an error": function() {
15-
var result = CSSLint.verify("@media (max-width:400px) {}", { });
15+
var result = CSSLint.verify("@media (max-width:400px) {}", {});
1616
Assert.areEqual(0, result.messages.length);
1717
},
1818

@@ -39,7 +39,7 @@
3939
Assert.areEqual(1, ruleset["box-sizing"]);
4040
},
4141

42-
"Embedded rulesets should accept whitespace between /* and 'csslint'": function () {
42+
"Embedded rulesets should accept whitespace between /* and 'csslint'": function() {
4343
var result = CSSLint.verify("/* csslint bogus, adjoining-classes:true, box-sizing:false */\n.foo.bar{}", {
4444
"text-indent": 1,
4545
"box-sizing": 1

tests/core/Reporter.js

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,110 @@
77
name: "Reporter Object Tests",
88

99
"Report should cause a warning": function() {
10-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1 });
11-
reporter.report("Foo", 1, 1, { id: "fake-rule" });
10+
var reporter = new CSSLint._Reporter([], {
11+
"fake-rule": 1
12+
});
13+
reporter.report("Foo", 1, 1, {
14+
id: "fake-rule"
15+
});
1216

1317
Assert.areEqual(1, reporter.messages.length);
1418
Assert.areEqual("warning", reporter.messages[0].type);
1519
},
1620

1721
"Report should cause an error": function() {
18-
var reporter = new CSSLint._Reporter([], { "fake-rule": 2 });
19-
reporter.report("Foo", 1, 1, { id: "fake-rule" });
22+
var reporter = new CSSLint._Reporter([], {
23+
"fake-rule": 2
24+
});
25+
reporter.report("Foo", 1, 1, {
26+
id: "fake-rule"
27+
});
2028

2129
Assert.areEqual(1, reporter.messages.length);
2230
Assert.areEqual("error", reporter.messages[0].type);
2331
},
2432

2533
"Calling error() should cause an error": function() {
26-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1 });
27-
reporter.error("Foo", 1, 1, { id: "fake-rule" });
34+
var reporter = new CSSLint._Reporter([], {
35+
"fake-rule": 1
36+
});
37+
reporter.error("Foo", 1, 1, {
38+
id: "fake-rule"
39+
});
2840

2941
Assert.areEqual(1, reporter.messages.length);
3042
Assert.areEqual("error", reporter.messages[0].type);
3143
},
3244

3345
"Allow statement should drop message about specific rule on specific line but not other lines": function() {
34-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1 }, { "3": { "fake-rule": true } });
35-
reporter.report("Foo", 2, 1, { id: "fake-rule" });
36-
reporter.report("Bar", 3, 1, { id: "fake-rule" });
46+
var reporter = new CSSLint._Reporter([], {
47+
"fake-rule": 1
48+
}, {
49+
"3": {
50+
"fake-rule": true
51+
}
52+
});
53+
reporter.report("Foo", 2, 1, {
54+
id: "fake-rule"
55+
});
56+
reporter.report("Bar", 3, 1, {
57+
id: "fake-rule"
58+
});
3759

3860
Assert.areEqual(1, reporter.messages.length);
3961
},
4062

4163
"Allow statement should drop message about specific rule on specific line but not other rules": function() {
42-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1, "fake-rule2": 1 }, { "3": { "fake-rule": true } });
43-
reporter.report("Foo", 3, 1, { id: "fake-rule" });
44-
reporter.report("Bar", 3, 1, { id: "fake-rule2" });
64+
var reporter = new CSSLint._Reporter([], {
65+
"fake-rule": 1,
66+
"fake-rule2": 1
67+
}, {
68+
"3": {
69+
"fake-rule": true
70+
}
71+
});
72+
reporter.report("Foo", 3, 1, {
73+
id: "fake-rule"
74+
});
75+
reporter.report("Bar", 3, 1, {
76+
id: "fake-rule2"
77+
});
4578

4679
Assert.areEqual(1, reporter.messages.length);
4780
},
4881

4982
"Allow statement should drop messages about multiple rules on specific line": function() {
50-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1, "fake-rule2": 1 }, { "3": { "fake-rule": true, "fake-rule2": true } });
51-
reporter.report("Foo", 3, 1, { id: "fake-rule" });
52-
reporter.report("Bar", 3, 1, { id: "fake-rule2" });
83+
var reporter = new CSSLint._Reporter([], {
84+
"fake-rule": 1,
85+
"fake-rule2": 1
86+
}, {
87+
"3": {
88+
"fake-rule": true,
89+
"fake-rule2": true
90+
}
91+
});
92+
reporter.report("Foo", 3, 1, {
93+
id: "fake-rule"
94+
});
95+
reporter.report("Bar", 3, 1, {
96+
id: "fake-rule2"
97+
});
5398

5499
Assert.areEqual(0, reporter.messages.length);
55100
},
56101

57102
"Ignores should step over a report in their range": function() {
58-
var reporter = new CSSLint._Reporter([], { "fake-rule": 1 }, {}, [[1, 3]]);
59-
reporter.report("Foo", 2, 1, { id: "fake-rule" });
60-
reporter.report("Bar", 5, 1, { id: "fake-rule" });
103+
var reporter = new CSSLint._Reporter([], {
104+
"fake-rule": 1
105+
}, {}, [
106+
[1, 3]
107+
]);
108+
reporter.report("Foo", 2, 1, {
109+
id: "fake-rule"
110+
});
111+
reporter.report("Bar", 5, 1, {
112+
id: "fake-rule"
113+
});
61114

62115
Assert.areEqual(1, reporter.messages.length);
63116
}

tests/formatters/checkstyle-xml.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,37 @@
77
name: "Checkstyle XML formatter test",
88

99
"File with no problems should say so": function() {
10-
var result = { messages: [], stats: [] },
10+
var result = {
11+
messages: [],
12+
stats: []
13+
},
1114
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle></checkstyle>";
1215
Assert.areEqual(expected, CSSLint.format(result, "FILE", "checkstyle-xml"));
1316
},
1417

1518
"File with problems should list them": function() {
16-
var result = { messages: [
17-
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "A Rule"} },
18-
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: { name: "Some Other Rule"} }
19-
], stats: [] },
19+
var result = {
20+
messages: [{
21+
type: "warning",
22+
line: 1,
23+
col: 1,
24+
message: "BOGUS",
25+
evidence: "ALSO BOGUS",
26+
rule: {
27+
name: "A Rule"
28+
}
29+
}, {
30+
type: "error",
31+
line: 2,
32+
col: 1,
33+
message: "BOGUS",
34+
evidence: "ALSO BOGUS",
35+
rule: {
36+
name: "Some Other Rule"
37+
}
38+
}],
39+
stats: []
40+
},
2041
file = "<file name=\"FILE\">",
2142
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"BOGUS\" source=\"net.csslint.ARule\"/>",
2243
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"BOGUS\" source=\"net.csslint.SomeOtherRule\"/>",
@@ -27,10 +48,24 @@
2748

2849
"Formatter should escape special characters": function() {
2950
var specialCharsSting = "sneaky, 'sneaky', <sneaky>, sneak & sneaky",
30-
result = { messages: [
31-
{ type: "warning", line: 1, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] },
32-
{ type: "error", line: 2, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] }
33-
], stats: [] },
51+
result = {
52+
messages: [{
53+
type: "warning",
54+
line: 1,
55+
col: 1,
56+
message: specialCharsSting,
57+
evidence: "ALSO BOGUS",
58+
rule: []
59+
}, {
60+
type: "error",
61+
line: 2,
62+
col: 1,
63+
message: specialCharsSting,
64+
evidence: "ALSO BOGUS",
65+
rule: []
66+
}],
67+
stats: []
68+
},
3469
file = "<file name=\"FILE\">",
3570
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
3671
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",

0 commit comments

Comments
 (0)