mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
[ci] format
This commit is contained in:
parent
134367427b
commit
a171c22f37
28 changed files with 59 additions and 59 deletions
4
packages/astro/content-types.template.d.ts
vendored
4
packages/astro/content-types.template.d.ts
vendored
|
@ -155,11 +155,11 @@ declare module 'astro:content' {
|
|||
? {
|
||||
collection: C;
|
||||
slug: ValidContentEntrySlug<C>;
|
||||
}
|
||||
}
|
||||
: {
|
||||
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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))}`
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(',')}}`;
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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...
|
||||
|
|
|
@ -420,7 +420,7 @@ function getInvalidRouteSegmentError(
|
|||
route.route,
|
||||
JSON.stringify(invalidParam),
|
||||
JSON.stringify(received)
|
||||
)
|
||||
)
|
||||
: `Generated path for ${route.route} is invalid.`,
|
||||
hint,
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -162,14 +162,14 @@ export type StripEnums<T extends Record<string, any>> = {
|
|||
[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<any>
|
||||
? T[K]
|
||||
: T[K] extends undefined
|
||||
? undefined
|
||||
: any;
|
||||
? T[K]
|
||||
: T[K] extends object
|
||||
? T[K]
|
||||
: T[K] extends Array<any>
|
||||
? T[K]
|
||||
: T[K] extends undefined
|
||||
? undefined
|
||||
: any;
|
||||
};
|
||||
|
||||
export interface TSConfig {
|
||||
|
|
|
@ -153,7 +153,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise<Astro
|
|||
lang: highlighterLang,
|
||||
theme: 'css-variables',
|
||||
lineOptions: err.loc?.line ? [{ line: err.loc.line, classes: ['error-line'] }] : undefined,
|
||||
})
|
||||
})
|
||||
: undefined;
|
||||
|
||||
if (highlightedCode) {
|
||||
|
|
|
@ -169,13 +169,13 @@ ${
|
|||
validRenderersCount > 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.`,
|
||||
|
|
|
@ -55,7 +55,7 @@ export function generatePaginateFunction(
|
|||
page:
|
||||
!includesFirstPageNumber && pageNum - 1 === 1 ? undefined : String(pageNum - 1),
|
||||
})
|
||||
);
|
||||
);
|
||||
return {
|
||||
params,
|
||||
props: {
|
||||
|
|
|
@ -14,7 +14,7 @@ type DotKeys<T> = T extends object
|
|||
[K in keyof T]: `${Exclude<K, symbol>}${DotKeys<T[K]> extends never
|
||||
? ''
|
||||
: `.${DotKeys<T[K]>}`}`;
|
||||
}[keyof T]
|
||||
}[keyof T]
|
||||
: never;
|
||||
|
||||
export type GetDotKey<
|
||||
|
@ -30,7 +30,7 @@ export interface PreferenceOptions {
|
|||
type DeepPartial<T> = T extends object
|
||||
? {
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
}
|
||||
}
|
||||
: T;
|
||||
|
||||
export type PreferenceKey = DotKeys<Preferences>;
|
||||
|
|
|
@ -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')!
|
||||
)
|
||||
)
|
||||
: ''
|
||||
}
|
||||
<div class="separator"></div>
|
||||
|
|
|
@ -211,7 +211,7 @@ async function renderElement(
|
|||
? `/>`
|
||||
: `>${
|
||||
children == null ? '' : await renderJSX(result, prerenderElementChildren(tag, children))
|
||||
}</${tag}>`
|
||||
}</${tag}>`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -37,6 +37,6 @@ export type DeepPartial<T> = {
|
|||
[P in keyof T]?: T[P] extends (infer U)[]
|
||||
? DeepPartial<U>[]
|
||||
: T[P] extends object | undefined
|
||||
? DeepPartial<T[P]>
|
||||
: T[P];
|
||||
? DeepPartial<T[P]>
|
||||
: T[P];
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -80,7 +80,7 @@ function renderToStaticMarkup(
|
|||
? h(StaticHtml, {
|
||||
hydrate: shouldHydrate(metadata),
|
||||
value: children,
|
||||
})
|
||||
})
|
||||
: children
|
||||
) as VNode<any>
|
||||
);
|
||||
|
|
|
@ -308,9 +308,9 @@ You can set functionPerRoute: false to prevent surpassing the limit.`
|
|||
...(imagesConfig.remotePatterns ?? []),
|
||||
..._config.image.remotePatterns,
|
||||
],
|
||||
}
|
||||
}
|
||||
: getDefaultImageConfig(_config.image),
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
|
||||
|
|
|
@ -129,9 +129,9 @@ export default function vercelStatic({
|
|||
...(imagesConfig.remotePatterns ?? []),
|
||||
..._config.image.remotePatterns,
|
||||
],
|
||||
}
|
||||
}
|
||||
: getDefaultImageConfig(_config.image),
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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.");`
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ export default async function build(...args) {
|
|||
to: ['./dist/assets/services/vendor/squoosh'],
|
||||
},
|
||||
}),
|
||||
]
|
||||
]
|
||||
: []),
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue