Browse Source

fix(compat): satisfy require-await on the adapters' fromCanonical

Both adapters mark fromCanonical async deliberately: it converts a malformed
source into a rejection rather than a synchronous throw that would bypass a
caller's .catch(). The keyword is load-bearing, so the rule's assumption that
async-without-await is an accident does not hold — suppressed with the reason
rather than dropping async and breaking the documented contract.

Caught by CI, not locally: the compatibility-layer job runs build + test +
lint, and only build and test had been run before pushing.
darrenhinde 4 weeks ago
parent
commit
13b159a759

+ 3 - 0
packages/compatibility-layer/src/adapters/ClaudeAdapter.ts

@@ -75,6 +75,9 @@ export class ClaudeAdapter extends BaseAdapter {
    * @returns the emitted path, its exact bytes, and one warning per semantic actually lost
    * @throws {Error} if the source does not parse against {@link CanonicalAgentSchema}
    */
+  // The `async` carries the rejection semantics documented above. It is load-bearing, not an
+  // accidental keyword, so require-await's assumption does not hold here.
+  // eslint-disable-next-line @typescript-eslint/require-await
   async fromCanonical(source: string): Promise<ClaudeEmission> {
     const parsed = CanonicalAgentSchema.safeParse(structuredClone(matter(source).data));
 

+ 3 - 0
packages/compatibility-layer/src/adapters/OpenCodeAdapter.ts

@@ -304,6 +304,9 @@ export class OpenCodeAdapter extends BaseAdapter {
    * @throws {OpenCodeEmitError} when the source is malformed, carries no `oac:` block, or when
    * the emitted result would not round-trip its permissions.
    */
+  // `async` turns a malformed source into a rejection rather than a synchronous throw past
+  // the caller's .catch(), so require-await's assumption does not hold here.
+  // eslint-disable-next-line @typescript-eslint/require-await
   async fromCanonical(
     source: string,
     options: FromCanonicalOptions = {}