diff --git a/.eslintrc.json b/.eslintrc.json index 262968bd1..306d0c245 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -28,6 +28,18 @@ "plugins": ["@typescript-eslint", "solid"], "rules": { "quotes": ["error", "double"], - "semi": "warn" + "semi": "warn", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "all", + "argsIgnorePattern": "^_", + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^_", + "destructuredArrayIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "ignoreRestSiblings": true + } + ] } } diff --git a/app.config.ts b/app.config.ts index cecb20649..eb6af5d81 100644 --- a/app.config.ts +++ b/app.config.ts @@ -58,6 +58,7 @@ export default defineConfig({ crawlLinks: true, autoSubfolderIndex: false, failOnError: true, + // eslint-disable-next-line no-useless-escape ignore: [/\{\getPath}/, /.*?emojiSvg\(.*/], }, }, diff --git a/src/data/get-nav.tsx b/src/data/get-nav.tsx index 1d3da9681..4e02c7a16 100644 --- a/src/data/get-nav.tsx +++ b/src/data/get-nav.tsx @@ -1,4 +1,4 @@ -import matter, { GrayMatterFile } from "gray-matter"; +import { GrayMatterFile } from "gray-matter"; export type Section = { type: "section"; diff --git a/src/data/page-state.tsx b/src/data/page-state.tsx index 815f0daa8..18693d5eb 100644 --- a/src/data/page-state.tsx +++ b/src/data/page-state.tsx @@ -1,5 +1,5 @@ -import { createEffect, createContext, ParentProps, useContext } from "solid-js"; -import { SetStoreFunction, StoreSetter, createStore } from "solid-js/store"; +import { createContext, ParentProps, useContext } from "solid-js"; +import { SetStoreFunction, createStore } from "solid-js/store"; type ChildSection = { text: string | undefined; diff --git a/src/data/theme-provider.tsx b/src/data/theme-provider.tsx index e8f5c801d..9bbeadf6a 100644 --- a/src/data/theme-provider.tsx +++ b/src/data/theme-provider.tsx @@ -36,8 +36,8 @@ function getCookie(name: string, cookieString: string) { const ThemeCtx = createContext(); const getUserTheme = () => { if (isServer) { - const e = getRequestEvent(); - return getCookie("theme", e?.request.headers.get("cookie")!); + const e = getRequestEvent()!; + return getCookie("theme", e.request.headers.get("cookie")!); } return getCookie("theme", document.cookie); }; diff --git a/src/i18n/dictionaries/index.ts b/src/i18n/dictionaries/index.ts index 49c9014e3..479b664f0 100644 --- a/src/i18n/dictionaries/index.ts +++ b/src/i18n/dictionaries/index.ts @@ -1,5 +1,5 @@ import english from "./en/ui"; -import ptbr from "./pt-br/ui"; +// import ptbr from "./pt-br/ui"; export const dictionaries = { default: english, diff --git a/src/i18n/helpers.ts b/src/i18n/helpers.ts index e56e5571a..990e1ef00 100644 --- a/src/i18n/helpers.ts +++ b/src/i18n/helpers.ts @@ -1,8 +1,7 @@ -import { useLocation, useMatch } from "@solidjs/router"; +import { useLocation } from "@solidjs/router"; import { SUPPORTED_LOCALES } from "./config"; import { useCurrentRouteMetaData } from "~/utils/route-metadata-helper"; - export function getLocaleFromPathname(pathname: string) { return pathname.split("/")[1]; } @@ -10,9 +9,6 @@ export function getLocaleFromPathname(pathname: string) { export function isValidLocale( locale: string ): locale is (typeof SUPPORTED_LOCALES)[number] { - // TS is being annoying. - // we are actually narrowing string here. - // @ts-ignore return SUPPORTED_LOCALES.includes(locale); } @@ -22,7 +18,6 @@ export function getValidLocaleFromPathname(pathname: string) { return isValidLocale(locale) ? locale : null; } - export function getEntryFileName() { const pathname = useLocation().pathname; const currentRouteMetaData = useCurrentRouteMetaData(); diff --git a/src/i18n/translator.ts b/src/i18n/translator.ts index 01f3880a4..f31a0d193 100644 --- a/src/i18n/translator.ts +++ b/src/i18n/translator.ts @@ -4,11 +4,11 @@ import { SUPPORTED_LOCALES } from "./config"; export function createTranslator( locale: (typeof SUPPORTED_LOCALES)[number] | null ) { + // type overlap will only be 100% when translations are done + // so we're fine with `dictionaries[locale][key]` being implicit `any` + // @ts-expect-error: expected any here const dictionary = dictionaries[locale || "default"]; return (key: keyof (typeof dictionaries)["default"]) => { - // type overlap will only be 100% when translations are done - // so we're fine with `dictionaries[locale][key]` being implicit `any` - // @ts-ignore return dictionary[key] || dictionaries["default"][key]; }; } diff --git a/src/ui/eraser-link/index.tsx b/src/ui/eraser-link/index.tsx index 9dd18cc01..4db07b614 100644 --- a/src/ui/eraser-link/index.tsx +++ b/src/ui/eraser-link/index.tsx @@ -1,4 +1,5 @@ -import { ParentProps, createSignal } from "solid-js"; +/* eslint-disable solid/reactivity */ +import { ParentProps, Show, createSignal } from "solid-js"; import "./eraser-link.css"; const ERASER_TRACKING_PARAMS = ""; @@ -28,9 +29,11 @@ const getEraserLinkData = (href: string): EraserLinkData | null => { }; }; -const EraserLink = (props: ParentProps<{ - linkData: EraserLinkData; -}>) => { +const EraserLink = ( + props: ParentProps<{ + linkData: EraserLinkData; + }> +) => { const workspaceUrl = `https://app.eraser.io/workspace/${props.linkData.workspaceId}`; const elementParams = props.linkData.elementsId ? `elements=${props.linkData.elementsId}` @@ -43,22 +46,38 @@ const EraserLink = (props: ParentProps<{ const [isLoaded, setIsLoaded] = createSignal(false); // if there are no children or this was a right click-copy as markdown embed. - if ( - props.children === undefined || - (Array.isArray(props.children) && props.children[0] === "View on Eraser") - ) { - const imageUrl = elementParams - ? `${workspaceUrl}/preview?${elementParams}&type=embed` - : `${workspaceUrl}/preview`; - - return ( + return ( + + {props.children} + + } + > - {""} setIsLoaded(true)} /> + {""} setIsLoaded(true)} + /> {isLoaded() ? (