diff --git a/package.json b/package.json index 6a94eb28..57ef5598 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "start": "start-storybook -p 9090", "build": "build-storybook", + "prettier": "prettier --write './**/*.svelte'", "prepack": "rollup -c" }, "sideEffects": false, @@ -29,6 +30,8 @@ "@tsconfig/svelte": "^1.0.8", "babel-loader": "^8.0.6", "comment-parser": "^0.7.5", + "prettier": "^2.0.5", + "prettier-plugin-svelte": "^1.1.0", "rollup": "^2.22.1", "rollup-plugin-svelte": "^5.2.3", "rollup-plugin-terser": "^6.1.0", diff --git a/scripts/generate-docs.js b/scripts/generate-docs.js index 3f667781..23100ffe 100644 --- a/scripts/generate-docs.js +++ b/scripts/generate-docs.js @@ -5,6 +5,7 @@ const svelte = require("rollup-plugin-svelte"); const resolve = require("@rollup/plugin-node-resolve").default; const commonjs = require("@rollup/plugin-commonjs"); const path = require("path"); +const prettier = require("prettier"); const { parseComponent } = require("./parse-component"); async function generateDocs() { @@ -43,10 +44,7 @@ class CarbonSvelteBase { const moduleName = name.replace(/\./g, ""); if (ext === ".svelte" && components.has(moduleName)) { - const group = dir - .split("src/") - .pop() - .split("/")[0]; + const group = dir.split("src/").pop().split("/")[0]; if (groups.has(group)) { groups.set(group, [...groups.get(group), moduleName]); @@ -126,7 +124,11 @@ class CarbonSvelteBase { } } - fs.writeFileSync(pkg.types, definitions); + const formatted_definitions = prettier.format(definitions, { + parser: "typescript", + }); + + fs.writeFileSync(pkg.types, formatted_definitions); } generateDocs(); diff --git a/src/Checkbox/Checkbox.Story.svelte b/src/Checkbox/Checkbox.Story.svelte index 6c795847..aa24e490 100644 --- a/src/Checkbox/Checkbox.Story.svelte +++ b/src/Checkbox/Checkbox.Story.svelte @@ -9,14 +9,14 @@ indeterminate, disabled, hideLabel, - wrapperClassName + wrapperClassName, } = $$props; const checkboxProps = { labelText, indeterminate, disabled, hideLabel, - wrapperClassName + wrapperClassName, }; let checked = true; diff --git a/src/CopyButton/CopyButton.Story.svelte b/src/CopyButton/CopyButton.Story.svelte index f131b5e6..d8035251 100644 --- a/src/CopyButton/CopyButton.Story.svelte +++ b/src/CopyButton/CopyButton.Story.svelte @@ -7,6 +7,6 @@ on:click={() => { console.log('click'); }} - on:animationend={e => { + on:animationend={(e) => { console.log('animation end', e.animationName); }} /> diff --git a/src/DataTable/DataTable.Story.svelte b/src/DataTable/DataTable.Story.svelte index af5f75a7..3427a9a1 100644 --- a/src/DataTable/DataTable.Story.svelte +++ b/src/DataTable/DataTable.Story.svelte @@ -18,7 +18,7 @@ port: 3000, rule: "Round robin", attached_groups: "Kevins VM Groups", - status: "Disabled" + status: "Disabled", }, { id: "b", @@ -27,7 +27,7 @@ port: 443, rule: "Round robin", attached_groups: "Maureens VM Groups", - status: "Starting" + status: "Starting", }, { id: "c", @@ -36,7 +36,7 @@ port: 80, rule: "DNS delegation", attached_groups: "Andrews VM Groups", - status: "Active" + status: "Active", }, { id: "d", @@ -45,7 +45,7 @@ port: 3000, rule: "Round robin", attached_groups: "Marcs VM Groups", - status: "Disabled" + status: "Disabled", }, { id: "e", @@ -54,7 +54,7 @@ port: 443, rule: "Round robin", attached_groups: "Mels VM Groups", - status: "Starting" + status: "Starting", }, { id: "f", @@ -63,8 +63,8 @@ port: 80, rule: "DNS delegation", attached_groups: "Ronjas VM Groups", - status: "Active" - } + status: "Active", + }, ]; const headers = [ { key: "name", value: "Name" }, @@ -72,7 +72,7 @@ { key: "port", value: "Port" }, { key: "rule", value: "Rule" }, { key: "attached_groups", value: "Attached Groups" }, - { key: "status", value: "Status" } + { key: "status", value: "Status" }, ]; $: sortable = true; diff --git a/src/Dropdown/Dropdown.Story.svelte b/src/Dropdown/Dropdown.Story.svelte index cdadcd22..26bcb5c6 100644 --- a/src/Dropdown/Dropdown.Story.svelte +++ b/src/Dropdown/Dropdown.Story.svelte @@ -9,7 +9,7 @@ { id: "option-0", text: "Option 1" }, { id: "option-1", text: "Option 2" }, { id: "option-2", text: "Option 3" }, - { id: "option-3", text: "Option 4" } + { id: "option-3", text: "Option 4" }, ]; $: selectedIndex = -1; diff --git a/src/Form/Form.Story.svelte b/src/Form/Form.Story.svelte index 7bd5b2f3..80617730 100644 --- a/src/Form/Form.Story.svelte +++ b/src/Form/Form.Story.svelte @@ -15,7 +15,7 @@