Skip to content

chore: configure knip #13016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/svelte/knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": [
"src/*/index.js",
"src/index-client.ts",
"src/index-server.ts",
"src/index.d.ts",
"tests/**/*.js",
"tests/**/*.ts",
"!tests/**/*.svelte",
"!tests/**/*.svelte.js",
"!tests/**/_output",
"!tests/runtime-browser/driver.js",
"!tests/runtime-browser/driver-ssr.js",
"!tests/types/component.ts"
],
"project": ["src/**"]
}
4 changes: 0 additions & 4 deletions packages/svelte/messages/client-errors/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,3 @@
## state_unsafe_mutation

> Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`

## svelte_component_invalid_this_value

> The `this={...}` property of a `<svelte:component>` must be a Svelte component, if defined
4 changes: 0 additions & 4 deletions packages/svelte/messages/compile-errors/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ HTML restricts where certain elements can appear. In case of a violation the bro

> `<svelte:fragment>` must be the direct child of a component

## svelte_fragment_invalid_slot

> `<svelte:fragment>` slot attribute must have a static value

## svelte_head_illegal_attribute

> `<svelte:head>` cannot have attributes nor directives
Expand Down
4 changes: 0 additions & 4 deletions packages/svelte/messages/compile-warnings/script.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## derived_iife

> Use `$derived.by(() => {...})` instead of `$derived((() => {...})())`

## export_let_unused

> Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`
Expand Down
20 changes: 6 additions & 14 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-virtual": "^3.0.2",
"@types/aria-query": "^5.0.4",
"@types/node": "^20.11.5",
"dts-buddy": "^0.5.1",
"esbuild": "^0.19.11",
"eslint": "^9.6.0",
"prettier": "^3.2.4",
"rollup": "^4.9.5",
"source-map": "^0.7.4",
"tiny-glob": "^0.2.9"
"tiny-glob": "^0.2.9",
"typescript": "^5.5.2",
"vitest": "^1.2.1"
},
"dependencies": {
"@ampproject/remapping": "^2.2.1",
Expand All @@ -144,18 +149,5 @@
"locate-character": "^3.0.0",
"magic-string": "^0.30.5",
"zimmerframe": "^1.1.2"
},
"knip": {
"entry": [
"src/*/index.js",
"src/index-client.ts",
"src/index-server.ts",
"src/index.d.ts",
"tests/**/*.js",
"tests/**/*.ts"
],
"project": [
"src/**"
]
}
}
9 changes: 0 additions & 9 deletions packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1246,15 +1246,6 @@ export function svelte_fragment_invalid_placement(node) {
e(node, "svelte_fragment_invalid_placement", "`<svelte:fragment>` must be the direct child of a component");
}

/**
* `<svelte:fragment>` slot attribute must have a static value
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function svelte_fragment_invalid_slot(node) {
e(node, "svelte_fragment_invalid_slot", "`<svelte:fragment>` slot attribute must have a static value");
}

/**
* `<svelte:head>` cannot have attributes nor directives
* @param {null | number | NodeLike} node
Expand Down
9 changes: 0 additions & 9 deletions packages/svelte/src/compiler/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const codes = [
"options_removed_hydratable",
"options_removed_loop_guard_timeout",
"options_renamed_ssr_dom",
"derived_iife",
"export_let_unused",
"legacy_component_creation",
"non_reactive_update",
Expand Down Expand Up @@ -574,14 +573,6 @@ export function options_renamed_ssr_dom(node) {
w(node, "options_renamed_ssr_dom", "`generate: \"dom\"` and `generate: \"ssr\"` options have been renamed to \"client\" and \"server\" respectively");
}

/**
* Use `$derived.by(() => {...})` instead of `$derived((() => {...})())`
* @param {null | NodeLike} node
*/
export function derived_iife(node) {
w(node, "derived_iife", "Use `$derived.by(() => {...})` instead of `$derived((() => {...})())`");
}

/**
* Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`
* @param {null | NodeLike} node
Expand Down
16 changes: 0 additions & 16 deletions packages/svelte/src/internal/client/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,4 @@ export function state_unsafe_mutation() {
// TODO print a link to the documentation
throw new Error("state_unsafe_mutation");
}
}

/**
* The `this={...}` property of a `<svelte:component>` must be a Svelte component, if defined
* @returns {never}
*/
export function svelte_component_invalid_this_value() {
if (DEV) {
const error = new Error(`svelte_component_invalid_this_value\nThe \`this={...}\` property of a \`<svelte:component>\` must be a Svelte component, if defined`);

error.name = 'Svelte error';
throw error;
} else {
// TODO print a link to the documentation
throw new Error("svelte_component_invalid_this_value");
}
}
34 changes: 0 additions & 34 deletions packages/svelte/tests/sourcemaps/samples/markup/test.js

This file was deleted.

This file was deleted.

This file was deleted.

41 changes: 0 additions & 41 deletions packages/svelte/tests/sourcemaps/samples/sourcemap-names/test.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/svelte/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"strict": true,
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably the bigger change than moving the knip config. but i guess its fine because svelte itself does not consume libs in a way we would gain something from these checks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I'm seeing some annoying errors due to some type changes in a dependency that are totally irrelevant to us and to Svelte consumers. I don't see much value in checking libs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't really do this, we won't be able to catch errors in our own d.ts files from now on. The alternative is to turn all our d.ts files into ts files which will be type checked

"paths": {
"acorn-typescript": ["./src/compiler/phases/1-parse/ambient.d.ts"],
"svelte": ["./src/index.d.ts"],
Expand Down
Loading
Loading