Skip to content

Commit

Permalink
chore(playground): upgrade prettier to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Nov 10, 2024
1 parent f2dd9a2 commit 9426e65
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
Binary file modified playground/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"carbon-components-svelte": "^0.85.4",
"carbon-preprocess-svelte": "^0.11.7",
"codemirror": "^5.65.18",
"prettier": "^2.8.8",
"prettier": "^3.3.3",
"svelte-highlight": "^7.7.0",
"typescript": "^5.6.3",
"vite": "^5.4.10"
Expand Down
21 changes: 15 additions & 6 deletions playground/src/TabMarkdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
export let parsed_component = {};
export let moduleName = "";
import plugin from "prettier/parser-markdown";
import prettier from "prettier/standalone";
import pluginMarkdown from "prettier/plugins/markdown";
import { format } from "prettier/standalone";
import writeMarkdown from "../../src/writer/writer-markdown";
import CodeHighlighter from "./CodeHighlighter.svelte";
let markdown = "";
let code = "";
$: components = new Map([[moduleName, { ...parsed_component, moduleName }]]);
$: writeMarkdown(components, { write: false })
Expand All @@ -17,10 +18,18 @@
.catch((error) => {
console.log(error);
});
$: code = prettier.format(markdown, {
parser: "markdown",
plugins: [plugin],
});
$: {
format(markdown, {
parser: "markdown",
plugins: [pluginMarkdown],
})
.then((formatted) => {
code = formatted;
})
.catch((error) => {
console.log(error);
});
}
</script>

<CodeHighlighter noWrap language="markdown" {code} />
23 changes: 13 additions & 10 deletions playground/src/TabTypeScript.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
export let parsed_component = {};
export let moduleName = "";
import plugin from "prettier/parser-typescript";
import prettier from "prettier/standalone";
import pluginTypeScript from "prettier/plugins/typescript";
import pluginEstree from "prettier/plugins/estree";
import { format } from "prettier/standalone";
import { writeTsDefinition } from "../../src/writer/writer-ts-definitions";
import CodeHighlighter from "./CodeHighlighter.svelte";
import TabContentOverlay from "./TabContentOverlay.svelte";
Expand All @@ -15,15 +16,17 @@
moduleName,
});
$: {
try {
prettier_error = null;
code = prettier.format(code, {
parser: "typescript",
plugins: [plugin],
prettier_error = null;
format(code, {
parser: "typescript",
plugins: [pluginTypeScript, pluginEstree],
})
.then((formatted) => {
code = formatted;
})
.catch((error) => {
prettier_error = error;
});
} catch (error) {
prettier_error = error;
}
}
</script>

Expand Down

0 comments on commit 9426e65

Please sign in to comment.