diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..757fd64caa --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "trailingComma": "es5" +} diff --git a/packages/adapter-next/.prettierrc b/packages/adapter-next/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/adapter-next/.prettierrc +++ b/packages/adapter-next/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/adapter-nuxt/.prettierrc b/packages/adapter-nuxt/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/adapter-nuxt/.prettierrc +++ b/packages/adapter-nuxt/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/adapter-nuxt/src/hooks/documentation-read.ts b/packages/adapter-nuxt/src/hooks/documentation-read.ts index 4451b59d5d..caac637b93 100644 --- a/packages/adapter-nuxt/src/hooks/documentation-read.ts +++ b/packages/adapter-nuxt/src/hooks/documentation-read.ts @@ -35,8 +35,8 @@ export const documentationRead: DocumentationReadHook = async ( model.id }-uid-\${route.params.uid}]\`, () => prismic.client.getByUID("${model.id}", route.params.uid${ - isTypeScriptProject ? " as string" : "" - }) + isTypeScriptProject ? " as string" : "" + }) ); useHead({ diff --git a/packages/adapter-nuxt2/.prettierrc b/packages/adapter-nuxt2/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/adapter-nuxt2/.prettierrc +++ b/packages/adapter-nuxt2/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/adapter-sveltekit/.prettierrc b/packages/adapter-sveltekit/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/adapter-sveltekit/.prettierrc +++ b/packages/adapter-sveltekit/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/init/.prettierrc b/packages/init/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/init/.prettierrc +++ b/packages/init/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/init/src/lib/prompt.ts b/packages/init/src/lib/prompt.ts index 0433eadd0b..33adca87d4 100644 --- a/packages/init/src/lib/prompt.ts +++ b/packages/init/src/lib/prompt.ts @@ -11,9 +11,8 @@ type promptArgs< export const prompt = async ( question: promptArgs, ): Promise> => { - const answers: Record = await prompts( - question, - ); + const answers: Record = + await prompts(question); if (!Object.keys(answers).length) { process.exit(130); diff --git a/packages/manager/.prettierrc b/packages/manager/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/manager/.prettierrc +++ b/packages/manager/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/manager/src/managers/slices/SlicesManager.ts b/packages/manager/src/managers/slices/SlicesManager.ts index a4a115b4d7..b0546d71ff 100644 --- a/packages/manager/src/managers/slices/SlicesManager.ts +++ b/packages/manager/src/managers/slices/SlicesManager.ts @@ -304,9 +304,8 @@ export class SlicesManager extends BaseManager { mocks: mockSlice({ model: args.model }), }; - const { errors: updateSliceHookErrors } = await this.updateSliceMocks( - updateSliceMocksArgs, - ); + const { errors: updateSliceHookErrors } = + await this.updateSliceMocks(updateSliceMocksArgs); return { errors: [...hookResult.errors, ...updateSliceHookErrors], @@ -368,9 +367,8 @@ export class SlicesManager extends BaseManager { mocks: updatedMocks, }; - const { errors: updateSliceMocksHookResult } = await this.updateSliceMocks( - updateSliceMocksArgs, - ); + const { errors: updateSliceMocksHookResult } = + await this.updateSliceMocks(updateSliceMocksArgs); return { errors: [...hookResult.errors, ...updateSliceMocksHookResult], diff --git a/packages/manager/src/types.ts b/packages/manager/src/types.ts index 3ee2dbce1e..cafd7b62ca 100644 --- a/packages/manager/src/types.ts +++ b/packages/manager/src/types.ts @@ -10,7 +10,8 @@ export type { APIEndpoints } from "./constants/API_ENDPOINTS"; * @typeParam TSliceMachinePluginOptions - User-provided options for the plugin. */ export type SliceMachineConfigPluginRegistration< - TSliceMachinePluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions, + TSliceMachinePluginOptions extends + SliceMachinePluginOptions = SliceMachinePluginOptions, > = | string | { diff --git a/packages/manager/test/__setup__.ts b/packages/manager/test/__setup__.ts index df48493260..2dbfa94492 100644 --- a/packages/manager/test/__setup__.ts +++ b/packages/manager/test/__setup__.ts @@ -74,9 +74,8 @@ vi.mock("fs/promises", async () => { }; const memfs: typeof import("memfs") = await vi.importActual("memfs"); - const _fs: typeof import("node:fs/promises") = await vi.importActual( - "node:fs/promises", - ); + const _fs: typeof import("node:fs/promises") = + await vi.importActual("node:fs/promises"); const readFile = escapeOnigurumaMethod( _fs.readFile, diff --git a/packages/plugin-kit/.prettierrc b/packages/plugin-kit/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/plugin-kit/.prettierrc +++ b/packages/plugin-kit/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/packages/plugin-kit/test/SliceMachinePluginRunner-loadPlugin.test.ts b/packages/plugin-kit/test/SliceMachinePluginRunner-loadPlugin.test.ts index 029f1fd86b..232eaece1c 100644 --- a/packages/plugin-kit/test/SliceMachinePluginRunner-loadPlugin.test.ts +++ b/packages/plugin-kit/test/SliceMachinePluginRunner-loadPlugin.test.ts @@ -4,12 +4,11 @@ import * as path from "node:path"; import * as plugin from "./__fixtures__/plugin"; const createRequireMock = - vi.fn>(); + vi.fn>(); vi.mock("module", async () => { - const actual: typeof import("node:module") = await vi.importActual( - "node:module", - ); + const actual: typeof import("node:module") = + await vi.importActual("node:module"); return { ...actual, diff --git a/packages/slice-machine/components/Simulator/components/IframeRenderer/index.tsx b/packages/slice-machine/components/Simulator/components/IframeRenderer/index.tsx index 1245d3bcdf..db5adcc3e7 100644 --- a/packages/slice-machine/components/Simulator/components/IframeRenderer/index.tsx +++ b/packages/slice-machine/components/Simulator/components/IframeRenderer/index.tsx @@ -9,7 +9,7 @@ import { ScreenDimensions } from "@lib/models/common/Screenshots"; function useSimulatorClient(): readonly [ SimulatorClient | undefined, - RefCallback + RefCallback, ] { const [client, setClient] = useState(); const clientRef = useRef(); diff --git a/packages/slice-machine/lib/models/common/ErrorWithStatus.ts b/packages/slice-machine/lib/models/common/ErrorWithStatus.ts index a88767090d..756b580f78 100644 --- a/packages/slice-machine/lib/models/common/ErrorWithStatus.ts +++ b/packages/slice-machine/lib/models/common/ErrorWithStatus.ts @@ -1,5 +1,8 @@ export default class ErrorWithStatus extends Error { - constructor(readonly reason: string, readonly status: number) { + constructor( + readonly reason: string, + readonly status: number + ) { super(reason); } } diff --git a/packages/slice-machine/lib/utils/poll.ts b/packages/slice-machine/lib/utils/poll.ts index f61a7f68fc..f7c26a09c6 100644 --- a/packages/slice-machine/lib/utils/poll.ts +++ b/packages/slice-machine/lib/utils/poll.ts @@ -1,6 +1,6 @@ export async function startPolling< Result, - ValidatedResult extends Result = Result + ValidatedResult extends Result = Result, >( fn: () => Promise, validate: (result: Result) => result is ValidatedResult, diff --git a/packages/slice-machine/src/features/labs/labsList/useLab.tsx b/packages/slice-machine/src/features/labs/labsList/useLab.tsx index 8617fdfa82..737bd4fa01 100644 --- a/packages/slice-machine/src/features/labs/labsList/useLab.tsx +++ b/packages/slice-machine/src/features/labs/labsList/useLab.tsx @@ -6,7 +6,7 @@ export type UseLabArgs = keyof Required["labs"]; export type UseLabReturnType = [ lab: { enabled: boolean }, - setLab: (enabled: boolean) => Promise + setLab: (enabled: boolean) => Promise, ]; export function useLab(key: UseLabArgs): UseLabReturnType { diff --git a/packages/slice-machine/src/hooks/useModelStatus.ts b/packages/slice-machine/src/hooks/useModelStatus.ts index ce9eb7012f..99a3f7288c 100644 --- a/packages/slice-machine/src/hooks/useModelStatus.ts +++ b/packages/slice-machine/src/hooks/useModelStatus.ts @@ -36,14 +36,17 @@ function computeStatuses( models: LocalOrRemoteModel[], userHasAccessToModels: boolean ) { - return models.reduce<{ [id: string]: ModelStatus }>((acc, model) => { - const { status } = computeModelStatus(model, userHasAccessToModels); + return models.reduce<{ [id: string]: ModelStatus }>( + (acc, model) => { + const { status } = computeModelStatus(model, userHasAccessToModels); - return { - ...acc, - [hasLocal(model) ? model.local.id : model.remote.id]: status, - }; - }, {} as { [sliceId: string]: ModelStatus }); + return { + ...acc, + [hasLocal(model) ? model.local.id : model.remote.id]: status, + }; + }, + {} as { [sliceId: string]: ModelStatus } + ); } export const useModelStatus = ({ diff --git a/packages/slice-machine/src/hooks/useSliceMachineConfig.ts b/packages/slice-machine/src/hooks/useSliceMachineConfig.ts index 3a4663c021..0331ebe717 100644 --- a/packages/slice-machine/src/hooks/useSliceMachineConfig.ts +++ b/packages/slice-machine/src/hooks/useSliceMachineConfig.ts @@ -5,7 +5,7 @@ import { managerClient } from "@src/managerClient"; type UseSliceMachineConfigReturnType = [ config: SliceMachineConfig, - setConfig: (config: SliceMachineConfig) => Promise + setConfig: (config: SliceMachineConfig) => Promise, ]; export function useSliceMachineConfig(): UseSliceMachineConfigReturnType { diff --git a/packages/slice-machine/src/hooks/useThrottle.ts b/packages/slice-machine/src/hooks/useThrottle.ts index 2fdd6cc69b..4cdc6ed771 100644 --- a/packages/slice-machine/src/hooks/useThrottle.ts +++ b/packages/slice-machine/src/hooks/useThrottle.ts @@ -9,12 +9,15 @@ function useThrottle( const lastRan = useRef(Date.now()); useEffect(() => { - const handler = setTimeout(function () { - if (Date.now() - lastRan.current >= limit) { - setThrottledValue(cb()); - lastRan.current = Date.now(); - } - }, limit - (Date.now() - lastRan.current)); + const handler = setTimeout( + function () { + if (Date.now() - lastRan.current >= limit) { + setThrottledValue(cb()); + lastRan.current = Date.now(); + } + }, + limit - (Date.now() - lastRan.current) + ); return () => { clearTimeout(handler); diff --git a/packages/slice-machine/src/modules/useSliceMachineActions.ts b/packages/slice-machine/src/modules/useSliceMachineActions.ts index c271994095..2404a73ea6 100644 --- a/packages/slice-machine/src/modules/useSliceMachineActions.ts +++ b/packages/slice-machine/src/modules/useSliceMachineActions.ts @@ -112,7 +112,9 @@ const useSliceMachineActions = () => { dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.DELETE_SLICE })); const openDeleteDocumentsDrawer = () => dispatch( - modalOpenCreator({ modalKey: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER }) + modalOpenCreator({ + modalKey: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER, + }) ); const openDeleteDocumentsDrawerOverLimit = () => dispatch( diff --git a/packages/slice-machine/src/theme.ts b/packages/slice-machine/src/theme.ts index 1ac57dffcc..3d02eb5e3a 100644 --- a/packages/slice-machine/src/theme.ts +++ b/packages/slice-machine/src/theme.ts @@ -993,6 +993,6 @@ const AppTheme = (): Theme => bg: "muted", }, }, - } as Theme); + }) as Theme; export default AppTheme; diff --git a/packages/slice-machine/test/__testutils__/createTestPlugin.ts b/packages/slice-machine/test/__testutils__/createTestPlugin.ts index b952219019..e606e71d93 100644 --- a/packages/slice-machine/test/__testutils__/createTestPlugin.ts +++ b/packages/slice-machine/test/__testutils__/createTestPlugin.ts @@ -39,7 +39,7 @@ type CreateTestPluginArgs = }; export const createTestPlugin = < - TPluginOptions extends SliceMachinePluginOptions + TPluginOptions extends SliceMachinePluginOptions, >({ setup, __autofillRequiredAdapterHooks = true, diff --git a/packages/slice-machine/test/src/hooks/useModelStatus.test.ts b/packages/slice-machine/test/src/hooks/useModelStatus.test.ts index 31fb6a1e8a..158a71e77d 100644 --- a/packages/slice-machine/test/src/hooks/useModelStatus.test.ts +++ b/packages/slice-machine/test/src/hooks/useModelStatus.test.ts @@ -12,9 +12,8 @@ import { ModelStatus } from "@lib/models/common/ModelStatus"; const mockSelector = vi.fn(); vi.mock("react-redux", async () => { - const actual: typeof import("react-redux") = await vi.importActual( - "react-redux" - ); + const actual: typeof import("react-redux") = + await vi.importActual("react-redux"); return { ...actual, diff --git a/packages/slice-machine/test/src/modules/availableCustomTypes/index.test.ts b/packages/slice-machine/test/src/modules/availableCustomTypes/index.test.ts index e615e90218..c69a490fb5 100644 --- a/packages/slice-machine/test/src/modules/availableCustomTypes/index.test.ts +++ b/packages/slice-machine/test/src/modules/availableCustomTypes/index.test.ts @@ -31,8 +31,10 @@ describe("[Available Custom types module]", () => { it("should return the initial state if no matching action", () => { expect( - // @ts-expect-error TS(2322) FIXME: Type '"NO.MATCH"' is not assignable to type '"CUST... Remove this comment to see the full error message - availableCustomTypesReducer(dummyCustomTypesState, { type: "NO.MATCH" }) + availableCustomTypesReducer(dummyCustomTypesState, { + // @ts-expect-error TS(2322) FIXME: Type '"NO.MATCH"' is not assignable to type '"CUST... Remove this comment to see the full error message + type: "NO.MATCH", + }) ).toEqual(dummyCustomTypesState); }); diff --git a/packages/start-slicemachine/.prettierrc b/packages/start-slicemachine/.prettierrc index 815c6788fa..a3bf3ac165 100644 --- a/packages/start-slicemachine/.prettierrc +++ b/packages/start-slicemachine/.prettierrc @@ -2,7 +2,7 @@ "plugins": ["prettier-plugin-jsdoc"], "jsdocSeparateReturnsFromParam": true, "jsdocSeparateTagGroups": true, - "jsdocSingleLineComment": false, + "jsdocCommentLineStrategy": "keep", "tsdoc": true, "printWidth": 80, "useTabs": true, diff --git a/yarn.lock b/yarn.lock index 194934ea3d..58485a23e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24831,8 +24831,6 @@ __metadata: "@types/react": ^18.2.25 "@types/react-dom": ^18.2.11 next: ^13.5.4 - prettier: ^3.0.3 - prettier-plugin-tailwindcss: ^0.5.6 react: ^18.2.0 react-dom: ^18.2.0 slice-machine-ui: "workspace:*" @@ -28155,59 +28153,6 @@ __metadata: languageName: node linkType: hard -"prettier-plugin-tailwindcss@npm:^0.5.6": - version: 0.5.6 - resolution: "prettier-plugin-tailwindcss@npm:0.5.6" - peerDependencies: - "@ianvs/prettier-plugin-sort-imports": "*" - "@prettier/plugin-pug": "*" - "@shopify/prettier-plugin-liquid": "*" - "@shufo/prettier-plugin-blade": "*" - "@trivago/prettier-plugin-sort-imports": "*" - prettier: ^3.0 - prettier-plugin-astro: "*" - prettier-plugin-css-order: "*" - prettier-plugin-import-sort: "*" - prettier-plugin-jsdoc: "*" - prettier-plugin-organize-attributes: "*" - prettier-plugin-organize-imports: "*" - prettier-plugin-style-order: "*" - prettier-plugin-svelte: "*" - peerDependenciesMeta: - "@ianvs/prettier-plugin-sort-imports": - optional: true - "@prettier/plugin-pug": - optional: true - "@shopify/prettier-plugin-liquid": - optional: true - "@shufo/prettier-plugin-blade": - optional: true - "@trivago/prettier-plugin-sort-imports": - optional: true - prettier-plugin-astro: - optional: true - prettier-plugin-css-order: - optional: true - prettier-plugin-import-sort: - optional: true - prettier-plugin-jsdoc: - optional: true - prettier-plugin-marko: - optional: true - prettier-plugin-organize-attributes: - optional: true - prettier-plugin-organize-imports: - optional: true - prettier-plugin-style-order: - optional: true - prettier-plugin-svelte: - optional: true - prettier-plugin-twig-melody: - optional: true - checksum: ea5b18daf8727ee77eb6f10e5ceb43416aedee48350b838faae5764083dadb93edba33b84ed5c6ce606de33c875fc444ca979e669f340373fa0f0b76a5cafeac - languageName: node - linkType: hard - "prettier@npm:*, prettier@npm:3.0.3, prettier@npm:^3.0.3": version: 3.0.3 resolution: "prettier@npm:3.0.3"