From 0f1e9d8361017350617e8882c9858ee56b2e8039 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 8 Aug 2023 13:01:38 +0100 Subject: [PATCH] chore: update prettier to `3.0` (#7957) --- .prettierrc.cjs | 2 +- .../src/content/blog/markdown-style-guide.md | 2 +- package.json | 6 +-- packages/astro/astro-jsx.d.ts | 2 + packages/astro/content-types.template.d.ts | 12 ++--- packages/astro/src/@types/astro.ts | 2 +- packages/astro/src/vite-plugin-head/index.ts | 2 +- packages/integrations/image/README.md | 18 ++++---- packages/integrations/image/src/build/ssg.ts | 2 +- .../node/src/response-iterator.ts | 6 +-- packages/integrations/node/src/types.ts | 2 +- pnpm-lock.yaml | 44 +++++++++++-------- 12 files changed, 53 insertions(+), 47 deletions(-) diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 0909ba219..39911db2c 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -6,7 +6,7 @@ module.exports = { tabWidth: 2, trailingComma: 'es5', useTabs: true, - plugins: ['./node_modules/prettier-plugin-astro'], + plugins: ['prettier-plugin-astro'], overrides: [ { files: ['.*', '*.json', '*.md', '*.toml', '*.yml'], diff --git a/examples/blog/src/content/blog/markdown-style-guide.md b/examples/blog/src/content/blog/markdown-style-guide.md index e7cede3d3..58a03467d 100644 --- a/examples/blog/src/content/blog/markdown-style-guide.md +++ b/examples/blog/src/content/blog/markdown-style-guide.md @@ -58,7 +58,7 @@ The blockquote element represents content that is quoted from another source, op ## Code Blocks ```html - + diff --git a/package.json b/package.json index f497b2770..d7343da53 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dev": "turbo run dev --concurrency=40 --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"", "format": "pnpm run format:code", "format:ci": "pnpm run format:imports && pnpm run format:code", - "format:code": "prettier -w . --cache --plugin-search-dir=.", + "format:code": "prettier -w . --cache", "format:imports": "organize-imports-cli ./packages/*/tsconfig.json ./packages/*/*/tsconfig.json", "test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"", "test:match": "cd packages/astro && pnpm run test:match", @@ -88,8 +88,8 @@ "eslint-plugin-prettier": "^4.2.1", "only-allow": "^1.1.1", "organize-imports-cli": "^0.10.0", - "prettier": "^2.8.8", - "prettier-plugin-astro": "^0.10.0", + "prettier": "^3.0.1", + "prettier-plugin-astro": "^0.11.0", "tiny-glob": "^0.2.9", "turbo": "^1.10.3", "typescript": "~5.1.6" diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts index a04d755ec..b82de9388 100644 --- a/packages/astro/astro-jsx.d.ts +++ b/packages/astro/astro-jsx.d.ts @@ -9,6 +9,8 @@ * Adapted from React’s TypeScript definition from DefinitelyTyped. * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts */ +// BUG! Prettier 3.0 removes `declare`: https://github.com/prettier/prettier/issues/15207 +// prettier-ignore declare namespace astroHTML.JSX { export type Child = Node | Node[] | string | number | boolean | null | undefined | unknown; export type Children = Child | Child[]; diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index 277d00acf..ba9fe1c2a 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -44,7 +44,7 @@ declare module 'astro:content' { import('astro/zod').ZodLiteral<'tiff'>, import('astro/zod').ZodLiteral<'webp'>, import('astro/zod').ZodLiteral<'gif'>, - import('astro/zod').ZodLiteral<'svg'> + import('astro/zod').ZodLiteral<'svg'>, ] >; }>; @@ -87,7 +87,7 @@ declare module 'astro:content' { export function getEntryBySlug< C extends keyof ContentEntryMap, - E extends ValidContentEntrySlug | (string & {}) + E extends ValidContentEntrySlug | (string & {}), >( collection: C, // Note that this has to accept a regular string too, for SSR @@ -112,7 +112,7 @@ declare module 'astro:content' { export function getEntry< C extends keyof ContentEntryMap, - E extends ValidContentEntrySlug | (string & {}) + E extends ValidContentEntrySlug | (string & {}), >(entry: { collection: C; slug: E; @@ -121,7 +121,7 @@ declare module 'astro:content' { : Promise | undefined>; export function getEntry< C extends keyof DataEntryMap, - E extends keyof DataEntryMap[C] | (string & {}) + E extends keyof DataEntryMap[C] | (string & {}), >(entry: { collection: C; id: E; @@ -130,7 +130,7 @@ declare module 'astro:content' { : Promise | undefined>; export function getEntry< C extends keyof ContentEntryMap, - E extends ValidContentEntrySlug | (string & {}) + E extends ValidContentEntrySlug | (string & {}), >( collection: C, slug: E @@ -139,7 +139,7 @@ declare module 'astro:content' { : Promise | undefined>; export function getEntry< C extends keyof DataEntryMap, - E extends keyof DataEntryMap[C] | (string & {}) + E extends keyof DataEntryMap[C] | (string & {}), >( collection: C, id: E diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 2cba086f5..dbebe4adf 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1916,7 +1916,7 @@ export interface SSRLoadedRenderer extends AstroRenderer { export type HookParameters< Hook extends keyof AstroIntegration['hooks'], - Fn = AstroIntegration['hooks'][Hook] + Fn = AstroIntegration['hooks'][Hook], > = Fn extends (...args: any) => any ? Parameters[0] : never; export interface AstroIntegration { diff --git a/packages/astro/src/vite-plugin-head/index.ts b/packages/astro/src/vite-plugin-head/index.ts index 9cfdc739f..ca95a334e 100644 --- a/packages/astro/src/vite-plugin-head/index.ts +++ b/packages/astro/src/vite-plugin-head/index.ts @@ -16,7 +16,7 @@ export default function configHeadVitePlugin(): vite.Plugin { function propagateMetadata< P extends keyof PluginMetadata['astro'], - V extends PluginMetadata['astro'][P] + V extends PluginMetadata['astro'][P], >( this: { getModuleInfo(id: string): ModuleInfo | null }, id: string, diff --git a/packages/integrations/image/README.md b/packages/integrations/image/README.md index a31854923..0d7db86fa 100644 --- a/packages/integrations/image/README.md +++ b/packages/integrations/image/README.md @@ -130,14 +130,14 @@ import heroImage from '../assets/hero.png'; // optimized image, keeping the original width, height, and image format descriptive text -// specify multiple sizes for responsive images or art direction + // specify multiple sizes for responsive images or art direction ---- + --- ``` The included image transformers support resizing images and encoding them to different image formats. Third-party image services will be able to add support for custom transformations as well (ex: `blur`, `filter`, `rotate`, etc). @@ -566,16 +566,16 @@ import heroImage from '../assets/hero.png'; // optimized image, keeping the original width, height, and image format descriptive text -// height will be recalculated to match the original aspect ratio + // height will be recalculated to match the original aspect ratio descriptive text -// cropping to a specific width and height + // cropping to a specific width and height descriptive text -// cropping to a specific aspect ratio and converting to an avif format + // cropping to a specific aspect ratio and converting to an avif format descriptive text -// image imports can also be inlined directly + // image imports can also be inlined directly descriptive text ``` @@ -612,7 +612,7 @@ const imageUrl = 'https://astro.build/assets/press/full-logo-dark.png'; // cropping to a specific width and height descriptive text -// height will be recalculated to match the aspect ratio + // height will be recalculated to match the aspect ratio descriptive text ``` @@ -641,7 +641,7 @@ const imageUrl = alt="descriptive text" /> -// Remote image (aspect ratio is required) + // Remote image (aspect ratio is required) -// Inlined imports are supported + // Inlined imports are supported + Map, ]): Promise { let inputFile: string | undefined = undefined; let inputBuffer: Buffer | undefined = undefined; diff --git a/packages/integrations/node/src/response-iterator.ts b/packages/integrations/node/src/response-iterator.ts index 84080e5d1..0dd6e63af 100644 --- a/packages/integrations/node/src/response-iterator.ts +++ b/packages/integrations/node/src/response-iterator.ts @@ -120,7 +120,7 @@ function nodeStreamIterator(stream: NodeReadableStream): AsyncIterableIterato | IteratorResult | PromiseLike> ) => void, - (reason?: any) => void + (reason?: any) => void, ][] = []; function onData(chunk: any) { @@ -200,9 +200,7 @@ function asyncIterator(source: AsyncIterableIterator): AsyncIterableIterat }; } -export function responseIterator( - response: Response | Buffer -): AsyncIterableIterator { +export function responseIterator(response: Response | Buffer): AsyncIterableIterator { let body: unknown = response; if (isNodeResponse(response)) body = response.body; diff --git a/packages/integrations/node/src/types.ts b/packages/integrations/node/src/types.ts index b0bd4a681..85f4f4fbc 100644 --- a/packages/integrations/node/src/types.ts +++ b/packages/integrations/node/src/types.ts @@ -21,7 +21,7 @@ export type RequestHandlerParams = [ req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void, - locals?: object + locals?: object, ]; export type ErrorHandlerParams = [unknown, ...RequestHandlerParams]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fca6dde17..a173118c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,7 +47,7 @@ importers: version: 2.6.0 eslint-plugin-prettier: specifier: ^4.2.1 - version: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.43.0)(prettier@2.8.8) + version: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.43.0)(prettier@3.0.1) only-allow: specifier: ^1.1.1 version: 1.1.1 @@ -55,11 +55,11 @@ importers: specifier: ^0.10.0 version: 0.10.0 prettier: - specifier: ^2.8.8 - version: 2.8.8 + specifier: ^3.0.1 + version: 3.0.1 prettier-plugin-astro: - specifier: ^0.10.0 - version: 0.10.0 + specifier: ^0.11.0 + version: 0.11.0 tiny-glob: specifier: ^0.2.9 version: 0.2.9 @@ -650,7 +650,7 @@ importers: devDependencies: '@astrojs/check': specifier: ^0.1.0 - version: 0.1.0(prettier-plugin-astro@0.10.0)(prettier@2.8.8)(typescript@5.1.6) + version: 0.1.0(prettier-plugin-astro@0.11.0)(prettier@3.0.1)(typescript@5.1.6) '@playwright/test': specifier: ^1.29.2 version: 1.29.2 @@ -5360,13 +5360,13 @@ packages: lite-youtube-embed: 0.2.0 dev: false - /@astrojs/check@0.1.0(prettier-plugin-astro@0.10.0)(prettier@2.8.8)(typescript@5.1.6): + /@astrojs/check@0.1.0(prettier-plugin-astro@0.11.0)(prettier@3.0.1)(typescript@5.1.6): resolution: {integrity: sha512-tgjq+Vehgv0dwdsRlT4ai3QgT3etn8W5C4E4dvQ0Xe9ccwjKdMTWmpty5exfBtHLLAAOvwe5/OkYQsQ9OyKoVw==} hasBin: true peerDependencies: typescript: ^5.0.0 dependencies: - '@astrojs/language-server': 2.2.0(prettier-plugin-astro@0.10.0)(prettier@2.8.8)(typescript@5.1.6) + '@astrojs/language-server': 2.2.0(prettier-plugin-astro@0.11.0)(prettier@3.0.1)(typescript@5.1.6) chokidar: 3.5.3 fast-glob: 3.3.1 kleur: 4.1.5 @@ -5420,7 +5420,7 @@ packages: vscode-uri: 3.0.7 dev: false - /@astrojs/language-server@2.2.0(prettier-plugin-astro@0.10.0)(prettier@2.8.8)(typescript@5.1.6): + /@astrojs/language-server@2.2.0(prettier-plugin-astro@0.11.0)(prettier@3.0.1)(typescript@5.1.6): resolution: {integrity: sha512-zyEumkwcep3pGyMpcEJFEn96jV6pEg3CUtjehnT9KseDFqf+gPYTbw5nwOpN9uXIJ/E5bAxhqpkr3J2LCQHRrg==} hasBin: true peerDependencies: @@ -5442,12 +5442,12 @@ packages: '@volar/typescript': 1.10.0 fast-glob: 3.3.1 muggle-string: 0.3.1 - prettier: 2.8.8 - prettier-plugin-astro: 0.10.0 + prettier: 3.0.1 + prettier-plugin-astro: 0.11.0 volar-service-css: 0.0.11(@volar/language-service@1.10.0) volar-service-emmet: 0.0.11(@volar/language-service@1.10.0) volar-service-html: 0.0.11(@volar/language-service@1.10.0) - volar-service-prettier: 0.0.11(@volar/language-service@1.10.0)(prettier@2.8.8) + volar-service-prettier: 0.0.11(@volar/language-service@1.10.0)(prettier@3.0.1) volar-service-typescript: 0.0.11(@volar/language-service@1.10.0)(@volar/typescript@1.10.0) volar-service-typescript-twoslash-queries: 0.0.11(@volar/language-service@1.10.0) vscode-html-languageservice: 5.0.6 @@ -11646,7 +11646,7 @@ packages: engines: {node: '>=4.0.0'} dev: true - /eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.8.0)(eslint@8.43.0)(prettier@2.8.8): + /eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.8.0)(eslint@8.43.0)(prettier@3.0.1): resolution: {integrity: sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==} engines: {node: '>=12.0.0'} peerDependencies: @@ -11659,7 +11659,7 @@ packages: dependencies: eslint: 8.43.0 eslint-config-prettier: 8.8.0(eslint@8.43.0) - prettier: 2.8.8 + prettier: 3.0.1 prettier-linter-helpers: 1.0.0 dev: true @@ -15600,12 +15600,12 @@ packages: fast-diff: 1.2.0 dev: true - /prettier-plugin-astro@0.10.0: - resolution: {integrity: sha512-dPzop0gKZyVGpTDQmfy+e7FKXC9JT3mlpfYA2diOVz+Ui+QR1U4G/s+OesKl2Hib2JJOtAYJs/l+ovgT0ljlFA==} + /prettier-plugin-astro@0.11.0: + resolution: {integrity: sha512-rl2hJ4Kty/aEfGjk3i4JS+bpng9MjgvwqLRNzeb9NqYhqKoWNwOR39cIJXFjU1vR3zYOPnwWNRMelKb0orunYA==} engines: {node: ^14.15.0 || >=16.0.0, pnpm: '>=7.14.0'} dependencies: '@astrojs/compiler': 1.8.1 - prettier: 2.8.8 + prettier: 3.0.1 sass-formatter: 0.7.6 dev: true @@ -15624,6 +15624,12 @@ packages: engines: {node: '>=10.13.0'} hasBin: true + /prettier@3.0.1: + resolution: {integrity: sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==} + engines: {node: '>=14'} + hasBin: true + dev: true + /pretty-bytes@5.6.0: resolution: {integrity: sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==} engines: {node: '>=6'} @@ -18029,7 +18035,7 @@ packages: vscode-uri: 3.0.7 dev: true - /volar-service-prettier@0.0.11(@volar/language-service@1.10.0)(prettier@2.8.8): + /volar-service-prettier@0.0.11(@volar/language-service@1.10.0)(prettier@3.0.1): resolution: {integrity: sha512-A4vEU5BUitNNAySb+t/fCjEoL01uYUkoe/Fe5UxR3JJbdgr2nTeXb5IlW90/1vzmnTKZznadJV4i1SoAf2CRbg==} peerDependencies: '@volar/language-service': ~1.10.0 @@ -18041,7 +18047,7 @@ packages: optional: true dependencies: '@volar/language-service': 1.10.0 - prettier: 2.8.8 + prettier: 3.0.1 dev: true /volar-service-typescript-twoslash-queries@0.0.11(@volar/language-service@1.10.0):