Skip to content

Commit

Permalink
[chore] Upgrade to Remix 2.8 + Vite (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
inssein authored Mar 4, 2024
1 parent 653cca9 commit d1a44c3
Show file tree
Hide file tree
Showing 54 changed files with 2,048 additions and 2,106 deletions.
81 changes: 80 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,83 @@
/**
* This is intended to be a basic starting point for linting in your app.
* It relies on recommended configs out of the box for simplicity, but you can
* and should modify this configuration to best suit your team's needs.
*/

/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
root: true,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},

// Base config
extends: ["eslint:recommended"],

overrides: [
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: ["react", "jsx-a11y"],
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
],
settings: {
react: {
version: "detect",
},
formComponents: ["Form"],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
"import/resolver": {
typescript: {},
},
},
},

// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
node: {
extensions: [".ts", ".tsx"],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
],
},

// Node
{
files: [".eslintrc.cjs"],
env: {
node: true,
},
},
],
};
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
node_modules

/.cache
/.wrangler
/functions
/public/build
/build
.env
.dev.vars
/test-results/

.wrangler

/playwright-report/
/playwright/.cache/
test-results
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/utiliti.dev.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9
20.9
6 changes: 3 additions & 3 deletions app/components/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function BoxContent({
isLast = true,
className,
}: PropsWithChildren<{
readonly isLast: Boolean;
readonly isLast: boolean;
readonly className?: string | undefined;
}>) {
return (
Expand Down Expand Up @@ -71,7 +71,7 @@ export function BoxOptions({
children,
className,
}: PropsWithChildren<{
readonly isLast: Boolean;
readonly isLast: boolean;
readonly className?: string | undefined;
}>) {
return (
Expand All @@ -87,7 +87,7 @@ export function BoxOptions({
);
}

export function BoxInfo({ children }: PropsWithChildren<{}>) {
export function BoxInfo({ children }: PropsWithChildren<object>) {
return (
<div className="px-3 py-2 flex border-t border-gray-600 rounded-b-lg text-sm items-center">
{children}
Expand Down
2 changes: 1 addition & 1 deletion app/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Button(props: Props) {
className,
)}
>
{props.label}
{label}
</button>
);
}
4 changes: 3 additions & 1 deletion app/components/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default function Code({
language = "javascript",
placeholder = "Paste some JSON…",
}: Props) {
const CodeEditor = (Editor as any).default;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const CodeEditor = (Editor as any).default || Editor;

return (
<CodeEditor
value={value}
Expand Down
2 changes: 1 addition & 1 deletion app/components/content-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PropsWithChildren } from "react";
import PopularUtilities from "~/components/popular-utilities";
import GoogleAd from "~/components/google-ad";

export default function ContentWrapper(props: PropsWithChildren<{}>) {
export default function ContentWrapper(props: PropsWithChildren<object>) {
return (
<>
{props.children}
Expand Down
2 changes: 1 addition & 1 deletion app/components/google-ad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function GoogleAd() {
scriptTag.setAttribute("crossorigin", "anonymous");
document.body.appendChild(scriptTag);

// @ts-ignore
// @ts-expect-error ignore for now
(window.adsbygoogle = window.adsbygoogle || []).push({});

adsLoaded.current = true;
Expand Down
2 changes: 1 addition & 1 deletion app/components/json-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ShouldExpandNodeInitially } from "react-json-tree/src/types";
import Box, { BoxContent, BoxTitle } from "~/components/box";

interface Props {
readonly json: Object;
readonly json: object | string;
}

export default function JsonViewer({ json }: Props) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Link, useLocation } from "@remix-run/react";
import Sidebar from "~/components/sidebar";
import { Dialog, Transition } from "@headlessui/react";
import Search from "~/components/search";
import useKeyboardShortcut from "use-keyboard-shortcut";
import useKeyboardShortcut from "~/hooks/use-keyboard-shortcut";
import { HTML5Backend } from "react-dnd-html5-backend";
import { DndProvider } from "react-dnd";

Expand Down
6 changes: 3 additions & 3 deletions app/components/popular-utilities.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from "@remix-run/react";
import { ArrowSmallRightIcon } from "@heroicons/react/24/solid";
import React, { memo } from "react";
import { ArrowRightIcon } from "@heroicons/react/20/solid";
import { memo } from "react";
import { utilities } from "~/utilities";
import { ClientOnly } from "~/components/client-only";

Expand Down Expand Up @@ -84,7 +84,7 @@ function PopularUtility({ name, description, path }: PopularUtilityProps) {
to={path}
>
Try
<ArrowSmallRightIcon
<ArrowRightIcon
className="h-4 w-4 relative top-px -mr-1"
aria-hidden="true"
/>
Expand Down
2 changes: 1 addition & 1 deletion app/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function Search({ open, setOpen }: Props) {
{query !== "" && filteredUtilities.length === 0 && (
<div className="py-14 px-6 text-center sm:px-14">
<p className="text-sm text-gray-200">
We couldn't find any utilities with that term.
We couldn&apos;t find any utilities with that term.
</p>
</div>
)}
Expand Down
1 change: 0 additions & 1 deletion app/components/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { useLocation } from "react-router";
import { Link } from "@remix-run/react";
import { sidebar } from "~/utilities";
Expand Down
2 changes: 2 additions & 0 deletions app/components/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const TooltipTrigger = React.forwardRef<
React.HTMLProps<HTMLElement> & { asChild?: boolean }
>(function TooltipTrigger({ children, asChild = false, ...props }, propRef) {
const context = useTooltipContext();
// eslint-disable-next-line
const childrenRef = (children as any).ref;
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);

Expand Down Expand Up @@ -162,6 +163,7 @@ export const TooltipContent = React.forwardRef<
top: context.y ?? 0,
left: context.x ?? 0,
visibility: context.x == null ? "hidden" : "visible",
// eslint-disable-next-line react/prop-types
...props.style,
...styles,
}}
Expand Down
5 changes: 3 additions & 2 deletions app/components/utiliti.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import Copy from "~/components/copy";
import Button from "~/components/button";
import { Transition } from "@headlessui/react";
import type { ReactNode } from "react";
import { useLayoutEffect, useState } from "react";
import { useState } from "react";
import Box, { BoxButtons, BoxContent, BoxTitle } from "~/components/box";
import ContentWrapper from "~/components/content-wrapper";
import { useLocalStorage } from "~/hooks/use-local-storage";
import { useIsomorphicLayoutEffect } from "~/hooks/use-isomorphic-layout-effect";

interface Props<T> {
readonly label: string;
Expand Down Expand Up @@ -45,7 +46,7 @@ export default function Utiliti<T>({

// using an effect to calculate the value after input has changed
// this allows us to re-render when actions array has changed, which happens when options change
useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
const fn = actions[action];

if (!fn || !input) {
Expand Down
7 changes: 3 additions & 4 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { AppLoadContext, EntryContext } from "@remix-run/cloudflare";
import type { EntryContext } from "@remix-run/cloudflare";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";

export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext,
) {
const body = await renderToReadableStream(
<RemixServer context={remixContext} url={request.url} />,
Expand All @@ -22,7 +21,7 @@ export default async function handleRequest(
},
);

if (isbot(request.headers.get("user-agent"))) {
if (isbot(request.headers.get("user-agent") || "")) {
await body.allReady;
}

Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-hydrated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
let hydrating = true;

export function useHydrated() {
let [hydrated, setHydrated] = useState(() => !hydrating);
const [hydrated, setHydrated] = useState(() => !hydrating);

useEffect(function hydrate() {
hydrating = false;
Expand Down
4 changes: 4 additions & 0 deletions app/hooks/use-isomorphic-layout-effect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { useEffect, useLayoutEffect } from "react";

export const useIsomorphicLayoutEffect =
typeof window !== "undefined" ? useLayoutEffect : useEffect;
Loading

0 comments on commit d1a44c3

Please sign in to comment.