Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
c6063f2
feat: add knip
florian-lefebvre Apr 9, 2025
bd2ffaa
feat: clean alpine
florian-lefebvre Apr 9, 2025
59e6f4d
feat: cloudflare
florian-lefebvre Apr 9, 2025
093bf2a
chore: remove dependencies
florian-lefebvre Apr 9, 2025
5026fe8
fix: cloudflare
florian-lefebvre Apr 9, 2025
e12c94f
chore: clean markdoc
florian-lefebvre Apr 9, 2025
0d8b509
chore: clean mdx
florian-lefebvre Apr 9, 2025
51a7341
feat: netlify
florian-lefebvre Apr 9, 2025
b3dc03a
feat: node
florian-lefebvre Apr 9, 2025
223a807
feat: partytown
florian-lefebvre Apr 9, 2025
2e1ab57
feat: preact
florian-lefebvre Apr 9, 2025
2f271f7
feat: work on react
florian-lefebvre Apr 9, 2025
de2c739
feat: work on react
florian-lefebvre Apr 9, 2025
07961d5
feat: react
florian-lefebvre Apr 9, 2025
55cb900
feat: sitemap
florian-lefebvre Apr 9, 2025
05ed518
feat: solid
florian-lefebvre Apr 9, 2025
fc334fd
feat: svelte
florian-lefebvre Apr 9, 2025
d6fb557
feat: vercel
florian-lefebvre Apr 9, 2025
5c16133
feat: vue
florian-lefebvre Apr 9, 2025
3d46cad
feat: web vitals
florian-lefebvre Apr 9, 2025
91f5f9b
fix: ignore temp fixtures
florian-lefebvre Apr 9, 2025
b6195a4
feat: work on astro
florian-lefebvre Apr 9, 2025
89633c9
feat: work on astro
florian-lefebvre Apr 9, 2025
58c16a6
feat: work on astro
florian-lefebvre Apr 9, 2025
a18efbc
feat: astro
florian-lefebvre Apr 9, 2025
e10cc74
feat: reduce entry list
florian-lefebvre Apr 9, 2025
e80b220
feat: even better
florian-lefebvre Apr 9, 2025
2cfc75f
chore: upgrade knip
florian-lefebvre Apr 10, 2025
ef2c0cf
fix: astro build
florian-lefebvre Apr 10, 2025
c1cd563
feat: simplify config
florian-lefebvre Apr 10, 2025
adc1565
feat: create-astro
florian-lefebvre Apr 10, 2025
b130d3f
feat: db
florian-lefebvre Apr 10, 2025
c97452f
feat: markdown/remark
florian-lefebvre Apr 10, 2025
4c6f88b
feat: studio
florian-lefebvre Apr 10, 2025
0eb9ab5
feat: last packages
florian-lefebvre Apr 10, 2025
0ba51cb
chore: tweak config
florian-lefebvre Apr 10, 2025
e22e1cd
chore: upgrade knip
florian-lefebvre Apr 10, 2025
b4d2dd1
fix: vue build
florian-lefebvre Apr 10, 2025
a0096d9
fix: build commands
florian-lefebvre Apr 10, 2025
6ad3834
Discard changes to packages/astro/test/units/teardown.js
florian-lefebvre Apr 10, 2025
a682892
fix: config
florian-lefebvre Apr 10, 2025
6726e76
chore: upgrade knip
florian-lefebvre Apr 10, 2025
f66cb3f
feat: improve knip
florian-lefebvre Apr 14, 2025
4c8261b
fix: build
florian-lefebvre Apr 14, 2025
39770ac
chore: shorten
florian-lefebvre Apr 14, 2025
3bb5a0b
fix: test
florian-lefebvre Apr 14, 2025
b96315c
Merge branch 'main' into feat/knip
florian-lefebvre Apr 21, 2025
7bf6087
chore: update knip
florian-lefebvre Apr 21, 2025
38c843b
fix
florian-lefebvre Apr 21, 2025
e498de3
feat: update lint commands
florian-lefebvre Apr 21, 2025
4f8f919
chore: format
florian-lefebvre Apr 21, 2025
ec5cab2
fix: test image service
florian-lefebvre Apr 21, 2025
7c9545a
chore: format
florian-lefebvre Apr 21, 2025
76969fc
fix: test remote image service
florian-lefebvre Apr 21, 2025
24dfbd3
test
florian-lefebvre Apr 21, 2025
a4f840e
test
florian-lefebvre Apr 21, 2025
29f0ad6
test
florian-lefebvre Apr 21, 2025
fd1bc2b
ci fix
florian-lefebvre Apr 21, 2025
612d49f
Merge branch 'main' into feat/knip
florian-lefebvre Apr 22, 2025
ea092db
feat: tsconfig update
florian-lefebvre Apr 22, 2025
64fe201
feat: biome and eslint
florian-lefebvre Apr 22, 2025
10b838f
chore: changeset
florian-lefebvre Apr 22, 2025
2c96607
fix: test
florian-lefebvre Apr 22, 2025
7d3a2cc
feat: config feedback
florian-lefebvre Apr 22, 2025
ca0f378
trigger ci
florian-lefebvre Apr 22, 2025
70aa2e2
Merge branch 'main' into feat/knip
florian-lefebvre Apr 22, 2025
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
22 changes: 22 additions & 0 deletions .changeset/icy-stars-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@astrojs/cloudflare': patch
'@astrojs/web-vitals': patch
'@astrojs/alpinejs': patch
'@astrojs/markdoc': patch
'@astrojs/netlify': patch
'@astrojs/sitemap': patch
'@astrojs/underscore-redirects': patch
'@astrojs/preact': patch
'@astrojs/vercel': patch
'@astrojs/solid-js': patch
'@astrojs/node': patch
'@astrojs/mdx': patch
'create-astro': patch
'@astrojs/telemetry': patch
'@astrojs/upgrade': patch
'@astrojs/studio': patch
'astro': patch
'@astrojs/db': patch
---

Removes unused code
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ jobs:
run: pnpm install

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

- name: Lint source code
run: pnpm run lint:ci
Expand Down
1 change: 1 addition & 0 deletions benchmark/make-project/_template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* Create a new project in the `projectDir` directory. Make sure to clean up the
* previous artifacts here before generating files.
Expand Down
6 changes: 3 additions & 3 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"noConsoleLog": "warn"
},
"correctness": {
"noUnusedVariables": "info",
"noUnusedFunctionParameters": "info",
"noUnusedImports": "warn"
"noUnusedVariables": "error",
"noUnusedFunctionParameters": "error",
"noUnusedImports": "error"
}
}
},
Expand Down
14 changes: 13 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default [
'packages/**/*.min.js',
'packages/**/dist/',
'packages/**/fixtures/',
'packages/**/_temp-fixtures/',
'packages/astro/vendor/vite/',
'benchmark/**/dist/',
'examples/',
Expand Down Expand Up @@ -54,7 +55,18 @@ export default [
'no-console': 'off',

// Todo: do we want these?
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
Expand Down
77 changes: 77 additions & 0 deletions knip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// @ts-check
const testEntry = 'test/**/*.test.js';

/** @type {import('knip').KnipConfig} */
export default {
ignore: ['**/test/**/{fixtures,_temp-fixtures}/**', '.github/scripts/**'],
tags: ['-lintignore'],
ignoreWorkspaces: [
'examples/**',
'**/{test,e2e}/**/{fixtures,_temp-fixtures}/**',
'benchmark/**',
],
workspaces: {
'.': {
ignoreDependencies: [
'@astrojs/check', // Used by the build script but not as a standard module import
],
// In smoke tests, we checkout to the docs repo so those binaries are not present in this project
ignoreBinaries: ['docgen', 'docgen:errors', 'playwright'],
},
'packages/*': {
entry: [testEntry],
},
'packages/astro': {
entry: [
// Can't be detected automatically since it's only in package.json#files
'templates/**/*',
testEntry,
'test/types/**/*',
'e2e/**/*.test.js',
'test/units/teardown.js',
],
ignore: ['**/e2e/**/{fixtures,_temp-fixtures}/**', 'performance/**/*'],
// Those deps are used in tests but only referenced as strings
ignoreDependencies: [
'rehype-autolink-headings',
'rehype-slug',
'rehype-toc',
'remark-code-titles',
],
},
'packages/integrations/*': {
entry: [testEntry],
},
'packages/integrations/cloudflare': {
entry: [testEntry],
// False positive because of cloudflare:workers
ignoreDependencies: ['cloudflare'],
},
'packages/integrations/mdx': {
entry: [testEntry],
// Required but not imported directly
ignoreDependencies: ['@types/*'],
},
'packages/integrations/netlify': {
entry: [testEntry],
ignore: ['test/hosted/**'],
},
'packages/integrations/solid': {
entry: [testEntry],
// It's an optional peer dep (triggers a warning) but it's fine in this case
ignoreDependencies: ['solid-devtools'],
},
'packages/integrations/vercel': {
entry: [testEntry, 'test/test-image-service.js'],
ignore: ['test/hosted/**'],
},
'packages/markdown/remark': {
entry: [testEntry],
// package.json#imports are not resolved at the moment
ignore: ['src/import-plugin-browser.ts'],
},
'packages/upgrade': {
entry: ['src/index.ts', testEntry],
},
},
};
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
"test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match",
"test:e2e:hosts": "turbo run test:hosted",
"benchmark": "astro-benchmark",
"lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn",
"lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn",
"lint": "biome lint && eslint . --report-unused-disable-directives-severity=warn && knip",
"lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives-severity=warn && knip",
"lint:fix": "biome lint --write --unsafe",
"publint": "pnpm -r --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --no-bail exec publint",
"version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format",
"preinstall": "npx only-allow pnpm"
"preinstall": "npx only-allow pnpm",
"knip": "knip"
},
"workspaces": [
"packages/markdown/*",
Expand All @@ -58,10 +59,11 @@
"@biomejs/biome": "1.9.4",
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.28.1",
"@types/node": "^18.17.8",
"@types/node": "^18.19.50",
"esbuild": "^0.25.0",
"eslint": "^9.24.0",
"eslint-plugin-regexp": "^2.7.0",
"knip": "5.50.5",
"only-allow": "^1.2.1",
"prettier": "^3.5.3",
"prettier-plugin-astro": "^0.14.1",
Expand Down
4 changes: 0 additions & 4 deletions packages/astro/e2e/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { fileURLToPath } from 'node:url';
import { expect, test as testBase } from '@playwright/test';
import { loadFixture as baseLoadFixture } from '../test/test-utils.js';

export const isWindows = process.platform === 'win32';

export { silentLogging } from '../test/test-utils.js';

// Get all test files in directory, assign unique port for each of them so they don't conflict
const testFiles = await fs.readdir(new URL('.', import.meta.url));
const testFileToPort = new Map();
Expand Down
10 changes: 2 additions & 8 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
"./compiler-runtime": "./dist/runtime/compiler/index.js",
"./runtime/*": "./dist/runtime/*",
"./config": "./dist/config/entrypoint.js",
"./container": {
"types": "./dist/container/index.d.ts",
"default": "./dist/container/index.js"
},
"./container": "./dist/container/index.js",
"./app": "./dist/core/app/index.js",
"./app/node": "./dist/core/app/node.js",
"./client/*": "./dist/runtime/client/*",
Expand All @@ -76,10 +73,7 @@
"default": "./zod.mjs"
},
"./errors": "./dist/core/errors/userError.js",
"./middleware": {
"types": "./dist/core/middleware/index.d.ts",
"default": "./dist/core/middleware/index.js"
},
"./middleware": "./dist/core/middleware/index.js",
"./virtual-modules/*": "./dist/virtual-modules/*"
},
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/fonts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const fallbacksSchema = z.object({
optimizedFallbacks: z.boolean().optional(),
});

export const requiredFamilyAttributesSchema = z.object({
const requiredFamilyAttributesSchema = z.object({
/**
* The font family name, as identified by your font provider.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/fonts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function renderFontFace(properties: Record<string, string | undefined>) {
return `@font-face {\n\t${toCSS(properties)}\n}\n`;
}

export function unifontFontFaceDataToProperties(
function unifontFontFaceDataToProperties(
font: Partial<unifont.FontFaceData>,
): Record<string, string | undefined> {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface SharedServiceProps<T extends Record<string, any> = Record<string, any>
export type ExternalImageService<T extends Record<string, any> = Record<string, any>> =
SharedServiceProps<T>;

export type LocalImageTransform = {
type LocalImageTransform = {
src: string;
[key: string]: any;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/etag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Simplified, optimized and add modified for 52 bit, which provides a larger hash space
* and still making use of Javascript's 53-bit integer space.
*/
export const fnv1a52 = (str: string) => {
const fnv1a52 = (str: string) => {
const len = str.length;
let i = 0,
t0 = 0,
Expand Down
17 changes: 0 additions & 17 deletions packages/astro/src/assets/utils/vendor/image-size/lookup.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import type { imageType } from './types/index.js'
import { typeHandlers } from './types/index.js'
import { detector } from './detector.js'
import type { ISizeCalculationResult } from './types/interface.ts'

type Options = {
disabledTypes: imageType[]
}

const globalOptions: Options = {
disabledTypes: [],
}

/**
* Return size information based on an Uint8Array
*
Expand All @@ -22,10 +13,6 @@ export function lookup(input: Uint8Array): ISizeCalculationResult {
const type = detector(input)

if (typeof type !== 'undefined') {
if (globalOptions.disabledTypes.includes(type)) {
throw new TypeError('disabled file type: ' + type)
}

// find an appropriate handler for this file type
const size = typeHandlers.get(type)!.calculate(input)
if (size !== undefined) {
Expand All @@ -37,7 +24,3 @@ export function lookup(input: Uint8Array): ISizeCalculationResult {
// throw up, if we don't understand the file
throw new TypeError('unsupported file type: ' + type)
}

export const disableTypes = (types: imageType[]): void => {
globalOptions.disabledTypes = types
}
6 changes: 1 addition & 5 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,7 @@ function addVitePlugin(mod: ProxifiedModule<any>, pluginId: string, packageName:
}
}

export function setAdapter(
mod: ProxifiedModule<any>,
adapter: IntegrationInfo,
exportName: string,
) {
function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo, exportName: string) {
const config = getDefaultExportOptions(mod);
const adapterId = toIdent(adapter.id);

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/cli/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function printInfo({ flags }: InfoOptions) {
await copyToClipboard(output, flags.copy);
}

export async function copyToClipboard(text: string, force?: boolean) {
async function copyToClipboard(text: string, force?: boolean) {
text = text.trim();
const system = platform();
let command = '';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/cli/preferences/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const PREFERENCES_SUBCOMMANDS = [
'reset',
'list',
] as const;
export type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number];
type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number];

type AnnotatedValue = { annotation: string; value: string | number | boolean };
type AnnotatedValues = Record<string, AnnotatedValue>;
Expand Down
12 changes: 1 addition & 11 deletions packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ export type AddClientRenderer = {
entrypoint: string;
};

type ContainerImportRendererFn = (
containerRenderer: ContainerRenderer,
) => Promise<SSRLoadedRenderer>;

function createManifest(
manifest?: AstroContainerManifest,
renderers?: SSRLoadedRenderer[],
Expand Down Expand Up @@ -269,12 +265,6 @@ export class experimental_AstroContainer {
*/
#withManifest = false;

/**
* Internal function responsible for importing a renderer
* @private
*/
#getRenderer: ContainerImportRendererFn | undefined;

private constructor({
streaming = false,
manifest,
Expand Down Expand Up @@ -414,7 +404,7 @@ export class experimental_AstroContainer {
}

// NOTE: we keep this private via TS instead via `#` so it's still available on the surface, so we can play with it.
// @ematipico: I plan to use it for a possible integration that could help people
// @ts-expect-error @ematipico: I plan to use it for a possible integration that could help people
private static async createFromManifest(
manifest: SSRManifest,
): Promise<experimental_AstroContainer> {
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/content/content-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from './utils.js';
import { type WrappedWatcher, createWatcherWrapper } from './watcher.js';

export interface ContentLayerOptions {
interface ContentLayerOptions {
store: MutableDataStore;
settings: AstroSettings;
logger: Logger;
Expand All @@ -39,7 +39,7 @@ type CollectionLoader<TData> = () =>
| Record<string, Record<string, unknown>>
| Promise<Record<string, Record<string, unknown>>>;

export class ContentLayer {
class ContentLayer {
#logger: Logger;
#store: MutableDataStore;
#settings: AstroSettings;
Expand Down Expand Up @@ -342,7 +342,7 @@ export class ContentLayer {
}
}

export async function simpleLoader<TData extends { id: string }>(
async function simpleLoader<TData extends { id: string }>(
handler: CollectionLoader<TData>,
context: LoaderContext,
) {
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/content/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from './consts.js';
export { attachContentServerListeners } from './server-listeners.js';
export { createContentTypesGenerator } from './types-generator.js';
export { contentObservable, getContentPaths, hasAssetPropagationFlag } from './utils.js';
export { getContentPaths, hasAssetPropagationFlag } from './utils.js';
export { astroContentAssetPropagationPlugin } from './vite-plugin-content-assets.js';
export { astroContentImportPlugin } from './vite-plugin-content-imports.js';
export { astroContentVirtualModPlugin } from './vite-plugin-content-virtual-mod.js';
Loading