Skip to content

Commit

Permalink
feat: upgrade svelte and jsdoc plugins (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Dec 6, 2023
1 parent c2c06ae commit 1840bd0
Show file tree
Hide file tree
Showing 6 changed files with 3,469 additions and 1,046 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/check_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: check_updates

on:
workflow_dispatch:
# temporarily disabled until next release
# schedule:
# # do this three times a week
# - cron: "0 7 * * 1,3,5"
schedule:
# do this three times a week
- cron: "0 7 * * 1,3,5"

jobs:
build:
Expand Down
20 changes: 18 additions & 2 deletions js/node/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { format, getSupportInfo, type Options, type Plugin, type SupportLanguage } from "prettier";
import * as pluginJsDoc from "prettier-plugin-jsdoc";
import * as pluginSvelte from "prettier-plugin-svelte";
import * as pluginAcorn from "prettier/plugins/acorn";
import * as pluginAngular from "prettier/plugins/angular";
import * as pluginBabel from "prettier/plugins/babel";
Expand Down Expand Up @@ -27,6 +29,7 @@ const plugins: Plugin[] = [
pluginMeriyah,
pluginPostCss,
pluginYaml,
pluginSvelte,
];

(globalThis as any).dprint = {
Expand Down Expand Up @@ -58,12 +61,17 @@ interface FormatTextOptions {
filePath: string;
fileText: string;
config: Options;
pluginsConfig: PluginsConfig;
}

async function formatText({ filePath, fileText, config }: FormatTextOptions) {
interface PluginsConfig {
js_doc: boolean;
}

async function formatText({ filePath, fileText, config, pluginsConfig }: FormatTextOptions) {
const formattedText = await format(fileText, {
filepath: filePath,
plugins,
plugins: getPlugins(pluginsConfig),
...config,
});
if (formattedText === fileText) {
Expand All @@ -72,3 +80,11 @@ async function formatText({ filePath, fileText, config }: FormatTextOptions) {
return formattedText;
}
}

function getPlugins(pluginsConfig: PluginsConfig) {
if (pluginsConfig.js_doc) {
return [...plugins, pluginJsDoc as Plugin<any>];
} else {
return plugins;
}
}
Loading

0 comments on commit 1840bd0

Please sign in to comment.