chore: add prettier to format definitions/svelte files

This commit is contained in:
Eric Liu 2020-08-11 06:21:06 -07:00
commit 25e437b746
11 changed files with 38 additions and 23 deletions

View file

@ -10,6 +10,7 @@
"scripts": { "scripts": {
"start": "start-storybook -p 9090", "start": "start-storybook -p 9090",
"build": "build-storybook", "build": "build-storybook",
"prettier": "prettier --write './**/*.svelte'",
"prepack": "rollup -c" "prepack": "rollup -c"
}, },
"sideEffects": false, "sideEffects": false,
@ -29,6 +30,8 @@
"@tsconfig/svelte": "^1.0.8", "@tsconfig/svelte": "^1.0.8",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"comment-parser": "^0.7.5", "comment-parser": "^0.7.5",
"prettier": "^2.0.5",
"prettier-plugin-svelte": "^1.1.0",
"rollup": "^2.22.1", "rollup": "^2.22.1",
"rollup-plugin-svelte": "^5.2.3", "rollup-plugin-svelte": "^5.2.3",
"rollup-plugin-terser": "^6.1.0", "rollup-plugin-terser": "^6.1.0",

View file

@ -5,6 +5,7 @@ const svelte = require("rollup-plugin-svelte");
const resolve = require("@rollup/plugin-node-resolve").default; const resolve = require("@rollup/plugin-node-resolve").default;
const commonjs = require("@rollup/plugin-commonjs"); const commonjs = require("@rollup/plugin-commonjs");
const path = require("path"); const path = require("path");
const prettier = require("prettier");
const { parseComponent } = require("./parse-component"); const { parseComponent } = require("./parse-component");
async function generateDocs() { async function generateDocs() {
@ -43,10 +44,7 @@ class CarbonSvelteBase {
const moduleName = name.replace(/\./g, ""); const moduleName = name.replace(/\./g, "");
if (ext === ".svelte" && components.has(moduleName)) { if (ext === ".svelte" && components.has(moduleName)) {
const group = dir const group = dir.split("src/").pop().split("/")[0];
.split("src/")
.pop()
.split("/")[0];
if (groups.has(group)) { if (groups.has(group)) {
groups.set(group, [...groups.get(group), moduleName]); 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(); generateDocs();

View file

@ -9,14 +9,14 @@
indeterminate, indeterminate,
disabled, disabled,
hideLabel, hideLabel,
wrapperClassName wrapperClassName,
} = $$props; } = $$props;
const checkboxProps = { const checkboxProps = {
labelText, labelText,
indeterminate, indeterminate,
disabled, disabled,
hideLabel, hideLabel,
wrapperClassName wrapperClassName,
}; };
let checked = true; let checked = true;

View file

@ -7,6 +7,6 @@
on:click={() => { on:click={() => {
console.log('click'); console.log('click');
}} }}
on:animationend={e => { on:animationend={(e) => {
console.log('animation end', e.animationName); console.log('animation end', e.animationName);
}} /> }} />

View file

@ -18,7 +18,7 @@
port: 3000, port: 3000,
rule: "Round robin", rule: "Round robin",
attached_groups: "Kevins VM Groups", attached_groups: "Kevins VM Groups",
status: "Disabled" status: "Disabled",
}, },
{ {
id: "b", id: "b",
@ -27,7 +27,7 @@
port: 443, port: 443,
rule: "Round robin", rule: "Round robin",
attached_groups: "Maureens VM Groups", attached_groups: "Maureens VM Groups",
status: "Starting" status: "Starting",
}, },
{ {
id: "c", id: "c",
@ -36,7 +36,7 @@
port: 80, port: 80,
rule: "DNS delegation", rule: "DNS delegation",
attached_groups: "Andrews VM Groups", attached_groups: "Andrews VM Groups",
status: "Active" status: "Active",
}, },
{ {
id: "d", id: "d",
@ -45,7 +45,7 @@
port: 3000, port: 3000,
rule: "Round robin", rule: "Round robin",
attached_groups: "Marcs VM Groups", attached_groups: "Marcs VM Groups",
status: "Disabled" status: "Disabled",
}, },
{ {
id: "e", id: "e",
@ -54,7 +54,7 @@
port: 443, port: 443,
rule: "Round robin", rule: "Round robin",
attached_groups: "Mels VM Groups", attached_groups: "Mels VM Groups",
status: "Starting" status: "Starting",
}, },
{ {
id: "f", id: "f",
@ -63,8 +63,8 @@
port: 80, port: 80,
rule: "DNS delegation", rule: "DNS delegation",
attached_groups: "Ronjas VM Groups", attached_groups: "Ronjas VM Groups",
status: "Active" status: "Active",
} },
]; ];
const headers = [ const headers = [
{ key: "name", value: "Name" }, { key: "name", value: "Name" },
@ -72,7 +72,7 @@
{ key: "port", value: "Port" }, { key: "port", value: "Port" },
{ key: "rule", value: "Rule" }, { key: "rule", value: "Rule" },
{ key: "attached_groups", value: "Attached Groups" }, { key: "attached_groups", value: "Attached Groups" },
{ key: "status", value: "Status" } { key: "status", value: "Status" },
]; ];
$: sortable = true; $: sortable = true;
</script> </script>

View file

@ -9,7 +9,7 @@
{ id: "option-0", text: "Option 1" }, { id: "option-0", text: "Option 1" },
{ id: "option-1", text: "Option 2" }, { id: "option-1", text: "Option 2" },
{ id: "option-2", text: "Option 3" }, { id: "option-2", text: "Option 3" },
{ id: "option-3", text: "Option 4" } { id: "option-3", text: "Option 4" },
]; ];
$: selectedIndex = -1; $: selectedIndex = -1;
</script> </script>

View file

@ -15,7 +15,7 @@
</script> </script>
<Form <Form
on:submit={event => { on:submit={(event) => {
console.log('on:submit', event); console.log('on:submit', event);
}}> }}>
<FormGroup {...$$props}> <FormGroup {...$$props}>

View file

@ -12,8 +12,8 @@
{ {
id: "option-4", id: "option-4",
text: text:
"An example option that is really long to show what should be done to handle long text" "An example option that is really long to show what should be done to handle long text",
} },
]; ];
</script> </script>

View file

@ -25,9 +25,9 @@
setContext("StructuredListWrapper", { setContext("StructuredListWrapper", {
selectedValue, selectedValue,
update: value => { update: (value) => {
selectedValue.set(value); selectedValue.set(value);
} },
}); });
$: selected = $selectedValue; $: selected = $selectedValue;

View file

@ -11,7 +11,7 @@
const radioTiles = [ const radioTiles = [
{ value: "standard", id: "tile-1", labelText: "Selectable Tile" }, { value: "standard", id: "tile-1", labelText: "Selectable Tile" },
{ value: "default-selected", id: "tile-2", labelText: "Selectable Tile" }, { value: "default-selected", id: "tile-2", labelText: "Selectable Tile" },
{ value: "selected", id: "tile-3", labelText: "Selectable Tile" } { value: "selected", id: "tile-3", labelText: "Selectable Tile" },
]; ];
$: selected = radioTiles[1].value; $: selected = radioTiles[1].value;

View file

@ -8039,11 +8039,21 @@ prepend-http@^2.0.0:
resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
prettier-plugin-svelte@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-1.1.0.tgz#e6ec282d8457598b0c02164083b11ad8cb8ab304"
integrity sha512-wmIggG/ryV0wcmE9D5p+k5TwKDpS2SGKJpF6IV1aYHK7dkBJD+di1w47Ci00DRsI4RrXZRC2Ef37DSyrTb6Zqg==
prettier@^1.16.4: prettier@^1.16.4:
version "1.19.1" version "1.19.1"
resolved "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" resolved "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@^2.0.5:
version "2.0.5"
resolved "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
pretty-error@^2.1.1: pretty-error@^2.1.1:
version "2.1.1" version "2.1.1"
resolved "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3" resolved "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"