Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BearToCode committed Aug 11, 2024
1 parent 972b23e commit 1a15159
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
14 changes: 8 additions & 6 deletions docs/src/pages/plugins/component.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ When pre-rendering content on the server (using the `<PreRendered>` component),
export let data;
let container;
let container;
// Needs access to the mapped components
const mapped = /* ... */;
// Needs access to the mapped components
const mapped = [
/* ... */
];
onMount(() => {
initializeComponents(mapped, container);
})
onMount(() => {
initializeComponents(mapped, container);
});
</script>
<div bind:this={container}>
Expand Down
34 changes: 26 additions & 8 deletions packages/carta-md/src/lib/internal/carta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { SvelteComponent } from 'svelte';
import { unified, type Processor } from 'unified';
import remarkParse from 'remark-parse';
import remarkGfm, { type Options as GfmOptions } from 'remark-gfm';
import remarkRehype, {Options as RehypeOptions} from 'remark-rehype'
import remarkRehype, { type Options as RehypeOptions } from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import type { TextAreaHistoryOptions } from './history';
import { InputEnhancer } from './input';
Expand Down Expand Up @@ -125,7 +125,7 @@ export interface Options {
/**
* Options that will be passed to rehype
*/
rehypeOptions?: RehypeOptions
rehypeOptions?: RehypeOptions;
}

/**
Expand Down Expand Up @@ -214,7 +214,7 @@ export class Carta {
public readonly gfmOptions: GfmOptions | undefined;
public readonly syncProcessor: Processor;
public readonly asyncProcessor: Promise<Processor>;
private readonly rehypeOptions: RehypeOptions
private readonly rehypeOptions: RehypeOptions;
private mElement: HTMLDivElement | undefined;
private mInput: InputEnhancer | undefined;
private mRenderer: Renderer | undefined;
Expand Down Expand Up @@ -279,7 +279,7 @@ export class Carta {
this.components = [];
this.grammarRules = [];
this.highlightingRules = [];
this.rehypeOptions = options?.rehypeOptions ?? {}
this.rehypeOptions = options?.rehypeOptions ?? {};
const listeners = [];
for (const ext of options?.extensions ?? []) {
this.keyboardShortcuts.push(...(ext.shortcuts ?? []));
Expand Down Expand Up @@ -347,8 +347,14 @@ export class Carta {
}

this.gfmOptions = options?.gfmOptions;
this.syncProcessor = this.setupSynchronousProcessor({ gfmOptions: this.gfmOptions, rehypeOptions: this.rehypeOptions });
this.asyncProcessor = this.setupAsynchronousProcessor({ gfmOptions: this.gfmOptions, rehypeOptions: this.rehypeOptions });
this.syncProcessor = this.setupSynchronousProcessor({
gfmOptions: this.gfmOptions,
rehypeOptions: this.rehypeOptions
});
this.asyncProcessor = this.setupAsynchronousProcessor({
gfmOptions: this.gfmOptions,
rehypeOptions: this.rehypeOptions
});

for (const ext of options?.extensions ?? []) {
if (ext.onLoad) {
Expand All @@ -359,7 +365,13 @@ export class Carta {
}
}

private setupSynchronousProcessor({ gfmOptions, rehypeOptions }: { gfmOptions?: GfmOptions, rehypeOptions?: RehypeOptions }) {
private setupSynchronousProcessor({
gfmOptions,
rehypeOptions
}: {
gfmOptions?: GfmOptions;
rehypeOptions?: RehypeOptions;
}) {
const syncProcessor = unified();

const remarkPlugins = this.mSyncTransformers.filter((it) => it.type === 'remark');
Expand All @@ -383,7 +395,13 @@ export class Carta {
return syncProcessor;
}

private async setupAsynchronousProcessor({ gfmOptions }: { gfmOptions?: GfmOptions, rehypeOptions?: RehypeOptions }) {
private async setupAsynchronousProcessor({
gfmOptions,
rehypeOptions
}: {
gfmOptions?: GfmOptions;
rehypeOptions?: RehypeOptions;
}) {
const asyncProcessor = unified();

const remarkPlugins = [...this.mSyncTransformers, ...this.mAsyncTransformers].filter(
Expand Down
14 changes: 8 additions & 6 deletions packages/plugin-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ When pre-rendering content on the server (using the `<PreRendered>` component),
export let data;
let container;
let container;
// Needs access to the mapped components
const mapped = /* ... */;
// Needs access to the mapped components
const mapped = [
/* ... */
];
onMount(() => {
initializeComponents(mapped, container);
})
onMount(() => {
initializeComponents(mapped, container);
});
</script>
<div bind:this={container}>
Expand Down

0 comments on commit 1a15159

Please sign in to comment.