From d887962dc6f198997a5b45e3166bb4f2ca5b06c6 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:43:09 -0700 Subject: [PATCH] chore: prefer const (#721) --- .eslintrc.js | 1 + packages/e2e-tests/e2e-server.js | 4 ++-- .../src/components/partial-hmr/ModuleContext.svelte | 4 ++-- .../e2e-tests/prebundle-svelte-deps/src/App.svelte | 2 +- packages/e2e-tests/preprocess-with-vite/src/Foo.svelte | 2 +- packages/e2e-tests/ts-type-import/src/App.svelte | 2 +- .../e2e-tests/vite-ssr-esm/src/components/Foo.svelte | 2 +- packages/e2e-tests/vite-ssr/src/components/Foo.svelte | 2 +- .../playground/optimizedeps-include/vite.config.js | 10 +--------- packages/vite-plugin-svelte/src/types/compile.d.ts | 4 ++-- 10 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cc56e840b..401fd32ec 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -57,6 +57,7 @@ module.exports = { 'n/no-unpublished-import': 'off', 'n/no-unpublished-require': 'off', 'no-process-exit': 'off', + 'prefer-const': ['error', { destructuring: 'all' }], quotes: ['error', 'single', { avoidEscape: true }], 'unicorn/prefer-node-protocol': 'error' }, diff --git a/packages/e2e-tests/e2e-server.js b/packages/e2e-tests/e2e-server.js index 67aa96ad5..46c4b516f 100644 --- a/packages/e2e-tests/e2e-server.js +++ b/packages/e2e-tests/e2e-server.js @@ -79,8 +79,8 @@ export async function serve(root, isBuild, port) { if (isBuild) { let buildResult; let hasErr = false; - let out = []; - let err = []; + const out = []; + const err = []; try { const buildProcess = execa('pnpm', ['build'], { diff --git a/packages/e2e-tests/hmr/src/components/partial-hmr/ModuleContext.svelte b/packages/e2e-tests/hmr/src/components/partial-hmr/ModuleContext.svelte index 74d037761..7a9c07442 100644 --- a/packages/e2e-tests/hmr/src/components/partial-hmr/ModuleContext.svelte +++ b/packages/e2e-tests/hmr/src/components/partial-hmr/ModuleContext.svelte @@ -1,10 +1,10 @@
diff --git a/packages/e2e-tests/prebundle-svelte-deps/src/App.svelte b/packages/e2e-tests/prebundle-svelte-deps/src/App.svelte index 244e460bc..93b620e67 100644 --- a/packages/e2e-tests/prebundle-svelte-deps/src/App.svelte +++ b/packages/e2e-tests/prebundle-svelte-deps/src/App.svelte @@ -6,7 +6,7 @@ import { setSomeContext } from 'e2e-test-dep-svelte-api-only'; import { getContext } from 'svelte'; setSomeContext(); - let apiOnlyLoaded = !!getContext('svelte-api-only'); + const apiOnlyLoaded = !!getContext('svelte-api-only');diff --git a/packages/e2e-tests/preprocess-with-vite/src/Foo.svelte b/packages/e2e-tests/preprocess-with-vite/src/Foo.svelte index f3fe3a3c3..e9866f9a2 100644 --- a/packages/e2e-tests/preprocess-with-vite/src/Foo.svelte +++ b/packages/e2e-tests/preprocess-with-vite/src/Foo.svelte @@ -1,5 +1,5 @@ Hello {s}diff --git a/packages/e2e-tests/vite-ssr-esm/src/components/Foo.svelte b/packages/e2e-tests/vite-ssr-esm/src/components/Foo.svelte index b4d22df46..a7d0e54c3 100644 --- a/packages/e2e-tests/vite-ssr-esm/src/components/Foo.svelte +++ b/packages/e2e-tests/vite-ssr-esm/src/components/Foo.svelte @@ -1,5 +1,5 @@Foo bar={bar}diff --git a/packages/e2e-tests/vite-ssr/src/components/Foo.svelte b/packages/e2e-tests/vite-ssr/src/components/Foo.svelte index b4d22df46..a7d0e54c3 100644 --- a/packages/e2e-tests/vite-ssr/src/components/Foo.svelte +++ b/packages/e2e-tests/vite-ssr/src/components/Foo.svelte @@ -1,5 +1,5 @@Foo bar={bar}diff --git a/packages/playground/optimizedeps-include/vite.config.js b/packages/playground/optimizedeps-include/vite.config.js index 75a5d5281..42692c704 100644 --- a/packages/playground/optimizedeps-include/vite.config.js +++ b/packages/playground/optimizedeps-include/vite.config.js @@ -1,14 +1,6 @@ import { defineConfig } from 'vite'; import { svelte } from '@sveltejs/vite-plugin-svelte'; -const SVELTE_IMPORTS = [ - 'svelte/animate', - 'svelte/easing', - 'svelte/internal', - 'svelte/motion', - 'svelte/store', - 'svelte/transition', - 'svelte' -]; + export default defineConfig(({ command, mode }) => { const isProduction = mode === 'production'; return { diff --git a/packages/vite-plugin-svelte/src/types/compile.d.ts b/packages/vite-plugin-svelte/src/types/compile.d.ts index a83552ae2..64d3e04e8 100644 --- a/packages/vite-plugin-svelte/src/types/compile.d.ts +++ b/packages/vite-plugin-svelte/src/types/compile.d.ts @@ -19,7 +19,7 @@ export interface Compiled { css: Code; ast: any; // TODO type warnings: any[]; // TODO type - vars: { + vars: Array<{ name: string; export_name: string; injected: boolean; @@ -29,7 +29,7 @@ export interface Compiled { referenced: boolean; writable: boolean; referenced_from_script: boolean; - }[]; + }>; stats: { timings: { total: number;