From b63d63be8b2adb185c5b1b5b63df35e299a4dd2b Mon Sep 17 00:00:00 2001 From: Mara Date: Sun, 22 Sep 2024 17:08:46 +0200 Subject: [PATCH] style(biome): run linting --- src/GitHub/branch.ts | 4 +++- src/GitHub/upload.ts | 9 +++++++-- src/commands/share/unique_note.ts | 12 ++++++++++-- src/conversion/file_path.ts | 10 +++++----- src/conversion/links.ts | 10 ++++++++-- src/settings.ts | 10 +++++----- src/settings/modals/import_export.ts | 6 ++++-- src/settings/modals/manage_repo.ts | 17 ++++++++++++++--- src/utils/data_validation_test.ts | 10 +++++++--- src/utils/parse_frontmatter.ts | 11 +++++++++-- 10 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/GitHub/branch.ts b/src/GitHub/branch.ts index ca024982..934a6016 100644 --- a/src/GitHub/branch.ts +++ b/src/GitHub/branch.ts @@ -42,7 +42,9 @@ export class GithubBranch extends FilesManagement { (branch: { name: string }) => branch.name === prop.branch ); if (!mainBranch) { - throw new Error(`No main branch found for ${prop.repo}, please check the branch name in the settings`); + throw new Error( + `No main branch found for ${prop.repo}, please check the branch name in the settings` + ); } try { const shaMainBranch = mainBranch!.commit.sha; diff --git a/src/GitHub/upload.ts b/src/GitHub/upload.ts index fe161312..0b0a9126 100644 --- a/src/GitHub/upload.ts +++ b/src/GitHub/upload.ts @@ -40,7 +40,8 @@ import { frontmatterFromFile, frontmatterSettingsRepository, getFrontmatterSettings, - getProperties, mergeFrontmatter, + getProperties, + mergeFrontmatter, } from "src/utils/parse_frontmatter"; import { ShareStatusBar } from "src/utils/status_bar"; import merge from "ts-deepmerge"; @@ -173,7 +174,11 @@ export default class Publisher { const shareFiles = new FilesManagement(this.octokit, this.plugin); let frontmatter = frontmatterFromFile(file, this.plugin, null); if (!isShared(frontmatter, this.settings, file, repo.repository)) return false; - frontmatter = mergeFrontmatter(frontmatter, sourceFrontmatter, this.settings.plugin.shareKey); + frontmatter = mergeFrontmatter( + frontmatter, + sourceFrontmatter, + this.settings.plugin.shareKey + ); const prop = getProperties(this.plugin, repo.repository, frontmatter); const isNotEmpty = await checkEmptyConfiguration(prop, this.plugin); repo.frontmatter = prop; diff --git a/src/commands/share/unique_note.ts b/src/commands/share/unique_note.ts index 8dec183a..6cdaf237 100644 --- a/src/commands/share/unique_note.ts +++ b/src/commands/share/unique_note.ts @@ -15,7 +15,11 @@ import { checkRepositoryValidityWithProperties, isShared, } from "src/utils/data_validation_test"; -import {frontmatterFromFile, getProperties, mergeFrontmatter} from "src/utils/parse_frontmatter"; +import { + frontmatterFromFile, + getProperties, + mergeFrontmatter, +} from "src/utils/parse_frontmatter"; /** * Command to upload the active file ; use checkCallback to check if the file is shared and if they are a active file @@ -70,7 +74,11 @@ export async function shareOneNote( const { settings, plugin } = PublisherManager; const app = PublisherManager.plugin.app; let frontmatter = frontmatterFromFile(file, PublisherManager.plugin, null); - frontmatter = mergeFrontmatter(frontmatter, sourceFrontmatter, PublisherManager.settings.plugin.shareKey); + frontmatter = mergeFrontmatter( + frontmatter, + sourceFrontmatter, + PublisherManager.settings.plugin.shareKey + ); try { const prop = getProperties(plugin, repository, frontmatter); let isValid: boolean; diff --git a/src/conversion/file_path.ts b/src/conversion/file_path.ts index 27db5d06..79396297 100644 --- a/src/conversion/file_path.ts +++ b/src/conversion/file_path.ts @@ -76,7 +76,7 @@ export async function createRelativePath( targetFile: LinkedNotes, frontmatter: FrontMatterCache | null | undefined, properties: MultiProperties -): Promise<{ link: string, unshared?: boolean }> { +): Promise<{ link: string; unshared?: boolean }> { const settings = properties.plugin.settings; const shortRepo = properties.repository; const sourcePath = getReceiptFolder( @@ -112,8 +112,8 @@ export async function createRelativePath( if (targetFile.linked.path === sourceFile.path) { return { link: getReceiptFolder(targetFile.linked, shortRepo, properties.plugin, targetRepo) - .split("/") - .at(-1) as string + .split("/") + .at(-1) as string, }; } @@ -179,8 +179,8 @@ export async function createRelativePath( //in case of errors return { link: getReceiptFolder(targetFile.linked, shortRepo, properties.plugin, targetRepo) - .split("/") - .at(-1) as string + .split("/") + .at(-1) as string, }; } return {link: relative}; diff --git a/src/conversion/links.ts b/src/conversion/links.ts index 382d98c6..66bed51b 100644 --- a/src/conversion/links.ts +++ b/src/conversion/links.ts @@ -355,7 +355,7 @@ export async function convertToInternalGithub( linkedFile, frontmatter, properties - ) + ); let pathInGithub = paths.link; pathInGithub = pathInGithub.replace(".md", ""); let anchor = linkedFile.anchor ? linkedFile.anchor : ""; @@ -372,7 +372,13 @@ export async function convertToInternalGithub( if (matchedLink) { for (const link of matchedLink) { if (frontmatterSettings.unlink && paths.unshared) { - fileContent = replaceText(fileContent, link, pathInGithub, properties.plugin, true); + fileContent = replaceText( + fileContent, + link, + pathInGithub, + properties.plugin, + true + ); continue; } diff --git a/src/settings.ts b/src/settings.ts index 4dcfde83..2c853ed3 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -712,7 +712,9 @@ export class EnveloppeSettingsTab extends PluginSettingTab { this.settingsPage.createEl("h5", { text: i18next.t("settings.conversion.links.title"), }); - this.settingsPage.append(sanitizeHTMLToDom(i18next.t("settings.conversion.links.desc"),)); + this.settingsPage.append( + sanitizeHTMLToDom(i18next.t("settings.conversion.links.desc")) + ); const shareAll = this.settings.plugin.shareAll?.enable ? ` ${i18next.t("settings.conversion.links.internals.shareAll")}` @@ -752,7 +754,7 @@ export class EnveloppeSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }); }); - + if (!textSettings.links.unshared) { new Setting(this.settingsPage) .setName(i18next.t("settings.conversion.links.unlink.title")) @@ -1368,9 +1370,7 @@ export class EnveloppeSettingsTab extends PluginSettingTab { .addToggle((toggle) => toggle.setValue(pluginSettings.saveTabId ?? true).onChange(async (value) => { pluginSettings.saveTabId = value; - this.settings.tabsId = value - ? ESettingsTabId.Plugin - : ESettingsTabId.Github; + this.settings.tabsId = value ? ESettingsTabId.Plugin : ESettingsTabId.Github; await this.plugin.saveSettings(); }) ); diff --git a/src/settings/modals/import_export.ts b/src/settings/modals/import_export.ts index 9d285ba2..113738cb 100644 --- a/src/settings/modals/import_export.ts +++ b/src/settings/modals/import_export.ts @@ -351,10 +351,12 @@ export class ImportLoadPreset extends FuzzySuggestModal { this.console.logs({}, "onChooseItem"); try { const original = clone(this.plugin.settings); - + // noinspection SuspiciousTypeOfGuard if (!(presetSettings.upload.replaceTitle instanceof Array)) { - presetSettings.upload.replaceTitle = [presetSettings.upload.replaceTitle as RegexReplace]; + presetSettings.upload.replaceTitle = [ + presetSettings.upload.replaceTitle as RegexReplace, + ]; } for (const [key, value] of Object.entries(presetSettings)) { diff --git a/src/settings/modals/manage_repo.ts b/src/settings/modals/manage_repo.ts index 1b12e2e8..0be98ad2 100644 --- a/src/settings/modals/manage_repo.ts +++ b/src/settings/modals/manage_repo.ts @@ -1,9 +1,19 @@ import {type EnveloppeSettings, GithubTiersVersion, type Repository} from "@interfaces"; import i18next from "i18next"; -import {AbstractInputSuggest, type App, Modal, Notice, Setting, type TFile,} from "obsidian"; +import { + AbstractInputSuggest, + type App, + Modal, + Notice, + Setting, + type TFile, +} from "obsidian"; import type Enveloppe from "src/main"; import {migrateToken} from "src/settings/migrate"; -import {checkRepositoryValidity, verifyRateLimitAPI,} from "src/utils/data_validation_test"; +import { + checkRepositoryValidity, + verifyRateLimitAPI, +} from "src/utils/data_validation_test"; class SetClassSuggester extends AbstractInputSuggest { plugin: Enveloppe; @@ -482,7 +492,8 @@ class ModalEditingRepository extends Modal { search.setValue(this.repository.set ?? "").setPlaceholder("path/to/file.md"); new SetClassSuggester(search.inputEl, this.plugin, (result) => { this.repository.set = result.path; - this.plugin.repositoryFrontmatter[this.repository.smartKey] = this.plugin.app.metadataCache.getFileCache(result)?.frontmatter; + this.plugin.repositoryFrontmatter[this.repository.smartKey] = + this.plugin.app.metadataCache.getFileCache(result)?.frontmatter; }); }); diff --git a/src/utils/data_validation_test.ts b/src/utils/data_validation_test.ts index 9c4f9cb6..b9166f14 100644 --- a/src/utils/data_validation_test.ts +++ b/src/utils/data_validation_test.ts @@ -21,7 +21,8 @@ import type Enveloppe from "src/main"; import { frontmatterFromFile, getLinkedFrontmatter, - getProperties, mergeFrontmatter, + getProperties, + mergeFrontmatter, } from "src/utils/parse_frontmatter"; import { escapeRegex } from "../conversion/links"; @@ -82,7 +83,11 @@ export function getRepoSharedKey( return defaultRepo(settings); } else if (!frontmatter) return null; const linkedFrontmatter = getLinkedFrontmatter(frontmatter, file, plugin); - frontmatter = mergeFrontmatter(frontmatter, linkedFrontmatter, settings.plugin.shareKey); + frontmatter = mergeFrontmatter( + frontmatter, + linkedFrontmatter, + settings.plugin.shareKey + ); return ( allOtherRepo.find((repo) => frontmatter?.[repo.shareKey]) ?? defaultRepo(settings) ); @@ -549,7 +554,6 @@ export function forcePushAttachment(file: TFile, settings: EnveloppeSettings): b ); }); return needToBeForPush.length !== 0; - } /** diff --git a/src/utils/parse_frontmatter.ts b/src/utils/parse_frontmatter.ts index 8a7980d4..04b192c3 100644 --- a/src/utils/parse_frontmatter.ts +++ b/src/utils/parse_frontmatter.ts @@ -211,7 +211,10 @@ export function getProperties( * @return {Properties[]} */ -function parseMultipleRepo(frontmatter: FrontMatterCache, Properties: Properties): Properties[] { +function parseMultipleRepo( + frontmatter: FrontMatterCache, + Properties: Properties +): Properties[] { const multipleRepo: Properties[] = []; if (frontmatter.multipleRepo instanceof Array && frontmatter.multipleRepo.length > 0) { for (const repo of frontmatter.multipleRepo) { @@ -689,7 +692,11 @@ function settingAttachment( return settingsConversion; } -export function mergeFrontmatter(frontmatter: FrontMatterCache | null, sourceFrontmatter: FrontMatterCache | null | undefined, shareKey: string) { +export function mergeFrontmatter( + frontmatter: FrontMatterCache | null, + sourceFrontmatter: FrontMatterCache | null | undefined, + shareKey: string +) { delete sourceFrontmatter?.[shareKey]; if (sourceFrontmatter && frontmatter) frontmatter = merge.withOptions(