From b06e3f91636f5f1dacbadb41efdc9cb535bdf1b0 Mon Sep 17 00:00:00 2001 From: Matthew M-B Date: Fri, 28 Jun 2024 22:25:43 -0400 Subject: [PATCH] Add svelte prettier plugin and ci --- .github/workflows/workflow.yml | 17 +++++++++++++++++ .prettierrc.mjs | 8 +++++++- package-lock.json | 11 +++++++++++ package.json | 1 + src/components/MathJax.svelte | 22 +++++++++++----------- 5 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 00000000..9fef73fe --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,17 @@ +name: CI +'on': + - push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: | + npm install + - name: Run Prettier + run: | + npm run check + - name: Run tests + run: | + npm run test \ No newline at end of file diff --git a/.prettierrc.mjs b/.prettierrc.mjs index 901d6e93..9c93d703 100644 --- a/.prettierrc.mjs +++ b/.prettierrc.mjs @@ -1,5 +1,5 @@ export default { - plugins: ['prettier-plugin-astro'], + plugins: ['prettier-plugin-astro', 'prettier-plugin-svelte'], overrides: [ { files: '*.astro', @@ -7,5 +7,11 @@ export default { parser: 'astro', }, }, + { + files: "*.svelte", + options: { + parser: 'svelte' + } + } ], }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c99198a7..71a84149 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "jest": "^29.7.0", "prettier": "^3.3.2", "prettier-plugin-astro": "^0.14.0", + "prettier-plugin-svelte": "^3.2.5", "sass": "^1.77.6", "ts-jest": "^29.1.5", "ts-node": "^10.9.2" @@ -9281,6 +9282,16 @@ "integrity": "sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==", "devOptional": true }, + "node_modules/prettier-plugin-svelte": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.2.5.tgz", + "integrity": "sha512-vP/M/Goc8z4iVIvrwXwbrYVjJgA0Hf8PO1G4LBh/ocSt6vUP6sLvyu9F3ABEGr+dbKyxZjEKLkeFsWy/yYl0HQ==", + "dev": true, + "peerDependencies": { + "prettier": "^3.0.0", + "svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", diff --git a/package.json b/package.json index df00e38b..fe0cf241 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "jest": "^29.7.0", "prettier": "^3.3.2", "prettier-plugin-astro": "^0.14.0", + "prettier-plugin-svelte": "^3.2.5", "sass": "^1.77.6", "ts-jest": "^29.1.5", "ts-node": "^10.9.2" diff --git a/src/components/MathJax.svelte b/src/components/MathJax.svelte index ca922443..354394c9 100644 --- a/src/components/MathJax.svelte +++ b/src/components/MathJax.svelte @@ -1,12 +1,12 @@ \ No newline at end of file + import { onMount, afterUpdate } from "svelte"; + import { mathjaxLoad, mathjaxTypeset } from "../utilities"; + + onMount(async () => { + mathjaxLoad(); + }); + + afterUpdate(() => { + mathjaxTypeset(); + }); +