Skip to content

Commit 282a28b

Browse files
fix: clean up linting errors
1 parent 2ad47f1 commit 282a28b

10 files changed

+73
-49
lines changed

.eslintrc.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
"plugins": ["@typescript-eslint", "solid"],
2929
"rules": {
3030
"quotes": ["error", "double"],
31-
"semi": "warn"
31+
"semi": "warn",
32+
"@typescript-eslint/no-unused-vars": [
33+
"error",
34+
{
35+
"args": "all",
36+
"argsIgnorePattern": "^_",
37+
"caughtErrors": "all",
38+
"caughtErrorsIgnorePattern": "^_",
39+
"destructuredArrayIgnorePattern": "^_",
40+
"varsIgnorePattern": "^_",
41+
"ignoreRestSiblings": true
42+
}
43+
]
3244
}
3345
}

app.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default defineConfig({
5858
crawlLinks: true,
5959
autoSubfolderIndex: false,
6060
failOnError: true,
61+
// eslint-disable-next-line no-useless-escape
6162
ignore: [/\{\getPath}/, /.*?emojiSvg\(.*/],
6263
},
6364
},

src/data/get-nav.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import matter, { GrayMatterFile } from "gray-matter";
1+
import { GrayMatterFile } from "gray-matter";
22

33
export type Section = {
44
type: "section";

src/data/page-state.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createEffect, createContext, ParentProps, useContext } from "solid-js";
2-
import { SetStoreFunction, StoreSetter, createStore } from "solid-js/store";
1+
import { createContext, ParentProps, useContext } from "solid-js";
2+
import { SetStoreFunction, createStore } from "solid-js/store";
33

44
type ChildSection = {
55
text: string | undefined;

src/data/theme-provider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function getCookie(name: string, cookieString: string) {
3636
const ThemeCtx = createContext<ThemeContext>();
3737
const getUserTheme = () => {
3838
if (isServer) {
39-
const e = getRequestEvent();
40-
return getCookie("theme", e?.request.headers.get("cookie")!);
39+
const e = getRequestEvent()!;
40+
return getCookie("theme", e.request.headers.get("cookie")!);
4141
}
4242
return getCookie("theme", document.cookie);
4343
};

src/i18n/dictionaries/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import english from "./en/ui";
2-
import ptbr from "./pt-br/ui";
2+
// import ptbr from "./pt-br/ui";
33

44
export const dictionaries = {
55
default: english,

src/i18n/helpers.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import { useLocation, useMatch } from "@solidjs/router";
1+
import { useLocation } from "@solidjs/router";
22
import { SUPPORTED_LOCALES } from "./config";
33
import { useCurrentRouteMetaData } from "~/utils/route-metadata-helper";
44

5-
65
export function getLocaleFromPathname(pathname: string) {
76
return pathname.split("/")[1];
87
}
98

109
export function isValidLocale(
1110
locale: string
1211
): locale is (typeof SUPPORTED_LOCALES)[number] {
13-
// TS is being annoying.
14-
// we are actually narrowing string here.
15-
// @ts-ignore
1612
return SUPPORTED_LOCALES.includes(locale);
1713
}
1814

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

25-
2621
export function getEntryFileName() {
2722
const pathname = useLocation().pathname;
2823
const currentRouteMetaData = useCurrentRouteMetaData();

src/i18n/translator.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { SUPPORTED_LOCALES } from "./config";
44
export function createTranslator(
55
locale: (typeof SUPPORTED_LOCALES)[number] | null
66
) {
7+
// type overlap will only be 100% when translations are done
8+
// so we're fine with `dictionaries[locale][key]` being implicit `any`
9+
// @ts-expect-error: expected any here
710
const dictionary = dictionaries[locale || "default"];
811
return (key: keyof (typeof dictionaries)["default"]) => {
9-
// type overlap will only be 100% when translations are done
10-
// so we're fine with `dictionaries[locale][key]` being implicit `any`
11-
// @ts-ignore
1212
return dictionary[key] || dictionaries["default"][key];
1313
};
1414
}

src/ui/eraser-link/index.tsx

+48-33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ParentProps, createSignal } from "solid-js";
1+
/* eslint-disable solid/reactivity */
2+
import { ParentProps, Show, createSignal } from "solid-js";
23
import "./eraser-link.css";
34

45
const ERASER_TRACKING_PARAMS = "";
@@ -28,9 +29,11 @@ const getEraserLinkData = (href: string): EraserLinkData | null => {
2829
};
2930
};
3031

31-
const EraserLink = (props: ParentProps<{
32-
linkData: EraserLinkData;
33-
}>) => {
32+
const EraserLink = (
33+
props: ParentProps<{
34+
linkData: EraserLinkData;
35+
}>
36+
) => {
3437
const workspaceUrl = `https://app.eraser.io/workspace/${props.linkData.workspaceId}`;
3538
const elementParams = props.linkData.elementsId
3639
? `elements=${props.linkData.elementsId}`
@@ -43,22 +46,38 @@ const EraserLink = (props: ParentProps<{
4346
const [isLoaded, setIsLoaded] = createSignal(false);
4447

4548
// if there are no children or this was a right click-copy as markdown embed.
46-
if (
47-
props.children === undefined ||
48-
(Array.isArray(props.children) && props.children[0] === "View on Eraser")
49-
) {
50-
const imageUrl = elementParams
51-
? `${workspaceUrl}/preview?${elementParams}&type=embed`
52-
: `${workspaceUrl}/preview`;
53-
54-
return (
49+
return (
50+
<Show
51+
when={
52+
props.children === undefined ||
53+
(Array.isArray(props.children) &&
54+
props.children[0] === "View on Eraser")
55+
}
56+
fallback={
57+
<a
58+
href={linkUrl}
59+
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
60+
rel="noopener noreferrer"
61+
>
62+
{props.children}
63+
</a>
64+
}
65+
>
5566
<a
5667
href={linkUrl}
5768
class="relative inline-block"
5869
target="_blank"
5970
rel="noopener noreferrer"
6071
>
61-
<img src={imageUrl} alt={""} onLoad={() => setIsLoaded(true)} />
72+
<img
73+
src={
74+
elementParams
75+
? `${workspaceUrl}/preview?${elementParams}&type=embed`
76+
: `${workspaceUrl}/preview`
77+
}
78+
alt={""}
79+
onLoad={() => setIsLoaded(true)}
80+
/>
6281
{isLoaded() ? (
6382
<div class="eraserLinkContainer">
6483
<img
@@ -69,31 +88,27 @@ const EraserLink = (props: ParentProps<{
6988
</div>
7089
) : null}
7190
</a>
72-
);
73-
}
74-
return (
75-
<a
76-
href={linkUrl}
77-
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
78-
rel="noopener noreferrer"
79-
>
80-
{props.children}
81-
</a>
91+
</Show>
8292
);
8393
};
8494

8595
export default function EraserOrAnchor(props: ParentProps<{ href: string }>) {
8696
const eraserLinkData = getEraserLinkData(props.href);
87-
if (eraserLinkData) {
88-
return <EraserLink linkData={eraserLinkData}>{props.children}</EraserLink>;
89-
}
97+
9098
return (
91-
<a
92-
{...props}
93-
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
94-
rel="noopener noreferrer"
99+
<Show
100+
when={eraserLinkData !== null}
101+
fallback={
102+
<a
103+
{...props}
104+
class="dark:text-solid-darklink break-normal text-solid-lightlink duration-100 ease-in font-semibold leading-normal transition hover:underline"
105+
rel="noopener noreferrer"
106+
>
107+
{props.children}
108+
</a>
109+
}
95110
>
96-
{props.children}
97-
</a>
111+
<EraserLink linkData={eraserLinkData}>{props.children}</EraserLink>
112+
</Show>
98113
);
99114
}

src/ui/layout/hero-code-snippet.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ const renderCode = async () => {
2828
export default function CodeSnippet() {
2929
const [code] = createResource(renderCode);
3030

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

0 commit comments

Comments
 (0)