From 5c4e7d1e02ed381f7adc967a573d15dcace3e207 Mon Sep 17 00:00:00 2001 From: FlorianWoelki Date: Sun, 1 Oct 2023 08:59:47 +0200 Subject: [PATCH] refactor: use linting for lint-staged --- .eslintignore | 2 ++ package.json | 2 +- src/@types/internalPluginInjector.ts | 1 + src/@types/obsidian.d.ts | 2 +- src/iconPackBrowserModal.ts | 1 + src/iconPackManager.ts | 2 +- src/iconsPickerModal.ts | 2 +- src/internal-plugins/bookmark.ts | 1 + src/internal-plugins/starred.ts | 1 + src/main.ts | 1 + src/zipUtil.ts | 2 +- 11 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..f06235c4 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/package.json b/package.json index 457d3322..96e1f79e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "license": "MIT", "lint-staged": { "*.{json,js,ts,jsx,tsx,html}": [ - "prettier --write --ignore-unknown" + "pnpm lint" ] }, "devDependencies": { diff --git a/src/@types/internalPluginInjector.ts b/src/@types/internalPluginInjector.ts index 2f47e36f..77ccba62 100644 --- a/src/@types/internalPluginInjector.ts +++ b/src/@types/internalPluginInjector.ts @@ -21,6 +21,7 @@ export default abstract class InternalPluginInjector { return this.plugin.app.workspace.getLeavesOfType('file-explorer') as unknown as FileExplorerWorkspaceLeaf[]; } + // eslint-disable-next-line onMount(): void {} abstract get enabled(): boolean; diff --git a/src/@types/obsidian.d.ts b/src/@types/obsidian.d.ts index afff56e7..cfc2f059 100644 --- a/src/@types/obsidian.d.ts +++ b/src/@types/obsidian.d.ts @@ -41,7 +41,7 @@ interface BookmarkInternalPlugin extends InternalPlugin { }; } -interface FileExplorerInternalPlugin extends InternalPlugin {} +type FileExplorerInternalPlugin = InternalPlugin interface InternalPlugins { starred: StarredInternalPlugin; diff --git a/src/iconPackBrowserModal.ts b/src/iconPackBrowserModal.ts index cb660c43..07b5bca2 100644 --- a/src/iconPackBrowserModal.ts +++ b/src/iconPackBrowserModal.ts @@ -15,6 +15,7 @@ export default class IconPackBrowserModal extends FuzzySuggestModal { this.inputEl.placeholder = 'Select to download icon pack'; } + // eslint-disable-next-line onAddedIconPack(): void {} onOpen(): void { diff --git a/src/iconPackManager.ts b/src/iconPackManager.ts index a4ef3b3c..00d36563 100644 --- a/src/iconPackManager.ts +++ b/src/iconPackManager.ts @@ -204,7 +204,7 @@ const generateIcon = (iconPackName: string, iconName: string, content: string): } const svgViewboxMatch = content.match(svgViewboxRegex); - let svgViewbox: string = ''; + let svgViewbox = ''; if (svgViewboxMatch && svgViewboxMatch.length !== 0) { svgViewbox = svgViewboxMatch[0]; } diff --git a/src/iconsPickerModal.ts b/src/iconsPickerModal.ts index 375acb7c..d645e0c0 100644 --- a/src/iconsPickerModal.ts +++ b/src/iconsPickerModal.ts @@ -23,7 +23,7 @@ export default class IconsPickerModal extends FuzzySuggestModal { private plugin: IconFolderPlugin; private path: string; - private renderIndex: number = 0; + private renderIndex = 0; private recentlyUsedItems: Set; diff --git a/src/internal-plugins/bookmark.ts b/src/internal-plugins/bookmark.ts index f2e1a5f4..92af45b4 100644 --- a/src/internal-plugins/bookmark.ts +++ b/src/internal-plugins/bookmark.ts @@ -136,6 +136,7 @@ export default class BookmarkInternalPlugin extends InternalPluginInjector { return; } + // eslint-disable-next-line const self = this; this.plugin.register( around(this.bookmark.instance, { diff --git a/src/internal-plugins/starred.ts b/src/internal-plugins/starred.ts index e4b6d287..d1ed0b40 100644 --- a/src/internal-plugins/starred.ts +++ b/src/internal-plugins/starred.ts @@ -87,6 +87,7 @@ export default class StarredInternalPlugin extends InternalPluginInjector { return; } + // eslint-disable-next-line const self = this; this.plugin.register( around(this.starred.instance, { diff --git a/src/main.ts b/src/main.ts index aeff28bf..f6747071 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,6 +35,7 @@ export default class IconFolderPlugin extends Plugin { console.log('...icons migrated'); } + // eslint-disable-next-line // @ts-ignore - Required because an older version of the plugin saved the `migrated` // property as a boolean instead of a number. if (this.getSettings().migrated === true) { diff --git a/src/zipUtil.ts b/src/zipUtil.ts index 80996743..35a3d901 100644 --- a/src/zipUtil.ts +++ b/src/zipUtil.ts @@ -30,7 +30,7 @@ export const getFileFromJSZipFile = async (file: JSZip.JSZipObject): Promise => { +export const readZipFile = async (bytes: ArrayBuffer, extraPath = ''): Promise => { const zipper = new JSZip(); const unzippedFiles = await zipper.loadAsync(bytes); return Promise.resolve(unzippedFiles).then((unzipped) => {