Skip to content

Commit

Permalink
chore: remove stuff identified by knip as unused (#12815)
Browse files Browse the repository at this point in the history
* chore: remove stuff identified by knip as unused

* need to continue exporting Parser, it is referenced as a type
  • Loading branch information
Rich-Harris committed Aug 12, 2024
1 parent dfb6755 commit b13d331
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 56 deletions.
4 changes: 3 additions & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
9 changes: 0 additions & 9 deletions packages/svelte/src/compiler/utils/assert.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/**
* @template T
* @param {T} value
* @returns {asserts value is NonNullable<T>}
*/
export function ok(value) {
if (!value) throw new Error('Assertion failed');
}

/**
* @template T
* @param {any} actual
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
7 changes: 1 addition & 6 deletions packages/svelte/src/internal/client/reactivity/deriveds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/reactivity/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions packages/svelte/src/internal/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 0 additions & 30 deletions packages/svelte/src/reactivity/utils.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
/** @import { Source } from '#client' */
import { set } from '../internal/client/reactivity/sources.js';

/**
* @template T
* @template U
* @param {Iterable<T>} iterable
* @param {(value: T) => U} fn
* @param {string} name
* @returns {IterableIterator<U>}
*/
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<number>} source */
export function increment(source) {
set(source, source.v + 1);
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit b13d331

Please sign in to comment.