From 53cd4edf9dfd080d0a8235ab47045b2299c60298 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Sat, 24 Oct 2026 16:15:06 +0200 Subject: [PATCH] fix: satisfy the obsidianmd console and settings-heading rules Drop the load/unload console.log calls, route the logger's informational messages to console.debug, and remove the redundant 'MetaEdit Settings' heading at the top of the settings tab. Encode both checks in the local ESLint guideline rules so they cannot regress. --- eslint.config.mjs | 10 +++++++++- src/Settings/metaEditSettingsTab.ts | 4 ---- src/logger/consoleErrorLogger.ts | 2 +- src/main.ts | 3 --- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 10beee2..f6ad5c7 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,7 +15,7 @@ const sharedGlobals = { }; // Obsidian developer-policy / guideline checks, expressed with core rules so we -// don't pull in eslint-plugin-obsidianmd's dependency tree for seven rules. Each +// don't pull in eslint-plugin-obsidianmd's dependency tree for nine rules. Each // entry mirrors the obsidianmd rule named in its message. Keep this scoped to // production plugin source: tests and harness code legitimately stub Obsidian // globals and should not inherit plugin-review restrictions. @@ -23,6 +23,7 @@ const sharedGlobals = { // `typeof globalThis` guards; none exist in the plugin source. const timerFunctions = ["setTimeout", "setInterval", "clearTimeout", "clearInterval", "requestAnimationFrame"]; const obsidianGuidelineRules = { + "no-console": ["error", { allow: ["debug", "warn", "error"] }], "no-restricted-globals": [ "error", ...timerFunctions.map((name) => ({ @@ -61,6 +62,13 @@ const obsidianGuidelineRules = { selector: "ClassDeclaration[superClass.name='PluginSettingTab'] CallExpression[callee.property.name='createEl'][arguments.0.value=/^h[1-6]$/]", message: "Use new Setting(containerEl).setName(...).setHeading() instead of HTML headings (obsidianmd/settings-tab/no-manual-html-headings).", }, + ...[ + "CallExpression[callee.property.name='setHeading'] > MemberExpression > CallExpression[callee.property.name='setName']", + "CallExpression[callee.property.name='setName'][callee.object.callee.property.name='setHeading']", + ].map((call) => ({ + selector: `ClassDeclaration[superClass.name='PluginSettingTab'] ${call} > Literal.arguments[value=/settings|options|${pluginNamePattern}/i]`, + message: "Don't put 'settings', 'options', or the plugin name in settings headings (obsidianmd/settings-tab/no-problematic-settings-headings).", + })), { selector: `CallExpression[callee.property.name='addCommand'] > ObjectExpression > Property[key.name='name'] > Literal.value[value=/${pluginNamePattern}/i]`, message: "Obsidian already prefixes command names with the plugin name (obsidianmd/commands/no-plugin-name-in-command-name).", diff --git a/src/Settings/metaEditSettingsTab.ts b/src/Settings/metaEditSettingsTab.ts index bfe7760..d7c507f 100644 --- a/src/Settings/metaEditSettingsTab.ts +++ b/src/Settings/metaEditSettingsTab.ts @@ -33,10 +33,6 @@ export class MetaEditSettingsTab extends PluginSettingTab { this.destroySvelteElements(); containerEl.empty(); - new Setting(containerEl) - .setName("MetaEdit Settings") - .setHeading(); - this.addProgressPropertiesSetting(containerEl); this.addAutoPropertiesSetting(containerEl); this.addEditMetaMenuSetting(containerEl); diff --git a/src/logger/consoleErrorLogger.ts b/src/logger/consoleErrorLogger.ts index 8174380..e81be48 100644 --- a/src/logger/consoleErrorLogger.ts +++ b/src/logger/consoleErrorLogger.ts @@ -23,7 +23,7 @@ export class ConsoleErrorLogger extends MetaEditLogger { const log = this.getMetaEditError(logMsg, ErrorLevel.Log); this.addMessageToErrorLog(log); - console.log(this.formatOutputString(log)); + console.debug(this.formatOutputString(log)); } private addMessageToErrorLog(error: MetaEditError): void { diff --git a/src/main.ts b/src/main.ts index aa9efbe..1325f9f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,8 +34,6 @@ export default class MetaEdit extends Plugin { private readonly settingsWriter = new SettingsWriter(() => this.saveData(this.settings)); async onload() { - console.log('Loading MetaEdit'); - this.controller = new MetaController(this.app, this); this.bulkEditor = new BulkMetadataEditor(this.app, this); @@ -100,7 +98,6 @@ export default class MetaEdit extends Plugin { } onunload() { - console.log('Unloading MetaEdit'); this.linkMenu.unregisterEvent(); }