From 3390eb975f708d70b9d9acf2d3e8c4a9bd65db10 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Wed, 11 Oct 2023 15:05:45 +1000 Subject: [PATCH 1/4] Update prettier --- design-system/pkg/src/badge/Badge.tsx | 2 +- design-system/pkg/src/checkbox/Checkbox.tsx | 2 +- design-system/pkg/src/core/globals.ts | 29 ++-- design-system/pkg/src/date-time/Input.tsx | 78 +++++---- .../pkg/src/field/FieldPrimitive.tsx | 163 +++++++++--------- design-system/pkg/src/link/linkContext.tsx | 2 +- design-system/pkg/src/nav-list/NavList.tsx | 2 +- design-system/pkg/src/notice/Notice.tsx | 2 +- design-system/pkg/src/radio/Radio.tsx | 2 +- design-system/pkg/src/style/animation.ts | 2 +- .../pkg/src/style/toDataAttributes.ts | 2 +- design-system/pkg/src/style/types.ts | 2 +- design-system/pkg/src/switch/Switch.tsx | 2 +- design-system/pkg/src/table/types.ts | 2 +- .../pkg/src/text-field/TextField.tsx | 37 ++-- design-system/pkg/src/toast/Toast.tsx | 2 +- design-system/pkg/src/tooltip/Tooltip.tsx | 2 +- .../pkg/src/utils/ts/forwardRefWithAs.ts | 2 +- design-system/primitives/package.json | 2 +- design-system/primitives/types.ts | 2 +- docs/package.json | 2 +- package.json | 2 +- pnpm-lock.yaml | 29 ++-- 23 files changed, 189 insertions(+), 183 deletions(-) diff --git a/design-system/pkg/src/badge/Badge.tsx b/design-system/pkg/src/badge/Badge.tsx index b6a7ca202..ffde34597 100644 --- a/design-system/pkg/src/badge/Badge.tsx +++ b/design-system/pkg/src/badge/Badge.tsx @@ -57,7 +57,7 @@ export const Badge: ForwardRefExoticComponent< ({ icon: { color: fg }, text: { trim: false, color: fg, weight: 'medium' }, - } as const), + }) as const, [fg] ); diff --git a/design-system/pkg/src/checkbox/Checkbox.tsx b/design-system/pkg/src/checkbox/Checkbox.tsx index 6223ab6b7..f72a18053 100644 --- a/design-system/pkg/src/checkbox/Checkbox.tsx +++ b/design-system/pkg/src/checkbox/Checkbox.tsx @@ -64,7 +64,7 @@ export function Checkbox(props: CheckboxProps) { ({ text: { color: 'inherit' }, description: { color: 'neutralTertiary' }, - } as const), + }) as const, [] ); diff --git a/design-system/pkg/src/core/globals.ts b/design-system/pkg/src/core/globals.ts index 8103eb4cb..567faaced 100644 --- a/design-system/pkg/src/core/globals.ts +++ b/design-system/pkg/src/core/globals.ts @@ -24,24 +24,23 @@ export const documentElementClasses = (args: { * Deactivate auto-enlargement of small text in Safari. Remove the default touch * highlight in Safari. Reset the body element to sane defaults. */ -const documentReset = (background: StrictBackground = 'canvas') => - css` +const documentReset = (background: StrictBackground = 'canvas') => css` + html& { + scroll-behavior: smooth; + text-size-adjust: none; + -webkit-tap-highlight-color: #0000; + } + @media (prefers-reduced-motion: reduce) { html& { - scroll-behavior: smooth; - text-size-adjust: none; - -webkit-tap-highlight-color: #0000; - } - @media (prefers-reduced-motion: reduce) { - html& { - scroll-behavior: auto; - } + scroll-behavior: auto; } + } - html& body { - background-color: ${tokenSchema.color.background[background]}; - margin: 0; - } - `; + html& body { + background-color: ${tokenSchema.color.background[background]}; + margin: 0; + } +`; function flatString(str: string) { return str.replace(/\n|\s{2,}/g, ''); diff --git a/design-system/pkg/src/date-time/Input.tsx b/design-system/pkg/src/date-time/Input.tsx index 70fe354da..07f585b2b 100644 --- a/design-system/pkg/src/date-time/Input.tsx +++ b/design-system/pkg/src/date-time/Input.tsx @@ -20,50 +20,54 @@ type InputProps = { validationState?: 'valid' | 'invalid'; }; -export const Input = forwardRef(function Input( - props, - forwardedRef -) { - let inputRef = useObjectRef(forwardedRef); - let { children, disableFocusRing, fieldProps, isDisabled, validationState } = - props; +export const Input = forwardRef( + function Input(props, forwardedRef) { + let inputRef = useObjectRef(forwardedRef); + let { + children, + disableFocusRing, + fieldProps, + isDisabled, + validationState, + } = props; - let { focusProps, isFocusVisible, isFocused } = useFocusRing({ - isTextInput: true, - within: true, - }); + let { focusProps, isFocusVisible, isFocused } = useFocusRing({ + isTextInput: true, + within: true, + }); - let isInvalid = validationState === 'invalid' && !isDisabled; - let styleProps = useInputStyles(props, { - isDisabled, - isInvalid, - isFocused, - isFocusVisible: isFocusVisible && !disableFocusRing, - }); + let isInvalid = validationState === 'invalid' && !isDisabled; + let styleProps = useInputStyles(props, { + isDisabled, + isInvalid, + isFocused, + isFocusVisible: isFocusVisible && !disableFocusRing, + }); - return ( -
+ return (
- {children} +
+ {children} +
-
- ); -}); + ); + } +); type InputState = { isDisabled?: boolean; diff --git a/design-system/pkg/src/field/FieldPrimitive.tsx b/design-system/pkg/src/field/FieldPrimitive.tsx index fbb40881a..8a45cfed7 100644 --- a/design-system/pkg/src/field/FieldPrimitive.tsx +++ b/design-system/pkg/src/field/FieldPrimitive.tsx @@ -21,92 +21,91 @@ import { SlotProvider } from '../slots'; */ export const FieldPrimitive: ForwardRefExoticComponent< FieldPrimitiveProps & { ref?: Ref } -> = forwardRef(function FieldPrimitive( - props, - forwardedRef -) { - const { - children, - contextualHelp, - isRequired, - label, - labelElementType, - labelProps, - description, - descriptionProps, - errorMessage, - errorMessageProps, - supplementRequiredState, - } = props; - const styleProps = useStyleProps(props); - const contextualHelpId = useId(); +> = forwardRef( + function FieldPrimitive(props, forwardedRef) { + const { + children, + contextualHelp, + isRequired, + label, + labelElementType, + labelProps, + description, + descriptionProps, + errorMessage, + errorMessageProps, + supplementRequiredState, + } = props; + const styleProps = useStyleProps(props); + const contextualHelpId = useId(); - const contextualHelpSlots = useMemo(() => { - return { - // match capsize styles from the label text. stops the contextual help button - // from pushing elements above/below it - button: { - UNSAFE_className: css({ - marginBottom: tokenSchema.typography.text.regular.capheightTrim, - marginTop: tokenSchema.typography.text.regular.baselineTrim, - }), - id: contextualHelpId, - 'aria-labelledby': labelProps?.id - ? `${labelProps.id} ${contextualHelpId}` - : undefined, - }, - }; - }, [contextualHelpId, labelProps?.id]); + const contextualHelpSlots = useMemo(() => { + return { + // match capsize styles from the label text. stops the contextual help button + // from pushing elements above/below it + button: { + UNSAFE_className: css({ + marginBottom: tokenSchema.typography.text.regular.capheightTrim, + marginTop: tokenSchema.typography.text.regular.baselineTrim, + }), + id: contextualHelpId, + 'aria-labelledby': labelProps?.id + ? `${labelProps.id} ${contextualHelpId}` + : undefined, + }, + }; + }, [contextualHelpId, labelProps?.id]); - return ( - - {(() => { - if (!label) { - return null; - } - const labelUI = ( - - {label} - - ); - - if (contextualHelp) { - return ( - - {labelUI} - - {contextualHelp} - - + return ( + + {(() => { + if (!label) { + return null; + } + const labelUI = ( + + {label} + ); - } - return labelUI; - })()} + if (contextualHelp) { + return ( + + {labelUI} + + {contextualHelp} + + + ); + } + + return labelUI; + })()} - {description && ( - - {description} - - )} + {description && ( + + {description} + + )} - {children} + {children} - {errorMessage && ( - {errorMessage} - )} - - ); -}); + {errorMessage && ( + {errorMessage} + )} + + ); + } +); diff --git a/design-system/pkg/src/link/linkContext.tsx b/design-system/pkg/src/link/linkContext.tsx index 47ccb5e5b..1d59a8582 100644 --- a/design-system/pkg/src/link/linkContext.tsx +++ b/design-system/pkg/src/link/linkContext.tsx @@ -16,7 +16,7 @@ export interface LinkComponentProps export const makeLinkComponent = ( render: ForwardRefRenderFunction -) => ({ __forwardRef__: forwardRef(render) } as const); +) => ({ __forwardRef__: forwardRef(render) }) as const; export type LinkComponent = | ReturnType diff --git a/design-system/pkg/src/nav-list/NavList.tsx b/design-system/pkg/src/nav-list/NavList.tsx index a6e96c47d..bdefa1baf 100644 --- a/design-system/pkg/src/nav-list/NavList.tsx +++ b/design-system/pkg/src/nav-list/NavList.tsx @@ -62,7 +62,7 @@ export const NavList: ForwardRefExoticComponent< size: 'medium', UNSAFE_className: dividerStyles, }, - } as const), + }) as const, [dividerStyles] ); diff --git a/design-system/pkg/src/notice/Notice.tsx b/design-system/pkg/src/notice/Notice.tsx index 3f15e5317..95fccf246 100644 --- a/design-system/pkg/src/notice/Notice.tsx +++ b/design-system/pkg/src/notice/Notice.tsx @@ -86,7 +86,7 @@ export function Notice(props: NoticeProps) { size: 'small', }, text: { color: coercedTone, weight: 'medium' }, - } as const), + }) as const, [ coercedTone, contentId, diff --git a/design-system/pkg/src/radio/Radio.tsx b/design-system/pkg/src/radio/Radio.tsx index 6dec9faf8..d2fb69be0 100644 --- a/design-system/pkg/src/radio/Radio.tsx +++ b/design-system/pkg/src/radio/Radio.tsx @@ -49,7 +49,7 @@ export function Radio(props: RadioProps) { ({ text: { color: 'inherit' }, description: { color: 'neutralTertiary' }, - } as const), + }) as const, [] ); diff --git a/design-system/pkg/src/style/animation.ts b/design-system/pkg/src/style/animation.ts index 2a2391a58..76777dfc6 100644 --- a/design-system/pkg/src/style/animation.ts +++ b/design-system/pkg/src/style/animation.ts @@ -6,7 +6,7 @@ import { AnimationDuration, AnimationEasing } from './types'; type Kebab< T extends string, - A extends string = '' + A extends string = '', > = T extends `${infer F}${infer R}` ? Kebab ? '' : '-'}${Lowercase}`> : A; diff --git a/design-system/pkg/src/style/toDataAttributes.ts b/design-system/pkg/src/style/toDataAttributes.ts index eeacb31ba..c0d17e188 100644 --- a/design-system/pkg/src/style/toDataAttributes.ts +++ b/design-system/pkg/src/style/toDataAttributes.ts @@ -2,7 +2,7 @@ export function toDataAttributes< T extends { [key: string]: string | number | boolean | null | undefined; - } + }, >( data: T, options: { diff --git a/design-system/pkg/src/style/types.ts b/design-system/pkg/src/style/types.ts index 75e92f976..95f67c847 100644 --- a/design-system/pkg/src/style/types.ts +++ b/design-system/pkg/src/style/types.ts @@ -26,7 +26,7 @@ export type VoussoirTheme = typeof tokenSchema; type ColorAliases = `color.alias.${keyof VoussoirTheme['color']['alias']}`; type KeysStartingWith< Keys, - Prefix extends string + Prefix extends string, > = Keys extends `${Prefix}${string}` ? Keys : never; type BackgroundAliases = KeysStartingWith< diff --git a/design-system/pkg/src/switch/Switch.tsx b/design-system/pkg/src/switch/Switch.tsx index d0f789d9e..b897eefbe 100644 --- a/design-system/pkg/src/switch/Switch.tsx +++ b/design-system/pkg/src/switch/Switch.tsx @@ -61,7 +61,7 @@ export const Switch: ForwardRefExoticComponent = forwardRef( ({ text: { color: 'inherit' }, description: { color: 'neutralTertiary' }, - } as const), + }) as const, [] ); diff --git a/design-system/pkg/src/table/types.ts b/design-system/pkg/src/table/types.ts index e5592abc3..bc4503acf 100644 --- a/design-system/pkg/src/table/types.ts +++ b/design-system/pkg/src/table/types.ts @@ -15,7 +15,7 @@ export type TableProps = { /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */ children: [ ReactElement>, - ReactElement> + ReactElement>, ]; /** A list of row keys to disable. */ disabledKeys?: Iterable; diff --git a/design-system/pkg/src/text-field/TextField.tsx b/design-system/pkg/src/text-field/TextField.tsx index 0eb835a15..6cadf8dc0 100644 --- a/design-system/pkg/src/text-field/TextField.tsx +++ b/design-system/pkg/src/text-field/TextField.tsx @@ -9,23 +9,22 @@ import { validateTextFieldProps } from './validateTextFieldProps'; /** Text fields allow users to input text with a keyboard. */ export const TextField: ForwardRefExoticComponent< TextFieldProps & { ref?: Ref } -> = forwardRef(function TextField( - props, - forwardedRef -) { - props = validateTextFieldProps(props); - let domRef = useObjectRef(forwardedRef); - let { labelProps, inputProps, descriptionProps, errorMessageProps } = - useTextField(props, domRef); +> = forwardRef( + function TextField(props, forwardedRef) { + props = validateTextFieldProps(props); + let domRef = useObjectRef(forwardedRef); + let { labelProps, inputProps, descriptionProps, errorMessageProps } = + useTextField(props, domRef); - return ( - - ); -}); + return ( + + ); + } +); diff --git a/design-system/pkg/src/toast/Toast.tsx b/design-system/pkg/src/toast/Toast.tsx index 6e0c9c500..69435fb42 100644 --- a/design-system/pkg/src/toast/Toast.tsx +++ b/design-system/pkg/src/toast/Toast.tsx @@ -65,7 +65,7 @@ function Toast(props: ToastProps, ref: ForwardedRef) { () => ({ text: { color: 'inherit' }, - } as const), + }) as const, [] ); diff --git a/design-system/pkg/src/tooltip/Tooltip.tsx b/design-system/pkg/src/tooltip/Tooltip.tsx index 58f25b1b9..e4d3ccb05 100644 --- a/design-system/pkg/src/tooltip/Tooltip.tsx +++ b/design-system/pkg/src/tooltip/Tooltip.tsx @@ -73,7 +73,7 @@ export const Tooltip: ForwardRefExoticComponent< icon: { size: 'small', color: 'inherit' }, text: { size: 'small', color: 'inherit' }, kbd: { size: 'small', color: 'inherit' }, - } as const), + }) as const, [] ); diff --git a/design-system/pkg/src/utils/ts/forwardRefWithAs.ts b/design-system/pkg/src/utils/ts/forwardRefWithAs.ts index bd1322c16..95d590c16 100644 --- a/design-system/pkg/src/utils/ts/forwardRefWithAs.ts +++ b/design-system/pkg/src/utils/ts/forwardRefWithAs.ts @@ -19,7 +19,7 @@ export type CompWithAsProp< BaseProps, // this is unused for now but kept for future use // eslint-disable-next-line @typescript-eslint/no-unused-vars - DefaultElementType extends HTMLTag + DefaultElementType extends HTMLTag, > = ( props: Omit< AllHTMLAttributes, diff --git a/design-system/primitives/package.json b/design-system/primitives/package.json index 6773f7d3d..38e3be4a9 100644 --- a/design-system/primitives/package.json +++ b/design-system/primitives/package.json @@ -18,7 +18,7 @@ "fast-glob": "^3.2.12", "json5": "^2.2.1", "lodash": "^4.17.21", - "prettier": "^2.7.1", + "prettier": "^3.0.3", "style-dictionary": "^3.8.0", "tsx": "^3.8.0", "typescript": "^5.2.2" diff --git a/design-system/primitives/types.ts b/design-system/primitives/types.ts index bc1793c41..f6c44e77f 100644 --- a/design-system/primitives/types.ts +++ b/design-system/primitives/types.ts @@ -80,7 +80,7 @@ export type CubicBezierTokenValue = [ x1: number, y1: number, x2: number, - y2: number + y2: number, ]; /** diff --git a/docs/package.json b/docs/package.json index 13ac992e7..c6c28b734 100644 --- a/docs/package.json +++ b/docs/package.json @@ -38,7 +38,7 @@ "@tailwindcss/typography": "^0.5.9", "autoprefixer": "^10.4.13", "postcss": "^8.4.21", - "prettier": "^2.7.1", + "prettier": "^3.0.3", "prettier-plugin-tailwindcss": "^0.2.2", "tailwindcss": "^3.3.3" } diff --git a/package.json b/package.json index 76b3b6d72..468907334 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "jest": "^29.0.1", "jest-environment-jsdom": "^29.0.1", "npm-run-all": "^4.1.5", - "prettier": "^2.7.1", + "prettier": "^3.0.3", "prettier-plugin-packagejson": "^2.2.18", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa55507a4..50dbb55f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,7 +35,7 @@ importers: jest: ^29.0.1 jest-environment-jsdom: ^29.0.1 npm-run-all: ^4.1.5 - prettier: ^2.7.1 + prettier: ^3.0.3 prettier-plugin-packagejson: ^2.2.18 react: ^18.2.0 react-dom: ^18.2.0 @@ -72,8 +72,8 @@ importers: jest: 29.6.4_@types+node@16.11.13 jest-environment-jsdom: 29.6.4 npm-run-all: 4.1.5 - prettier: 2.8.8 - prettier-plugin-packagejson: 2.4.5_prettier@2.8.8 + prettier: 3.0.3 + prettier-plugin-packagejson: 2.4.5_prettier@3.0.3 react: 18.2.0 react-dom: 18.2.0_react@18.2.0 typescript: 5.2.2 @@ -383,7 +383,7 @@ importers: fast-glob: ^3.2.12 json5: ^2.2.1 lodash: ^4.17.21 - prettier: ^2.7.1 + prettier: ^3.0.3 style-dictionary: ^3.8.0 tsx: ^3.8.0 typescript: ^5.2.2 @@ -396,7 +396,7 @@ importers: fast-glob: 3.3.1 json5: 2.2.3 lodash: 4.17.21 - prettier: 2.8.8 + prettier: 3.0.3 style-dictionary: 3.8.0 tsx: 3.12.8 typescript: 5.2.2 @@ -597,7 +597,7 @@ importers: date-fns: ^2.28.0 next: ^13.5.3 postcss: ^8.4.21 - prettier: ^2.7.1 + prettier: ^3.0.3 prettier-plugin-tailwindcss: ^0.2.2 react: ^18.2.0 react-dom: ^18.2.0 @@ -632,8 +632,8 @@ importers: '@tailwindcss/typography': 0.5.9_tailwindcss@3.3.3 autoprefixer: 10.4.15_postcss@8.4.29 postcss: 8.4.29 - prettier: 2.8.8 - prettier-plugin-tailwindcss: 0.2.8_prettier@2.8.8 + prettier: 3.0.3 + prettier-plugin-tailwindcss: 0.2.8_prettier@3.0.3 tailwindcss: 3.3.3 packages/astro: @@ -17695,7 +17695,7 @@ packages: engines: {node: '>=4'} dev: false - /prettier-plugin-packagejson/2.4.5_prettier@2.8.8: + /prettier-plugin-packagejson/2.4.5_prettier@3.0.3: resolution: {integrity: sha512-glG71jE1gO3y5+JNAhC8X+4yrlN28rub6Aj461SKbaPie9RgMiHKcInH2Moi2VGOfkTXaEHBhg4uVMBqa+kBUA==} peerDependencies: prettier: '>= 1.16.0' @@ -17703,12 +17703,12 @@ packages: prettier: optional: true dependencies: - prettier: 2.8.8 + prettier: 3.0.3 sort-package-json: 2.5.1 synckit: 0.8.5 dev: false - /prettier-plugin-tailwindcss/0.2.8_prettier@2.8.8: + /prettier-plugin-tailwindcss/0.2.8_prettier@3.0.3: resolution: {integrity: sha512-KgPcEnJeIijlMjsA6WwYgRs5rh3/q76oInqtMXBA/EMcamrcYJpyhtRhyX1ayT9hnHlHTuO8sIifHF10WuSDKg==} engines: {node: '>=12.17.0'} peerDependencies: @@ -17757,7 +17757,7 @@ packages: prettier-plugin-twig-melody: optional: true dependencies: - prettier: 2.8.8 + prettier: 3.0.3 dev: true /prettier/2.8.8: @@ -17765,6 +17765,11 @@ packages: engines: {node: '>=10.13.0'} hasBin: true + /prettier/3.0.3: + resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} + engines: {node: '>=14'} + hasBin: true + /pretty-error/4.0.0: resolution: {integrity: sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==} dependencies: From d76eb818475dc6beb691b0e0f623f43cab1c2013 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Wed, 11 Oct 2023 15:17:06 +1000 Subject: [PATCH 2/4] Fix a programmatic use of prettier --- design-system/primitives/formatters/cssThemed.ts | 2 +- design-system/primitives/formatters/jsonFigma.ts | 2 +- design-system/primitives/package.json | 3 +++ pnpm-lock.yaml | 11 +++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/design-system/primitives/formatters/cssThemed.ts b/design-system/primitives/formatters/cssThemed.ts index 837c45044..bf2bb0db9 100644 --- a/design-system/primitives/formatters/cssThemed.ts +++ b/design-system/primitives/formatters/cssThemed.ts @@ -1,4 +1,4 @@ -import { format } from 'prettier'; +import { format } from '@prettier/sync'; import StyleDictionary from 'style-dictionary'; import type { FormatterArguments } from 'style-dictionary/types/Format'; import type { LineFormatting } from 'style-dictionary/types/FormatHelpers'; diff --git a/design-system/primitives/formatters/jsonFigma.ts b/design-system/primitives/formatters/jsonFigma.ts index e838f879c..100878c4f 100644 --- a/design-system/primitives/formatters/jsonFigma.ts +++ b/design-system/primitives/formatters/jsonFigma.ts @@ -1,6 +1,6 @@ // credit: https://github.com/primer/primitives/blob/main/src/formats/jsonFigma.ts import StyleDictionary from 'style-dictionary'; -import { format } from 'prettier'; +import { format } from '@prettier/sync'; import type { FormatterArguments } from 'style-dictionary/types/Format'; import { transformNamePathToFigma } from '../transformers/namePathToFigma'; diff --git a/design-system/primitives/package.json b/design-system/primitives/package.json index 38e3be4a9..dff7a7c20 100644 --- a/design-system/primitives/package.json +++ b/design-system/primitives/package.json @@ -22,5 +22,8 @@ "style-dictionary": "^3.8.0", "tsx": "^3.8.0", "typescript": "^5.2.2" + }, + "dependencies": { + "@prettier/sync": "^0.3.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50dbb55f4..8180d8628 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -377,6 +377,7 @@ importers: specifiers: '@capsizecss/core': ^3.1.1 '@capsizecss/metrics': ^1.2.0 + '@prettier/sync': ^0.3.0 '@types/lodash': ^4.14.191 color2k: ^2.0.2 emery: ^1.4.1 @@ -387,6 +388,8 @@ importers: style-dictionary: ^3.8.0 tsx: ^3.8.0 typescript: ^5.2.2 + dependencies: + '@prettier/sync': 0.3.0_prettier@3.0.3 devDependencies: '@capsizecss/core': 3.1.1 '@capsizecss/metrics': 1.2.0 @@ -4360,6 +4363,14 @@ packages: /@preconstruct/next/4.0.0: resolution: {integrity: sha512-vSrc8wFQgBErU7dKTKSQtr/DLWPHcN9jMoiWOAQodB1+B4Kpqqry6QhGYoRm0DQU5gNL+Rcp+Xb350O1E/gjsg==} + /@prettier/sync/0.3.0_prettier@3.0.3: + resolution: {integrity: sha512-3dcmCyAxIcxy036h1I7MQU/uEEBq8oLwf1CE3xeze+MPlgkdlb/+w6rGR/1dhp6Hqi17fRS6nvwnOzkESxEkOw==} + peerDependencies: + prettier: ^3.0.0 + dependencies: + prettier: 3.0.3 + dev: false + /@radix-ui/number/1.0.1: resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==} dependencies: From 66e9e425b3cd893bbbb601be36cb4e664d9ab548 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Tue, 17 Oct 2023 10:27:32 +1000 Subject: [PATCH 3/4] Update prettier-plugin-tailwindcss --- docs/package.json | 2 +- pnpm-lock.yaml | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/package.json b/docs/package.json index c6c28b734..8f342c8d5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -39,7 +39,7 @@ "autoprefixer": "^10.4.13", "postcss": "^8.4.21", "prettier": "^3.0.3", - "prettier-plugin-tailwindcss": "^0.2.2", + "prettier-plugin-tailwindcss": "^0.5.6", "tailwindcss": "^3.3.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8180d8628..3b167ef5c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -601,7 +601,7 @@ importers: next: ^13.5.3 postcss: ^8.4.21 prettier: ^3.0.3 - prettier-plugin-tailwindcss: ^0.2.2 + prettier-plugin-tailwindcss: ^0.5.6 react: ^18.2.0 react-dom: ^18.2.0 react-focus-lock: ^2.9.4 @@ -636,7 +636,7 @@ importers: autoprefixer: 10.4.15_postcss@8.4.29 postcss: 8.4.29 prettier: 3.0.3 - prettier-plugin-tailwindcss: 0.2.8_prettier@3.0.3 + prettier-plugin-tailwindcss: 0.5.6_prettier@3.0.3 tailwindcss: 3.3.3 packages/astro: @@ -17719,20 +17719,21 @@ packages: synckit: 0.8.5 dev: false - /prettier-plugin-tailwindcss/0.2.8_prettier@3.0.3: - resolution: {integrity: sha512-KgPcEnJeIijlMjsA6WwYgRs5rh3/q76oInqtMXBA/EMcamrcYJpyhtRhyX1ayT9hnHlHTuO8sIifHF10WuSDKg==} - engines: {node: '>=12.17.0'} + /prettier-plugin-tailwindcss/0.5.6_prettier@3.0.3: + resolution: {integrity: sha512-2Xgb+GQlkPAUCFi3sV+NOYcSI5XgduvDBL2Zt/hwJudeKXkyvRS65c38SB0yb9UB40+1rL83I6m0RtlOQ8eHdg==} + engines: {node: '>=14.21.3'} peerDependencies: '@ianvs/prettier-plugin-sort-imports': '*' '@prettier/plugin-pug': '*' '@shopify/prettier-plugin-liquid': '*' '@shufo/prettier-plugin-blade': '*' '@trivago/prettier-plugin-sort-imports': '*' - prettier: '>=2.2.0' + prettier: ^3.0 prettier-plugin-astro: '*' prettier-plugin-css-order: '*' prettier-plugin-import-sort: '*' prettier-plugin-jsdoc: '*' + prettier-plugin-marko: '*' prettier-plugin-organize-attributes: '*' prettier-plugin-organize-imports: '*' prettier-plugin-style-order: '*' @@ -17757,6 +17758,8 @@ packages: optional: true prettier-plugin-jsdoc: optional: true + prettier-plugin-marko: + optional: true prettier-plugin-organize-attributes: optional: true prettier-plugin-organize-imports: From 9476e47cd78de3e9fe7730a8d78424bc724968ed Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Tue, 17 Oct 2023 10:32:29 +1000 Subject: [PATCH 4/4] Format --- packages/keystatic/scripts/l10n.ts | 60 +++++++++---------- packages/keystatic/src/app/persistence.tsx | 2 +- packages/keystatic/src/config.tsx | 14 ++--- packages/keystatic/src/form/api.tsx | 34 +++++------ .../src/form/fields/conditional/index.tsx | 2 +- .../src/form/fields/conditional/ui.tsx | 2 +- .../with-component-blocks.tsx | 4 +- .../fields/document/DocumentEditor/editor.tsx | 2 +- .../form/fields/markdoc/editor/dropcursor.ts | 5 +- .../keystatic/src/form/fields/object/ui.tsx | 2 +- packages/keystatic/src/form/fields/utils.tsx | 2 +- packages/keystatic/src/form/initial-values.ts | 2 +- packages/keystatic/src/form/preview-props.tsx | 4 +- packages/keystatic/src/reader/index.ts | 20 +++---- packages/keystatic/src/renderer.tsx | 4 +- 15 files changed, 82 insertions(+), 77 deletions(-) diff --git a/packages/keystatic/scripts/l10n.ts b/packages/keystatic/scripts/l10n.ts index 692f6e9d6..5701d8255 100644 --- a/packages/keystatic/scripts/l10n.ts +++ b/packages/keystatic/scripts/l10n.ts @@ -5,38 +5,38 @@ const localesDir = path.join(__dirname, '../src/app/l10n'); (async () => { const locales: Record> = {}; await Promise.all( - ( - await fs.readdir(localesDir, { withFileTypes: true }) - ).map(async localeEntry => { - if (!localeEntry.isDirectory()) return; - const localeDir = path.join(localesDir, localeEntry.name); - const entries: Record = {}; - await Promise.all( - ( - await fs.readdir(localeDir, { withFileTypes: true }) - ).map(async entry => { - if (!entry.isDirectory()) return; - let json; - try { - json = JSON.parse( - await fs.readFile( - path.join(localeDir, entry.name, 'index.json'), - 'utf-8' - ) - ); - } catch (err) { - if ((err as any).code === 'ENOENT') { - return; + (await fs.readdir(localesDir, { withFileTypes: true })).map( + async localeEntry => { + if (!localeEntry.isDirectory()) return; + const localeDir = path.join(localesDir, localeEntry.name); + const entries: Record = {}; + await Promise.all( + (await fs.readdir(localeDir, { withFileTypes: true })).map( + async entry => { + if (!entry.isDirectory()) return; + let json; + try { + json = JSON.parse( + await fs.readFile( + path.join(localeDir, entry.name, 'index.json'), + 'utf-8' + ) + ); + } catch (err) { + if ((err as any).code === 'ENOENT') { + return; + } + throw err; + } + entries[entry.name] = json.value; } - throw err; - } - entries[entry.name] = json.value; - }) - ); - if (Object.keys(entries).length) { - locales[localeEntry.name] = entries; + ) + ); + if (Object.keys(entries).length) { + locales[localeEntry.name] = entries; + } } - }) + ) ); await fs.writeFile( path.join(localesDir, 'index.json'), diff --git a/packages/keystatic/src/app/persistence.tsx b/packages/keystatic/src/app/persistence.tsx index 86755529f..7abd507ab 100644 --- a/packages/keystatic/src/app/persistence.tsx +++ b/packages/keystatic/src/app/persistence.tsx @@ -23,7 +23,7 @@ function formatTimeAgo( for (const [name, amount] of Object.entries(units) as [ keyof typeof units, - number + number, ][]) { if (Math.abs(duration) < amount) { return formatter.format(Math.round(duration), name); diff --git a/packages/keystatic/src/config.tsx b/packages/keystatic/src/config.tsx index c4032212a..b2b914507 100644 --- a/packages/keystatic/src/config.tsx +++ b/packages/keystatic/src/config.tsx @@ -8,7 +8,7 @@ export type EntryLayout = 'content' | 'form'; export type Glob = '*' | '**'; export type Collection< Schema extends Record, - SlugField extends string + SlugField extends string, > = { label: string; path?: `${string}/${Glob}` | `${string}/${Glob}/${string}`; @@ -53,7 +53,7 @@ export type GitHubConfig< [key: string]: Singleton>; } = { [key: string]: Singleton>; - } + }, > = { storage: GitHubStorageConfig; collections?: Collections; @@ -72,7 +72,7 @@ export type LocalConfig< [key: string]: Singleton>; } = { [key: string]: Singleton>; - } + }, > = { storage: LocalStorageConfig; collections?: Collections; @@ -91,7 +91,7 @@ export type CloudConfig< [key: string]: Singleton>; } = { [key: string]: Singleton>; - } + }, > = { storage: CloudStorageConfig; cloud: { project: string }; @@ -109,7 +109,7 @@ export type Config< [key: string]: Singleton>; } = { [key: string]: Singleton>; - } + }, > = { storage: LocalStorageConfig | GitHubStorageConfig | CloudStorageConfig; collections?: Collections; @@ -124,7 +124,7 @@ export function config< }, Singletons extends { [key: string]: Singleton>; - } + }, >(config: Config) { return config; } @@ -135,7 +135,7 @@ export function collection< [K in keyof Schema]: Schema[K] extends SlugFormField ? K : never; - }[keyof Schema] + }[keyof Schema], >( collection: Collection ): Collection { diff --git a/packages/keystatic/src/form/api.tsx b/packages/keystatic/src/form/api.tsx index 1bc808af8..9805d1864 100644 --- a/packages/keystatic/src/form/api.tsx +++ b/packages/keystatic/src/form/api.tsx @@ -29,7 +29,7 @@ export type FormFieldStoredValue = JsonValueWithoutNull | undefined; export type BasicFormField< ParsedValue extends {} | null, ValidatedValue extends ParsedValue = ParsedValue, - ReaderValue = ValidatedValue + ReaderValue = ValidatedValue, > = { kind: 'form'; formKind?: undefined; @@ -51,7 +51,7 @@ export type SlugFormField< ParsedValue extends {} | null, ValidatedValue extends ParsedValue, ReaderValue, - ReaderValueAsSlugField + ReaderValueAsSlugField, > = { kind: 'form'; formKind: 'slug'; @@ -86,7 +86,7 @@ export type SlugFormField< export type AssetFormField< ParsedValue extends {} | null, ValidatedValue extends ParsedValue, - ReaderValue + ReaderValue, > = { kind: 'form'; formKind: 'asset'; @@ -127,7 +127,7 @@ export type AssetFormField< export type ContentFormField< ParsedValue extends {} | null, ValidatedValue extends ParsedValue, - ReaderValue + ReaderValue, > = { kind: 'form'; formKind: 'content'; @@ -171,7 +171,7 @@ export type ContentFormField< export type FormField< ParsedValue extends {} | null, ValidatedValue extends ParsedValue, - ReaderValue + ReaderValue, > = | BasicFormField | SlugFormField @@ -219,7 +219,7 @@ export interface ObjectField< Fields extends Record = Record< string, ComponentSchema - > + >, > extends ObjectFieldOptions { kind: 'object'; fields: Fields; @@ -232,7 +232,7 @@ export type ConditionalField< [Key in `${ReturnType< DiscriminantField['defaultValue'] >}`]: ComponentSchema; - } + }, > = { kind: 'conditional'; discriminant: DiscriminantField; @@ -275,7 +275,7 @@ export type ComponentBlock< Fields extends Record = Record< string, ComponentSchema - > + >, > = { preview: (props: any) => ReactElement | null; schema: Fields; @@ -312,7 +312,7 @@ type FormFieldPreviewProps> = { type ObjectFieldPreviewProps< Schema extends ObjectField, - ChildFieldElement + ChildFieldElement, > = { readonly fields: { readonly [Key in keyof Schema['fields']]: GenericPreviewProps< @@ -330,7 +330,7 @@ type ObjectFieldPreviewProps< type ConditionalFieldPreviewProps< Schema extends ConditionalField, any>, - ChildFieldElement + ChildFieldElement, > = { readonly [Key in keyof Schema['values']]: { readonly discriminant: DiscriminantStringToDiscriminantValue< @@ -338,7 +338,7 @@ type ConditionalFieldPreviewProps< Key >; onChange< - Discriminant extends ReturnType + Discriminant extends ReturnType, >( discriminant: Discriminant, value?: InitialOrUpdateValueFromComponentPropField< @@ -355,7 +355,7 @@ type ConditionalFieldPreviewProps< type ArrayFieldPreviewProps< Schema extends ArrayField, - ChildFieldElement + ChildFieldElement, > = { readonly elements: readonly (GenericPreviewProps< Schema['element'], @@ -374,7 +374,7 @@ type ArrayFieldPreviewProps< export type GenericPreviewProps< Schema extends ComponentSchema, - ChildFieldElement + ChildFieldElement, > = Schema extends ChildField ? ChildFieldPreviewProps : Schema extends FormField @@ -393,7 +393,7 @@ export type PreviewProps = GenericPreviewProps< >; export type InitialOrUpdateValueFromComponentPropField< - Schema extends ComponentSchema + Schema extends ComponentSchema, > = Schema extends ChildField ? undefined : Schema extends FormField @@ -425,7 +425,7 @@ export type InitialOrUpdateValueFromComponentPropField< type DiscriminantStringToDiscriminantValue< DiscriminantField extends FormField, - DiscriminantString extends PropertyKey + DiscriminantString extends PropertyKey, > = ReturnType extends boolean ? 'true' extends DiscriminantString ? true @@ -440,7 +440,7 @@ export type PreviewPropsForToolbar = export function component< Schema extends { [Key in any]: ComponentSchema; - } + }, >( options: { /** The preview component shown in the editor */ @@ -554,7 +554,7 @@ export type ValueForReadingDeep = : never; export type InferRenderersForComponentBlocks< - ComponentBlocks extends Record> + ComponentBlocks extends Record>, > = { [Key in keyof ComponentBlocks]: Comp< ValueForReading> diff --git a/packages/keystatic/src/form/fields/conditional/index.tsx b/packages/keystatic/src/form/fields/conditional/index.tsx index bfae602c7..53b848591 100644 --- a/packages/keystatic/src/form/fields/conditional/index.tsx +++ b/packages/keystatic/src/form/fields/conditional/index.tsx @@ -6,7 +6,7 @@ export function conditional< [Key in `${ReturnType< DiscriminantField['defaultValue'] >}`]: ComponentSchema; - } + }, >( discriminant: DiscriminantField, values: ConditionalValues diff --git a/packages/keystatic/src/form/fields/conditional/ui.tsx b/packages/keystatic/src/form/fields/conditional/ui.tsx index 8cdccebe7..0db6799e8 100644 --- a/packages/keystatic/src/form/fields/conditional/ui.tsx +++ b/packages/keystatic/src/form/fields/conditional/ui.tsx @@ -19,7 +19,7 @@ export function ConditionalFieldInput< [Key in `${ReturnType< DiscriminantField['defaultValue'] >}`]: ComponentSchema; - } + }, >({ schema, autoFocus, diff --git a/packages/keystatic/src/form/fields/document/DocumentEditor/component-blocks/with-component-blocks.tsx b/packages/keystatic/src/form/fields/document/DocumentEditor/component-blocks/with-component-blocks.tsx index 9f9bde4f0..bf4445f91 100644 --- a/packages/keystatic/src/form/fields/document/DocumentEditor/component-blocks/with-component-blocks.tsx +++ b/packages/keystatic/src/form/fields/document/DocumentEditor/component-blocks/with-component-blocks.tsx @@ -411,7 +411,9 @@ export function withComponentBlocks( } const nodesWithin: [ number, - Element & { type: 'component-block-prop' | 'component-inline-prop' } + Element & { + type: 'component-block-prop' | 'component-inline-prop'; + }, ][] = []; for (const [idx, childNode] of node.children.entries()) { if ( diff --git a/packages/keystatic/src/form/fields/document/DocumentEditor/editor.tsx b/packages/keystatic/src/form/fields/document/DocumentEditor/editor.tsx index 187827843..01ef57b49 100644 --- a/packages/keystatic/src/form/fields/document/DocumentEditor/editor.tsx +++ b/packages/keystatic/src/form/fields/document/DocumentEditor/editor.tsx @@ -42,7 +42,7 @@ const insideOfLayouts = [...paragraphLike, 'component-block'] as const; function blockContainer(args: { allowedChildren: readonly [ TypesWhichHaveNoExtraRequiredProps, - ...Block['type'][] + ...Block['type'][], ]; invalidPositionHandleMode: 'unwrap' | 'move'; }): BlockContainerSchema { diff --git a/packages/keystatic/src/form/fields/markdoc/editor/dropcursor.ts b/packages/keystatic/src/form/fields/markdoc/editor/dropcursor.ts index 18e70c6ca..b86eb7ce2 100644 --- a/packages/keystatic/src/form/fields/markdoc/editor/dropcursor.ts +++ b/packages/keystatic/src/form/fields/markdoc/editor/dropcursor.ts @@ -39,7 +39,10 @@ class DropCursorView { timeout?: ReturnType; handlers: { name: string; handler: (event: Event) => void }[]; - constructor(readonly editorView: EditorView, options: DropCursorOptions) { + constructor( + readonly editorView: EditorView, + options: DropCursorOptions + ) { this.width = options.width ?? 1; this.color = options.color === false ? undefined : options.color || 'black'; this.class = options.class; diff --git a/packages/keystatic/src/form/fields/object/ui.tsx b/packages/keystatic/src/form/fields/object/ui.tsx index c88d53cc3..87e5b70a5 100644 --- a/packages/keystatic/src/form/fields/object/ui.tsx +++ b/packages/keystatic/src/form/fields/object/ui.tsx @@ -11,7 +11,7 @@ import { useId } from 'react'; import { Text } from '@keystar/ui/typography'; export function ObjectFieldInput< - Fields extends Record + Fields extends Record, >({ schema, autoFocus, diff --git a/packages/keystatic/src/form/fields/utils.tsx b/packages/keystatic/src/form/fields/utils.tsx index aff28fd8a..b3a93c5c9 100644 --- a/packages/keystatic/src/form/fields/utils.tsx +++ b/packages/keystatic/src/form/fields/utils.tsx @@ -21,7 +21,7 @@ export function assertRequired( export function basicFormFieldWithSimpleReaderParse< ParsedValue extends {} | null, - ValidatedValue extends ParsedValue + ValidatedValue extends ParsedValue, >(config: { Input(props: FormFieldInputProps): ReactElement | null; defaultValue(): ParsedValue; diff --git a/packages/keystatic/src/form/initial-values.ts b/packages/keystatic/src/form/initial-values.ts index c877a07bb..ba27f76af 100644 --- a/packages/keystatic/src/form/initial-values.ts +++ b/packages/keystatic/src/form/initial-values.ts @@ -31,7 +31,7 @@ export function getNewArrayElementKey() { } export const getInitialPropsValue = _getInitialPropsValue as < - Schema extends ComponentSchema + Schema extends ComponentSchema, >( schema: Schema ) => ParsedValueForComponentSchema; diff --git a/packages/keystatic/src/form/preview-props.tsx b/packages/keystatic/src/form/preview-props.tsx index 090bad383..445963067 100644 --- a/packages/keystatic/src/form/preview-props.tsx +++ b/packages/keystatic/src/form/preview-props.tsx @@ -27,7 +27,7 @@ function castToMemoizedInfoForSchema< > ) => void ) => unknown; - } + }, >(val: T): T { return val; } @@ -51,7 +51,7 @@ function getOrInsert( export function createGetPreviewProps< Schema extends ComponentSchema, - ChildFieldElement + ChildFieldElement, >( rootSchema: Schema, rootOnChange: ( diff --git a/packages/keystatic/src/reader/index.ts b/packages/keystatic/src/reader/index.ts index 3dcd969f4..f900ab0da 100644 --- a/packages/keystatic/src/reader/index.ts +++ b/packages/keystatic/src/reader/index.ts @@ -32,18 +32,18 @@ type EntryReaderOpts = { resolveLinkedFiles?: boolean }; type ValueForReadingWithMode< Schema extends ComponentSchema, - ResolveLinkedFiles extends boolean | undefined + ResolveLinkedFiles extends boolean | undefined, > = ResolveLinkedFiles extends true ? ValueForReadingDeep : ValueForReading; type OptionalChain< T extends {} | undefined, - Key extends keyof (T & {}) + Key extends keyof (T & {}), > = T extends {} ? T[Key] : undefined; export type Entry< - CollectionOrSingleton extends Collection | Singleton + CollectionOrSingleton extends Collection | Singleton, > = CollectionOrSingleton extends Collection ? CollectionEntry : CollectionOrSingleton extends Singleton @@ -51,7 +51,7 @@ export type Entry< : never; export type EntryWithResolvedLinkedFiles< - CollectionOrSingleton extends Collection | Singleton + CollectionOrSingleton extends Collection | Singleton, > = CollectionOrSingleton extends Collection ? CollectionEntryWithResolvedLinkedFiles : CollectionOrSingleton extends Singleton @@ -60,7 +60,7 @@ export type EntryWithResolvedLinkedFiles< type CollectionEntryWithResolvedLinkedFiles< Schema extends Record, - SlugField extends string + SlugField extends string, > = { [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField< @@ -76,7 +76,7 @@ type CollectionEntryWithResolvedLinkedFiles< type CollectionEntry< Schema extends Record, - SlugField extends string + SlugField extends string, > = { [Key in keyof Schema]: SlugField extends Key ? Schema[Key] extends SlugFormField< @@ -91,7 +91,7 @@ type CollectionEntry< }; type SingletonEntryWithResolvedLinkedFiles< - Schema extends Record + Schema extends Record, > = ValueForReadingDeep>; type SingletonEntry> = @@ -99,7 +99,7 @@ type SingletonEntry> = type CollectionReader< Schema extends Record, - SlugField extends string + SlugField extends string, > = { read: ( slug: string, @@ -455,7 +455,7 @@ export type Reader< }, Singletons extends { [key: string]: Singleton>; - } + }, > = { collections: { [Key in keyof Collections]: CollectionReader< @@ -476,7 +476,7 @@ export function createReader< }, Singletons extends { [key: string]: Singleton>; - } + }, >( repoPath: string, config: Config diff --git a/packages/keystatic/src/renderer.tsx b/packages/keystatic/src/renderer.tsx index e980db3e4..7171c3d26 100644 --- a/packages/keystatic/src/renderer.tsx +++ b/packages/keystatic/src/renderer.tsx @@ -342,7 +342,7 @@ export type DocumentRendererProps< ComponentBlocks extends Record> = Record< string, Component - > + >, > = { document: Element[]; renderers?: { @@ -353,7 +353,7 @@ export type DocumentRendererProps< }; export function DocumentRenderer< - ComponentBlocks extends Record> + ComponentBlocks extends Record>, >(props: DocumentRendererProps) { const renderers = { inline: { ...defaultRenderers.inline, ...props.renderers?.inline },