@@ -127,7 +127,7 @@ exports.beautify = function(session) {
127
127
}
128
128
129
129
// line break before }
130
- if ( ! inTag && ! rowsToAdd && token . type === "paren.rparen" && token . value . substr ( 0 , 1 ) === "}" ) {
130
+ if ( ! inTag && ! rowsToAdd && token . type == "paren.rparen" && token . value . substr ( 0 , 1 ) === "}" ) {
131
131
rowsToAdd ++ ;
132
132
}
133
133
@@ -153,7 +153,7 @@ exports.beautify = function(session) {
153
153
154
154
if ( value ) {
155
155
// whitespace
156
- if ( token . type === "keyword" && value . match ( / ^ ( i f | e l s e | e l s e i f | f o r | f o r e a c h | w h i l e | s w i t c h ) $ / ) ) {
156
+ if ( token . type == "keyword" && value . match ( / ^ ( i f | e l s e | e l s e i f | f o r | f o r e a c h | w h i l e | s w i t c h ) $ / ) ) {
157
157
parents [ depth ] = value ;
158
158
159
159
trimNext ( ) ;
@@ -167,7 +167,7 @@ exports.beautify = function(session) {
167
167
}
168
168
}
169
169
// trim value after opening paren
170
- } else if ( token . type === "paren.lparen" ) {
170
+ } else if ( token . type == "paren.lparen" ) {
171
171
trimNext ( ) ;
172
172
173
173
// whitespace after {
@@ -194,7 +194,7 @@ exports.beautify = function(session) {
194
194
}
195
195
}
196
196
// remove space before closing paren
197
- } else if ( token . type === "paren.rparen" ) {
197
+ } else if ( token . type == "paren.rparen" ) {
198
198
unindent = 1 ;
199
199
200
200
// ensure curly brace is preceeded by whitespace
@@ -232,21 +232,21 @@ exports.beautify = function(session) {
232
232
233
233
trimLine ( ) ;
234
234
// add spaces around conditional operators
235
- } else if ( ( token . type === "keyword.operator" || token . type = == "keyword" ) && value . match ( / ^ ( = | = = | = = = | ! = | ! = = | & & | \| \| | a n d | o r | x o r | \+ = | .= | > | > = | < | < = | = > ) $ / ) ) {
235
+ } else if ( ( token . type == "keyword.operator" || token . type == "keyword" ) && value . match ( / ^ ( = | = = | = = = | ! = | ! = = | & & | \| \| | a n d | o r | x o r | \+ = | .= | > | > = | < | < = | = > ) $ / ) ) {
236
236
trimCode ( ) ;
237
237
trimNext ( ) ;
238
238
spaceBefore = true ;
239
239
spaceAfter = true ;
240
240
// remove space before semicolon
241
- } else if ( token . type === "punctuation.operator" && value === ';' ) {
241
+ } else if ( token . type == "punctuation.operator" && value === ';' ) {
242
242
trimCode ( ) ;
243
243
trimNext ( ) ;
244
244
spaceAfter = true ;
245
245
246
246
if ( inCSS )
247
247
rowsToAdd ++ ;
248
248
// space after colon or comma
249
- } else if ( token . type === "punctuation.operator" && value . match ( / ^ ( : | , ) $ / ) ) {
249
+ } else if ( token . type == "punctuation.operator" && value . match ( / ^ ( : | , ) $ / ) ) {
250
250
trimCode ( ) ;
251
251
trimNext ( ) ;
252
252
@@ -258,7 +258,7 @@ exports.beautify = function(session) {
258
258
breakBefore = false ;
259
259
}
260
260
// ensure space before php closing tag
261
- } else if ( token . type === "support.php_tag" && value === "?>" && ! breakBefore ) {
261
+ } else if ( token . type == "support.php_tag" && value === "?>" && ! breakBefore ) {
262
262
trimCode ( ) ;
263
263
spaceBefore = true ;
264
264
// remove excess space before HTML attribute
@@ -273,7 +273,7 @@ exports.beautify = function(session) {
273
273
trimLine ( ) ;
274
274
if ( value === "/>" )
275
275
spaceBefore = true ;
276
- } else if ( token . type === "keyword" && value . match ( / ^ ( c a s e | d e f a u l t ) $ / ) ) {
276
+ } else if ( token . type == "keyword" && value . match ( / ^ ( c a s e | d e f a u l t ) $ / ) ) {
277
277
if ( caseBody )
278
278
unindent = 1 ;
279
279
}
@@ -306,33 +306,33 @@ exports.beautify = function(session) {
306
306
code += tabString ;
307
307
}
308
308
309
- if ( token . type === "keyword" && value . match ( / ^ ( c a s e | d e f a u l t ) $ / ) ) {
309
+ if ( token . type == "keyword" && value . match ( / ^ ( c a s e | d e f a u l t ) $ / ) ) {
310
310
if ( caseBody === false ) {
311
311
parents [ depth ] = value ;
312
312
depth ++ ;
313
313
caseBody = true ;
314
314
}
315
- } else if ( token . type === "keyword" && value . match ( / ^ ( b r e a k ) $ / ) ) {
315
+ } else if ( token . type == "keyword" && value . match ( / ^ ( b r e a k ) $ / ) ) {
316
316
if ( parents [ depth - 1 ] && parents [ depth - 1 ] . match ( / ^ ( c a s e | d e f a u l t ) $ / ) ) {
317
317
depth -- ;
318
318
caseBody = false ;
319
319
}
320
320
}
321
321
322
322
// indent one line after if or else
323
- if ( token . type === "paren.lparen" ) {
323
+ if ( token . type == "paren.lparen" ) {
324
324
roundDepth += ( value . match ( / \( / g) || [ ] ) . length ;
325
325
curlyDepth += ( value . match ( / \{ / g) || [ ] ) . length ;
326
326
depth += value . length ;
327
327
}
328
328
329
- if ( token . type === "keyword" && value . match ( / ^ ( i f | e l s e | e l s e i f | f o r | w h i l e ) $ / ) ) {
329
+ if ( token . type == "keyword" && value . match ( / ^ ( i f | e l s e | e l s e i f | f o r | w h i l e ) $ / ) ) {
330
330
indentNextLine = true ;
331
331
roundDepth = 0 ;
332
332
} else if ( ! roundDepth && value . trim ( ) && token . type !== "comment" )
333
333
indentNextLine = false ;
334
334
335
- if ( token . type === "paren.rparen" ) {
335
+ if ( token . type == "paren.rparen" ) {
336
336
roundDepth -= ( value . match ( / \) / g) || [ ] ) . length ;
337
337
curlyDepth -= ( value . match ( / \} / g) || [ ] ) . length ;
338
338
0 commit comments