Skip to content

Commit 9d92020

Browse files
committed
fixup! Fix rig-package test failure caused by x-tsdoc-release-tag custom keyword in strict mode AJV.
1 parent 710d695 commit 9d92020

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

libraries/rig-package/src/RigConfig.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,12 @@ export class RigConfig implements IRigConfig {
258258
public static get jsonSchemaObject(): object {
259259
if (RigConfig._jsonSchemaObject === undefined) {
260260
const jsonSchemaContent: string = fs.readFileSync(RigConfig.jsonSchemaPath).toString();
261-
RigConfig._jsonSchemaObject = JSON.parse(jsonSchemaContent);
261+
// Remove nonstandard fields that are not part of the JSON Schema specification
262+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
263+
const { 'x-tsdoc-release-tag': _, ...schemaObject } = JSON.parse(jsonSchemaContent);
264+
RigConfig._jsonSchemaObject = schemaObject;
262265
}
266+
263267
return RigConfig._jsonSchemaObject!;
264268
}
265269

@@ -500,6 +504,7 @@ export class RigConfig implements IRigConfig {
500504
throw new Error(`Unsupported field ${JSON.stringify(key)}`);
501505
}
502506
}
507+
503508
if (!json.rigPackageName) {
504509
throw new Error('Missing required field "rigPackageName"');
505510
}

libraries/rig-package/src/test/RigConfig.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,12 @@ describe(RigConfig.name, () => {
191191
it('validates a rig.json file using the schema', () => {
192192
const rigConfigFilePath: string = path.join(testProjectFolder, 'config', 'rig.json');
193193

194-
// Remove fields that AJV strict mode doesn't recognize
195-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
196-
const { 'x-tsdoc-release-tag': _releaseTag, ...schemaObject } = RigConfig.jsonSchemaObject as Record<
197-
string,
198-
unknown
199-
>;
200-
201194
const ajv = new Ajv({
202195
verbose: true
203196
});
204197

205198
// Compile our schema
206-
const validateRigFile: ValidateFunction = ajv.compile(schemaObject);
199+
const validateRigFile: ValidateFunction = ajv.compile(RigConfig.jsonSchemaObject);
207200

208201
// Load the rig.json file
209202
const rigConfigFileContent: string = fs.readFileSync(rigConfigFilePath).toString();

0 commit comments

Comments
 (0)