Update ESLint rules and resolve bot review feedback #8

Merged
AlexKucera merged 24 commits from obsidian-bot-review into master 2025-11-09 12:06:31 +01:00
Showing only changes of commit 003d6d105b - Show all commits
+3 -3
View File
@@ -9,7 +9,7 @@
* - Consistent error messaging and logging
* - Batch export result tracking and reporting
* - User-facing notices with appropriate durations
* - Support for different log levels (error, warn, info)
* - Support for different log levels (error, warn, debug)
* - Specialized handlers for different error types (dependency, processing, validation)
*/
@@ -43,7 +43,7 @@ export interface ExportError {
operation: string;
error: Error | string;
shouldShowNotice?: boolean;
logLevel?: 'error' | 'warn' | 'info';
logLevel?: 'error' | 'warn' | 'debug';
}
/**
@@ -180,7 +180,7 @@ export class ExportErrorHandler {
case 'warn':
console.warn(`${operation}:`, error);
coderabbitai[bot] commented 2025-11-05 13:54:26 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟡 Minor

Align logLevel parameter with actual logging behavior.

The logLevel parameter accepts 'info' per the interface definition (line 46), but the implementation now uses console.debug() instead of console.info(). This creates a semantic mismatch where callers specify 'info' but receive debug-level logging.

Consider one of these options:

  1. Revert to console.info() if info-level logging is the intended behavior, OR
  2. Update the interface to accept 'debug' instead of 'info' to match the implementation

Option 1: Revert to console.info

 case 'info':
-	console.debug(`${operation}:`, error);
+	console.info(`${operation}:`, error);
 	break;

Option 2: Update interface and documentation

 export interface ExportError {
 	fileName?: string;
 	operation: string;
 	error: Error | string;
 	shouldShowNotice?: boolean;
-	logLevel?: 'error' | 'warn' | 'info';
+	logLevel?: 'error' | 'warn' | 'debug';
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

			case 'info':
				console.info(`${operation}:`, error);
				break;
🤖 Prompt for AI Agents
In src/core/ExportErrorHandler.ts around lines 183 to 185, the method accepts a
logLevel of 'info' per the interface but calls console.debug(), creating a
mismatch; either change the implementation to call console.info() to match the
declared 'info' logLevel, or update the interface and any docs to accept 'debug'
(replace 'info' with 'debug' where the type/interface and comments mention it)
and ensure all callers using 'info' are updated to 'debug' or adjusted
accordingly.

✅ Addressed in commits f0daebc to c1c02ee

_⚠️ Potential issue_ | _🟡 Minor_ **Align logLevel parameter with actual logging behavior.** The `logLevel` parameter accepts `'info'` per the interface definition (line 46), but the implementation now uses `console.debug()` instead of `console.info()`. This creates a semantic mismatch where callers specify `'info'` but receive debug-level logging. Consider one of these options: 1. **Revert to `console.info()`** if info-level logging is the intended behavior, OR 2. **Update the interface** to accept `'debug'` instead of `'info'` to match the implementation **Option 1: Revert to console.info** ```diff case 'info': - console.debug(`${operation}:`, error); + console.info(`${operation}:`, error); break; ``` **Option 2: Update interface and documentation** ```diff export interface ExportError { fileName?: string; operation: string; error: Error | string; shouldShowNotice?: boolean; - logLevel?: 'error' | 'warn' | 'info'; + logLevel?: 'error' | 'warn' | 'debug'; } ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion case 'info': console.info(`${operation}:`, error); break; ``` </details> <!-- suggestion_end --> <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/core/ExportErrorHandler.ts around lines 183 to 185, the method accepts a logLevel of 'info' per the interface but calls console.debug(), creating a mismatch; either change the implementation to call console.info() to match the declared 'info' logLevel, or update the interface and any docs to accept 'debug' (replace 'info' with 'debug' where the type/interface and comments mention it) and ensure all callers using 'info' are updated to 'debug' or adjusted accordingly. ``` </details> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commits f0daebc to c1c02ee <!-- This is an auto-generated comment by CodeRabbit -->
AlexKucera commented 2025-11-05 15:16:04 +01:00 (Migrated from github.com)
Review

@coderabbitai ObsidianReviewBot raised this issue:

Unexpected console statement. Only these console methods are allowed: warn, error, debug.

@coderabbitai ObsidianReviewBot raised this issue: > Unexpected console statement. Only these console methods are allowed: warn, error, debug.
coderabbitai[bot] commented 2025-11-05 15:17:37 +01:00 (Migrated from github.com)
Review
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any code using logLevel with 'info' value
rg -n "logLevel.*['\"]info['\"]" --type ts

Length of output: 72


🏁 Script executed:

#!/bin/bash
# Also search for the ExportError interface usage to find all places where logLevel might be specified
rg -n "ExportError|handleExportError" --type ts -C3

Length of output: 28847


@AlexKucera, thank you for clarifying! That makes sense—ObsidianReviewBot's restriction to only console.warn, console.error, and console.debug means we need to align the interface with the implementation.

Since no code in the codebase is currently using logLevel: 'info' (confirmed by the search), you only need to update:

  1. Line 46 - Update the ExportError interface:
logLevel?: 'error' | 'warn' | 'debug';
  1. Line 39 - Update the JSDoc comment above the interface:
 * @property logLevel - Logging severity level (default: 'error')

(This is fine as-is, but you could optionally clarify it accepts 'error' | 'warn' | 'debug')

  1. Line 165 in the example comment, change:
 *   logLevel: 'warn'

to remain as 'warn' (already correct), but the comment text that mentions "info" in the example doesn't exist, so you're good there.

The change from console.info() to console.debug() is the right approach given the ObsidianReviewBot constraint. Just update the interface definition to match! 🎯


🧬 Code Graph Analysis Results

tests/mocks/obsidian.ts

At lines 4-6: ``` export class Notice { constructor(message: string) {} } ```

src/core/constants.ts

At lines 122-128: ``` export const EXPORT_CONSTANTS = { DEFAULT_TIMEOUT: 120000, // 2 minutes NOTICE_DURATION: { SHORT: 5000, LONG: 12000 } } as const; ```

✏️ Learnings added
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 8
File: src/core/ExportErrorHandler.ts:183-185
Timestamp: 2025-11-05T14:17:36.572Z
Learning: In Obsidian plugin development, ObsidianReviewBot (a linting tool for Obsidian plugins) only allows the following console methods: console.warn(), console.error(), and console.debug(). The console.info() and console.log() methods are forbidden. When implementing logging functionality, use console.debug() for informational/debug messages instead of console.info().

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

<details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ``` #!/bin/bash # Search for any code using logLevel with 'info' value rg -n "logLevel.*['\"]info['\"]" --type ts ``` Length of output: 72 --- 🏁 Script executed: ``` #!/bin/bash # Also search for the ExportError interface usage to find all places where logLevel might be specified rg -n "ExportError|handleExportError" --type ts -C3 ``` Length of output: 28847 --- </details> @AlexKucera, thank you for clarifying! That makes sense—ObsidianReviewBot's restriction to only `console.warn`, `console.error`, and `console.debug` means we need to align the interface with the implementation. Since no code in the codebase is currently using `logLevel: 'info'` (confirmed by the search), you only need to update: 1. **Line 46** - Update the `ExportError` interface: ```typescript logLevel?: 'error' | 'warn' | 'debug'; ``` 2. **Line 39** - Update the JSDoc comment above the interface: ```typescript * @property logLevel - Logging severity level (default: 'error') ``` (This is fine as-is, but you could optionally clarify it accepts 'error' | 'warn' | 'debug') 3. **Line 165** in the example comment, change: ```typescript * logLevel: 'warn' ``` to remain as 'warn' (already correct), but the comment text that mentions "info" in the example doesn't exist, so you're good there. The change from `console.info()` to `console.debug()` is the right approach given the ObsidianReviewBot constraint. Just update the interface definition to match! 🎯 --- <details> <summary>🧬 Code Graph Analysis Results</summary> <filename>tests/__mocks__/obsidian.ts</filename> <snippet> At lines 4-6: ``` export class Notice { constructor(message: string) {} } ``` </snippet> <filename>src/core/constants.ts</filename> <snippet> At lines 122-128: ``` export const EXPORT_CONSTANTS = { DEFAULT_TIMEOUT: 120000, // 2 minutes NOTICE_DURATION: { SHORT: 5000, LONG: 12000 } } as const; ``` </snippet> </details> --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: AlexKucera Repo: AlexKucera/obsidian-typst-pdf-export PR: 8 File: src/core/ExportErrorHandler.ts:183-185 Timestamp: 2025-11-05T14:17:36.572Z Learning: In Obsidian plugin development, ObsidianReviewBot (a linting tool for Obsidian plugins) only allows the following console methods: console.warn(), console.error(), and console.debug(). The console.info() and console.log() methods are forbidden. When implementing logging functionality, use console.debug() for informational/debug messages instead of console.info(). ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> <!-- <agentComponentType>chat-answer</agentComponentType> --> <!-- <rawResChunk><answer><details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ``` #!/bin/bash # Search for any code using logLevel with 'info' value rg -n "logLevel.*['\"]info['\"]" --type ts ``` Length of output: 72 --- 🏁 Script executed: ``` #!/bin/bash # Also search for the ExportError interface usage to find all places where logLevel might be specified rg -n "ExportError|handleExportError" --type ts -C3 ``` Length of output: 28847 --- </details> @AlexKucera, thank you for clarifying! That makes sense—ObsidianReviewBot's restriction to only `console.warn`, `console.error`, and `console.debug` means we need to align the interface with the implementation. Since no code in the codebase is currently using `logLevel: 'info'` (confirmed by the search), you only need to update: 1. **Line 46** - Update the `ExportError` interface: ```typescript logLevel?: 'error' | 'warn' | 'debug'; ``` 2. **Line 39** - Update the JSDoc comment above the interface: ```typescript * @property logLevel - Logging severity level (default: 'error') ``` (This is fine as-is, but you could optionally clarify it accepts 'error' | 'warn' | 'debug') 3. **Line 165** in the example comment, change: ```typescript * logLevel: 'warn' ``` to remain as 'warn' (already correct), but the comment text that mentions "info" in the example doesn't exist, so you're good there. The change from `console.info()` to `console.debug()` is the right approach given the ObsidianReviewBot constraint. Just update the interface definition to match! 🎯 --- <details> <summary>🧬 Code Graph Analysis Results</summary> <filename>tests/__mocks__/obsidian.ts</filename> <snippet> At lines 4-6: ``` export class Notice { constructor(message: string) {} } ``` </snippet> <filename>src/core/constants.ts</filename> <snippet> At lines 122-128: ``` export const EXPORT_CONSTANTS = { DEFAULT_TIMEOUT: 120000, // 2 minutes NOTICE_DURATION: { SHORT: 5000, LONG: 12000 } } as const; ``` </snippet> </details> --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: AlexKucera Repo: AlexKucera/obsidian-typst-pdf-export PR: 8 File: src/core/ExportErrorHandler.ts:183-185 Timestamp: 2025-11-05T14:17:36.572Z Learning: In Obsidian plugin development, ObsidianReviewBot (a linting tool for Obsidian plugins) only allows the following console methods: console.warn(), console.error(), and console.debug(). The console.info() and console.log() methods are forbidden. When implementing logging functionality, use console.debug() for informational/debug messages instead of console.info(). ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> </answer></rawResChunk> --> <!-- This is an auto-generated reply by CodeRabbit -->
break;
case 'info':
case 'debug':
console.debug(`${operation}:`, error);
break;
}