Skip to content

Commit

Permalink
fix: clean up linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljcafonso committed Sep 27, 2024
1 parent 2ad47f1 commit 282a28b
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 49 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
}
1 change: 1 addition & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default defineConfig({
crawlLinks: true,
autoSubfolderIndex: false,
failOnError: true,
// eslint-disable-next-line no-useless-escape
ignore: [/\{\getPath}/, /.*?emojiSvg\(.*/],
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/data/get-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import matter, { GrayMatterFile } from "gray-matter";
import { GrayMatterFile } from "gray-matter";

export type Section = {
type: "section";
Expand Down
4 changes: 2 additions & 2 deletions src/data/page-state.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/data/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function getCookie(name: string, cookieString: string) {
const ThemeCtx = createContext<ThemeContext>();
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);
};
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/dictionaries/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 1 addition & 6 deletions src/i18n/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
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];
}

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);
}

Expand All @@ -22,7 +18,6 @@ export function getValidLocaleFromPathname(pathname: string) {
return isValidLocale(locale) ? locale : null;
}


export function getEntryFileName() {
const pathname = useLocation().pathname;
const currentRouteMetaData = useCurrentRouteMetaData();
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
}
81 changes: 48 additions & 33 deletions src/ui/eraser-link/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = "";
Expand Down Expand Up @@ -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}`
Expand All @@ -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 (
<Show
when={
props.children === undefined ||
(Array.isArray(props.children) &&
props.children[0] === "View on Eraser")
}
fallback={
<a
href={linkUrl}
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
rel="noopener noreferrer"
>
{props.children}
</a>
}
>
<a
href={linkUrl}
class="relative inline-block"
target="_blank"
rel="noopener noreferrer"
>
<img src={imageUrl} alt={""} onLoad={() => setIsLoaded(true)} />
<img
src={
elementParams
? `${workspaceUrl}/preview?${elementParams}&type=embed`
: `${workspaceUrl}/preview`
}
alt={""}
onLoad={() => setIsLoaded(true)}
/>
{isLoaded() ? (
<div class="eraserLinkContainer">
<img
Expand All @@ -69,31 +88,27 @@ const EraserLink = (props: ParentProps<{
</div>
) : null}
</a>
);
}
return (
<a
href={linkUrl}
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
rel="noopener noreferrer"
>
{props.children}
</a>
</Show>
);
};

export default function EraserOrAnchor(props: ParentProps<{ href: string }>) {
const eraserLinkData = getEraserLinkData(props.href);
if (eraserLinkData) {
return <EraserLink linkData={eraserLinkData}>{props.children}</EraserLink>;
}

return (
<a
{...props}
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
rel="noopener noreferrer"
<Show
when={eraserLinkData !== null}
fallback={
<a
{...props}
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
rel="noopener noreferrer"
>
{props.children}
</a>
}
>
{props.children}
</a>
<EraserLink linkData={eraserLinkData}>{props.children}</EraserLink>
</Show>
);
}
1 change: 1 addition & 0 deletions src/ui/layout/hero-code-snippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ const renderCode = async () => {
export default function CodeSnippet() {
const [code] = createResource(renderCode);

// eslint-disable-next-line solid/no-innerhtml
return <div innerHTML={code()} />;
}

0 comments on commit 282a28b

Please sign in to comment.