From b13d331f78ceef9987cdedd60ad86904b5b296b8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 12 Aug 2024 15:53:29 -0400 Subject: [PATCH] chore: remove stuff identified by knip as unused (#12815) * chore: remove stuff identified by knip as unused * need to continue exporting Parser, it is referenced as a type --- packages/svelte/package.json | 4 ++- .../templates/compile-errors.js | 2 +- .../templates/compile-warnings.js | 2 +- packages/svelte/src/compiler/errors.js | 2 +- .../client/visitors/AssignmentExpression.js | 2 +- packages/svelte/src/compiler/utils/assert.js | 9 ------ packages/svelte/src/compiler/warnings.js | 2 +- .../internal/client/reactivity/deriveds.js | 7 +---- .../src/internal/client/reactivity/effects.js | 2 +- packages/svelte/src/internal/shared/utils.js | 2 -- packages/svelte/src/reactivity/utils.js | 30 ------------------- packages/svelte/src/utils.js | 4 +-- 12 files changed, 12 insertions(+), 56 deletions(-) diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 57d8fa2f3d..e7dedf022b 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -150,7 +150,9 @@ "src/*/index.js", "src/index-client.ts", "src/index-server.ts", - "src/index.d.ts" + "src/index.d.ts", + "tests/**/*.js", + "tests/**/*.ts" ], "project": [ "src/**" diff --git a/packages/svelte/scripts/process-messages/templates/compile-errors.js b/packages/svelte/scripts/process-messages/templates/compile-errors.js index 349e0b38ef..a407699e1b 100644 --- a/packages/svelte/scripts/process-messages/templates/compile-errors.js +++ b/packages/svelte/scripts/process-messages/templates/compile-errors.js @@ -2,7 +2,7 @@ import { CompileDiagnostic } from './utils/compile_diagnostic.js'; /** @typedef {{ start?: number, end?: number }} NodeLike */ -export class InternalCompileError extends CompileDiagnostic { +class InternalCompileError extends CompileDiagnostic { name = 'CompileError'; /** diff --git a/packages/svelte/scripts/process-messages/templates/compile-warnings.js b/packages/svelte/scripts/process-messages/templates/compile-warnings.js index e0de722e80..8300d803d5 100644 --- a/packages/svelte/scripts/process-messages/templates/compile-warnings.js +++ b/packages/svelte/scripts/process-messages/templates/compile-warnings.js @@ -3,7 +3,7 @@ import { CompileDiagnostic } from './utils/compile_diagnostic.js'; /** @typedef {{ start?: number, end?: number }} NodeLike */ -export class InternalCompileWarning extends CompileDiagnostic { +class InternalCompileWarning extends CompileDiagnostic { name = 'CompileWarning'; /** diff --git a/packages/svelte/src/compiler/errors.js b/packages/svelte/src/compiler/errors.js index 3892e688e4..c6c388fd3f 100644 --- a/packages/svelte/src/compiler/errors.js +++ b/packages/svelte/src/compiler/errors.js @@ -3,7 +3,7 @@ import { CompileDiagnostic } from './utils/compile_diagnostic.js'; /** @typedef {{ start?: number, end?: number }} NodeLike */ -export class InternalCompileError extends CompileDiagnostic { +class InternalCompileError extends CompileDiagnostic { name = 'CompileError'; /** diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js index bdc144fe32..6636b82a20 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js @@ -21,7 +21,7 @@ export function AssignmentExpression(node, context) { * @param {Context} context * @returns {Expression | null} */ -export function build_assignment(operator, left, right, context) { +function build_assignment(operator, left, right, context) { // Handle class private/public state assignment cases if ( context.state.analysis.runes && diff --git a/packages/svelte/src/compiler/utils/assert.js b/packages/svelte/src/compiler/utils/assert.js index b6dc6bf90c..6434e4d3e6 100644 --- a/packages/svelte/src/compiler/utils/assert.js +++ b/packages/svelte/src/compiler/utils/assert.js @@ -1,12 +1,3 @@ -/** - * @template T - * @param {T} value - * @returns {asserts value is NonNullable} - */ -export function ok(value) { - if (!value) throw new Error('Assertion failed'); -} - /** * @template T * @param {any} actual diff --git a/packages/svelte/src/compiler/warnings.js b/packages/svelte/src/compiler/warnings.js index 9a2628068b..0aab91b540 100644 --- a/packages/svelte/src/compiler/warnings.js +++ b/packages/svelte/src/compiler/warnings.js @@ -10,7 +10,7 @@ import { import { CompileDiagnostic } from './utils/compile_diagnostic.js'; /** @typedef {{ start?: number, end?: number }} NodeLike */ -export class InternalCompileWarning extends CompileDiagnostic { +class InternalCompileWarning extends CompileDiagnostic { name = 'CompileWarning'; /** diff --git a/packages/svelte/src/internal/client/reactivity/deriveds.js b/packages/svelte/src/internal/client/reactivity/deriveds.js index 2063b96cb0..6ec5946070 100644 --- a/packages/svelte/src/internal/client/reactivity/deriveds.js +++ b/packages/svelte/src/internal/client/reactivity/deriveds.js @@ -14,8 +14,6 @@ import { import { equals, safe_equals } from './equality.js'; import * as e from '../errors.js'; -export let updating_derived = false; - /** * @template V * @param {() => V} fn @@ -101,11 +99,8 @@ export function update_derived(derived) { stack.push(derived); } - var previous_updating_derived = updating_derived; - updating_derived = true; destroy_derived_children(derived); var value = update_reaction(derived); - updating_derived = previous_updating_derived; if (DEV) { stack.pop(); @@ -128,7 +123,7 @@ export function update_derived(derived) { * @param {Derived} signal * @returns {void} */ -export function destroy_derived(signal) { +function destroy_derived(signal) { destroy_derived_children(signal); remove_reactions(signal, 0); set_signal_status(signal, DESTROYED); diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index d05243bb14..c5be02466e 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -61,7 +61,7 @@ export function validate_effect(rune) { * @param {Effect} effect * @param {Reaction} parent_effect */ -export function push_effect(effect, parent_effect) { +function push_effect(effect, parent_effect) { var parent_last = parent_effect.last; if (parent_last === null) { parent_effect.last = parent_effect.first = effect; diff --git a/packages/svelte/src/internal/shared/utils.js b/packages/svelte/src/internal/shared/utils.js index f32af747a4..c2f0b24c11 100644 --- a/packages/svelte/src/internal/shared/utils.js +++ b/packages/svelte/src/internal/shared/utils.js @@ -3,9 +3,7 @@ export var is_array = Array.isArray; export var array_from = Array.from; export var object_keys = Object.keys; -export var object_assign = Object.assign; export var is_frozen = Object.isFrozen; -export var object_freeze = Object.freeze; export var define_property = Object.defineProperty; export var get_descriptor = Object.getOwnPropertyDescriptor; export var get_descriptors = Object.getOwnPropertyDescriptors; diff --git a/packages/svelte/src/reactivity/utils.js b/packages/svelte/src/reactivity/utils.js index 355a000e9d..cd55e0e0ba 100644 --- a/packages/svelte/src/reactivity/utils.js +++ b/packages/svelte/src/reactivity/utils.js @@ -1,36 +1,6 @@ /** @import { Source } from '#client' */ import { set } from '../internal/client/reactivity/sources.js'; -/** - * @template T - * @template U - * @param {Iterable} iterable - * @param {(value: T) => U} fn - * @param {string} name - * @returns {IterableIterator} - */ -export function map(iterable, fn, name) { - return { - [Symbol.iterator]: get_this, - next() { - for (const value of iterable) { - return { done: false, value: fn(value) }; - } - - return { done: true, value: undefined }; - }, - // @ts-expect-error - get [Symbol.toStringTag]() { - return name; - } - }; -} - -/** @this {any} */ -function get_this() { - return this; -} - /** @param {Source} source */ export function increment(source) { set(source, source.v + 1); diff --git a/packages/svelte/src/utils.js b/packages/svelte/src/utils.js index f5a523f107..0cf50bd774 100644 --- a/packages/svelte/src/utils.js +++ b/packages/svelte/src/utils.js @@ -107,7 +107,7 @@ export function is_capture_event(name) { } /** List of Element events that will be delegated */ -export const DELEGATED_EVENTS = [ +const DELEGATED_EVENTS = [ 'beforeinput', 'click', 'change', @@ -144,7 +144,7 @@ export function is_delegated(event_name) { /** * Attributes that are boolean, i.e. they are present or not present. */ -export const DOM_BOOLEAN_ATTRIBUTES = [ +const DOM_BOOLEAN_ATTRIBUTES = [ 'allowfullscreen', 'async', 'autofocus',