diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index 4d59d140fd2e..146c52e73e10 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -155,11 +155,11 @@ declare module 'astro:content' { ? { collection: C; slug: ValidContentEntrySlug; - } + } : { collection: C; id: keyof DataEntryMap[C]; - } + } >; // Allow generic `string` to avoid excessive type errors in the config // if `dev` is not running to update as you edit. diff --git a/packages/astro/performance/content-benchmark.mjs b/packages/astro/performance/content-benchmark.mjs index c2d1d69184de..ce391c35194c 100644 --- a/packages/astro/performance/content-benchmark.mjs +++ b/packages/astro/performance/content-benchmark.mjs @@ -44,14 +44,14 @@ async function benchmark({ fixtures, templates, numPosts }) { const test = Array.isArray(flags.test) ? flags.test : typeof flags.test === 'string' - ? [flags.test] - : ['simple', 'with-astro-components', 'with-react-components']; + ? [flags.test] + : ['simple', 'with-astro-components', 'with-react-components']; const formats = Array.isArray(flags.format) ? flags.format : typeof flags.format === 'string' - ? [flags.format] - : ['md', 'mdx', 'mdoc']; + ? [flags.format] + : ['md', 'mdx', 'mdoc']; const numPosts = flags.numPosts || 1000; diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index f6b8e40dc26e..7a08da15feff 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -65,7 +65,7 @@ export async function getImage( // Causing our generate step to think the image is used outside of the image optimization pipeline const clonedSrc = isESMImportedImage(resolvedOptions.src) ? // @ts-expect-error - clone is a private, hidden prop - resolvedOptions.src.clone ?? resolvedOptions.src + resolvedOptions.src.clone ?? resolvedOptions.src : resolvedOptions.src; resolvedOptions.src = clonedSrc; diff --git a/packages/astro/src/content/error-map.ts b/packages/astro/src/content/error-map.ts index 706de3882373..c3372b708b5c 100644 --- a/packages/astro/src/content/error-map.ts +++ b/packages/astro/src/content/error-map.ts @@ -45,7 +45,7 @@ export const errorMap: ZodErrorMap = (baseError, ctx) => { .map(([key, error]) => key === baseErrorPath ? // Avoid printing the key again if it's a base error - `> ${getTypeOrLiteralMsg(error)}` + `> ${getTypeOrLiteralMsg(error)}` : `> ${prefix(key, getTypeOrLiteralMsg(error))}` ) ) diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index 5ca396da8c30..cccef41d8974 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -95,12 +95,12 @@ export function createGetCollection({ renderEntryImport: await getRenderEntryImport(collection, entry.slug), }); }, - } + } : { id: entry.id, collection: entry.collection, data: entry.data, - }; + }; }) ); cacheEntriesByCollection.set(collection, entries); diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index dc9c1ecc76ed..82300f9c77bb 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -410,8 +410,8 @@ async function writeContentFiles({ const resolvedType: 'content' | 'data' = collection.type === 'unknown' ? // Add empty / unknown collections to the data type map by default - // This ensures `getCollection('empty-collection')` doesn't raise a type error - collectionConfig?.type ?? 'data' + // This ensures `getCollection('empty-collection')` doesn't raise a type error + collectionConfig?.type ?? 'data' : collection.type; switch (resolvedType) { diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index e95e167c8611..f6f3dae1cafa 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -504,6 +504,6 @@ export async function getEntrySlug({ export function getExtGlob(exts: string[]) { return exts.length === 1 ? // Wrapping {...} breaks when there is only one extension - exts[0] + exts[0] : `{${exts.join(',')}}`; } diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts index 052a673f48e2..d75378c2a811 100644 --- a/packages/astro/src/content/vite-plugin-content-imports.ts +++ b/packages/astro/src/content/vite-plugin-content-imports.ts @@ -224,7 +224,7 @@ async function getContentEntryModule( { id, collection, _internal, unvalidatedData }, collectionConfig, pluginContext - ) + ) : unvalidatedData; const contentEntryModule: ContentEntryModule = { @@ -258,7 +258,7 @@ async function getDataEntryModule( { id, collection, _internal, unvalidatedData }, collectionConfig, pluginContext - ) + ) : unvalidatedData; const dataEntryModule: DataEntryModule = { diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index ca1de94fd795..9c7d3828f258 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -409,8 +409,8 @@ export class App { const status = override?.status ? override.status : originalResponse.status === 200 - ? newResponse.status - : originalResponse.status; + ? newResponse.status + : originalResponse.status; try { // this function could throw an error... diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index d26aad71e684..32e12cf9477d 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -420,7 +420,7 @@ function getInvalidRouteSegmentError( route.route, JSON.stringify(invalidParam), JSON.stringify(received) - ) + ) : `Generated path for ${route.route} is invalid.`, hint, }); diff --git a/packages/astro/src/core/build/plugins/plugin-css.ts b/packages/astro/src/core/build/plugins/plugin-css.ts index 318a1fee545e..9ff25c81f7dd 100644 --- a/packages/astro/src/core/build/plugins/plugin-css.ts +++ b/packages/astro/src/core/build/plugins/plugin-css.ts @@ -223,8 +223,8 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { inlineConfig === 'always' ? true : inlineConfig === 'never' - ? false - : assetSize <= assetsInlineLimit; + ? false + : assetSize <= assetsInlineLimit; // there should be a single js object for each stylesheet, // allowing the single reference to be shared and checked for duplicates diff --git a/packages/astro/src/core/config/tsconfig.ts b/packages/astro/src/core/config/tsconfig.ts index 3375be9c8b87..d61868f3c3c7 100644 --- a/packages/astro/src/core/config/tsconfig.ts +++ b/packages/astro/src/core/config/tsconfig.ts @@ -162,14 +162,14 @@ export type StripEnums> = { [K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string - ? T[K] - : T[K] extends object - ? T[K] - : T[K] extends Array - ? T[K] - : T[K] extends undefined - ? undefined - : any; + ? T[K] + : T[K] extends object + ? T[K] + : T[K] extends Array + ? T[K] + : T[K] extends undefined + ? undefined + : any; }; export interface TSConfig { diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index 7d67806f8fa4..f2f149b3f51d 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -153,7 +153,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise 0 ? `There ${plural ? 'are' : 'is'} ${validRenderersCount} renderer${ plural ? 's' : '' - } configured in your \`astro.config.mjs\` file, + } configured in your \`astro.config.mjs\` file, but ${plural ? 'none were' : 'it was not'} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${ componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.` - }` + }` }`, hint: (probableRenderers: string) => `Did you mean to enable the ${probableRenderers} integration?\n\nSee https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`, diff --git a/packages/astro/src/core/render/paginate.ts b/packages/astro/src/core/render/paginate.ts index a8d6abbd2f78..00aba3702bac 100644 --- a/packages/astro/src/core/render/paginate.ts +++ b/packages/astro/src/core/render/paginate.ts @@ -55,7 +55,7 @@ export function generatePaginateFunction( page: !includesFirstPageNumber && pageNum - 1 === 1 ? undefined : String(pageNum - 1), }) - ); + ); return { params, props: { diff --git a/packages/astro/src/preferences/index.ts b/packages/astro/src/preferences/index.ts index ee50261158bc..fdaba8372db9 100644 --- a/packages/astro/src/preferences/index.ts +++ b/packages/astro/src/preferences/index.ts @@ -14,7 +14,7 @@ type DotKeys = T extends object [K in keyof T]: `${Exclude}${DotKeys extends never ? '' : `.${DotKeys}`}`; - }[keyof T] + }[keyof T] : never; export type GetDotKey< @@ -30,7 +30,7 @@ export interface PreferenceOptions { type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; - } + } : T; export type PreferenceKey = DotKeys; diff --git a/packages/astro/src/runtime/client/dev-overlay/overlay.ts b/packages/astro/src/runtime/client/dev-overlay/overlay.ts index 48241ded9f77..91ba7e279303 100644 --- a/packages/astro/src/runtime/client/dev-overlay/overlay.ts +++ b/packages/astro/src/runtime/client/dev-overlay/overlay.ts @@ -253,7 +253,7 @@ export class AstroDevOverlay extends HTMLElement { this.plugins.filter((plugin) => !plugin.builtIn).length > this.customPluginsToShow ? this.getPluginTemplate( this.plugins.find((plugin) => plugin.builtIn && plugin.id === 'astro:more')! - ) + ) : '' }
diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts index d2cb87a6147b..b83178c92d1c 100644 --- a/packages/astro/src/runtime/server/jsx.ts +++ b/packages/astro/src/runtime/server/jsx.ts @@ -211,7 +211,7 @@ async function renderElement( ? `/>` : `>${ children == null ? '' : await renderJSX(result, prerenderElementChildren(tag, children)) - }` + }` )}` ); } diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index f595dc78cf13..d08bd959747c 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -68,8 +68,8 @@ function stringifyChunk( let prescriptType: PrescriptType = needsHydrationScript ? 'both' : needsDirectiveScript - ? 'directive' - : null; + ? 'directive' + : null; if (prescriptType) { let prescripts = getPrescripts(result, prescriptType, hydration.directive); return markHTMLString(prescripts); diff --git a/packages/astro/src/runtime/server/transition.ts b/packages/astro/src/runtime/server/transition.ts index 0fed017dfdc9..9d039da9dfad 100644 --- a/packages/astro/src/runtime/server/transition.ts +++ b/packages/astro/src/runtime/server/transition.ts @@ -145,8 +145,8 @@ class ViewTransitionStyleSheet { direction === 'backwards' ? `[data-astro-transition=back]` : direction === 'forwards' - ? '' - : `[data-astro-transition=${direction}]`; + ? '' + : `[data-astro-transition=${direction}]`; this.addRule('modern', `${prefix}::view-transition-${image}(${name}) { ${animation} }`); this.addRule( 'fallback', diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 98cdf2066f71..d77842f4da3c 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -432,8 +432,8 @@ async function transition( const navigationType = historyState ? 'traverse' : options.history === 'replace' - ? 'replace' - : 'push'; + ? 'replace' + : 'push'; if (navigationType !== 'traverse') { updateScrollPosition({ scrollX, scrollY }); @@ -467,9 +467,9 @@ async function transition( preparationEvent.sourceElement instanceof HTMLFormElement ? preparationEvent.sourceElement : preparationEvent.sourceElement instanceof HTMLElement && - 'form' in preparationEvent.sourceElement - ? (preparationEvent.sourceElement.form as HTMLFormElement) - : preparationEvent.sourceElement?.closest('form'); + 'form' in preparationEvent.sourceElement + ? (preparationEvent.sourceElement.form as HTMLFormElement) + : preparationEvent.sourceElement?.closest('form'); // Form elements without enctype explicitly set default to application/x-www-form-urlencoded. // In order to maintain compatibility with Astro 4.x, we need to check the value of enctype // on the attributes property rather than accessing .enctype directly. Astro 5.x may diff --git a/packages/astro/src/type-utils.ts b/packages/astro/src/type-utils.ts index 4304438dbfde..efd234b0ec9c 100644 --- a/packages/astro/src/type-utils.ts +++ b/packages/astro/src/type-utils.ts @@ -37,6 +37,6 @@ export type DeepPartial = { [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial[] : T[P] extends object | undefined - ? DeepPartial - : T[P]; + ? DeepPartial + : T[P]; }; diff --git a/packages/astro/src/vite-plugin-astro-server/vite.ts b/packages/astro/src/vite-plugin-astro-server/vite.ts index 6c2bc2497af1..7a25a71a5711 100644 --- a/packages/astro/src/vite-plugin-astro-server/vite.ts +++ b/packages/astro/src/vite-plugin-astro-server/vite.ts @@ -25,12 +25,12 @@ export async function* crawlGraph( const moduleEntriesForId = isRootFile ? // "getModulesByFile" pulls from a delayed module cache (fun implementation detail), - // So we can get up-to-date info on initial server load. - // Needed for slower CSS preprocessing like Tailwind - loader.getModulesByFile(id) ?? new Set() + // So we can get up-to-date info on initial server load. + // Needed for slower CSS preprocessing like Tailwind + loader.getModulesByFile(id) ?? new Set() : // For non-root files, we're safe to pull from "getModuleById" based on testing. - // TODO: Find better invalidation strat to use "getModuleById" in all cases! - new Set([loader.getModuleById(id)]); + // TODO: Find better invalidation strat to use "getModuleById" in all cases! + new Set([loader.getModuleById(id)]); // Collect all imported modules for the module(s). for (const entry of moduleEntriesForId) { diff --git a/packages/integrations/preact/src/server.ts b/packages/integrations/preact/src/server.ts index 7d017a413951..bd9eda3aa348 100644 --- a/packages/integrations/preact/src/server.ts +++ b/packages/integrations/preact/src/server.ts @@ -80,7 +80,7 @@ function renderToStaticMarkup( ? h(StaticHtml, { hydrate: shouldHydrate(metadata), value: children, - }) + }) : children ) as VNode ); diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 26e33663a752..efefe2df89d5 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -308,9 +308,9 @@ You can set functionPerRoute: false to prevent surpassing the limit.` ...(imagesConfig.remotePatterns ?? []), ..._config.image.remotePatterns, ], - } + } : getDefaultImageConfig(_config.image), - } + } : {}), }); diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts index 80b42b95d267..cbd7cb51ad93 100644 --- a/packages/integrations/vercel/src/static/adapter.ts +++ b/packages/integrations/vercel/src/static/adapter.ts @@ -129,9 +129,9 @@ export default function vercelStatic({ ...(imagesConfig.remotePatterns ?? []), ..._config.image.remotePatterns, ], - } + } : getDefaultImageConfig(_config.image), - } + } : {}), }); }, diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index 12e05a3c48ec..00cb9f19a74a 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -71,7 +71,7 @@ export const setup = (app) => { !isBuild ? `console.warn("[@astrojs/vue] appEntrypoint \`" + ${JSON.stringify( appEntrypoint - )} + "\` does not export a default function. Check out https://docs.astro.build/en/guides/integrations-guide/vue/#appentrypoint.");` + )} + "\` does not export a default function. Check out https://docs.astro.build/en/guides/integrations-guide/vue/#appentrypoint.");` : '' } } diff --git a/scripts/cmd/build.js b/scripts/cmd/build.js index b516e6b5105f..32e92068a321 100644 --- a/scripts/cmd/build.js +++ b/scripts/cmd/build.js @@ -120,7 +120,7 @@ export default async function build(...args) { to: ['./dist/assets/services/vendor/squoosh'], }, }), - ] + ] : []), ], });