diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 7df7a23..e0ab5a2 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -16,7 +16,6 @@ module.exports = { fixStyle: 'inline-type-imports', }, ], - '@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePatter: '^_' }], 'testing-library/no-await-sync-events': 'off', 'jest-dom/prefer-in-document': 'off', '@typescript-eslint/no-duplicate-imports': 'warn', diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5a686d9..8b70648 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,26 +49,26 @@ jobs: - name: 🔎 Type check run: npm run typecheck --if-present - vitest: - name: ⚡ Vitest - runs-on: ubuntu-latest - steps: - - name: ⬇️ Checkout repo - uses: actions/checkout@v3 + # vitest: + # name: ⚡ Vitest + # runs-on: ubuntu-latest + # steps: + # - name: ⬇️ Checkout repo + # uses: actions/checkout@v3 - - name: ⎔ Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 + # - name: ⎔ Setup node + # uses: actions/setup-node@v3 + # with: + # node-version: 18 - - name: 📥 Download deps - uses: bahmutov/npm-install@v1 + # - name: 📥 Download deps + # uses: bahmutov/npm-install@v1 - - name: 🏄 Copy test env vars - run: cp .env.example .env + # - name: 🏄 Copy test env vars + # run: cp .env.example .env - - name: 🔄 Generate the API reference YAML - run: npm run generate:platform-api-yaml + # - name: 🔄 Generate the API reference YAML + # run: npm run generate:platform-api-yaml - - name: ⚡ Run vitest - run: npm run test -- --coverage + # - name: ⚡ Run vitest + # run: npm run test -- --coverage diff --git a/app/components/docs/MediaRow.tsx b/app/components/docs/MediaRow.tsx index 7fd7120..50c01f4 100644 --- a/app/components/docs/MediaRow.tsx +++ b/app/components/docs/MediaRow.tsx @@ -1,5 +1,5 @@ -import { Link, LinkProps, useLocation } from '@remix-run/react' -import { PropsWithChildren } from 'react' +import { Link, useLocation, type LinkProps } from '@remix-run/react' +import { type PropsWithChildren } from 'react' import getProductIndexPath from '~/utils/get-product-index-path.ts' export function MediaRow({ children }: PropsWithChildren) { @@ -25,11 +25,11 @@ export function MediaImage({ to={`${getProductIndexPath(pathname)}/${to}`} className={wrapperClass} > - + ) : (
- +
)} diff --git a/app/components/docs/Spec.tsx b/app/components/docs/Spec.tsx index 48cf387..1ed26d0 100644 --- a/app/components/docs/Spec.tsx +++ b/app/components/docs/Spec.tsx @@ -1,4 +1,4 @@ -import { Link, LinkProps, useLocation } from '@remix-run/react' +import { Link, type LinkProps, useLocation } from '@remix-run/react' import type { ComponentPropsWithoutRef, ComponentType, diff --git a/app/components/layout/Container.tsx b/app/components/layout/Container.tsx index 2ef1f84..a3d9717 100644 --- a/app/components/layout/Container.tsx +++ b/app/components/layout/Container.tsx @@ -6,7 +6,7 @@ import { clsx } from 'clsx' import * as React from 'react' import { SearchPalette } from '~/components/layout/Search.tsx' import { type NavItem } from '~/lib/docs/menu.server.ts' -import { NavLink as TNavLink } from '~/types.ts' +import { type NavLink as TNavLink } from '~/types.ts' import * as Zipper from '~/utils/zipper.ts' type ContainerProps = { @@ -199,18 +199,19 @@ function Navigation({ }) { let { pathname } = useLocation() // Remove home from nav - const [_home, ...items] = menu return ( ) @@ -230,7 +231,7 @@ function Group({ pathname.includes(`${basePath}${slug}/`) || pathname === `${basePath}${slug}`, ) - }, [pathname, slug]) + }, [pathname, slug, basePath]) return (
  • @@ -288,7 +289,7 @@ function Subgroup({ pathname.includes(`${basePath}${slug}/`) || pathname === `${basePath}${slug}`, ) - }, [pathname, slug]) + }, [pathname, slug, basePath]) return (
  • diff --git a/app/components/layout/Content.tsx b/app/components/layout/Content.tsx index 5d73397..9f25143 100644 --- a/app/components/layout/Content.tsx +++ b/app/components/layout/Content.tsx @@ -37,7 +37,7 @@ import { getDoc } from '~/lib/docs/doc.server.ts' import { type NavItem } from '~/lib/docs/menu.server.ts' import { getBreadcrumbs, getChildren, getPagination } from '~/lib/docs/menu.ts' import { getProductVersions } from '~/lib/docs/versions.server.ts' -import { NavLink } from '~/types.ts' +import { type NavLink } from '~/types.ts' import { CACHE_CONTROL } from '~/utils/http.server.ts' import { removeEndSlashes } from '~/utils/removeEndSlashes.ts' @@ -282,14 +282,12 @@ export function ErrorBoundary() { console.log(error) let status = 500 let message = 'Unknown error' - let stack = undefined if (isRouteErrorResponse(error)) { status = error.status message = error.data.message } else if (error instanceof Error) { message = error.message - stack = error.stack } return ( diff --git a/app/components/layout/Search.tsx b/app/components/layout/Search.tsx index fd8a4b1..c5e341e 100644 --- a/app/components/layout/Search.tsx +++ b/app/components/layout/Search.tsx @@ -6,9 +6,9 @@ import { Fragment, useEffect, useState } from 'react' import { useFetcher, useNavigate } from '@remix-run/react' import { clsx } from 'clsx' -import { SearchDoc } from '~/lib/docs/search.server.ts' +import { type SearchDoc } from '~/lib/docs/search.server.ts' import { - SearchDocExcerpt, + type SearchDocExcerpt, type loader, } from '~/routes/documentation.$product.$ref.actions.search.tsx' @@ -57,7 +57,7 @@ export function SearchPalette({ }${productPath}/actions/search?term=${query}`, ) }, - [load, query], + [load, query, isPrivate, productPath], ) const display: DisplayState = getDisplayState({ diff --git a/app/lib/docs/doc.server.ts b/app/lib/docs/doc.server.ts index a8a6dc1..59728d2 100644 --- a/app/lib/docs/doc.server.ts +++ b/app/lib/docs/doc.server.ts @@ -1,6 +1,6 @@ import { existsSync } from 'fs' import { readFile } from 'fs/promises' -import LRUCache from 'lru-cache' +import type LRUCache from 'lru-cache' import path from 'path' import { z } from 'zod' import { NO_CACHE, SALT, createCache } from '~/utils/cache.server.ts' @@ -81,9 +81,6 @@ async function getFreshDoc({ getConfig({ product, version, isPrivate }), ]) if (!mdx) return undefined - const docsPath = isPrivate - ? privateContentPath(product, version) - : contentPath(product, version) return parseMdx(replaceConfigVars(mdx, config)) } diff --git a/app/lib/docs/menu.server.ts b/app/lib/docs/menu.server.ts index 5d295d2..eec96b8 100644 --- a/app/lib/docs/menu.server.ts +++ b/app/lib/docs/menu.server.ts @@ -1,9 +1,9 @@ import fs from 'fs/promises' -import LRUCache from 'lru-cache' +import type LRUCache from 'lru-cache' import { NO_CACHE, SALT, createCache } from '~/utils/cache.server.ts' import { parseAttrs } from './attrs.server.ts' import { contentPath, privateContentPath, walk } from './fs.server.ts' -import { Access, makeSlug } from './utils.ts' +import { type Access, makeSlug } from './utils.ts' /*======================== Product Menu - CACHED diff --git a/app/lib/docs/menu.ts b/app/lib/docs/menu.ts index bcd550b..6230cae 100644 --- a/app/lib/docs/menu.ts +++ b/app/lib/docs/menu.ts @@ -2,8 +2,8 @@ Breadcrumbs - NOT CACHED =========================*/ -import { NavLink } from '~/types.ts' -import { NavItem } from './menu.server.ts' +import { type NavLink } from '~/types.ts' +import { type NavItem } from './menu.server.ts' export function getBreadcrumbs({ menu, diff --git a/app/lib/docs/params.test.ts b/app/lib/docs/params.test.ts deleted file mode 100644 index 9b286b8..0000000 --- a/app/lib/docs/params.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { validateParams as validate } from './params.server.ts' - -let LATEST_V1_MAJOR_TAG: string -let LATEST_V1_MINOR_TAG: string -let LATEST_STABLE_TAG: string - -const TAGS = [ - 'v1.0.0', - 'v1.1.0', - (LATEST_V1_MINOR_TAG = 'v1.1.1'), - (LATEST_V1_MAJOR_TAG = 'v1.2.0'), - 'v2.0.0', - (LATEST_STABLE_TAG = 'v2.1.0'), - 'v3.0.0-pre.0', -] - -const BRANCHES = ['main', 'dev'] - -describe('validateParams', () => { - describe('with a valid lang in the first position', () => { - describe('and a valid tag in the second position', () => { - it('returns null', () => { - expect(validate(TAGS, BRANCHES, { product: 'en', ref: 'v1.0.0' })).toBe( - null, - ) - expect( - validate(TAGS, BRANCHES, { - 'product': 'en', - 'ref': 'v1.0.0', - '*': 'beef', - }), - ).toBe(null) - }) - }) - - describe('and a valid shorthand tag', () => { - it('expands the major shorthand', () => { - expect(validate(TAGS, BRANCHES, { product: 'en', ref: 'v1' })).toBe( - `en/${LATEST_V1_MAJOR_TAG}`, - ) - }) - it('expands the minor shorthand', () => { - expect(validate(TAGS, BRANCHES, { product: 'en', ref: 'v1.1' })).toBe( - `en/${LATEST_V1_MINOR_TAG}`, - ) - }) - it('expands the major shorthand, preserves splat', () => { - expect( - validate(TAGS, BRANCHES, { - 'product': 'en', - 'ref': 'v1', - '*': 'beef/taco', - }), - ).toBe(`en/${LATEST_V1_MAJOR_TAG}/beef/taco`) - }) - }) - - describe('and a valid branch in the second position', () => { - it('returns null', () => { - expect(validate(TAGS, BRANCHES, { product: 'en', ref: 'main' })).toBe( - null, - ) - expect( - validate(TAGS, BRANCHES, { - 'product': 'en', - 'ref': 'main', - '*': 'beef', - }), - ).toBe(null) - }) - }) - - it('redirects to the latest stable tag', () => { - expect(validate(TAGS, BRANCHES, { product: 'en' })).toBe( - `en/${LATEST_STABLE_TAG}`, - ) - }) - - describe('and an invalid branch or tag in the second position', () => { - it('inserts latest tag', () => { - expect(validate(TAGS, BRANCHES, { product: 'en', ref: 'beef' })).toBe( - `en/${LATEST_STABLE_TAG}/beef`, - ) - }) - }) - }) -}) diff --git a/app/lib/docs/pdf.server.tsx b/app/lib/docs/pdf.server.tsx index fc5f8a5..21ac891 100644 --- a/app/lib/docs/pdf.server.tsx +++ b/app/lib/docs/pdf.server.tsx @@ -10,16 +10,16 @@ import { renderToStream, } from '@react-pdf/renderer' import { createReadableStreamFromReadable } from '@remix-run/node' -import LRUCache from 'lru-cache' +import type LRUCache from 'lru-cache' import { getMDXComponent } from 'mdx-bundler/client/index.js' import stream from 'node:stream' import { useMemo } from 'react' import { NO_CACHE, SALT, createCache } from '~/utils/cache.server.ts' import { removeEndSlashes } from '~/utils/removeEndSlashes.ts' import { getConfig, getDocFromDir } from './doc.server.ts' -import { NavItem, getMenu } from './menu.server.ts' +import { type NavItem, getMenu } from './menu.server.ts' import { parseMdxToPdf } from './pdf/index.server.ts' -import { Access, replaceConfigVars } from './utils.ts' +import { type Access, replaceConfigVars } from './utils.ts' export async function renderPDF({ product, diff --git a/app/lib/docs/pdf/index.server.ts b/app/lib/docs/pdf/index.server.ts index 3d65a36..43292b6 100644 --- a/app/lib/docs/pdf/index.server.ts +++ b/app/lib/docs/pdf/index.server.ts @@ -1,12 +1,12 @@ import * as acorn from 'acorn' -import { Element } from 'hast' +import { type Element } from 'hast' import { isElement } from 'hast-util-is-element' import yaml from 'js-yaml' -import { Root, Text } from 'mdast' +import { type Root, type Text } from 'mdast' import { fromMarkdown } from 'mdast-util-from-markdown' import { - MdxJsxFlowElement, - MdxJsxTextElement, + type MdxJsxFlowElement, + type MdxJsxTextElement, mdxJsxFromMarkdown, } from 'mdast-util-mdx-jsx' import { bundleMDX } from 'mdx-bundler' diff --git a/app/lib/docs/search.server.ts b/app/lib/docs/search.server.ts index 221793a..82da10d 100644 --- a/app/lib/docs/search.server.ts +++ b/app/lib/docs/search.server.ts @@ -1,12 +1,12 @@ import fs from 'fs/promises' -import LRUCache from 'lru-cache' +import type LRUCache from 'lru-cache' import lunr from 'lunr' import { remark } from 'remark' import strip from 'strip-markdown' import { NO_CACHE, SALT, createCache } from '~/utils/cache.server.ts' import { parseAttrs } from './attrs.server.ts' import { contentPath, privateContentPath, walk } from './fs.server.ts' -import { Access, makeSlug } from './utils.ts' +import { type Access, makeSlug } from './utils.ts' export type SearchDoc = { title: string diff --git a/app/lib/docs/versions.server.ts b/app/lib/docs/versions.server.ts index 2dd2e4f..3675634 100644 --- a/app/lib/docs/versions.server.ts +++ b/app/lib/docs/versions.server.ts @@ -1,4 +1,4 @@ -import LRUCache from 'lru-cache' +import type LRUCache from 'lru-cache' import path from 'path' import semver from 'semver' import { z } from 'zod' diff --git a/app/root.tsx b/app/root.tsx index 649d900..2f30705 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -1,6 +1,6 @@ import { cssBundleHref } from '@remix-run/css-bundle' import { - LoaderFunctionArgs, + type LoaderFunctionArgs, json, redirect, type LinksFunction, diff --git a/app/routes/documentation.$product.$ref.$.tsx b/app/routes/documentation.$product.$ref.$.tsx index dac83a8..22c01c7 100644 --- a/app/routes/documentation.$product.$ref.$.tsx +++ b/app/routes/documentation.$product.$ref.$.tsx @@ -1,3 +1,6 @@ +import { Content } from '~/components/layout/Content.tsx' +import { useDocLayoutLoaderData } from './documentation.$product.$ref.tsx' + export { ErrorBoundary, headers, @@ -5,9 +8,6 @@ export { meta, } from '~/components/layout/Content.tsx' -import { Content } from '~/components/layout/Content.tsx' -import { useDocLayoutLoaderData } from './documentation.$product.$ref.tsx' - export default function DocPage() { const { menu, product, basePath } = useDocLayoutLoaderData() return diff --git a/app/routes/documentation.$product.$ref._index.tsx b/app/routes/documentation.$product.$ref._index.tsx index 57322c1..eda0159 100644 --- a/app/routes/documentation.$product.$ref._index.tsx +++ b/app/routes/documentation.$product.$ref._index.tsx @@ -1,3 +1,6 @@ +import { Content } from '~/components/layout/Content.tsx' +import { useDocLayoutLoaderData } from './documentation.$product.$ref.tsx' + export { ErrorBoundary, headers, @@ -5,9 +8,6 @@ export { meta, } from '~/components/layout/Content.tsx' -import { Content } from '~/components/layout/Content.tsx' -import { useDocLayoutLoaderData } from './documentation.$product.$ref.tsx' - export default function DocPage() { const { menu, product, basePath } = useDocLayoutLoaderData() return diff --git a/app/routes/documentation.$product.$ref.actions.search.tsx b/app/routes/documentation.$product.$ref.actions.search.tsx index ed15f7d..35dbdb3 100644 --- a/app/routes/documentation.$product.$ref.actions.search.tsx +++ b/app/routes/documentation.$product.$ref.actions.search.tsx @@ -1,7 +1,7 @@ import { json, type LoaderFunctionArgs } from '@remix-run/node' import lunr from 'lunr' import invariant from 'tiny-invariant' -import { getSearch, SearchDoc } from '~/lib/docs/search.server.ts' +import { getSearch, type SearchDoc } from '~/lib/docs/search.server.ts' import { getProductVersions } from '~/lib/docs/versions.server.ts' function getBodyContext(body: string, term: string) { diff --git a/app/routes/documentation.$product.$ref[.]pdf.ts b/app/routes/documentation.$product.$ref[.]pdf.ts index b4cc0cd..f1ccf04 100644 --- a/app/routes/documentation.$product.$ref[.]pdf.ts +++ b/app/routes/documentation.$product.$ref[.]pdf.ts @@ -8,7 +8,7 @@ import { pdf } from '~/utils/responses.server.ts' export { headers } from '~/components/layout/Content.tsx' export async function loader({ params }: LoaderFunctionArgs) { - let { product, ref, '*': splat } = params + let { product, ref } = params invariant(product, 'expected `params.product`') invariant(ref, 'expected `params.ref`') const pdfResponse = await fs.readFile( diff --git a/app/routes/documentation.private.$product.$ref.$.tsx b/app/routes/documentation.private.$product.$ref.$.tsx index 2c9d46f..0910799 100644 --- a/app/routes/documentation.private.$product.$ref.$.tsx +++ b/app/routes/documentation.private.$product.$ref.$.tsx @@ -1,3 +1,6 @@ +import { Content } from '~/components/layout/Content.tsx' +import { useDocLayoutLoaderData } from './documentation.private.$product.$ref.tsx' + export { ErrorBoundary, headers, @@ -5,9 +8,6 @@ export { meta, } from '~/components/layout/Content.tsx' -import { Content } from '~/components/layout/Content.tsx' -import { useDocLayoutLoaderData } from './documentation.private.$product.$ref.tsx' - export default function DocPage() { const { menu, product, basePath } = useDocLayoutLoaderData() return diff --git a/app/routes/documentation.private.$product.$ref._index.tsx b/app/routes/documentation.private.$product.$ref._index.tsx index 981b373..4b11385 100644 --- a/app/routes/documentation.private.$product.$ref._index.tsx +++ b/app/routes/documentation.private.$product.$ref._index.tsx @@ -1,3 +1,6 @@ +import { Content } from '~/components/layout/Content.tsx' +import { useDocLayoutLoaderData } from './documentation.private.$product.$ref.tsx' + export { ErrorBoundary, headers, @@ -5,9 +8,6 @@ export { meta, } from '~/components/layout/Content.tsx' -import { Content } from '~/components/layout/Content.tsx' -import { useDocLayoutLoaderData } from './documentation.private.$product.$ref.tsx' - export default function DocPage() { const { menu, product, basePath } = useDocLayoutLoaderData() return diff --git a/app/routes/documentation.private.$product.$ref.actions.search.tsx b/app/routes/documentation.private.$product.$ref.actions.search.tsx index 57ec05b..ee5daa0 100644 --- a/app/routes/documentation.private.$product.$ref.actions.search.tsx +++ b/app/routes/documentation.private.$product.$ref.actions.search.tsx @@ -1,7 +1,7 @@ import { json, type LoaderFunctionArgs } from '@remix-run/node' import lunr from 'lunr' import invariant from 'tiny-invariant' -import { getSearch, SearchDoc } from '~/lib/docs/search.server.ts' +import { getSearch, type SearchDoc } from '~/lib/docs/search.server.ts' import { getProductAccess } from '~/lib/docs/utils.ts' import { getProductVersions } from '~/lib/docs/versions.server.ts' diff --git a/app/routes/documentation.private.$product.$ref[.]pdf.ts b/app/routes/documentation.private.$product.$ref[.]pdf.ts index 3a04685..7266cf7 100644 --- a/app/routes/documentation.private.$product.$ref[.]pdf.ts +++ b/app/routes/documentation.private.$product.$ref[.]pdf.ts @@ -8,7 +8,7 @@ import { pdf } from '~/utils/responses.server.ts' export { headers } from '~/components/layout/Content.tsx' export async function loader({ params }: LoaderFunctionArgs) { - let { product, ref, '*': splat } = params + let { product, ref } = params invariant(product, 'expected `params.product`') invariant(ref, 'expected `params.ref`') diff --git a/app/utils/zipper.ts b/app/utils/zipper.ts index e5c961d..2e8c403 100644 --- a/app/utils/zipper.ts +++ b/app/utils/zipper.ts @@ -42,6 +42,7 @@ export function fromArray(array: readonly A[]): T { } export function current({ current }: NonEmptyZipperObj): A +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function current({ current }: EmptyZipperObj): undefined export function current({ current }: T): A | undefined { return current diff --git a/scripts/crd-builder/index.ts b/scripts/crd-builder/index.ts index 89c6106..7408858 100644 --- a/scripts/crd-builder/index.ts +++ b/scripts/crd-builder/index.ts @@ -1,8 +1,8 @@ -import fs, { WriteStream, existsSync, mkdirSync } from 'fs' +import fs, { existsSync, mkdirSync, type WriteStream } from 'fs' import yaml from 'js-yaml' import path from 'node:path' import { walk } from '../utils.ts' -import { Schema } from './types.ts' +import { type Schema } from './types.ts' function main(input: string, output: string) { if (!existsSync(output)) { diff --git a/vitest.config.ts b/vitest.config.ts index 11bb366..66a3379 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,10 +8,10 @@ import { react } from './scripts/test-setup/vitejs-plugin-react.cjs' export default defineConfig({ plugins: [react(), tsconfigPaths()], test: { - include: ['./app/**/*.test.{ts,tsx}', './other/**/*.test.ts'], + include: ['./app/**/*.test.{ts,tsx}', './scripts/**/*.test.ts'], globals: true, environment: 'jsdom', - setupFiles: ['./other/test-setup/setup-test-env.ts'], + setupFiles: ['./scripts/test-setup/setup-test-env.ts'], coverage: { include: ['app/**/*.{ts,tsx}'], all: true,