async function assertSchemaHasCorrectMetadata(
  /** @type {SchemaFile} */ schema,
) {
  const schemasWithDollarlessId = [
    'http://json-schema.org/draft-03/schema#',
    'http://json-schema.org/draft-04/schema#',
  ]

  if (schemasWithDollarlessId.includes(schema.json.$schema)) {
    if (schema.json.$id) {
      printErrorAndExit(new Error(), [
        `Expected to find correct metadata on schema file "./${schema.path}"`,
        `Bad property of '$id'; expected 'id' for this schema version`,
      ])
    }

    if (schema.json.id !== `https://json.schemastore.org/${schema.name}`) {
      printErrorAndExit(new Error(), [
        `Expected to find correct metadata on schema file "./${schema.path}"`,
        `Incorrect property 'id' for schema "./${path.join(SchemaDir, schema.name)}"`,
        `Expected value of "https://json.schemastore.org/${schema.name}"`,
        `Found value of "${schema.json.id}"`,
      ])
    }
  } else {
    if (schema.json.id) {
      printErrorAndExit(new Error(), [
        `Expected to find correct metadata on schema file "./${schema.path}"`,
        `Bad property of 'id'; expected '$id' for this schema version`,
      ])
    }

    if (schema.json.$id !== `https://json.schemastore.org/${schema.name}`) {
      printErrorAndExit(new Error(), [
        `Expected to find correct metadata on schema file "./${schema.path}"`,
        `Incorrect property '$id' for schema "./${path.join(SchemaDir, schema.name)}"`,
        `Expected value of "https://json.schemastore.org/${schema.name}"`,
        `Found value of "${schema.json.$id}"`,
      ])
    }
  }
}
Old JSON Schema specification versions use the "id" key for unique
identifiers, rather than "$id". See for details:
https://json-schema.org/understanding-json-schema/basics.html#declaring-a-unique-identifier