From e42bfcf54e6dc2fb9b2d87ce7f2ba55748b6840a Mon Sep 17 00:00:00 2001 From: Austin Parker Date: Mon, 21 Apr 2025 15:15:23 -0400 Subject: [PATCH] Add copyright headers and SPDX license info to source files - Add copyright headers to all source files - Configure ESLint to check for copyright headers - Add CLAUDE.md with build commands and code style guidelines --- .eslintrc.json | 10 +++++++++- CLAUDE.md | 20 ++++++++++++++++++++ eslint.config.mjs | 19 +++++++++++++++++++ package-lock.json | 11 +++++++++++ package.json | 1 + src/app/api/revalidate/route.ts | 5 +++++ src/app/api/test/route.ts | 5 +++++ src/app/api/webhook/route.ts | 5 +++++ src/app/feed/route.ts | 5 +++++ src/app/layout.tsx | 5 +++++ src/app/page.tsx | 5 +++++ src/components/changelog-description.tsx | 5 +++++ src/components/commit-sha.tsx | 5 +++++ src/components/filtered-list.tsx | 5 +++++ src/components/github-username.tsx | 5 +++++ src/components/list.tsx | 5 +++++ src/components/test-controls.tsx | 5 +++++ src/lib/store.ts | 5 +++++ src/types/entry.ts | 5 +++++ tsconfig.json | 24 +++++++++++++++++++----- 20 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 CLAUDE.md create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json index 3722418..1762a0d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,11 @@ { - "extends": ["next/core-web-vitals", "next/typescript"] + "extends": ["next/core-web-vitals", "next/typescript"], + "plugins": ["header"], + "rules": { + "header/header": [ + 2, + "block", + "Copyright The OpenTelemetry Authors\nSPDX-License-Identifier: Apache-2.0" + ] + } } diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1345d6f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,20 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Build Commands +- `npm run dev` - Start development server +- `npm run build` - Build for production +- `npm run start` - Start production server +- `npm run lint` - Run linting with ESLint +- Testing: Use `/api/test` endpoint in development mode only + +## Code Style Guidelines +- TypeScript: Strict mode with strictNullChecks enabled +- ESLint: Extends Next.js core-web-vitals and TypeScript configs +- Imports: Use absolute imports with `@/` prefix for src directory +- Components: Use functional React components with TypeScript types +- Error handling: Use try/catch with specific error types when possible +- Naming: PascalCase for components, camelCase for functions/variables +- Styling: Use Tailwind CSS with custom theme extensions +- State management: Use React hooks (useState, useEffect) \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..5811de4 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,19 @@ +// eslint.config.mjs + +import { FlatCompat } from "@eslint/eslintrc"; +import pluginHeader from "eslint-plugin-header"; + +pluginHeader.rules.header.meta.schema = false; + +const compat = new FlatCompat({ + // import.meta.dirname is available after Node.js v20.11.0 + baseDirectory: import.meta.dirname, +}); + +const eslintConfig = [ + ...compat.config({ + extends: ["next", "next/core-web-vitals", "next/typescript"], + }), +]; + +export default eslintConfig; diff --git a/package-lock.json b/package-lock.json index 3c1967f..d737540 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "@types/react-dom": "^18", "eslint": "^9.0.0", "eslint-config-next": "15.3.1", + "eslint-plugin-header": "^3.1.1", "postcss": "^8", "tailwindcss": "^3.4.1", "typescript": "^5" @@ -2656,6 +2657,16 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint": ">=7.7.0" + } + }, "node_modules/eslint-plugin-import": { "version": "2.31.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz", diff --git a/package.json b/package.json index 1015ede..8517504 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@types/react-dom": "^18", "eslint": "^9.0.0", "eslint-config-next": "15.3.1", + "eslint-plugin-header": "^3.1.1", "postcss": "^8", "tailwindcss": "^3.4.1", "typescript": "^5" diff --git a/src/app/api/revalidate/route.ts b/src/app/api/revalidate/route.ts index d3fc7e5..9b289b8 100644 --- a/src/app/api/revalidate/route.ts +++ b/src/app/api/revalidate/route.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { revalidatePath } from "next/cache"; import { NextRequest } from "next/server"; diff --git a/src/app/api/test/route.ts b/src/app/api/test/route.ts index 3bb4f49..28a225f 100644 --- a/src/app/api/test/route.ts +++ b/src/app/api/test/route.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { saveEntry } from "@/lib/store"; import { ChangelogEntry } from "@/types/entry"; diff --git a/src/app/api/webhook/route.ts b/src/app/api/webhook/route.ts index 68ea9fe..cccc86d 100644 --- a/src/app/api/webhook/route.ts +++ b/src/app/api/webhook/route.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { NextRequest } from "next/server"; import { saveEntry } from "@/lib/store"; import { ChangelogEntry } from "@/types/entry"; diff --git a/src/app/feed/route.ts b/src/app/feed/route.ts index 615f93d..f7ab01f 100644 --- a/src/app/feed/route.ts +++ b/src/app/feed/route.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { getAllEntries } from "@/lib/store"; export const dynamic = "force-dynamic"; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f8f07ce..2f95bf0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import type { Metadata } from "next"; import localFont from "next/font/local"; import "./globals.css"; diff --git a/src/app/page.tsx b/src/app/page.tsx index b0d51b4..86219f6 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { getAllEntries } from "@/lib/store"; import { ChangelogList } from "@/components/list"; import { TestControls } from "@/components/test-controls"; diff --git a/src/components/changelog-description.tsx b/src/components/changelog-description.tsx index d262e28..e543d51 100644 --- a/src/components/changelog-description.tsx +++ b/src/components/changelog-description.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + "use client"; import { useState } from "react"; diff --git a/src/components/commit-sha.tsx b/src/components/commit-sha.tsx index 6938b15..3d2cb48 100644 --- a/src/components/commit-sha.tsx +++ b/src/components/commit-sha.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + "use client"; interface CommitShaProps { diff --git a/src/components/filtered-list.tsx b/src/components/filtered-list.tsx index 5264ba0..b3a1060 100644 --- a/src/components/filtered-list.tsx +++ b/src/components/filtered-list.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + "use client"; import { useState, useId } from "react"; diff --git a/src/components/github-username.tsx b/src/components/github-username.tsx index 846dc39..be70277 100644 --- a/src/components/github-username.tsx +++ b/src/components/github-username.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + "use client"; interface GitHubUsernameProps { diff --git a/src/components/list.tsx b/src/components/list.tsx index 46716de..bbba68b 100644 --- a/src/components/list.tsx +++ b/src/components/list.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { FilteredList } from "./filtered-list"; import { ChangelogEntry } from "@/types/entry"; diff --git a/src/components/test-controls.tsx b/src/components/test-controls.tsx index 0aa5c15..cfc3f62 100644 --- a/src/components/test-controls.tsx +++ b/src/components/test-controls.tsx @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + "use client"; import { useState } from "react"; diff --git a/src/lib/store.ts b/src/lib/store.ts index 5256e5f..e313bfc 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import { getStore } from "@netlify/blobs"; import { ChangelogEntry } from "@/types/entry"; diff --git a/src/types/entry.ts b/src/types/entry.ts index 0c15add..7945540 100644 --- a/src/types/entry.ts +++ b/src/types/entry.ts @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + export interface ChangelogEntry { id: number; title: string; diff --git a/tsconfig.json b/tsconfig.json index 94da14b..7e65d23 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -19,9 +23,19 @@ } ], "paths": { - "@/*": ["./src/*"] - } + "@/*": [ + "./src/*" + ] + }, + "target": "ES2017" }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] }