Skip to content

Commit cdaeabe

Browse files
committed
Enhance ESLint configuration with rules for code readability; add padding-line-between-statements and no-multiple-empty-lines rules. Refactor components for improved structure and readability by adding blank lines in various sections. Update TimestampConverter, InstallPWAButton, ServiceWorkerUpdateToast, CopyField, Header, Footer, and layout components for better spacing and organization.
1 parent 8cecf1b commit cdaeabe

File tree

11 files changed

+44
-2
lines changed

11 files changed

+44
-2
lines changed

eslint.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ const compat = new FlatCompat({
1111

1212
const eslintConfig = [
1313
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
{
15+
rules: {
16+
// Encourage airy, readable layouts between logical sections
17+
'padding-line-between-statements': [
18+
'warn',
19+
// Always add a blank line before returns
20+
{ blankLine: 'always', prev: '*', next: 'return' },
21+
22+
// Always add a blank line after variable declarations
23+
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
24+
// But allow consecutive var/let/const without blank lines between themselves
25+
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
26+
27+
// Ensure breathing room around blocks and function/class boundaries
28+
{ blankLine: 'always', prev: 'block-like', next: '*' },
29+
{ blankLine: 'always', prev: '*', next: 'block-like' },
30+
{ blankLine: 'always', prev: '*', next: ['function', 'class'] },
31+
{ blankLine: 'always', prev: ['function', 'class'], next: '*' },
32+
],
33+
34+
// Keep it tidy: no large vertical gaps
35+
'no-multiple-empty-lines': ['warn', { max: 1, maxBOF: 1, maxEOF: 1 }],
36+
},
37+
},
1438
];
1539

1640
export default eslintConfig;

src/app/components/TimestampConverter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function TimestampConverter({ controller }: Props) {
3232
validators={{
3333
onChange: ({ value }) => {
3434
const result = timestampSchema.shape.timestamp.safeParse(value);
35+
3536
return result.success ? undefined : result.error.issues[0]?.message;
3637
},
3738
}}

src/app/components/client/InstallPWAButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export default function InstallPWAButton() {
1919
setDeferredPrompt(e);
2020
setVisible(true);
2121
};
22+
2223
window.addEventListener("beforeinstallprompt", onBeforeInstallPrompt as EventListener);
24+
2325
return () => window.removeEventListener("beforeinstallprompt", onBeforeInstallPrompt as EventListener);
2426
}, []);
2527

@@ -29,6 +31,7 @@ export default function InstallPWAButton() {
2931
if (!deferredPrompt) return;
3032
deferredPrompt.prompt();
3133
const { outcome } = await deferredPrompt.userChoice;
34+
3235
setVisible(false);
3336
setDeferredPrompt(null);
3437
console.log("PWA install outcome:", outcome);

src/app/components/client/ServiceWorkerUpdateToast.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default function ServiceWorkerUpdateToast() {
2424
.catch(() => {});
2525
}
2626
};
27+
2728
document.addEventListener("visibilitychange", onVisibility);
2829

2930
return () => {

src/app/components/common/CopyField.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ export default function CopyField({ label, value, onCopy, large }: CopyFieldProp
1212
<label className="label">
1313
<span className="label-text font-medium text-orange-400">{label}</span>
1414
</label>
15+
1516
<div className="input-group">
1617
<input
1718
type="text"
1819
className={`input input-bordered flex-1 font-mono bg-base-200 ${large ? 'text-lg' : ''}`}
1920
value={value}
2021
readOnly
2122
/>
23+
2224
<button
2325
type="button"
2426
className="btn btn-square bg-orange-500 hover:bg-orange-600 border-orange-500 text-white"
2527
onClick={onCopy}
2628
>
2729
<TbCopy />
2830
</button>
31+
2932
</div>
3033
</div>
3134
);

src/app/components/server/Footer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default function Footer() {
66
Built with <span className="text-orange-500">DaisyUI</span> + Next.js 15 • Open Source ♥️ • Made for developers who live in
77
<span className="mx-1">⏱️</span> time.
88
</p>
9+
910
<nav className="grid grid-flow-col gap-4">
1011
<a className="link link-hover" href="https://github.com/mCodex/react-timestamper" target="_blank" rel="noreferrer">
1112
GitHub
@@ -17,6 +18,7 @@ export default function Footer() {
1718
Next.js
1819
</a>
1920
</nav>
21+
2022
</aside>
2123
</footer>
2224
);

src/app/components/server/Header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TbRefresh } from "react-icons/tb";
33
export default function Header() {
44
return (
55
<div className="navbar bg-base-100/60 sticky top-0 z-10 shadow-sm">
6+
67
<div className="container mx-auto">
78
<div className="flex-1">
89
<span className="flex items-center gap-2 text-xl">
@@ -11,6 +12,7 @@ export default function Header() {
1112
</span>
1213
</div>
1314
</div>
15+
1416
</div>
1517
);
1618
}

src/app/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const firaSans = Fira_Sans({
88
weight: ["400", "500", "600", "700"],
99
});
1010

11-
1211
export const metadata: Metadata = {
1312
title: "Timestamper - Convert timestamps into dates",
1413
description: "A simple tool to convert Unix timestamps into human-readable dates and view the current timestamp",

src/app/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import InteractiveIsland from "./components/client/InteractiveIsland";
55

66
export default function Home() {
77
return (
8-
<div className="min-h-screen bg-base-300 relative overflow-hidden isolate flex flex-col">
8+
<div className="min-h-screen bg-base-300 relative overflow-hidden isolate flex flex-col">
99
<Background />
10+
1011
<Header />
12+
1113
<main className="flex-1">
1214
<InteractiveIsland />
1315
</main>
16+
1417
<Footer />
1518
</div>
1619
);

src/app/schemas/timestamp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const timestampSchema = z.object({
66
.refine((val) => {
77
// Check if it's a valid number (timestamp can be string representation of number)
88
const num = Number(val);
9+
910
if (isNaN(num)) return false;
1011

1112
// Check if it's a reasonable timestamp (between 1970 and 2100)

0 commit comments

Comments
 (0)