Skip to content

Commit 2387d36

Browse files
committed
Merge pull request #188 from cscott/jshint-batch-1
Lint source code (part 1).
2 parents d27ee2b + 697cc34 commit 2387d36

13 files changed

+132
-174
lines changed

src/css/Combinator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function Combinator(text, line, col){
2323
//pretty simple
2424
if (/^\s+$/.test(text)){
2525
this.type = "descendant";
26-
} else if (text == ">"){
26+
} else if (text === ">"){
2727
this.type = "child";
28-
} else if (text == "+"){
28+
} else if (text === "+"){
2929
this.type = "adjacent-sibling";
30-
} else if (text == "~"){
30+
} else if (text === "~"){
3131
this.type = "sibling";
3232
}
3333

src/css/Parser.js

Lines changed: 44 additions & 56 deletions
Large diffs are not rendered by default.

src/css/Properties.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ var Properties = {
162162
var valid = false,
163163
simple = "<length> | <percentage> | inherit",
164164
slash = false,
165-
fill = false,
166165
count = 0,
167166
max = 8,
168167
part;
@@ -226,8 +225,7 @@ var Properties = {
226225
"-webkit-box-pack" : "start | end | center | justify",
227226
"box-decoration-break" : "slice | clone",
228227
"box-shadow" : function (expression) {
229-
var result = false,
230-
part;
228+
var part;
231229

232230
if (!ValidationTypes.isAny(expression, "none")) {
233231
Validation.multiProperty("<shadow>", expression, true, Infinity);

src/css/PropertyValueIterator.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*global SyntaxUnit, Parser*/
21
/**
32
* A utility class that allows for easy iteration over the various parts of a
43
* property value.
@@ -105,7 +104,7 @@ PropertyValueIterator.prototype.next = function(){
105104
* Returns the previous part of the property value or null if there is no
106105
* previous part.
107106
* @return {parserlib.css.PropertyValuePart} The previous part of the
108-
* property value or null if there is no next part.
107+
* property value or null if there is no previous part.
109108
* @method previous
110109
*/
111110
PropertyValueIterator.prototype.previous = function(){

src/css/PropertyValuePart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function PropertyValuePart(text, line, col){
9393
} else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
9494
this.type = "color";
9595
temp = RegExp.$1;
96-
if (temp.length == 3){
96+
if (temp.length === 3){
9797
this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
9898
this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
9999
this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);

src/css/Pseudos.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Pseudos.ELEMENT = 1;
99
Pseudos.CLASS = 2;
1010

1111
Pseudos.isElement = function(pseudo){
12-
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] == Pseudos.ELEMENT;
13-
};
12+
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
13+
};

src/css/Specificity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Specificity.calculate = function(selector){
7979
elementName = part.elementName ? part.elementName.text : "",
8080
modifier;
8181

82-
if (elementName && elementName.charAt(elementName.length-1) != "*") {
82+
if (elementName && elementName.charAt(elementName.length-1) !== "*") {
8383
d++;
8484
}
8585

src/css/TokenStream.js

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*global Tokens, TokenStreamBase*/
22

33
var h = /^[0-9a-fA-F]$/,
4-
nonascii = /^[\u00A0-\uFFFF]$/,
4+
//nonascii = /^[\u00A0-\uFFFF]$/,
55
nl = /\n|\r\n|\r|\f/,
66
whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
77

@@ -96,7 +96,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
9696
*/
9797
case "/":
9898

99-
if(reader.peek() == "*"){
99+
if(reader.peek() === "*"){
100100
token = this.commentToken(c, startLine, startCol);
101101
} else {
102102
token = this.charToken(c, startLine, startCol);
@@ -117,7 +117,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
117117
case "^":
118118
case "$":
119119
case "*":
120-
if(reader.peek() == "="){
120+
if(reader.peek() === "="){
121121
token = this.comparisonToken(c, startLine, startCol);
122122
} else {
123123
token = this.charToken(c, startLine, startCol);
@@ -171,7 +171,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
171171
* - PERCENTAGE
172172
*/
173173
case "-":
174-
if (reader.peek() == "-"){ //could be closing HTML-style comment
174+
if (reader.peek() === "-"){ //could be closing HTML-style comment
175175
token = this.htmlCommentEndToken(c, startLine, startCol);
176176
} else if (isNameStart(reader.peek())){
177177
token = this.identOrFunctionToken(c, startLine, startCol);
@@ -235,7 +235,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
235235
*/
236236
case "U":
237237
case "u":
238-
if (reader.peek() == "+"){
238+
if (reader.peek() === "+"){
239239
token = this.unicodeRangeToken(c, startLine, startCol);
240240
break;
241241
}
@@ -354,9 +354,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
354354
var rule = first,
355355
reader = this._reader,
356356
tt = Tokens.CHAR,
357-
valid = false,
358-
ident,
359-
c;
357+
ident;
360358

361359
/*
362360
* First, mark where we are. There are only four @ rules,
@@ -373,7 +371,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
373371
tt = Tokens.type(rule.toLowerCase());
374372

375373
//if it's not valid, use the first character only and reset the reader
376-
if (tt == Tokens.CHAR || tt == Tokens.UNKNOWN){
374+
if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN){
377375
if (rule.length > 1){
378376
tt = Tokens.UNKNOWN_SYM;
379377
} else {
@@ -400,7 +398,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
400398
var tt = Tokens.type(c);
401399
var opts = {};
402400

403-
if (tt == -1){
401+
if (tt === -1){
404402
tt = Tokens.CHAR;
405403
} else {
406404
opts.endChar = Tokens[tt].endChar;
@@ -420,8 +418,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
420418
* @method commentToken
421419
*/
422420
commentToken: function(first, startLine, startCol){
423-
var reader = this._reader,
424-
comment = this.readComment(first);
421+
var comment = this.readComment(first);
425422

426423
return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
427424
},
@@ -455,8 +452,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
455452
* @method hashToken
456453
*/
457454
hashToken: function(first, startLine, startCol){
458-
var reader = this._reader,
459-
name = this.readName(first);
455+
var name = this.readName(first);
460456

461457
return this.createToken(Tokens.HASH, name, startLine, startCol);
462458
},
@@ -478,7 +474,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
478474
reader.mark();
479475
text += reader.readCount(3);
480476

481-
if (text == "<!--"){
477+
if (text === "<!--"){
482478
return this.createToken(Tokens.CDO, text, startLine, startCol);
483479
} else {
484480
reader.reset();
@@ -503,7 +499,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
503499
reader.mark();
504500
text += reader.readCount(2);
505501

506-
if (text == "-->"){
502+
if (text === "-->"){
507503
return this.createToken(Tokens.CDC, text, startLine, startCol);
508504
} else {
509505
reader.reset();
@@ -528,7 +524,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
528524
uriFns = ["url(", "url-prefix(", "domain("];
529525

530526
//if there's a left paren immediately after, it's a URI or function
531-
if (reader.peek() == "("){
527+
if (reader.peek() === "("){
532528
ident += reader.read();
533529
if (uriFns.indexOf(ident.toLowerCase()) > -1){
534530
tt = Tokens.URI;
@@ -541,10 +537,10 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
541537
} else {
542538
tt = Tokens.FUNCTION;
543539
}
544-
} else if (reader.peek() == ":"){ //might be an IE function
540+
} else if (reader.peek() === ":"){ //might be an IE function
545541

546542
//IE-specific functions always being with progid:
547-
if (ident.toLowerCase() == "progid"){
543+
if (ident.toLowerCase() === "progid"){
548544
ident += reader.readTo("(");
549545
tt = Tokens.IE_FUNCTION;
550546
}
@@ -576,10 +572,10 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
576572
while(c){
577573

578574
//there can be a comment in here
579-
if (c == "/"){
575+
if (c === "/"){
580576

581577
//if the next character isn't a star, then this isn't a valid !important token
582-
if (reader.peek() != "*"){
578+
if (reader.peek() !== "*"){
583579
break;
584580
} else {
585581
temp = this.readComment(c);
@@ -604,7 +600,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
604600
c = reader.read();
605601
}
606602

607-
if (tt == Tokens.CHAR){
603+
if (tt === Tokens.CHAR){
608604
reader.reset();
609605
return this.charToken(first, startLine, startCol);
610606
} else {
@@ -631,7 +627,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
631627
reader.mark();
632628
text += reader.readCount(4);
633629

634-
if (text.toLowerCase() == ":not("){
630+
if (text.toLowerCase() === ":not("){
635631
return this.createToken(Tokens.NOT, text, startLine, startCol);
636632
} else {
637633
reader.reset();
@@ -675,7 +671,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
675671
tt = Tokens.DIMENSION;
676672
}
677673

678-
} else if (c == "%"){
674+
} else if (c === "%"){
679675
value += reader.read();
680676
tt = Tokens.PERCENTAGE;
681677
}
@@ -708,12 +704,12 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
708704
string += c;
709705

710706
//if the delimiter is found with an escapement, we're done.
711-
if (c == delim && prev != "\\"){
707+
if (c === delim && prev !== "\\"){
712708
break;
713709
}
714710

715711
//if there's a newline without an escapement, it's an invalid string
716-
if (isNewLine(reader.peek()) && c != "\\"){
712+
if (isNewLine(reader.peek()) && c !== "\\"){
717713
tt = Tokens.INVALID;
718714
break;
719715
}
@@ -738,28 +734,28 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
738734
tt = Tokens.CHAR;
739735

740736
//then it should be a unicode range
741-
if (reader.peek() == "+"){
737+
if (reader.peek() === "+"){
742738
reader.mark();
743739
value += reader.read();
744740
value += this.readUnicodeRangePart(true);
745741

746742
//ensure there's an actual unicode range here
747-
if (value.length == 2){
743+
if (value.length === 2){
748744
reader.reset();
749745
} else {
750746

751747
tt = Tokens.UNICODE_RANGE;
752748

753749
//if there's a ? in the first part, there can't be a second part
754-
if (value.indexOf("?") == -1){
750+
if (value.indexOf("?") === -1){
755751

756-
if (reader.peek() == "-"){
752+
if (reader.peek() === "-"){
757753
reader.mark();
758754
temp = reader.read();
759755
temp += this.readUnicodeRangePart(false);
760756

761757
//if there's not another value, back up and just take the first
762-
if (temp.length == 1){
758+
if (temp.length === 1){
763759
reader.reset();
764760
} else {
765761
value += temp;
@@ -784,8 +780,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
784780
* @method whitespaceToken
785781
*/
786782
whitespaceToken: function(first, startLine, startCol){
787-
var reader = this._reader,
788-
value = first + this.readWhitespace();
783+
var value = first + this.readWhitespace();
789784
return this.createToken(Tokens.S, value, startLine, startCol);
790785
},
791786

@@ -810,7 +805,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
810805

811806
//then read question marks if allowed
812807
if (allowQuestionMark){
813-
while(c == "?" && part.length < 6){
808+
while(c === "?" && part.length < 6){
814809
reader.read();
815810
part += c;
816811
c = reader.peek();
@@ -838,14 +833,14 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
838833
readNumber: function(first){
839834
var reader = this._reader,
840835
number = first,
841-
hasDot = (first == "."),
836+
hasDot = (first === "."),
842837
c = reader.peek();
843838

844839

845840
while(c){
846841
if (isDigit(c)){
847842
number += reader.read();
848-
} else if (c == "."){
843+
} else if (c === "."){
849844
if (hasDot){
850845
break;
851846
} else {
@@ -873,12 +868,12 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
873868
string += c;
874869

875870
//if the delimiter is found with an escapement, we're done.
876-
if (c == delim && prev != "\\"){
871+
if (c === delim && prev !== "\\"){
877872
break;
878873
}
879874

880875
//if there's a newline without an escapement, it's an invalid string
881-
if (isNewLine(reader.peek()) && c != "\\"){
876+
if (isNewLine(reader.peek()) && c !== "\\"){
882877
string = "";
883878
break;
884879
}
@@ -910,7 +905,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
910905
}
911906

912907
//it's a string
913-
if (c == "'" || c == "\""){
908+
if (c === "'" || c === "\""){
914909
inner = this.readString();
915910
} else {
916911
inner = this.readURL();
@@ -925,7 +920,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
925920
}
926921

927922
//if there was no inner value or the next character isn't closing paren, it's not a URI
928-
if (inner === "" || c != ")"){
923+
if (inner === "" || c !== ")"){
929924
uri = first;
930925
reader.reset();
931926
} else {
@@ -954,7 +949,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
954949
c = reader.peek();
955950

956951
while(true){
957-
if (c == "\\"){
952+
if (c === "\\"){
958953
if (/^[^\r\n\f]$/.test(reader.peek(2))) {
959954
ident += this.readEscape(reader.read(), true);
960955
c = reader.peek();
@@ -1019,12 +1014,12 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
10191014
comment = first || "",
10201015
c = reader.read();
10211016

1022-
if (c == "*"){
1017+
if (c === "*"){
10231018
while(c){
10241019
comment += c;
10251020

10261021
//look for end of comment
1027-
if (comment.length > 2 && c == "*" && reader.peek() == "/"){
1022+
if (comment.length > 2 && c === "*" && reader.peek() === "/"){
10281023
comment += reader.read();
10291024
break;
10301025
}

0 commit comments

Comments
 (0)