From 69d4e81e239ed603e51bef7cf999a4affc57a2f6 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 27 Jul 2024 22:21:10 -0400 Subject: [PATCH] Lint fix --- packages/repl-sdk/src/compilers/markdown.js | 3 ++ packages/repl-sdk/src/index.js | 3 +- packages/repl-sdk/src/types.ts | 38 ++++++++++--------- .../tests-self/tests/markdown.test.ts | 27 ++++++------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/packages/repl-sdk/src/compilers/markdown.js b/packages/repl-sdk/src/compilers/markdown.js index 270ba6539a..1c879405f3 100644 --- a/packages/repl-sdk/src/compilers/markdown.js +++ b/packages/repl-sdk/src/compilers/markdown.js @@ -24,11 +24,13 @@ export async function compiler(config = {}, api) { function isPreview(meta) { if (!meta) return false; + return meta.includes('preview'); } function isBelow(meta) { if (!meta) return false; + return meta.includes('below'); } @@ -148,6 +150,7 @@ export async function compiler(config = {}, api) { if (!lang) { return 'skip'; } + /** * Sometimes, meta is not required, * like with the `mermaid` language diff --git a/packages/repl-sdk/src/index.js b/packages/repl-sdk/src/index.js index 989b558e24..1a5090dd1f 100644 --- a/packages/repl-sdk/src/index.js +++ b/packages/repl-sdk/src/index.js @@ -143,10 +143,9 @@ export class Compiler { * @returns {import('./types.ts').ResolvedCompilerOptions)} */ optionsFor = (format, flavor) => { - const { compiler: _, needsLiveMeta, ...rest } = this.#resolveFormat(format, flavor); + const { needsLiveMeta } = this.#resolveFormat(format, flavor); return { - ...rest, needsLiveMeta: needsLiveMeta ?? true, importMap: this.#options.importMap ?? {}, resolve: this.#options.resolve ?? {}, diff --git a/packages/repl-sdk/src/types.ts b/packages/repl-sdk/src/types.ts index e3a4101b39..9b5cbfe2be 100644 --- a/packages/repl-sdk/src/types.ts +++ b/packages/repl-sdk/src/types.ts @@ -1,14 +1,18 @@ interface PublicMethods { - compile: (format: string, text: string, options?: { - flavor?: string; - fileName?: string; - }) => Promise + compile: ( + format: string, + text: string, + options?: { + flavor?: string; + fileName?: string; + } + ) => Promise; - optionsFor: (format: string, flavor?: string) => Omit + optionsFor: (format: string, flavor?: string) => Omit; } export interface ResolvedCompilerOptions { - importMap?: { [importPath: string]: string; }; - resolve?: { [importPath: string]: unknown; }; + importMap?: { [importPath: string]: string }; + resolve?: { [importPath: string]: unknown }; needsLiveMeta?: boolean; versions?: { [packageName: string]: string }; } @@ -82,7 +86,7 @@ export interface CompilerConfig { element: HTMLElement, defaultExport: any, extras: { compiled: string } & Record, - compiler: PublicMethods, + compiler: PublicMethods ) => void; }>; } @@ -93,26 +97,26 @@ export interface Options { * * Thehse will take precedence over the default CDN fallback. */ - importMap?: { [importPath: string]: string; }; + importMap?: { [importPath: string]: string }; /** * Map of pre-resolved JS values to use as the import map * These could assume the role of runtime virtual modules. * * These will take precedence over the importMap, and implicit CDN fallback. */ - resolve?: { [importPath: string]: unknown; } + resolve?: { [importPath: string]: unknown }; /** - * Specifies which vesions of dependencies to when pulling from a CDN. - * Defaults to latest. - */ + * Specifies which vesions of dependencies to when pulling from a CDN. + * Defaults to latest. + */ versions?: { [packageName: string]: string }; formats: { [fileExtension: string]: - | CompilerConfig - | { - [flavor: string]: CompilerConfig; - }; + | CompilerConfig + | { + [flavor: string]: CompilerConfig; + }; }; } diff --git a/packages/repl-sdk/tests-self/tests/markdown.test.ts b/packages/repl-sdk/tests-self/tests/markdown.test.ts index f8e0f8aaf4..c26a36963a 100644 --- a/packages/repl-sdk/tests-self/tests/markdown.test.ts +++ b/packages/repl-sdk/tests-self/tests/markdown.test.ts @@ -86,21 +86,20 @@ graph TD; test('jsx requires a flavor to be specified', async () => { let compiler = new Compiler(); - expect(compiler.compile( - 'md', - `# Hello\n\n` + - fenced(jsxReact, 'jsx react live') + - '\n\n' + - fenced(`export default <>hi`, 'jsx live') - )).rejects.toThrow('make sure you specify the flavor.'); + expect( + compiler.compile( + 'md', + `# Hello\n\n` + + fenced(jsxReact, 'jsx react live') + + '\n\n' + + fenced(`export default <>hi`, 'jsx live') + ) + ).rejects.toThrow('make sure you specify the flavor.'); }); test('svelte live', async () => { let compiler = new Compiler(); - let element = await compiler.compile( - 'md', - fenced(svelte, 'svelte live') - ); + let element = await compiler.compile('md', fenced(svelte, 'svelte live')); let h1 = element.querySelector('h1'); @@ -114,11 +113,7 @@ graph TD; test('mermaid (no live)', async () => { let compiler = new Compiler(); - let element = await compiler.compile( - 'md', - fenced(mermaid, 'mermaid') - ); - + let element = await compiler.compile('md', fenced(mermaid, 'mermaid')); let rootSVG = element.querySelector('svg');