Skip to content

Commit 27ec2bf

Browse files
committed
Cleanup console logs and lint errors
1 parent fadc386 commit 27ec2bf

13 files changed

+22
-61
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ LATER
4646
[![Remix](https://www.vectorlogo.zone/logos/remixrun/remixrun-ar21.svg)](https://remix.run/ "React Framework")
4747
[![TypeScript](https://www.vectorlogo.zone/logos/typescriptlang/typescriptlang-ar21.svg)](https://www.typescriptlang.org/ "Programming Language")
4848
[![Vite](https://www.vectorlogo.zone/logos/vitejsdev/vitejsdev-ar21.svg)](https://vitejs.dev/ "Bundler")
49+
50+
* [SVGR](https://react-svgr.com/)
51+
* [Drizzle ORM](https://orm.drizzle.team/)
52+
* [Postgres.js](https://github.com/porsager/postgres)

app/components/AuthButton.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export function AuthButton() {
1414
}
1515
}
1616

17-
console.log('authbutton', JSON.stringify(user));
1817
return (
1918
<>
2019
<RemixLink className="d-none d-sm-inline text-body-emphasis" to="/auth/" style={{ "fontSize": "1.75rem" }}>

app/components/Patterns.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function initialize() {
3030
const fileNames = await fsPromises.readdir(PATTERN_DIR);
3131
for await (const fileName of fileNames) {
3232
const fullPath = path.join(PATTERN_DIR, fileName);
33-
console.log(`filename=${fullPath}`);
33+
console.log(`loading filename=${fullPath}`);
3434

3535
const raw = await fsPromises.readFile(fullPath, "utf-8");
3636
const parsed = yaml.load(raw, {

app/components/RegexZoneSvg.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as React from "react"
2-
1+
// code generated at https://react-svgr.com/playground/
32

43
const SvgComponent = (props) => (
54
<svg

app/routes/auth._index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { cookieStorage } from "~/services/session.server";
55
import { User } from "~/types/User";
66

77
export async function loader({ request }: LoaderFunctionArgs) {
8-
//console.log('in loader', (await cookieStorage.getSession(request.headers.get("Cookie"))).get("user"))
98
const session = await cookieStorage.getSession(request.headers.get("Cookie"));
109
const sessionUser = session.get("user");
1110
const authUser = await authenticator.isAuthenticated(request);

app/routes/auth.github.callback.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { cookieStorage } from "~/services/session.server";
55
export async function loader({ request }: LoaderFunctionArgs) {
66
const user = await authenticator.authenticate("github", request);
77

8-
console.log('user in callback', JSON.stringify(user));
98
if (user != null) {
109
const session = await cookieStorage.getSession(request.headers.get("Cookie"));
1110
session.set("user", user);

app/routes/links._index.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export async function loader({ request }: LoaderFunctionArgs) {
2525

2626
// Retrieve the session value set in the previous request
2727
const message = session.get("message");
28-
console.log("loader message", JSON.stringify(message));
2928

3029
const links = await dborm.select().from(regex_link).orderBy(desc(regex_link.rxl_created_at)).limit(100);
3130

@@ -46,8 +45,6 @@ export default function Index() {
4645
const user = useRouteLoaderData<User | null>("root");
4746
const data = useLoaderData<typeof loader>();
4847

49-
console.log("func message", JSON.stringify(data));
50-
5148
const message = data.message as AlertMessage | undefined;
5249

5350
const links = data.links as unknown as typeof regex_link.$inferSelect[];

app/routes/links.archive.$year._index.tsx

+11-31
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,22 @@ import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
22
import { json, Link as RemixLink, useLoaderData, useParams, useRouteLoaderData } from "@remix-run/react";
33
import { desc, sql } from "drizzle-orm";
44

5-
import { cookieStorage } from "~/services/session.server";
65
import { User } from "~/types/User";
76
import { AlertWidget } from "~/components/AlertWidget";
8-
import type { AlertMessage } from "~/types/AlertMessage";
97
import { dborm } from "~/db/connection.server";
108
import { regex_link } from "~/db/schema";
119
import { authenticator } from "~/services/auth.server";
12-
import { AdminIcon } from "~/components/AdminIcon";
1310
import LinksTable from "~/components/LinksTable";
1411
import { PiArrowFatUpBold, PiCaretLeftBold, PiCaretRightBold } from "react-icons/pi";
12+
import { MIN_ARCHIVE_YEAR } from "~/util/constants";
1513

1614
export const meta: MetaFunction = ({ params }) => {
1715
return [
1816
{ title: `Links Archive for ${params.year} - Regex Zone` },
1917
];
2018
};
2119

22-
const MIN_YEAR = 2007;
23-
2420
export async function loader({ request, params }: LoaderFunctionArgs) {
25-
// Retrieves the current session from the incoming request's Cookie header
26-
const session = await cookieStorage.getSession(request.headers.get("Cookie"));
27-
28-
// Retrieve the session value set in the previous request
29-
const message = session.get("message");
30-
console.log("loader message", JSON.stringify(message));
3121

3222
if (!params || !params.year || !/^2\d{3}$/.test(params.year)) {
3323
throw new Error("Invalid year");
@@ -43,14 +33,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
4333

4434
// Commit the session and return the message
4535
return json(
46-
{ links, message, user },
47-
{
48-
headers: {
49-
"Set-Cookie": await cookieStorage.commitSession(session),
50-
},
51-
}
36+
{ links, user },
5237
);
5338
}
39+
5440
export default function Index() {
5541
const params = useParams();
5642
const user = useRouteLoaderData<User | null>("root");
@@ -59,27 +45,21 @@ export default function Index() {
5945
const currentYear = new Date().getFullYear();
6046
const year = parseInt(params.year || currentYear.toString());
6147

62-
63-
console.log("func message", JSON.stringify(data));
64-
65-
const message = data.message as AlertMessage | undefined;
66-
6748
const links = data.links as unknown as typeof regex_link.$inferSelect[];
6849

6950
return (
7051
<>
7152
<div className="d-flex justify-content-between align-items-center">
7253
<h1 className="py-2">Links Archive for {year}</h1>
73-
<div>
74-
{ year > MIN_YEAR ? <RemixLink to={`/links/archive/${year - 1}/`} className="btn btn-primary mx-1"><PiCaretLeftBold /> {year - 1}</RemixLink> : null }
75-
<RemixLink to="/links/archive/" className="btn btn-primary"><PiArrowFatUpBold /></RemixLink>
76-
{ year < currentYear ? <RemixLink to={`/links/archive/${year + 1}/`} className="btn btn-primary mx-1">{year + 1} <PiCaretRightBold /></RemixLink> : null }
77-
</div>
54+
<div>
55+
{year > MIN_ARCHIVE_YEAR ? <RemixLink to={`/links/archive/${year - 1}/`} className="btn btn-primary mx-1"><PiCaretLeftBold /> {year - 1}</RemixLink> : null}
56+
<RemixLink to="/links/archive/" className="btn btn-primary"><PiArrowFatUpBold /></RemixLink>
57+
{year < currentYear ? <RemixLink to={`/links/archive/${year + 1}/`} className="btn btn-primary mx-1">{year + 1} <PiCaretRightBold /></RemixLink> : null}
58+
</div>
7859
</div>
79-
{message ? <AlertWidget alert={message} /> : null}
80-
{ links.length == 0
81-
? <AlertWidget alert={{type: "danger", message: `No links for ${year}`}} />
82-
: <LinksTable currentUrl={`/links/archive/${year}/`} links={links} isAdmin={user?.isAdmin} />
60+
{links.length == 0
61+
? <AlertWidget alert={{ type: "danger", message: `No links for ${year}` }} />
62+
: <LinksTable currentUrl={`/links/archive/${year}/`} links={links} isAdmin={user?.isAdmin} />
8363
}
8464
</>
8565
);

app/routes/links.archive._index.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { MetaFunction } from "@remix-run/node";
2-
import { json, Link as RemixLink, useLoaderData, useSearchParams } from "@remix-run/react";
2+
import { json, Link as RemixLink, useLoaderData } from "@remix-run/react";
33
import { dbconnection } from "~/db/connection.server";
4-
import { TagTree, TagTreeEntry } from "~/components/TagTree";
54

65

76
export const meta: MetaFunction = () => {
@@ -14,8 +13,6 @@ export async function loader() {
1413

1514
const archiveyears = await dbconnection`SELECT EXTRACT(YEAR FROM rxl_created_at) AS year, COUNT(*) as count FROM regex_link GROUP BY EXTRACT(YEAR FROM rxl_created_at) ORDER BY EXTRACT(YEAR FROM rxl_created_at) DESC`;
1615

17-
console.log(archiveyears);
18-
1916
return json(archiveyears);
2017
}
2118

app/routes/links.import[.]html.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const meta: MetaFunction = () => {
3030
export const action = async ({
3131
request,
3232
}: ActionFunctionArgs) => {
33-
console.log("import action");
3433

3534
const user: User | null = await authenticator.isAuthenticated(request);
3635
if (!user) {
@@ -56,8 +55,6 @@ export const action = async ({
5655

5756
const textData = await dataBlob.text();
5857

59-
console.log("data length", textData.length);
60-
6158
let jsonData = JSON.parse(textData) as PinboardEntry[];
6259

6360
jsonData = jsonData.filter(entry => entry.tags.indexOf("regex") !== -1);
@@ -68,7 +65,7 @@ export const action = async ({
6865
console.log(`found ${entry.href}, stopping...`);
6966
break;
7067
}
71-
console.log("inserting", entry.href);
68+
console.log(`inserting ${entry.href}`);
7269
await dborm.insert(regex_link).values({
7370
rxl_url: entry.href,
7471
rxl_title: entry.description,
@@ -96,7 +93,6 @@ export const action = async ({
9693
};
9794

9895
export function loader(args: LoaderFunctionArgs) {
99-
console.log("import loader");
10096
return adminOnlyLoader(args);
10197
}
10298

@@ -106,7 +102,7 @@ import { dborm } from "~/db/connection.server";
106102
import { regex_link } from "~/db/schema";
107103

108104
export const shouldRevalidate: ShouldRevalidateFunction = (params) => {
109-
console.log("shouldRevalidate", params);
105+
console.log("shouldRevalidate", params); // never called
110106
return params.defaultShouldRevalidate;
111107
};
112108

app/routes/links.tags[.]html.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export async function loader() {
1414

1515
const taglinks = await dbconnection`SELECT rxl_id, rxl_title, rxl_url, UNNEST(rxl_tags) as tag FROM regex_link ORDER BY tag`;
1616

17-
console.log(taglinks);
18-
1917
const tagmap: { [key: string]: TagTreeEntry[]; } = {};
2018
for (const taglink of taglinks) {
2119
const tag = taglink.tag;
@@ -27,8 +25,6 @@ export async function loader() {
2725
links.push({ id: taglink.rxl_id, title: taglink.rxl_title, url: taglink.rxl_url });
2826
}
2927

30-
console.log(tagmap);
31-
3228
return json(tagmap);
3329
}
3430

app/routes/links.untagged[.]html.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ export const meta: MetaFunction = () => {
1616
};
1717

1818
export async function loader({ request }: LoaderFunctionArgs) {
19-
// Retrieves the current session from the incoming request's Cookie header
20-
const session = await cookieStorage.getSession(request.headers.get("Cookie"));
21-
22-
// Retrieve the session value set in the previous request
23-
const message = session.get("message");
2419

2520
const links = await dborm.select().from(regex_link).where(sql`ARRAY_LENGTH(${regex_link.rxl_tags}, 1) IS NULL`);
26-
console.log("untagged links", JSON.stringify(links));
2721
const user = authenticator.isAuthenticated(request);
2822

2923

3024
// Commit the session and return the message
3125
return json(
32-
{ links, message, user },
26+
{ links, user },
3327
{
3428
headers: {
3529
"Set-Cookie": await cookieStorage.commitSession(session),

app/routes/patterns.$entry._index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function PatternEntryView(entry: PatternEntry) {
5858
}
5959

6060
function PatternEntryVariationView(variation: PatternEntryVariation) {
61+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6162
const [_, copyToClipboard] = useCopyToClipboard();
6263
return (
6364
<tr>

0 commit comments

Comments
 (0)