mirror of
https://github.com/lossless-group/perplexed-plugin.git
synced 2026-07-22 06:49:50 +00:00
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:
parent
577bae753f
commit
2fa52794ec
3 changed files with 9 additions and 9 deletions
4
main.ts
4
main.ts
|
|
@ -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...');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue