Skip to content

Commit 6cbb389

Browse files
committed
Fix lint and string interpolation issues.
1 parent a5308ec commit 6cbb389

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

lib/compact.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,12 @@ api.compact = async ({
521521
}
522522
key = expandedItem['@language'];
523523
} else if(container.includes('@index')) {
524-
const indexKey = _getContextValue(activeCtx, itemActiveProperty, '@index') || '@index';
525-
const containerKey = api.compactIri({activeCtx, iri: indexKey, vocab: true});
524+
const indexKey = _getContextValue(
525+
activeCtx, itemActiveProperty, '@index') || '@index';
526+
const containerKey = api.compactIri(
527+
{activeCtx, iri: indexKey, vocab: true});
526528
if(indexKey === '@index') {
527-
key = expandedItem['@index'];
529+
key = expandedItem['@index'];
528530
delete compactedItem[containerKey];
529531
} else {
530532
let others;
@@ -572,7 +574,8 @@ api.compact = async ({
572574

573575
// If compactedItem contains a single entry
574576
// whose key maps to @id, recompact without @type
575-
if(Object.keys(compactedItem).length === 1 && '@id' in expandedItem) {
577+
if(Object.keys(compactedItem).length === 1 &&
578+
'@id' in expandedItem) {
576579
compactedItem = await api.compact({
577580
activeCtx,
578581
activeProperty: itemActiveProperty,

lib/context.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ api.createTermDefinition = (
569569
// type mapping must be either @id or @vocab
570570
if(!['@id', '@vocab'].includes(mapping['@type'])) {
571571
throw new JsonLdError(
572-
'Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.',
572+
'Invalid JSON-LD syntax; container: @type requires @type to be ' +
573+
'@id or @vocab.',
573574
'jsonld.SyntaxError',
574575
{code: 'invalid type mapping', context: localCtx});
575576
}
@@ -611,17 +612,19 @@ api.createTermDefinition = (
611612

612613
// property indexing
613614
if('@index' in value) {
614-
if (!('@container' in value) || !mapping['@container'].includes('@index')) {
615+
if(!('@container' in value) || !mapping['@container'].includes('@index')) {
615616
throw new JsonLdError(
616-
'Invalid JSON-LD syntax; @index without @index in @container: ${value["@index"]} on term ${term}.', 'jsonld.SyntaxError',
617+
'Invalid JSON-LD syntax; @index without @index in @container: ' +
618+
`"${value['@index']}" on term "${term}".`, 'jsonld.SyntaxError',
617619
{code: 'invalid term definition', context: localCtx});
618620
}
619-
if (!_isString(value['@index']) || value['@index'].indexOf('@') === 0) {
621+
if(!_isString(value['@index']) || value['@index'].indexOf('@') === 0) {
620622
throw new JsonLdError(
621-
'Invalid JSON-LD syntax; "@index must expand to an IRI: ${value["@index"]} on term ${term}.', 'jsonld.SyntaxError',
623+
'Invalid JSON-LD syntax; @index must expand to an IRI: ' +
624+
`"${value['@index']}" on term "${term}".`, 'jsonld.SyntaxError',
622625
{code: 'invalid term definition', context: localCtx});
623626
}
624-
mapping['@index'] = value['@index']
627+
mapping['@index'] = value['@index'];
625628
}
626629

627630
// scoped contexts

lib/expand.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ async function _expandObject({
621621
value,
622622
expansionMap,
623623
asGraph,
624-
indexKey: indexKey,
624+
indexKey,
625625
propertyIndex
626626
});
627627
} else if(container.includes('@id') && _isObject(value)) {
@@ -932,9 +932,10 @@ async function _expandIndexMap(
932932
let expandedKey;
933933
if(propertyIndex) {
934934
if(key === '@none') {
935-
expandedKey = '@none'
935+
expandedKey = '@none';
936936
} else {
937-
expandedKey =_expandValue({activeCtx, activeProperty: indexKey, value: key, options});
937+
expandedKey = _expandValue(
938+
{activeCtx, activeProperty: indexKey, value: key, options});
938939
}
939940
} else {
940941
expandedKey = _expandIri(activeCtx, key, {vocab: true}, options);
@@ -960,13 +961,16 @@ async function _expandIndexMap(
960961
} else {
961962
item['@type'] = [key];
962963
}
963-
} else if(_isValue(item) && !['@language', '@type', '@index'].includes(indexKey)) {
964+
} else if(_isValue(item) &&
965+
!['@language', '@type', '@index'].includes(indexKey)) {
964966
throw new JsonLdError(
965-
'Invalid JSON-LD syntax; Attempt to add illegal key to value object: ${indexKey}.',
967+
'Invalid JSON-LD syntax; Attempt to add illegal key to value ' +
968+
`object: "${indexKey}".`,
966969
'jsonld.SyntaxError',
967970
{code: 'invalid value object', value: item});
968971
} else if(propertyIndex) {
969-
// index is a property to be expanded, and values interpreted for that property
972+
// index is a property to be expanded, and values interpreted for that
973+
// property
970974
if(expandedKey !== '@none') {
971975
// expand key as a value
972976
_addValue(item, propertyIndex, expandedKey, {

lib/util.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ api.hasValue = (subject, property, value) => {
234234
* an array (lists) (default: false).
235235
* [allowDuplicate] true to allow duplicates, false not to (uses a
236236
* simple shallow comparison of subject ID or value) (default: true).
237-
* [prependValue] false to prepend value to any existing values. (default: false)
237+
* [prependValue] false to prepend value to any existing values.
238+
* (default: false)
238239
*/
239240
api.addValue = (subject, property, value, options) => {
240241
options = options || {};
@@ -279,7 +280,7 @@ api.addValue = (subject, property, value, options) => {
279280
// add new value
280281
if(!hasValue) {
281282
if(options.prependValue) {
282-
subject[property].unshift(value)
283+
subject[property].unshift(value);
283284
} else {
284285
subject[property].push(value);
285286
}

0 commit comments

Comments
 (0)