Skip to content

Commit 5dd2d3f

Browse files
chore: clean dead code (#13591)
1 parent a3fe86e commit 5dd2d3f

142 files changed

Lines changed: 402 additions & 855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/icy-stars-begin.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@astrojs/cloudflare': patch
3+
'@astrojs/web-vitals': patch
4+
'@astrojs/alpinejs': patch
5+
'@astrojs/markdoc': patch
6+
'@astrojs/netlify': patch
7+
'@astrojs/sitemap': patch
8+
'@astrojs/underscore-redirects': patch
9+
'@astrojs/preact': patch
10+
'@astrojs/vercel': patch
11+
'@astrojs/solid-js': patch
12+
'@astrojs/node': patch
13+
'@astrojs/mdx': patch
14+
'create-astro': patch
15+
'@astrojs/telemetry': patch
16+
'@astrojs/upgrade': patch
17+
'@astrojs/studio': patch
18+
'astro': patch
19+
'@astrojs/db': patch
20+
---
21+
22+
Removes unused code

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ jobs:
9292
run: pnpm install
9393

9494
- name: Build Packages
95-
run: pnpm run build
95+
# The cache doesn't contain prebuild files and causes knip to fail
96+
run: pnpm run build --force
9697

9798
- name: Lint source code
9899
run: pnpm run lint:ci

benchmark/make-project/_template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
/**
23
* Create a new project in the `projectDir` directory. Make sure to clean up the
34
* previous artifacts here before generating files.

biome.jsonc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"noConsoleLog": "warn"
3333
},
3434
"correctness": {
35-
"noUnusedVariables": "info",
36-
"noUnusedFunctionParameters": "info",
37-
"noUnusedImports": "warn"
35+
"noUnusedVariables": "error",
36+
"noUnusedFunctionParameters": "error",
37+
"noUnusedImports": "error"
3838
}
3939
}
4040
},

eslint.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default [
2323
'packages/**/*.min.js',
2424
'packages/**/dist/',
2525
'packages/**/fixtures/',
26+
'packages/**/_temp-fixtures/',
2627
'packages/astro/vendor/vite/',
2728
'benchmark/**/dist/',
2829
'examples/',
@@ -54,7 +55,18 @@ export default [
5455
'no-console': 'off',
5556

5657
// Todo: do we want these?
57-
'@typescript-eslint/no-unused-vars': 'off',
58+
'@typescript-eslint/no-unused-vars': [
59+
'error',
60+
{
61+
args: 'all',
62+
argsIgnorePattern: '^_',
63+
caughtErrors: 'all',
64+
caughtErrorsIgnorePattern: '^_',
65+
destructuredArrayIgnorePattern: '^_',
66+
varsIgnorePattern: '^_',
67+
ignoreRestSiblings: true,
68+
},
69+
],
5870
'@typescript-eslint/array-type': 'off',
5971
'@typescript-eslint/ban-ts-comment': 'off',
6072
'@typescript-eslint/class-literal-property-style': 'off',

knip.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// @ts-check
2+
const testEntry = 'test/**/*.test.js';
3+
4+
/** @type {import('knip').KnipConfig} */
5+
export default {
6+
ignore: ['**/test/**/{fixtures,_temp-fixtures}/**', '.github/scripts/**'],
7+
tags: ['-lintignore'],
8+
ignoreWorkspaces: [
9+
'examples/**',
10+
'**/{test,e2e}/**/{fixtures,_temp-fixtures}/**',
11+
'benchmark/**',
12+
],
13+
workspaces: {
14+
'.': {
15+
ignoreDependencies: [
16+
'@astrojs/check', // Used by the build script but not as a standard module import
17+
],
18+
// In smoke tests, we checkout to the docs repo so those binaries are not present in this project
19+
ignoreBinaries: ['docgen', 'docgen:errors', 'playwright'],
20+
},
21+
'packages/*': {
22+
entry: [testEntry],
23+
},
24+
'packages/astro': {
25+
entry: [
26+
// Can't be detected automatically since it's only in package.json#files
27+
'templates/**/*',
28+
testEntry,
29+
'test/types/**/*',
30+
'e2e/**/*.test.js',
31+
'test/units/teardown.js',
32+
],
33+
ignore: ['**/e2e/**/{fixtures,_temp-fixtures}/**', 'performance/**/*'],
34+
// Those deps are used in tests but only referenced as strings
35+
ignoreDependencies: [
36+
'rehype-autolink-headings',
37+
'rehype-slug',
38+
'rehype-toc',
39+
'remark-code-titles',
40+
],
41+
},
42+
'packages/integrations/*': {
43+
entry: [testEntry],
44+
},
45+
'packages/integrations/cloudflare': {
46+
entry: [testEntry],
47+
// False positive because of cloudflare:workers
48+
ignoreDependencies: ['cloudflare'],
49+
},
50+
'packages/integrations/mdx': {
51+
entry: [testEntry],
52+
// Required but not imported directly
53+
ignoreDependencies: ['@types/*'],
54+
},
55+
'packages/integrations/netlify': {
56+
entry: [testEntry],
57+
ignore: ['test/hosted/**'],
58+
},
59+
'packages/integrations/solid': {
60+
entry: [testEntry],
61+
// It's an optional peer dep (triggers a warning) but it's fine in this case
62+
ignoreDependencies: ['solid-devtools'],
63+
},
64+
'packages/integrations/vercel': {
65+
entry: [testEntry, 'test/test-image-service.js'],
66+
ignore: ['test/hosted/**'],
67+
},
68+
'packages/markdown/remark': {
69+
entry: [testEntry],
70+
// package.json#imports are not resolved at the moment
71+
ignore: ['src/import-plugin-browser.ts'],
72+
},
73+
'packages/upgrade': {
74+
entry: ['src/index.ts', testEntry],
75+
},
76+
},
77+
};

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
"test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match",
3535
"test:e2e:hosts": "turbo run test:hosted",
3636
"benchmark": "astro-benchmark",
37-
"lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn",
38-
"lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn",
37+
"lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn && knip",
38+
"lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn && knip",
3939
"lint:fix": "biome lint --write --unsafe",
4040
"publint": "pnpm -r --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --no-bail exec publint",
4141
"version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format",
42-
"preinstall": "npx only-allow pnpm"
42+
"preinstall": "npx only-allow pnpm",
43+
"knip": "knip"
4344
},
4445
"workspaces": [
4546
"packages/markdown/*",
@@ -58,10 +59,11 @@
5859
"@biomejs/biome": "1.9.4",
5960
"@changesets/changelog-github": "^0.5.1",
6061
"@changesets/cli": "^2.28.1",
61-
"@types/node": "^18.17.8",
62+
"@types/node": "^18.19.50",
6263
"esbuild": "^0.25.0",
6364
"eslint": "^9.24.0",
6465
"eslint-plugin-regexp": "^2.7.0",
66+
"knip": "5.50.5",
6567
"only-allow": "^1.2.1",
6668
"prettier": "^3.5.3",
6769
"prettier-plugin-astro": "^0.14.1",

packages/astro/e2e/test-utils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import { fileURLToPath } from 'node:url';
44
import { expect, test as testBase } from '@playwright/test';
55
import { loadFixture as baseLoadFixture } from '../test/test-utils.js';
66

7-
export const isWindows = process.platform === 'win32';
8-
9-
export { silentLogging } from '../test/test-utils.js';
10-
117
// Get all test files in directory, assign unique port for each of them so they don't conflict
128
const testFiles = await fs.readdir(new URL('.', import.meta.url));
139
const testFileToPort = new Map();

packages/astro/package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
"./compiler-runtime": "./dist/runtime/compiler/index.js",
4848
"./runtime/*": "./dist/runtime/*",
4949
"./config": "./dist/config/entrypoint.js",
50-
"./container": {
51-
"types": "./dist/container/index.d.ts",
52-
"default": "./dist/container/index.js"
53-
},
50+
"./container": "./dist/container/index.js",
5451
"./app": "./dist/core/app/index.js",
5552
"./app/node": "./dist/core/app/node.js",
5653
"./client/*": "./dist/runtime/client/*",
@@ -76,10 +73,7 @@
7673
"default": "./zod.mjs"
7774
},
7875
"./errors": "./dist/core/errors/userError.js",
79-
"./middleware": {
80-
"types": "./dist/core/middleware/index.d.ts",
81-
"default": "./dist/core/middleware/index.js"
82-
},
76+
"./middleware": "./dist/core/middleware/index.js",
8377
"./virtual-modules/*": "./dist/virtual-modules/*"
8478
},
8579
"bin": {

packages/astro/src/assets/fonts/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const fallbacksSchema = z.object({
6969
optimizedFallbacks: z.boolean().optional(),
7070
});
7171

72-
export const requiredFamilyAttributesSchema = z.object({
72+
const requiredFamilyAttributesSchema = z.object({
7373
/**
7474
* The font family name, as identified by your font provider.
7575
*/

0 commit comments

Comments
 (0)