Skip to content

Commit 6517ddb

Browse files
ematipicoastrobot-houston
authored andcommitted
[ci] format
1 parent 3c04c1f commit 6517ddb

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

packages/astro/src/content/config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ZodLiteral, ZodNumber, ZodObject, ZodString, ZodType, ZodUnion } from 'zod';
2+
import { AstroError, AstroErrorData, AstroUserError } from '../core/errors/index.js';
23
import { CONTENT_LAYER_TYPE, LIVE_CONTENT_TYPE } from './consts.js';
34
import type { LiveLoader, Loader } from './loaders/types.js';
4-
import { AstroError, AstroErrorData, AstroUserError } from '../core/errors/index.js';
55

66
function getImporterFilename() {
77
// Find the first line in the stack trace that doesn't include 'defineCollection' or 'getImporterFilename'
@@ -94,7 +94,10 @@ type ContentCollectionConfig<S extends BaseSchema> = {
9494
loader?: never;
9595
};
9696

97-
export type LiveCollectionConfig<L extends LiveLoader, S extends BaseSchema | undefined = undefined> = {
97+
export type LiveCollectionConfig<
98+
L extends LiveLoader,
99+
S extends BaseSchema | undefined = undefined,
100+
> = {
98101
type: 'live';
99102
schema?: S;
100103
loader: L;
@@ -106,8 +109,8 @@ export type CollectionConfig<S extends BaseSchema> =
106109
| ContentLayerConfig<S>;
107110

108111
export function defineLiveCollection<
109-
L extends LiveLoader,
110-
S extends BaseSchema | undefined = undefined,
112+
L extends LiveLoader,
113+
S extends BaseSchema | undefined = undefined,
111114
>(config: LiveCollectionConfig<L, S>): LiveCollectionConfig<L, S> {
112115
const importerFilename = getImporterFilename();
113116
if (!importerFilename?.includes('live.config')) {

packages/astro/src/content/loaders/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ZodError } from "zod";
1+
import type { ZodError } from 'zod';
22

33
export class LiveCollectionError extends Error {
44
constructor(

packages/astro/src/content/runtime.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import pLimit from 'p-limit';
55
import { ZodIssueCode, z } from 'zod';
66
import type { GetImageResult, ImageMetadata } from '../assets/types.js';
77
import { imageSrcToImportId } from '../assets/utils/resolveImports.js';
8-
import { defineCollection as defineCollectionOrig } from './config.js';
98
import { AstroError, AstroErrorData } from '../core/errors/index.js';
109
import { prependForwardSlash } from '../core/path.js';
10+
import { defineCollection as defineCollectionOrig } from './config.js';
1111

1212
import {
1313
type AstroComponentFactory,
@@ -27,14 +27,14 @@ import type {
2727
} from '../types/public/content.js';
2828
import { IMAGE_IMPORT_PREFIX, type LIVE_CONTENT_TYPE } from './consts.js';
2929
import { type DataEntry, globalDataStore } from './data-store.js';
30-
import type { LiveLoader } from './loaders/types.js';
31-
import type { ContentLookupMap } from './utils.js';
3230
import {
33-
LiveCollectionError,
3431
LiveCollectionCacheHintError,
35-
LiveEntryNotFoundError,
32+
LiveCollectionError,
3633
LiveCollectionValidationError,
34+
LiveEntryNotFoundError,
3735
} from './loaders/errors.js';
36+
import type { LiveLoader } from './loaders/types.js';
37+
import type { ContentLookupMap } from './utils.js';
3838
export {
3939
LiveCollectionError,
4040
LiveCollectionCacheHintError,

packages/astro/src/content/vite-plugin-content-virtual-mod.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
44
import { dataToEsm } from '@rollup/pluginutils';
55
import pLimit from 'p-limit';
66
import { glob } from 'tinyglobby';
7-
import { normalizePath, type Plugin, type ViteDevServer } from 'vite';
7+
import { type Plugin, type ViteDevServer, normalizePath } from 'vite';
88
import { AstroError, AstroErrorData } from '../core/errors/index.js';
99
import { rootRelativePath } from '../core/viteUtils.js';
1010
import type { AstroSettings } from '../types/astro.js';
@@ -69,7 +69,7 @@ export function astroContentVirtualModPlugin({
6969
enforce: 'pre',
7070
config(_, env) {
7171
dataStoreFile = getDataStoreFile(settings, env.command === 'serve');
72-
const contentPaths = getContentPaths(settings.config);
72+
const contentPaths = getContentPaths(settings.config);
7373
if (contentPaths.liveConfig.exists) {
7474
liveConfig = normalizePath(fileURLToPath(contentPaths.liveConfig.url));
7575
}
@@ -87,8 +87,8 @@ export function astroContentVirtualModPlugin({
8787
// Live content config can't import the virtual module directly,
8888
// because it would create a circular dependency from the colleciton exports.
8989
// Instead, we resolve the config util module, because that's all that it should use anyway.
90-
if(liveConfig && importer && liveConfig === normalizePath(importer)) {
91-
return this.resolve("astro/content/config", importer, {
90+
if (liveConfig && importer && liveConfig === normalizePath(importer)) {
91+
return this.resolve('astro/content/config', importer, {
9292
skipSelf: true,
9393
});
9494
}

packages/astro/src/types/public/content.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { MarkdownHeading } from '@astrojs/markdown-remark';
22
import type * as rollup from 'rollup';
33
import type { DataEntry, RenderedContent } from '../../content/data-store.js';
4+
import type { LiveCollectionError } from '../../content/loaders/errors.js';
45
import type { AstroComponentFactory } from '../../runtime/server/index.js';
56
import type { AstroConfig } from './config.js';
6-
import type { LiveCollectionError } from '../../content/loaders/errors.js';
77

88
export interface AstroInstance {
99
file: string;
@@ -142,9 +142,7 @@ export interface LiveDataEntry<TData extends Record<string, any> = Record<string
142142
cacheHint?: CacheHint;
143143
}
144144

145-
export interface LiveDataCollection<
146-
TData extends Record<string, any> = Record<string, unknown>,
147-
> {
145+
export interface LiveDataCollection<TData extends Record<string, any> = Record<string, unknown>> {
148146
entries: Array<LiveDataEntry<TData>>;
149147
/** A hint for how to cache this collection. Individual entries can also have cache hints */
150148
cacheHint?: CacheHint;
@@ -155,7 +153,7 @@ export interface LiveDataCollectionResult<
155153
TError extends Error = Error,
156154
> {
157155
entries?: Array<LiveDataEntry<TData>>;
158-
error?: TError | LiveCollectionError
156+
error?: TError | LiveCollectionError;
159157
cacheHint?: CacheHint;
160158
}
161159

packages/astro/templates/content/types.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ declare module 'astro:content' {
8080
export function getLiveCollection<C extends keyof LiveContentConfig['collections']>(
8181
collection: C,
8282
filter?: LiveLoaderCollectionFilterType<C>,
83-
): Promise<import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
83+
): Promise<
84+
import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
85+
>;
8486

8587
export function getEntry<
8688
C extends keyof ContentEntryMap,
@@ -188,8 +190,9 @@ declare module 'astro:content' {
188190
ExtractEntryFilterType<LiveContentConfig['collections'][C]['loader']>;
189191
type LiveLoaderCollectionFilterType<C extends keyof LiveContentConfig['collections']> =
190192
ExtractCollectionFilterType<LiveContentConfig['collections'][C]['loader']>;
191-
type LiveLoaderErrorType<C extends keyof LiveContentConfig['collections']> =
192-
ExtractErrorType<LiveContentConfig['collections'][C]['loader']>;
193+
type LiveLoaderErrorType<C extends keyof LiveContentConfig['collections']> = ExtractErrorType<
194+
LiveContentConfig['collections'][C]['loader']
195+
>;
193196

194197
export type ContentConfig = '@@CONTENT_CONFIG_TYPE@@';
195198
export type LiveContentConfig = '@@LIVE_CONTENT_CONFIG_TYPE@@';

packages/astro/test/live-loaders.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ describe('Live content collections', () => {
135135
it('returns an error for invalid data', async () => {
136136
const res = await fixture.fetch('/api/?returnInvalid=true&addToAge=1');
137137
const data = await res.json();
138-
assert.ok(data.collection.error.message.includes('data does not match the collection schema'));
138+
assert.ok(
139+
data.collection.error.message.includes('data does not match the collection schema'),
140+
);
139141
assert.equal(data.collection.error.name, 'LiveCollectionValidationError');
140142
});
141143

0 commit comments

Comments
 (0)