fix(lint): drop async on methods with no await expression

ObsidianReviewBot's last scan (commit 4423052f, 2026-05-09) flagged
three `require-await` violations. The bodies of all three are fully
synchronous — promoting them to sync is the correct fix and removes
the false-positive shape for the marketplace scanner.

- main.ts#reinitializeServices: instantiates services synchronously
  inside try/catch blocks. Drop `async`/`Promise<void>`; drop the
  unnecessary `await` at the lone call site in the settings-saved
  callback.
- claudeService.ts#afterMessage: walks message content and writes
  to the editor via `replaceRange` — both sync. Drop `async`; drop
  the `await` at the two call sites in the Claude streaming flow.
- perplexityService.ts#processStreamingMetadata: post-processes the
  streaming response (think blocks, image placement, search-result
  footer). All operations are sync editor mutations and string
  processing. Drop `async`; drop the `await` at the lone call site.

`pnpm build` passes (eslint clean + tsc + esbuild). Local lint was
already clean against the obsidianmd recommended config — the bot
enforces `@typescript-eslint/require-await: "error"` while the
recommended config disables it, hence the divergence.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
mpstaton 2026-05-10 23:06:27 -05:00
parent 577bae753f
commit 2fa52794ec
3 changed files with 9 additions and 9 deletions

View file

@ -502,7 +502,7 @@ export default class PerplexedPlugin extends Plugin {
id: 'reinitialize-services',
name: 'Reinitialize provider services',
callback: async () => {
await this.reinitializeServices();
this.reinitializeServices();
}
});
@ -1011,7 +1011,7 @@ export default class PerplexedPlugin extends Plugin {
}
}
private async reinitializeServices(): Promise<void> {
private reinitializeServices(): void {
try {
console.debug('Perplexed Plugin: Reinitializing services...');
new Notice('Reinitializing perplexed services...');

View file

@ -141,7 +141,7 @@ export class ClaudeService {
});
const finalMessage = await stream.finalMessage();
await this.afterMessage(finalMessage, editor, headerText);
this.afterMessage(finalMessage, editor, headerText);
}
private async handleNonStreamingResponse(
@ -165,14 +165,14 @@ export class ClaudeService {
editor.replaceRange(text, responseCursor);
}
await this.afterMessage(finalMessage, editor, headerText);
this.afterMessage(finalMessage, editor, headerText);
}
private async afterMessage(
private afterMessage(
message: Anthropic.Messages.Message,
editor: Editor,
headerText: string
): Promise<void> {
): void {
const citations = this.extractWebCitations(message);
if (citations.length > 0) {
this.addCitations(editor, citations);

View file

@ -731,7 +731,7 @@ export class PerplexityService {
// Process final metadata (citations, images) after streaming is complete
if (finalResponseData) {
console.debug(`📝 Processing final response data [${requestId || 'unknown'}]:`, finalResponseData);
await this.processStreamingMetadata(finalResponseData, editor, headerText);
this.processStreamingMetadata(finalResponseData, editor, headerText);
}
// Add final separator at the very end of the document
@ -754,11 +754,11 @@ export class PerplexityService {
}
}
private async processStreamingMetadata(
private processStreamingMetadata(
finalResponseData: PerplexityStreamChunk,
editor: Editor,
headerText?: string
): Promise<void> {
): void {
console.debug('🔍 Processing streaming metadata');
console.debug('📊 Response data keys:', Object.keys(finalResponseData || {}));
if (finalResponseData.images) {