From 3fd1e3c75c8076d4c6fb8f981ab4b6ff7d75f3c5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 20 Dec 2018 16:48:53 -0500 Subject: [PATCH] various --- site/.eslintrc.json | 45 +++++ site/content/examples/line-chart/App.html | 4 +- site/package-lock.json | 5 + site/package.json | 1 + .../repl/_components/AppControls/index.html | 3 +- .../routes/repl/_components/CodeMirror.html | 2 +- .../_components/Input/ComponentSelector.html | 49 ++--- .../repl/_components/Input/ModuleEditor.html | 2 +- .../routes/repl/_components/Input/index.html | 20 +- .../repl/_components/Output/PropEditor.html | 38 ++-- .../repl/_components/Output/Viewer.html | 42 ++--- .../routes/repl/_components/Output/index.html | 57 +++--- site/src/routes/repl/_components/Repl.html | 173 +++++++++--------- site/src/routes/repl/index.html | 82 +++++---- .../{repl-worker.js => workers/bundler.js} | 72 ++------ site/static/workers/compiler.js | 41 +++++ 16 files changed, 339 insertions(+), 297 deletions(-) create mode 100644 site/.eslintrc.json rename site/static/{repl-worker.js => workers/bundler.js} (75%) create mode 100644 site/static/workers/compiler.js diff --git a/site/.eslintrc.json b/site/.eslintrc.json new file mode 100644 index 0000000000..cb0d06a2ec --- /dev/null +++ b/site/.eslintrc.json @@ -0,0 +1,45 @@ +{ + "root": true, + "rules": { + "indent": [2, "tab", { "SwitchCase": 1 }], + "semi": [2, "always"], + "keyword-spacing": [2, { "before": true, "after": true }], + "space-before-blocks": [2, "always"], + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + "no-cond-assign": 0, + "no-unused-vars": 2, + "object-shorthand": [2, "always"], + "no-const-assign": 2, + "no-class-assign": 2, + "no-this-before-super": 2, + "no-var": 2, + "no-unreachable": 2, + "valid-typeof": 2, + "quote-props": [2, "as-needed"], + "one-var": [2, "never"], + "prefer-arrow-callback": 2, + "prefer-const": [2, { "destructuring": "all" }], + "arrow-spacing": 2, + "no-inner-declarations": 0 + }, + "env": { + "es6": true, + "browser": true, + "node": true, + "mocha": true + }, + "extends": [ + "eslint:recommended", + "plugin:import/errors", + "plugin:import/warnings" + ], + "plugins": ["svelte3"], + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "settings": { + "import/core-modules": ["svelte"], + "svelte3/extensions": [".html"] + } +} diff --git a/site/content/examples/line-chart/App.html b/site/content/examples/line-chart/App.html index d5d83ec49c..41881f8a8f 100644 --- a/site/content/examples/line-chart/App.html +++ b/site/content/examples/line-chart/App.html @@ -23,7 +23,7 @@ .domain([minX, maxX]) .range([padding.left, width - padding.right]); - $: yScale = scaleLinear + $: yScale = scaleLinear() .domain([Math.min.apply(null, yTicks), Math.max.apply(null, yTicks)]) .range([height - padding.bottom, padding.top]); @@ -50,7 +50,7 @@

Arctic sea ice minimum

- + {#each yTicks as tick} diff --git a/site/package-lock.json b/site/package-lock.json index 71ff3c1df7..6775b8ee6b 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -1423,6 +1423,11 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "eslint-plugin-svelte3": { + "version": "git+https://github.com/sveltejs/eslint-plugin-svelte3.git#d4da8a7d98f2efa70266313ab798cd4d400ca86c", + "from": "git+https://github.com/sveltejs/eslint-plugin-svelte3.git", + "dev": true + }, "estree-walker": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", diff --git a/site/package.json b/site/package.json index f266d261f8..520e325105 100644 --- a/site/package.json +++ b/site/package.json @@ -29,6 +29,7 @@ "@babel/preset-env": "^7.0.0", "@babel/runtime": "^7.0.0", "chokidar": "^2.0.4", + "eslint-plugin-svelte3": "git+https://github.com/sveltejs/eslint-plugin-svelte3.git", "npm-run-all": "^4.1.5", "rollup": "^0.68.0", "rollup-plugin-babel": "^4.0.2", diff --git a/site/src/routes/repl/_components/AppControls/index.html b/site/src/routes/repl/_components/AppControls/index.html index f8aba63c20..b73f98fb81 100644 --- a/site/src/routes/repl/_components/AppControls/index.html +++ b/site/src/routes/repl/_components/AppControls/index.html @@ -9,11 +9,10 @@ const dispatch = createEventDispatcher(); + export let repl; export let examples; export let gist; export let name; - export let components; - export let json5; export let zen_mode; export let bundle; diff --git a/site/src/routes/repl/_components/CodeMirror.html b/site/src/routes/repl/_components/CodeMirror.html index 7e05948359..32903fecc6 100644 --- a/site/src/routes/repl/_components/CodeMirror.html +++ b/site/src/routes/repl/_components/CodeMirror.html @@ -84,7 +84,7 @@ let previous_error_line; $: if (editor) { if (previous_error_line != null) { - editor.removeLineClass(previousLine, 'wrap', 'error-line') + editor.removeLineClass(previous_error_line, 'wrap', 'error-line') } if (error_line && (error_line !== previous_error_line)) { diff --git a/site/src/routes/repl/_components/Input/ComponentSelector.html b/site/src/routes/repl/_components/Input/ComponentSelector.html index 9d2057ed01..7eeef3dfbb 100644 --- a/site/src/routes/repl/_components/Input/ComponentSelector.html +++ b/site/src/routes/repl/_components/Input/ComponentSelector.html @@ -5,39 +5,29 @@ const dispatch = createEventDispatcher(); - export let components = []; - export let selectedComponent; + export let component_store; + export let selected_store; let editing = null; - // let previous_components; - - // $: { - // // bit of a hack... - // if (components !== previous_components) { - // selectedComponent = components[0]; - // previous_components = components; - // } - // } - - function selectComponent(component, selectedComponent) { - if (selectedComponent != component) { + function selectComponent(component) { + if ($selected_store != component) { editing = null; } - dispatch('select', { component }); + selected_store.set(component); } - function editTab(component, selectedComponent) { - if (selectedComponent === component) { - editing = selectedComponent; + function editTab(component) { + if ($selected_store === component) { + editing = $selected_store; } } - function closeEdit(selectedComponent) { - const match = /(.+)\.(html|js)$/.exec(selectedComponent.name); - selectedComponent.name = match ? match[1] : selectedComponent.name; - if (match && match[2]) selectedComponent.type = match[2]; + function closeEdit() { + const match = /(.+)\.(html|js)$/.exec($selected_store.name); + $selected_store.name = match ? match[1] : $selected_store.name; + if (match && match[2]) $selected_store.type = match[2]; editing = null; components = components; // TODO necessary? @@ -68,11 +58,10 @@ setTimeout(() => { // TODO we can do this without IDs document.getElementById(component.name).scrollIntoView(false); - // selectedComponent = component; }); - dispatch('create', { component }); - dispatch('select', { component }); + component_store.update(components => components.concat(component)); + selected_store.set(component); } @@ -180,12 +169,12 @@
- {#each components as component} + {#each $component_store as component}