Linter fixes. Added mentioning plugin works in light and dark modes.

This commit is contained in:
Jalad 2026-05-04 01:05:26 -05:00
parent eaee15e946
commit bbcea0434d
9 changed files with 85 additions and 1 deletions

View file

@ -96,6 +96,19 @@ body:
validations:
required: true
- type: dropdown
id: theme-mode
attributes:
label: Theme mode
description: Which Obsidian appearance mode does the bug occur in? If you haven't checked the other mode, please try to reproduce there as well — some issues are theme-specific.
options:
- Both light and dark mode
- Light mode only
- Dark mode only
- Not applicable / not visual
validations:
required: true
- type: textarea
id: other-plugins
attributes:

View file

@ -42,3 +42,4 @@ Fixes #
- [ ] `npm run lint` passes.
- [ ] `npm run build` passes with no TypeScript errors.
- [ ] I have tested with existing contact notes to confirm no regression.
- [ ] I have verified the fix in both light and dark mode (if the bug is visual).

View file

@ -40,5 +40,6 @@ Closes #
- [ ] `npm run build` passes with no TypeScript errors.
- [ ] I have tested with both folder-based and tag-based contact identification (if relevant).
- [ ] I have tested with existing contact notes to confirm no regression.
- [ ] I have verified the feature renders correctly in both light and dark mode (if it adds or modifies UI).
- [ ] I have updated the README to document the new feature (if relevant).
- [ ] Settings persist correctly across reloads (if settings were changed).

View file

@ -33,3 +33,4 @@
- [ ] `npm run lint` passes.
- [ ] `npm run build` passes with no TypeScript errors.
- [ ] I have tested the affected areas in a local vault to confirm no regression.
- [ ] I have verified the affected UI in both light and dark mode (if any styles or DOM structure were touched).

View file

@ -15,6 +15,7 @@ Before opening a new bug report:
- Search [existing issues](https://github.com/Jalad25/contact-note/issues) to see if it has already been reported.
- Make sure you are running the latest version of the plugin and the minimum required version of Obsidian.
- Try to reproduce the bug in a clean vault with other plugins disabled or removed.
- Try to reproduce the bug in **both light and dark mode**, since some issues are theme-specific.
## Suggesting Enhancements

View file

@ -97,6 +97,7 @@ Currently, the project relies on manual testing within an Obsidian vault. When m
- Settings persist across reloads.
- The contact list view updates correctly when notes are added, modified, or deleted.
- Both folder-based and tag-based contact identification work.
- The plugin renders correctly in **both light and dark mode**. All bugs, features, and UI changes should be verified against both themes before submission.
## Submitting Changes

View file

@ -20,6 +20,7 @@ An [Obsidian](https://obsidian.md/) plugin that renders visual contact cards fro
- **Multiple Values for Certain Frontmatter Properties**: Supports multiple emails, phone numbers, and social media profiles per contact.
- **Default Filters**: Create default list filters based on any frontmatter property!
- **Contact Note Identification**: Contacts identified by folder or tag.
- **Light and Dark Mode Support**: All plugin UI is styled for both Obsidian themes.
## Installation

59
src/SchemaMigration.ts Normal file
View file

@ -0,0 +1,59 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument -- This module reads untyped JSON of unknown shape from prior plugin versions. Strict typing here would only obscure the runtime guards that actually protect against malformed input. */
import { ContactNoteSettings } from "./main";
//#region Constants
export const CURRENT_SCHEMA_VERSION = 0;
const MIGRATIONS: Migration[] = [];
//#endregion
//#region Types/Objects/Interfaces
type Migration = {
from: number;
to: number;
apply: (raw: any) => Partial<ContactNoteSettings> & { schemaVersion: number };
};
export type MigrationResult = {
values: Partial<ContactNoteSettings>;
migrated: boolean;
};
//#endregion
//#region Migration
export function migrate(raw: unknown): MigrationResult {
if (!raw || typeof raw !== "object") {
return { values: { schemaVersion: CURRENT_SCHEMA_VERSION }, migrated: true };
}
let current: any = raw;
let version: number = typeof current.schemaVersion === "number" ? current.schemaVersion : 0;
let migrated = false;
while (version < CURRENT_SCHEMA_VERSION) {
const step = MIGRATIONS.find((m) => m.from === version);
if (!step) break;
current = step.apply(current);
version = step.to;
migrated = true;
}
return {
values: current as Partial<ContactNoteSettings>,
migrated
};
}
//#endregion
//#region Migration Step Functions
/* This is a per-version migration steps. Append new functions below for each schema change and add it to MIGRATIONS. Never edit existing steps. */
//#endregion

View file

@ -10,6 +10,7 @@ import { ContactListView } from "./ContactListView";
import { ContactNoteSettingTab } from "./ContactNoteSettingTab";
import { Contact } from "./Contact";
import { buildContactCard } from "./ContactCard";
import { CURRENT_SCHEMA_VERSION, migrate } from "./SchemaMigration";
//#region Types/Objects/Interface
@ -20,6 +21,7 @@ export interface FrontmatterFilter {
}
export interface ContactNoteSettings {
schemaVersion: number;
useFolder: boolean;
folderPath: string;
tag: string;
@ -34,6 +36,7 @@ export interface ContactNoteSettings {
//#region Constants/Defaults
export const DEFAULT_SETTINGS: ContactNoteSettings = {
schemaVersion: CURRENT_SCHEMA_VERSION,
useFolder: true,
folderPath: "Contacts",
tag: "contact",
@ -140,7 +143,10 @@ export default class ContactNotePlugin extends Plugin {
async loadSettings() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Disabling eslint as this is an issue triggered by Obsidian's API. Triggers locally
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
const raw = await this.loadData();
const { values, migrated } = migrate(raw);
this.settings = Object.assign({}, DEFAULT_SETTINGS, values);
if (migrated) await this.saveSettings();
}
async saveSettings() {