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

feat: upgrade svelte and jsdoc plugins #68

Merged
merged 1 commit into from
Dec 6, 2023
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
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
Loading