From cce6898d839f2c7122e62b390a10752d8a5bd7c8 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:07:49 -0700 Subject: [PATCH] Chore: Fix CI (#11281) --- packages/app-desktop/commands/renderMarkup.test.ts | 4 ++-- packages/lib/shim-init-node.ts | 5 ++--- packages/lib/shim.ts | 10 ++++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/app-desktop/commands/renderMarkup.test.ts b/packages/app-desktop/commands/renderMarkup.test.ts index 83dc3f6ca..101801b8f 100644 --- a/packages/app-desktop/commands/renderMarkup.test.ts +++ b/packages/app-desktop/commands/renderMarkup.test.ts @@ -34,11 +34,11 @@ describe('renderMarkup', () => { { const note = await Note.save({ }); - await shim.attachFileToNote(note, testImagePath, null, { resizeLargeImages: 'never' }); + await shim.attachFileToNote(note, testImagePath, { resizeLargeImages: 'never' }); const resource = (await Resource.all())[0]; const noteBody = (await Note.load(note.id)).body; const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, noteBody); - expect(renderedNote.html).toContain(`

photo.jpg

'); } diff --git a/packages/lib/shim-init-node.ts b/packages/lib/shim-init-node.ts index 4a4b5f8e9..0d6b7f6b9 100644 --- a/packages/lib/shim-init-node.ts +++ b/packages/lib/shim-init-node.ts @@ -416,11 +416,10 @@ function shimInit(options: ShimInitOptions = null) { return newBody.join('\n\n'); }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied - shim.attachFileToNote = async function(note, filePath, position: number = null, options: any = null) { + shim.attachFileToNote = async function(note, filePath, options = {}) { if (!options) options = {}; if (note.markup_language) options.markupLanguage = note.markup_language; - const newBody = await shim.attachFileToNoteBody(note.body, filePath, position, options); + const newBody = await shim.attachFileToNoteBody(note.body, filePath, options.position ?? 0, options); if (!newBody) return null; const newNote = { ...note, body: newBody }; diff --git a/packages/lib/shim.ts b/packages/lib/shim.ts index 4b831904c..27cf3de13 100644 --- a/packages/lib/shim.ts +++ b/packages/lib/shim.ts @@ -3,6 +3,7 @@ import { NoteEntity, ResourceEntity } from './services/database/types'; import type FsDriverBase from './fs-driver-base'; import type FileApiDriverLocal from './file-api-driver-local'; import { Crypto } from './services/e2ee/types'; +import { MarkupLanguage } from '@joplin/renderer'; export interface CreateResourceFromPathOptions { resizeLargeImages?: 'always' | 'never' | 'ask'; @@ -33,6 +34,12 @@ interface FetchOptions { agent?: unknown; } +interface AttachFileToNoteOptions { + resizeLargeImages?: 'always'|'never'; + position?: number; + markupLanguage?: MarkupLanguage; +} + let isTestingEnv_ = false; // We need to ensure that there's only one instance of React being used by all @@ -308,8 +315,7 @@ const shim = { // eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied detectAndSetLocale: null as Function, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied - attachFileToNote: async (_note: any, _filePath: string, _position: number, _options: any): Promise => { + attachFileToNote: async (_note: NoteEntity, _filePath: string, _options?: AttachFileToNoteOptions): Promise => { throw new Error('Not implemented: attachFileToNote'); },