Skip to content

Commit

Permalink
Refactor codebase (#245)
Browse files Browse the repository at this point in the history
* Refactor codebase

* Rename to utils

* Sprinkle some comments

* Move elements to printer folder
  • Loading branch information
Princesseuh authored Aug 2, 2022
1 parent 4706687 commit 1adfd4a
Show file tree
Hide file tree
Showing 10 changed files with 877 additions and 1,748 deletions.
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import printer from './printer';
import { options } from './options';
import { createRequire } from 'node:module';
import { Parser, Printer, SupportLanguage } from 'prettier';
import { createSyncFn } from 'synckit';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
import { options } from './options';
import { print } from './printer';
import { embed } from './printer/embed';

const require = createRequire(import.meta.url);
// the worker path must be absolute
const parse = createSyncFn(require.resolve('../workers/parse-worker.js'));

// https://prettier.io/docs/en/plugins.html#languages
export const languages: Partial<SupportLanguage>[] = [
{
name: 'astro',
Expand All @@ -17,6 +19,7 @@ export const languages: Partial<SupportLanguage>[] = [
},
];

// https://prettier.io/docs/en/plugins.html#parsers
export const parsers: Record<string, Parser> = {
astro: {
parse: (source) => parse(source),
Expand All @@ -26,8 +29,12 @@ export const parsers: Record<string, Parser> = {
},
};

// https://prettier.io/docs/en/plugins.html#printers
export const printers: Record<string, Printer> = {
astro: printer,
astro: {
print,
embed,
},
};

const defaultOptions = {
Expand Down
313 changes: 0 additions & 313 deletions src/nodes.ts

This file was deleted.

Loading

0 comments on commit 1adfd4a

Please sign in to comment.