From 43f82af4a8172efa9a4735d6fd9c8fd41e9943c5 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 5 May 2019 09:25:39 -0400 Subject: [PATCH] some linting and tidying --- easing.mjs | 36 ++--- register.js | 2 +- site/.eslintrc.json | 2 +- site/rollup.config.js | 6 - .../src/components/PreloadingIndicator.svelte | 8 - site/src/components/Repl/ReplWidget.svelte | 2 +- site/src/routes/_error.svelte | 2 +- site/src/routes/docs/_GuideContents.svelte | 140 ------------------ site/src/routes/docs/index.svelte | 2 +- site/src/routes/examples/index.svelte | 32 ++-- site/src/routes/index.svelte | 2 +- .../[id]/_components/AppControls/index.svelte | 5 +- site/src/routes/repl/[id]/index.json.js | 1 - site/src/routes/repl/[id]/index.svelte | 4 +- site/src/service-worker.js | 2 +- site/src/utils/slug.js | 66 ++++----- site/static/repl-runner.js | 26 ++-- src/compile/css/Selector.ts | 4 +- src/compile/css/gather_possible_values.ts | 2 +- src/compile/render-ssr/handlers/Element.ts | 1 + 20 files changed, 94 insertions(+), 251 deletions(-) delete mode 100644 site/src/routes/docs/_GuideContents.svelte diff --git a/easing.mjs b/easing.mjs index 759c1046e5..4fc625c24f 100644 --- a/easing.mjs +++ b/easing.mjs @@ -6,39 +6,39 @@ Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICE export { identity as linear } from './internal'; export function backInOut(t) { - var s = 1.70158 * 1.525; + const s = 1.70158 * 1.525; if ((t *= 2) < 1) return 0.5 * (t * t * ((s + 1) * t - s)); return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2); } export function backIn(t) { - var s = 1.70158; + const s = 1.70158; return t * t * ((s + 1) * t - s); } export function backOut(t) { - var s = 1.70158; + const s = 1.70158; return --t * t * ((s + 1) * t + s) + 1; } export function bounceOut(t) { - var a = 4.0 / 11.0; - var b = 8.0 / 11.0; - var c = 9.0 / 10.0; + const a = 4.0 / 11.0; + const b = 8.0 / 11.0; + const c = 9.0 / 10.0; - var ca = 4356.0 / 361.0; - var cb = 35442.0 / 1805.0; - var cc = 16061.0 / 1805.0; + const ca = 4356.0 / 361.0; + const cb = 35442.0 / 1805.0; + const cc = 16061.0 / 1805.0; - var t2 = t * t; + const t2 = t * t; return t < a ? 7.5625 * t2 : t < b - ? 9.075 * t2 - 9.9 * t + 3.4 - : t < c - ? ca * t2 - cb * t + cc - : 10.8 * t * t - 20.52 * t + 10.72; + ? 9.075 * t2 - 9.9 * t + 3.4 + : t < c + ? ca * t2 - cb * t + cc + : 10.8 * t * t - 20.52 * t + 10.72; } export function bounceInOut(t) { @@ -73,7 +73,7 @@ export function cubicIn(t) { } export function cubicOut(t) { - var f = t - 1.0; + const f = t - 1.0; return f * f * f + 1.0; } @@ -102,8 +102,8 @@ export function expoInOut(t) { return t === 0.0 || t === 1.0 ? t : t < 0.5 - ? +0.5 * Math.pow(2.0, 20.0 * t - 10.0) - : -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0; + ? +0.5 * Math.pow(2.0, 20.0 * t - 10.0) + : -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0; } export function expoIn(t) { @@ -161,7 +161,7 @@ export function sineInOut(t) { } export function sineIn(t) { - var v = Math.cos(t * Math.PI * 0.5); + const v = Math.cos(t * Math.PI * 0.5); if (Math.abs(v) < 1e-14) return 1; else return 1 - v; } diff --git a/register.js b/register.js index 2c0069c241..f5cbeb5063 100644 --- a/register.js +++ b/register.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); const { compile } = require('./compiler.js'); -let extensions = ['.svelte', '.html']; +const extensions = ['.svelte', '.html']; let compileOptions = {}; function capitalise(name) { diff --git a/site/.eslintrc.json b/site/.eslintrc.json index 98a3b0889c..df5e719204 100644 --- a/site/.eslintrc.json +++ b/site/.eslintrc.json @@ -35,7 +35,7 @@ ], "plugins": ["svelte3"], "parserOptions": { - "ecmaVersion": 8, + "ecmaVersion": 9, "sourceType": "module" }, "settings": { diff --git a/site/rollup.config.js b/site/rollup.config.js index 029cf65bcf..c713be33c1 100644 --- a/site/rollup.config.js +++ b/site/rollup.config.js @@ -53,9 +53,6 @@ export default { module: true }) ], - - // temporary, pending Rollup 1.0 - experimentalCodeSplitting: true }, server: { @@ -81,9 +78,6 @@ export default { require('module').builtinModules || Object.keys(process.binding('natives')) ) ], - - // temporary, pending Rollup 1.0 - experimentalCodeSplitting: true }, serviceworker: { diff --git a/site/src/components/PreloadingIndicator.svelte b/site/src/components/PreloadingIndicator.svelte index 43bcf3ab5a..8b88029abb 100644 --- a/site/src/components/PreloadingIndicator.svelte +++ b/site/src/components/PreloadingIndicator.svelte @@ -4,11 +4,7 @@ let p = 0; let visible = false; - const sleep = ms => new Promise(f => setTimeout(f, ms)); - onMount(() => { - let running = true; - function next() { visible = true; p += 0.1; @@ -18,10 +14,6 @@ } setTimeout(next, 250); - - return () => { - running = false; - }; }); diff --git a/site/src/components/Repl/ReplWidget.svelte b/site/src/components/Repl/ReplWidget.svelte index fbdd3622a7..07a5814010 100644 --- a/site/src/components/Repl/ReplWidget.svelte +++ b/site/src/components/Repl/ReplWidget.svelte @@ -29,7 +29,7 @@ if (gist) { fetch(`repl/${gist}.json`).then(r => r.json()).then(data => { - const { id, description, files } = data; + const { description, files } = data; name = description; diff --git a/site/src/routes/_error.svelte b/site/src/routes/_error.svelte index 0071e3cea7..282980a2ad 100644 --- a/site/src/routes/_error.svelte +++ b/site/src/routes/_error.svelte @@ -7,7 +7,7 @@ // we don't want to use here, // because we only care about the online state when // the page first loads - let online = typeof navigator !== 'undefined' + const online = typeof navigator !== 'undefined' ? navigator.onLine : true; diff --git a/site/src/routes/docs/_GuideContents.svelte b/site/src/routes/docs/_GuideContents.svelte deleted file mode 100644 index f5407164e4..0000000000 --- a/site/src/routes/docs/_GuideContents.svelte +++ /dev/null @@ -1,140 +0,0 @@ - - - - - diff --git a/site/src/routes/docs/index.svelte b/site/src/routes/docs/index.svelte index d60347994e..7f6fad92d3 100644 --- a/site/src/routes/docs/index.svelte +++ b/site/src/routes/docs/index.svelte @@ -6,7 +6,7 @@ diff --git a/site/src/routes/examples/index.svelte b/site/src/routes/examples/index.svelte index abeebb0696..a5c816561b 100644 --- a/site/src/routes/examples/index.svelte +++ b/site/src/routes/examples/index.svelte @@ -37,7 +37,7 @@ let offset = 1; let repl; let isLoading = false; - let cache = {}; + const cache = {}; $: title = title_by_slug[active_slug] || ''; $: first_slug = sections[0].examples[0].slug; @@ -50,21 +50,21 @@ } else { isLoading = true; fetch(`examples/${active_slug}.json`) - .then(async response => { - if (response.ok) { - const {files} = await response.json(); - return process_example(files); - } - }) - .then(components => { - cache[active_slug] = components; - repl.set({components}); - offset = 1; - isLoading = false; - }) - .catch(function(error) { - isLoading = false; - }); + .then(async response => { + if (response.ok) { + const {files} = await response.json(); + return process_example(files); + } + }) + .then(components => { + cache[active_slug] = components; + repl.set({components}); + offset = 1; + isLoading = false; + }) + .catch(() => { + isLoading = false; + }); } } diff --git a/site/src/routes/index.svelte b/site/src/routes/index.svelte index b076fe3a0d..539f522b4e 100644 --- a/site/src/routes/index.svelte +++ b/site/src/routes/index.svelte @@ -13,7 +13,7 @@