Skip to content

Commit 1daffce

Browse files
committed
Cleanup for jshint
1 parent 7528714 commit 1daffce

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

lib/parse.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*jshint -W030 */
12
var tagRE = /<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>/g;
23
var parseTag = require('./parse-tag');
34
// re-used obj for quick lookups of components
@@ -20,15 +21,15 @@ module.exports = function parse(html, options) {
2021
} else {
2122
inComponent = false;
2223
}
23-
}
24+
}
2425
var isOpen = tag.charAt(1) !== '/';
2526
var start = index + tag.length;
2627
var nextChar = html.charAt(start);
2728
var parent;
28-
29+
2930
if (isOpen) {
3031
level++;
31-
32+
3233
current = parseTag(tag);
3334
if (current.type === 'tag' && options.components[current.name]) {
3435
current.type = 'component';
@@ -45,7 +46,9 @@ module.exports = function parse(html, options) {
4546
byTag[current.tagName] = current;
4647

4748
// if we're at root, push new base node
48-
if (level === 0) result.push(current);
49+
if (level === 0) {
50+
result.push(current);
51+
}
4952

5053
parent = arr[level - 1];
5154

@@ -66,7 +69,7 @@ module.exports = function parse(html, options) {
6669
});
6770
}
6871
}
69-
});
72+
});
7073

7174
return result;
7275
};

test/parse.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
/* global console */
12
var test = require('tape');
23
var HTML = require('../index');
34

45

56
test('parse', function (t) {
67
var html = '<div class="oh"><p></p></div>';
7-
var parsed = HTML.parse(html);
8+
var parsed = HTML.parse(html);
89
t.deepEqual(parsed, [{
910
type: 'tag',
1011
name: 'div',
@@ -278,12 +279,13 @@ test('simple speed sanity check', function (t) {
278279
var waitLoopSize = 10000000;
279280
var groups = i / groupSize;
280281
var html = '<html><head><title>Some page</title></head><body class="hey there"><img src="someURL"><h3>Hey, we need content</h3><br></body></html>';
281-
282+
282283
var parse = HTML.parse;
283284
var times = [];
284285
var count;
285286
var waitCount;
286287
var total = 0;
288+
var start, stepAverage;
287289

288290
console.log('running ' + i + ' iterations...');
289291

@@ -296,10 +298,10 @@ test('simple speed sanity check', function (t) {
296298
parse(html);
297299
}
298300
var diff = Date.now() - start;
299-
var average = diff/groupSize
300-
console.log('group ' + (groups - (i / groupSize)) + ': ' + average);
301-
times.push(average);
302-
total += average;
301+
stepAverage = diff/groupSize;
302+
console.log('group ' + (groups - (i / groupSize)) + ': ' + stepAverage);
303+
times.push(stepAverage);
304+
total += stepAverage;
303305
waitCount = waitLoopSize;
304306
// forcing a bit of a pause between tests
305307
while(waitCount--) {}
@@ -308,8 +310,8 @@ test('simple speed sanity check', function (t) {
308310
}
309311

310312
// trim off first
311-
// it's always a slower outlier
312-
// with higher variability that
313+
// it's always a slower outlier
314+
// with higher variability that
313315
// makes it harder to find differences
314316
times.shift();
315317

@@ -320,6 +322,6 @@ test('simple speed sanity check', function (t) {
320322
console.log('max', max);
321323
console.log('min', min);
322324
console.log('avg', average);
323-
325+
324326
t.end();
325327
});

0 commit comments

Comments
 (0)