From 1fe56daf9a3c6aa4da6f33bd227526ef19810ff8 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolski Date: Mon, 4 Apr 2022 18:30:10 +0200 Subject: [PATCH] Update paths helper lib --- .eslintrc | 3 +-- .prettierignore | 1 + lib/$path.ts | 39 +++++++++++++++++---------------------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.eslintrc b/.eslintrc index b1855a433..508fac115 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,7 +7,7 @@ "plugin:@typescript-eslint/recommended", "prettier" // prettier *has* to be the last one, to avoid conflicting rules ], - "ignorePatterns": ["saleor/api.tsx", "pnpm-lock.yaml", "graphql.schema.json"], + "ignorePatterns": ["saleor/api.tsx", "pnpm-lock.yaml", "graphql.schema.json", "lib/$path.ts"], "plugins": ["simple-import-sort", "formatjs", "@typescript-eslint"], "rules": { "quotes": ["error", "double"], @@ -31,7 +31,6 @@ "no-console": ["error", { "allow": ["warn", "error"] }], "operator-linebreak": "off", "max-len": "off", - // To be discussed "array-callback-return": "off", "implicit-arrow-linebreak": "off", "@typescript-eslint/no-non-null-asserted-optional-chain": "off", diff --git a/.prettierignore b/.prettierignore index e0bb33f20..d605ec8f6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,4 @@ saleor/api.tsx pnpm-lock.yaml graphql.schema.json +lib/$path.ts diff --git a/lib/$path.ts b/lib/$path.ts index cd47266f4..e18dcec94 100644 --- a/lib/$path.ts +++ b/lib/$path.ts @@ -1,12 +1,8 @@ -/* eslint-disable */ -// prettier-ignore -import { OptionalQuery as OptionalQuery0 } from '../pages/[channel]/[locale]/account/login' -// prettier-ignore -import { OptionalQuery as OptionalQuery1 } from '../pages/[channel]/[locale]/products/[slug]' +import type { OptionalQuery as OptionalQuery0 } from '../pages/[channel]/[locale]/account/login' +import type { OptionalQuery as OptionalQuery1 } from '../pages/[channel]/[locale]/products/[slug]' -// prettier-ignore export const pagesPath = { - $404: { + "$404": { $url: (url?: { hash?: string }) => ({ pathname: '/404' as const, hash: url?.hash }) }, _channel: (channel: string | number) => ({ @@ -14,56 +10,56 @@ export const pagesPath = { _sitemap: (sitemap: string | number) => ({ $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/[sitemap]' as const, query: { channel, locale, sitemap }, hash: url?.hash }) }), - account: { - addressBook: { + "account": { + "addressBook": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/addressBook' as const, query: { channel, locale }, hash: url?.hash }) }, - login: { + "login": { $url: (url?: { query?: OptionalQuery0, hash?: string }) => ({ pathname: '/[channel]/[locale]/account/login' as const, query: { channel, locale, ...url?.query }, hash: url?.hash }) }, - orders: { + "orders": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/orders' as const, query: { channel, locale }, hash: url?.hash }), _token: (token: string | number) => ({ $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/orders/[token]' as const, query: { channel, locale, token }, hash: url?.hash }) }) }, - preferences: { + "preferences": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/preferences' as const, query: { channel, locale }, hash: url?.hash }) }, - register: { + "register": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/account/register' as const, query: { channel, locale }, hash: url?.hash }) } }, - cart: { + "cart": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/cart' as const, query: { channel, locale }, hash: url?.hash }) }, - category: { + "category": { _slug: (slug: string | number) => ({ $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/category/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash }) }) }, - checkout: { + "checkout": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/checkout' as const, query: { channel, locale }, hash: url?.hash }) }, - collection: { + "collection": { _slug: (slug: string | number) => ({ $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/collection/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash }) }) }, - order: { + "order": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/order' as const, query: { channel, locale }, hash: url?.hash }) }, - page: { + "page": { _slug: (slug: string | number) => ({ $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/page/[slug]' as const, query: { channel, locale, slug }, hash: url?.hash }) }) }, - products: { + "products": { _slug: (slug: string | number) => ({ $url: (url?: { query?: OptionalQuery1, hash?: string }) => ({ pathname: '/[channel]/[locale]/products/[slug]' as const, query: { channel, locale, slug, ...url?.query }, hash: url?.hash }) }) }, - search: { + "search": { $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]/search' as const, query: { channel, locale }, hash: url?.hash }) }, $url: (url?: { hash?: string }) => ({ pathname: '/[channel]/[locale]' as const, query: { channel, locale }, hash: url?.hash }) @@ -72,5 +68,4 @@ export const pagesPath = { $url: (url?: { hash?: string }) => ({ pathname: '/' as const, hash: url?.hash }) } -// prettier-ignore export type PagesPath = typeof pagesPath