1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 06:45:23 -04:00

marginally better error logging

This commit is contained in:
Jake Jarvis 2025-03-06 13:25:21 -05:00
parent f7d5413165
commit 8b2e513ca9
Signed by: jake
SSH Key Fingerprint: SHA256:nCkvAjYA6XaSPUqc4TfbBQTpzr8Xj7ritg/sGInCdkc
6 changed files with 31 additions and 44 deletions

View File

@ -27,7 +27,7 @@ export async function sendMessage(
// backup to client-side validations just in case someone squeezes through without them
if (!validatedFields.success) {
console.error(validatedFields.error.flatten());
console.error("[contact form] validation error:", validatedFields.error.flatten());
return {
success: false,
@ -51,7 +51,7 @@ export async function sendMessage(
});
if (!turnstileResponse.ok) {
throw new Error(`Turnstile validation failed: ${turnstileResponse.status}`);
throw new Error(`[contact form] turnstile validation failed: ${turnstileResponse.status}`);
}
const turnstileData = await turnstileResponse?.json();
@ -76,7 +76,7 @@ export async function sendMessage(
return { success: true, message: "Thanks! You should hear from me soon.", payload: formData };
} catch (error) {
console.error("Contact form error:", error);
console.error("[contact form] fatal error:", error);
return {
success: false,

View File

@ -19,7 +19,8 @@ const HitCounter = async ({ slug }: { slug: string }) => {
// we have data!
return <span title={`${commaNumber(hits)} ${hits === 1 ? "view" : "views"}`}>{commaNumber(hits)}</span>;
} catch (error) {
console.error(error);
console.error("[hit counter] fatal error:", error);
throw new Error();
}
};

View File

@ -117,7 +117,7 @@ export default async function Page({ params }: { params: Promise<{ slug: string
</div>
{/* only count hits on production site */}
{process.env.NEXT_PUBLIC_VERCEL_ENV === "production" && (
{process.env.NEXT_PUBLIC_VERCEL_ENV !== "development" && process.env.NODE_ENV !== "development" ? (
<ErrorBoundary fallback={null}>
<div
className={styles.metaItem}
@ -133,7 +133,7 @@ export default async function Page({ params }: { params: Promise<{ slug: string
</Suspense>
</div>
</ErrorBoundary>
)}
) : null}
</div>
<h1 className={styles.title}>

View File

@ -1,24 +1,25 @@
/* eslint-disable import/no-anonymous-default-export */
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import { fixupConfigRules } from "@eslint/compat";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import customConfig from "@jakejarvis/eslint-config";
import * as mdx from "eslint-plugin-mdx";
import * as eslintPluginMdx from "eslint-plugin-mdx";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import eslintCustomConfig from "@jakejarvis/eslint-config";
/** @type {import("@eslint/eslintrc").FlatCompat} */
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
recommendedConfig: js.configs.recommended,
});
// eslint-disable-next-line import/no-anonymous-default-export
/** @type {import("eslint").Linter.Config[]} */
export default [
{ ignores: ["README.md", ".next", ".vercel", "node_modules"] },
js.configs.recommended,
...customConfig,
...fixupConfigRules(
// https://github.com/vercel/next.js/issues/64114#issuecomment-2325268516
compat.extends("next/core-web-vitals", "next/typescript")
),
prettierRecommended,
...compat.config({
extends: ["eslint:recommended", "next/core-web-vitals", "next/typescript"],
}),
...eslintCustomConfig,
eslintPluginPrettierRecommended,
{
rules: {
"prettier/prettier": [
@ -38,7 +39,6 @@ export default [
"@typescript-eslint/no-explicit-any": "warn",
"react/no-unescaped-entities": "off",
"react/jsx-boolean-value": "error",
"react/jsx-wrap-multilines": [
"error",
{
@ -54,19 +54,14 @@ export default [
},
},
{
...mdx.flat,
processor: mdx.createRemarkProcessor({
...eslintPluginMdx.flat,
processor: eslintPluginMdx.createRemarkProcessor({
lintCodeBlocks: false,
}),
rules: {
"mdx/remark": "warn",
"mdx/code-blocks": "off",
"react/jsx-no-undef": "off",
"react/jsx-boolean-value": "off",
"react/no-unescaped-entities": "off",
// TODO: skip these correctly
"max-len": "off",
semi: "off",
"react/jsx-no-undef": "off", // components are injected automatically from mdx-components.ts
},
},
];

View File

@ -69,7 +69,6 @@
"zod": "^3.24.2"
},
"devDependencies": {
"@eslint/compat": "^1.2.7",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.21.0",
"@jakejarvis/eslint-config": "^4.0.7",
@ -84,6 +83,8 @@
"eslint": "^9.21.0",
"eslint-config-next": "15.2.2-canary.1",
"eslint-config-prettier": "^10.0.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-react": "^7.37.4",

22
pnpm-lock.yaml generated
View File

@ -153,9 +153,6 @@ importers:
specifier: ^3.24.2
version: 3.24.2
devDependencies:
'@eslint/compat':
specifier: ^1.2.7
version: 1.2.7(eslint@9.21.0)
'@eslint/eslintrc':
specifier: ^3.3.0
version: 3.3.0
@ -198,6 +195,12 @@ importers:
eslint-config-prettier:
specifier: ^10.0.2
version: 10.0.2(eslint@9.21.0)
eslint-plugin-import:
specifier: ^2.31.0
version: 2.31.0(@typescript-eslint/parser@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint-import-resolver-typescript@3.8.3)(eslint@9.21.0)
eslint-plugin-jsx-a11y:
specifier: ^6.10.2
version: 6.10.2(eslint@9.21.0)
eslint-plugin-mdx:
specifier: ^3.1.5
version: 3.1.5(eslint@9.21.0)
@ -414,15 +417,6 @@ packages:
resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
'@eslint/compat@1.2.7':
resolution: {integrity: sha512-xvv7hJE32yhegJ8xNAnb62ggiAwTYHBpUCWhRxEj/ksvgDJuSXfoDkBcRYaYNFiJ+jH0IE3K16hd+xXzhBgNbg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^9.10.0
peerDependenciesMeta:
eslint:
optional: true
'@eslint/config-array@0.19.2':
resolution: {integrity: sha512-GNKqxfHG2ySmJOBSHg7LxeUx4xpuCoFjacmlCoYWEbaPXLwvfIjixRI12xCQZeULksQb23uiA8F40w5TojpV7w==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@ -3552,10 +3546,6 @@ snapshots:
'@eslint-community/regexpp@4.12.1': {}
'@eslint/compat@1.2.7(eslint@9.21.0)':
optionalDependencies:
eslint: 9.21.0
'@eslint/config-array@0.19.2':
dependencies:
'@eslint/object-schema': 2.1.6