Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor codebase #245

Merged
merged 4 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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