Address issues flagged by Obsidian plugin review

- Raise minAppVersion to 1.4.0 to cover the APIs in use (getLeaf,
  createFolder, ExtraButtonComponent.setTooltip), fixes no-unsupported-api
- Type the loadData() result in loadSettings, fixes no-unsafe-assignment
- Make settings event callbacks synchronous and fire saves via void,
  fixes no-misused-promises
- Replace the builtin-modules dependency with node:module builtinModules
- Re-render only the skills sub-section instead of calling the deprecated
  PluginSettingTab.display() on each edit
This commit is contained in:
pdriggett 2026-06-18 05:48:00 -04:00
parent 0a53a6dc24
commit 802b73c161
5 changed files with 28 additions and 36 deletions

View file

@ -1,6 +1,6 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import { builtinModules } from "node:module";
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
@ -28,7 +28,8 @@ const context = await esbuild.context({
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins,
...builtinModules,
...builtinModules.map((m) => `node:${m}`),
],
format: "cjs",
target: "es2018",

42
main.ts
View file

@ -62,7 +62,9 @@ export default class PracticePlannerPlugin extends Plugin {
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
const data =
(await this.loadData()) as Partial<PracticePlannerSettings> | null;
this.settings = Object.assign({}, DEFAULT_SETTINGS, data);
}
async saveSettings() {
@ -238,9 +240,9 @@ class PracticePlannerSettingTab extends PluginSettingTab {
text
.setPlaceholder("Practice")
.setValue(this.plugin.settings.folderPath)
.onChange(async (value) => {
.onChange((value) => {
this.plugin.settings.folderPath = value || "Practice";
await this.plugin.saveSettings();
void this.plugin.saveSettings();
}),
);
@ -250,18 +252,22 @@ class PracticePlannerSettingTab extends PluginSettingTab {
"First day of the practice week. Weeks that cross into a new year are stored under the year they started.",
)
.addDropdown((dd) => {
DAY_NAMES.forEach((name, i) => dd.addOption(String(i), name));
DAY_NAMES.forEach((name, i) => {
dd.addOption(String(i), name);
});
dd.setValue(String(this.plugin.settings.weekStartDay));
dd.onChange(async (value) => {
dd.onChange((value) => {
this.plugin.settings.weekStartDay = Number(value) as DayIndex;
await this.plugin.saveSettings();
void this.plugin.saveSettings();
});
});
this.renderSkills(containerEl);
this.renderSkills(containerEl.createDiv());
}
private renderSkills(containerEl: HTMLElement): void {
containerEl.empty();
new Setting(containerEl)
.setName("Default skills")
.setDesc("Rows used in each new week's skill table. Edit a name inline, remove a skill, add new ones, or reset to the built-in defaults.")
@ -272,18 +278,18 @@ class PracticePlannerSettingTab extends PluginSettingTab {
text
.setPlaceholder("Skill name")
.setValue(skill)
.onChange(async (value) => {
.onChange((value) => {
this.plugin.settings.skills[index] = value.trim();
await this.plugin.saveSettings();
void this.plugin.saveSettings();
});
}).addExtraButton((btn) => {
btn
.setIcon("trash")
.setTooltip("Remove skill")
.onClick(async () => {
.onClick(() => {
this.plugin.settings.skills.splice(index, 1);
await this.plugin.saveSettings();
this.display();
void this.plugin.saveSettings();
this.renderSkills(containerEl);
});
});
});
@ -292,20 +298,20 @@ class PracticePlannerSettingTab extends PluginSettingTab {
.addButton((btn) => {
btn
.setButtonText("Add skill")
.onClick(async () => {
.onClick(() => {
this.plugin.settings.skills.push("");
await this.plugin.saveSettings();
this.display();
void this.plugin.saveSettings();
this.renderSkills(containerEl);
});
})
.addButton((btn) => {
btn
.setButtonText("Reset to default")
.setCta()
.onClick(async () => {
.onClick(() => {
this.plugin.settings.skills = [...DEFAULT_SETTINGS.skills];
await this.plugin.saveSettings();
this.display();
void this.plugin.saveSettings();
this.renderSkills(containerEl);
});
});
}

View file

@ -2,7 +2,7 @@
"id": "practice-planner",
"name": "Weekly Music Practice Planner",
"version": "0.1.1",
"minAppVersion": "0.15.0",
"minAppVersion": "1.4.0",
"description": "Plan and track weekly music practice: per-skill progress by day, plus per-day notes.",
"author": "Patrick Driggett",
"authorUrl": "",

14
package-lock.json generated
View file

@ -12,7 +12,6 @@
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "^0.28.1",
"obsidian": "latest",
"tslib": "2.4.0",
@ -1003,19 +1002,6 @@
"node": ">=8"
}
},
"node_modules/builtin-modules": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",

View file

@ -20,7 +20,6 @@
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "^0.28.1",
"obsidian": "latest",
"tslib": "2.4.0",