From ceb8efa67f57206100e35a2e4096d6bed3815f84 Mon Sep 17 00:00:00 2001 From: FlorianWoelki Date: Sat, 30 Nov 2024 11:36:49 +0100 Subject: [PATCH] refactor: clean up some import paths --- src/editor/icons-suggestion.test.ts | 6 +++--- src/editor/icons-suggestion.ts | 6 +++--- .../decorations/build-link-decorations.ts | 2 +- src/lib/custom-rule.test.ts | 4 ++-- src/lib/custom-rule.ts | 12 ++++++------ src/lib/util/dom.test.ts | 2 +- src/lib/util/style.test.ts | 2 +- src/lib/util/style.ts | 6 +++--- src/settings/ui/customIconRule.ts | 8 ++++---- src/settings/ui/toggleIconInTabs.ts | 2 +- vitest.config.ts | 5 ++++- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/editor/icons-suggestion.test.ts b/src/editor/icons-suggestion.test.ts index f740b53f..fc65073e 100644 --- a/src/editor/icons-suggestion.test.ts +++ b/src/editor/icons-suggestion.test.ts @@ -7,9 +7,9 @@ import { it, vi, } from 'vitest'; -import icon from '../lib/icon'; -import * as iconPackManager from '../icon-pack-manager'; -import * as util from '../util'; +import icon from '@lib/icon'; +import * as iconPackManager from '@app/icon-pack-manager'; +import * as util from '@app/util'; import SuggestionIcon from './icons-suggestion'; vi.mock('obsidian', () => ({ diff --git a/src/editor/icons-suggestion.ts b/src/editor/icons-suggestion.ts index 489d5b3c..3dcbfbed 100644 --- a/src/editor/icons-suggestion.ts +++ b/src/editor/icons-suggestion.ts @@ -6,9 +6,9 @@ import { EditorSuggestContext, EditorSuggestTriggerInfo, } from 'obsidian'; -import { getAllLoadedIconNames } from '../icon-pack-manager'; -import icon from '../lib/icon'; -import emoji from '../emoji'; +import { getAllLoadedIconNames } from '@app/icon-pack-manager'; +import icon from '@app/lib/icon'; +import emoji from '@app/emoji'; import { saveIconToIconPack } from '@app/util'; import IconizePlugin from '@app/main'; diff --git a/src/editor/live-preview/decorations/build-link-decorations.ts b/src/editor/live-preview/decorations/build-link-decorations.ts index 4e5ed1d5..3abcb2f3 100644 --- a/src/editor/live-preview/decorations/build-link-decorations.ts +++ b/src/editor/live-preview/decorations/build-link-decorations.ts @@ -4,7 +4,7 @@ import { MarkdownView, editorInfoField } from 'obsidian'; import { RangeSetBuilder } from '@codemirror/state'; import { syntaxTree, tokenClassNodeProp } from '@codemirror/language'; import icon from '@lib/icon'; -import { IconInLinkWidget } from '../widgets'; +import { IconInLinkWidget } from '@app/editor/live-preview/widgets'; import { HeaderToken } from '@app/lib/util/text'; export const buildLinkDecorations = ( diff --git a/src/lib/custom-rule.test.ts b/src/lib/custom-rule.test.ts index 7d2d476a..e5e26102 100644 --- a/src/lib/custom-rule.test.ts +++ b/src/lib/custom-rule.test.ts @@ -1,9 +1,9 @@ import { vi, it, describe, beforeEach, expect, MockInstance } from 'vitest'; import { Plugin, TAbstractFile } from 'obsidian'; +import { CustomRule } from '@app/settings/data'; +import config from '@app/config'; import dom from './util/dom'; -import { CustomRule } from '../settings/data'; import customRule, { CustomRuleFileType } from './custom-rule'; -import config from '../config'; describe('doesMatchFileType', () => { let rule: CustomRule; diff --git a/src/lib/custom-rule.ts b/src/lib/custom-rule.ts index 99d5abc1..dde711e2 100644 --- a/src/lib/custom-rule.ts +++ b/src/lib/custom-rule.ts @@ -1,11 +1,11 @@ import { Plugin, TAbstractFile } from 'obsidian'; -import IconizePlugin from '../main'; -import { CustomRule } from '../settings/data'; -import dom from './util/dom'; -import { getFileItemTitleEl } from '../util'; -import config from '../config'; -import { FileItem } from '../@types/obsidian'; +import IconizePlugin from '@app/main'; +import { CustomRule } from '@app/settings/data'; +import { getFileItemTitleEl } from '@app/util'; +import config from '@app/config'; +import { FileItem } from '@app/@types/obsidian'; import { IconCache } from './icon-cache'; +import dom from './util/dom'; export type CustomRuleFileType = 'file' | 'folder'; diff --git a/src/lib/util/dom.test.ts b/src/lib/util/dom.test.ts index a6f5a227..d0850660 100644 --- a/src/lib/util/dom.test.ts +++ b/src/lib/util/dom.test.ts @@ -1,5 +1,5 @@ import { beforeEach, it, expect, describe, vi, MockInstance } from 'vitest'; -import * as iconPackManager from '../../icon-pack-manager'; +import * as iconPackManager from '@app/icon-pack-manager'; import dom from './dom'; import svg from './svg'; import style from './style'; diff --git a/src/lib/util/style.test.ts b/src/lib/util/style.test.ts index 2c173597..0b014cae 100644 --- a/src/lib/util/style.test.ts +++ b/src/lib/util/style.test.ts @@ -7,7 +7,7 @@ import { it, vi, } from 'vitest'; -import * as util from '../../util'; +import * as util from '@app/util'; import svg from './svg'; import style from './style'; diff --git a/src/lib/util/style.ts b/src/lib/util/style.ts index ac6b8e35..bb283d2e 100644 --- a/src/lib/util/style.ts +++ b/src/lib/util/style.ts @@ -2,10 +2,10 @@ // only include utility functions for setting styles for nodes or icons. The only // dependency is the `svg` library. -import emoji from '../../emoji'; -import IconizePlugin from '../../main'; +import emoji from '@app/emoji'; +import IconizePlugin from '@app/main'; +import { getFileItemTitleEl } from '@app/util'; import svg from './svg'; -import { getFileItemTitleEl } from '../../util'; interface Margin { top: number; diff --git a/src/settings/ui/customIconRule.ts b/src/settings/ui/customIconRule.ts index 1427131c..515f56a5 100644 --- a/src/settings/ui/customIconRule.ts +++ b/src/settings/ui/customIconRule.ts @@ -20,10 +20,10 @@ import { import { CustomRule } from '../data'; import customRule from '@lib/custom-rule'; import iconTabs from '@lib/icon-tabs'; -import dom from '../../lib/util/dom'; -import svg from '../../lib/util/svg'; -import { getNormalizedName } from '../../icon-pack-manager'; -import { TabHeaderLeaf } from '../../@types/obsidian'; +import dom from '@lib/util/dom'; +import svg from '@lib/util/svg'; +import { getNormalizedName } from '@app/icon-pack-manager'; +import { TabHeaderLeaf } from '@app/@types/obsidian'; import emoji from '@app/emoji'; export default class CustomIconRuleSetting extends IconFolderSetting { diff --git a/src/settings/ui/toggleIconInTabs.ts b/src/settings/ui/toggleIconInTabs.ts index 9b91ff38..76428b5a 100644 --- a/src/settings/ui/toggleIconInTabs.ts +++ b/src/settings/ui/toggleIconInTabs.ts @@ -1,7 +1,7 @@ import { Setting } from 'obsidian'; import iconTabs from '@lib/icon-tabs'; +import { TabHeaderLeaf } from '@app/@types/obsidian'; import IconFolderSetting from './iconFolderSetting'; -import { TabHeaderLeaf } from '../../@types/obsidian'; export default class ToggleIconInTabs extends IconFolderSetting { public display(): void { diff --git a/vitest.config.ts b/vitest.config.ts index 22799944..61dcd8b4 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -18,6 +18,9 @@ export default defineConfig({ }, }, resolve: { - alias: [{ find: '@app', replacement: resolve(__dirname, './src') }], + alias: [ + { find: '@app', replacement: resolve(__dirname, './src') }, + { find: '@lib', replacement: resolve(__dirname, './src/lib') }, + ], }, });