Skip to content

Commit e934afa

Browse files
committed
Update xo
1 parent bc0b312 commit e934afa

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

lib/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ module.exports = wrapper;
1818

1919
/* Schema. */
2020
var NODES = {
21-
'root': {children: all},
22-
'element': {
21+
root: {children: all},
22+
element: {
2323
tagName: handleTagName,
2424
properties: handleProperties,
2525
children: all
2626
},
27-
'text': {value: handleValue},
27+
text: {value: handleValue},
2828
'*': {
2929
data: allow,
3030
position: allow
@@ -95,7 +95,7 @@ function one(schema, node, stack) {
9595

9696
/* Set the non-safe value. */
9797
replacement[key] = node[key];
98-
} else if (result != null) {
98+
} else if (result !== null && result !== undefined) {
9999
replacement[key] = result;
100100
}
101101
}
@@ -104,7 +104,7 @@ function one(schema, node, stack) {
104104
if (!replace) {
105105
if (
106106
!replacement.children ||
107-
!replacement.children.length ||
107+
replacement.children.length === 0 ||
108108
schema.strip.indexOf(replacement.tagName) !== -1
109109
) {
110110
return null;
@@ -186,7 +186,7 @@ function handleProperties(schema, properties, node, stack) {
186186
value = handlePropertyValue(schema, value, prop);
187187
}
188188

189-
if (value != null) {
189+
if (value !== null && value !== undefined) {
190190
result[prop] = value;
191191
}
192192
}
@@ -211,7 +211,7 @@ function handlePropertyValues(schema, values, prop) {
211211
while (++index < length) {
212212
value = handlePropertyValue(schema, values[index], prop);
213213

214-
if (value != null) {
214+
if (value !== null && value !== undefined) {
215215
result.push(value);
216216
}
217217
}
@@ -265,7 +265,7 @@ function handleProtocol(schema, value, prop) {
265265

266266
protocols = has(protocols, prop) ? protocols[prop].concat() : [];
267267

268-
if (!protocols.length) {
268+
if (protocols.length === 0) {
269269
return true;
270270
}
271271

@@ -336,7 +336,7 @@ function handleTagName(schema, tagName, node, stack) {
336336

337337
/* Some nodes can break out of their context if they
338338
* don’t have a certain ancestor. */
339-
if (ancestors.length) {
339+
if (ancestors.length !== 0) {
340340
length = ancestors.length + 1;
341341
index = -1;
342342

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"remark-preset-wooorm": "^1.0.0",
3434
"tape": "^4.0.0",
3535
"unist-builder": "^1.0.1",
36-
"xo": "^0.16.0"
36+
"xo": "^0.17.0"
3737
},
3838
"scripts": {
3939
"build-md": "remark . --quiet --frail",
@@ -55,13 +55,7 @@
5555
"space": true,
5656
"rules": {
5757
"no-negated-condition": "off",
58-
"guard-for-in": "off",
59-
"no-eq-null": "off",
60-
"eqeqeq": [
61-
2,
62-
"allow-null"
63-
],
64-
"max-lines": "off"
58+
"guard-for-in": "off"
6559
},
6660
"ignores": [
6761
"hast-util-sanitize.js"

test.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,17 @@ test('sanitize()', function (t) {
351351
st.test('href`', function (sst) {
352352
testAllURLs(sst, 'a', 'href', {
353353
valid: {
354-
'anchor': '#heading',
355-
'relative': '/file.html',
356-
'search': 'example.com?foo:bar',
357-
'hash': 'example.com#foo:bar',
354+
anchor: '#heading',
355+
relative: '/file.html',
356+
search: 'example.com?foo:bar',
357+
hash: 'example.com#foo:bar',
358358
'protocol-less': 'www.example.com',
359-
'mailto': 'mailto:foo@bar.com',
360-
'https': 'http://example.com',
361-
'http': 'http://example.com'
359+
mailto: 'mailto:foo@bar.com',
360+
https: 'http://example.com',
361+
http: 'http://example.com'
362362
},
363363
invalid: {
364-
'javascript': 'javascript:alert(1)',
364+
javascript: 'javascript:alert(1)',
365365
'Unicode LS/PS I': '\u2028javascript:alert(1)',
366366
'Unicode Whitespace (#1)': ' javascript:alert(1)',
367367
'Unicode Whitespace (#2)': ' javascript:alert(1)',
@@ -376,17 +376,17 @@ test('sanitize()', function (t) {
376376
st.test('`cite`', function (sst) {
377377
testAllURLs(sst, 'blockquote', 'cite', {
378378
valid: {
379-
'anchor': '#heading',
380-
'relative': '/file.html',
381-
'search': 'example.com?foo:bar',
382-
'hash': 'example.com#foo:bar',
379+
anchor: '#heading',
380+
relative: '/file.html',
381+
search: 'example.com?foo:bar',
382+
hash: 'example.com#foo:bar',
383383
'protocol-less': 'www.example.com',
384-
'https': 'http://example.com',
385-
'http': 'http://example.com'
384+
https: 'http://example.com',
385+
http: 'http://example.com'
386386
},
387387
invalid: {
388-
'mailto': 'mailto:foo@bar.com',
389-
'javascript': 'javascript:alert(1)',
388+
mailto: 'mailto:foo@bar.com',
389+
javascript: 'javascript:alert(1)',
390390
'Unicode LS/PS I': '\u2028javascript:alert(1)',
391391
'Unicode Whitespace (#1)': ' javascript:alert(1)',
392392
'Unicode Whitespace (#2)': ' javascript:alert(1)',
@@ -401,17 +401,17 @@ test('sanitize()', function (t) {
401401
st.test('`src`', function (sst) {
402402
testAllURLs(sst, 'img', 'src', {
403403
valid: {
404-
'anchor': '#heading',
405-
'relative': '/file.html',
406-
'search': 'example.com?foo:bar',
407-
'hash': 'example.com#foo:bar',
404+
anchor: '#heading',
405+
relative: '/file.html',
406+
search: 'example.com?foo:bar',
407+
hash: 'example.com#foo:bar',
408408
'protocol-less': 'www.example.com',
409-
'https': 'http://example.com',
410-
'http': 'http://example.com'
409+
https: 'http://example.com',
410+
http: 'http://example.com'
411411
},
412412
invalid: {
413-
'mailto': 'mailto:foo@bar.com',
414-
'javascript': 'javascript:alert(1)',
413+
mailto: 'mailto:foo@bar.com',
414+
javascript: 'javascript:alert(1)',
415415
'Unicode LS/PS I': '\u2028javascript:alert(1)',
416416
'Unicode Whitespace (#1)': ' javascript:alert(1)',
417417
'Unicode Whitespace (#2)': ' javascript:alert(1)',
@@ -426,17 +426,17 @@ test('sanitize()', function (t) {
426426
st.test('`longDesc`', function (sst) {
427427
testAllURLs(sst, 'img', 'longDesc', {
428428
valid: {
429-
'anchor': '#heading',
430-
'relative': '/file.html',
431-
'search': 'example.com?foo:bar',
432-
'hash': 'example.com#foo:bar',
429+
anchor: '#heading',
430+
relative: '/file.html',
431+
search: 'example.com?foo:bar',
432+
hash: 'example.com#foo:bar',
433433
'protocol-less': 'www.example.com',
434-
'https': 'http://example.com',
435-
'http': 'http://example.com'
434+
https: 'http://example.com',
435+
http: 'http://example.com'
436436
},
437437
invalid: {
438-
'mailto': 'mailto:foo@bar.com',
439-
'javascript': 'javascript:alert(1)',
438+
mailto: 'mailto:foo@bar.com',
439+
javascript: 'javascript:alert(1)',
440440
'Unicode LS/PS I': '\u2028javascript:alert(1)',
441441
'Unicode Whitespace (#1)': ' javascript:alert(1)',
442442
'Unicode Whitespace (#2)': ' javascript:alert(1)',

0 commit comments

Comments
 (0)