diff --git a/packages/resource/src/json-resource.js b/packages/resource/src/json-resource.js index 3df1b06..76efb90 100644 --- a/packages/resource/src/json-resource.js +++ b/packages/resource/src/json-resource.js @@ -10,20 +10,26 @@ export default class JsonResource extends Resource { } static async extendJson(json) { - if ('string' === typeof json.extends) { - // eslint-disable-next-line no-param-reassign - json.extends = await this.read(json.extends); - } - return this.mergeJson(json); + return this.mergeJson( + 'string' === typeof json.extends + ? { + ...json, + extends: await this.read(json.extends), + } + : json, + ); } static async load(json = {}) { const resource = new this(); - if ('string' === typeof json.extends) { - // eslint-disable-next-line no-param-reassign - json.uri = json.extends; - } - await resource.load(await this.extendJson(json)); + await resource.load(await this.extendJson( + 'string' === typeof json.extends + ? { + ...json, + uri: json.extends, + } + : json, + )); return resource; }