Skip to content

Commit c03c041

Browse files
authored
Merge branch 'master' into greenkeeper/eslint-6.0.0
2 parents e1141c1 + 25e60d6 commit c03c041

File tree

4 files changed

+74
-6
lines changed

4 files changed

+74
-6
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rules:
1919
# no-console: [ 2, { allow: [ warn, error ] } ]
2020
no-console: 0
2121
block-scoped-var: 2
22-
complexity: [ 2, 15 ]
22+
complexity: [ 2, 18 ]
2323
curly: [ 2, multi-or-nest, consistent ]
2424
dot-location: [ 2, property ]
2525
dot-notation: 2

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22
node_js:
3-
- "7"
43
- "8"
5-
- "9"
64
- "10"
5+
- "11"
6+
- "12"
77
after_script:
88
- coveralls < coverage/lcov.info

keywords/uniqueItemProperties.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function defFunc(ajv) {
1616
if (scalar[k]) {
1717
var hash = {};
1818
for (i = data.length; i--;) {
19-
if (typeof data[i] != 'object') continue;
19+
if (!data[i] || typeof data[i] != 'object') continue;
2020
var prop = data[i][key];
2121
if (prop && typeof prop == 'object') continue;
2222
if (typeof prop == 'string') prop = '"' + prop;
@@ -25,9 +25,9 @@ module.exports = function defFunc(ajv) {
2525
}
2626
} else {
2727
for (i = data.length; i--;) {
28-
if (typeof data[i] != 'object') continue;
28+
if (!data[i] || typeof data[i] != 'object') continue;
2929
for (var j = i; j--;) {
30-
if (typeof data[j] == 'object' && equal(data[i][key], data[j][key]))
30+
if (data[j] && typeof data[j] == 'object' && equal(data[i][key], data[j][key]))
3131
return false;
3232
}
3333
}

spec/tests/uniqueItemProperties.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,73 @@
395395
"valid": false
396396
}
397397
]
398+
},
399+
{
400+
"description": "uniqueItemProperties keyword with null item(s)",
401+
"schema": {
402+
"type": "array",
403+
"uniqueItemProperties": ["id"],
404+
"items": {
405+
"properties": {
406+
"id": {"type": "integer"}
407+
}
408+
}
409+
},
410+
"tests": [
411+
{
412+
"description": "with all unique ids and null items is valid",
413+
"data": [
414+
{ "id": 1 },
415+
{ "id": 2 },
416+
null,
417+
null
418+
],
419+
"valid": true
420+
},
421+
{
422+
"description": "with non-unique ids and null item is invalid",
423+
"data": [
424+
{ "id": 1 },
425+
{ "id": 1 },
426+
null,
427+
null
428+
],
429+
"valid": false
430+
}
431+
]
432+
},
433+
{
434+
"description": "uniqueItemProperties keyword with null item(s) and object keys",
435+
"schema": {
436+
"type": "array",
437+
"uniqueItemProperties": ["id"],
438+
"items": {
439+
"properties": {
440+
"id": {"type": "object"}
441+
}
442+
}
443+
},
444+
"tests": [
445+
{
446+
"description": "with all unique ids and null items is valid",
447+
"data": [
448+
{ "id": {"_id": 1} },
449+
{ "id": {"_id": 2} },
450+
null,
451+
null
452+
],
453+
"valid": true
454+
},
455+
{
456+
"description": "with non-unique ids and null item is invalid",
457+
"data": [
458+
{ "id": {"_id": 1} },
459+
{ "id": {"_id": 1} },
460+
null,
461+
null
462+
],
463+
"valid": false
464+
}
465+
]
398466
}
399467
]

0 commit comments

Comments
 (0)