From da1ef7e0c38e4729e0a89b856ceb785726b5c741 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Fri, 6 Feb 2026 16:35:42 -0500 Subject: [PATCH] chore: add linting, formatting, and type-checking Add ESLint, Prettier, and TypeScript config files extending the shared Headlamp plugin configs. Add npm scripts for lint/format. Auto-fix existing source files. Add CI workflow for PRs and main pushes. Co-Authored-By: Claude Opus 4.6 --- .eslintrc.js | 3 +++ .gitea/workflows/ci.yaml | 27 +++++++++++++++++++++++++ .prettierrc.js | 1 + package.json | 6 +++++- src/api/polaris.ts | 2 +- src/components/PolarisView.tsx | 36 ++++++++++++---------------------- src/index.tsx | 5 +---- tsconfig.json | 4 ++++ 8 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .gitea/workflows/ci.yaml create mode 100644 .prettierrc.js create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..e37cc11 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['@headlamp-k8s/eslint-config'], +}; diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..2bd7dda --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + container: node:20 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npx eslint --ext .ts,.tsx src/ + + - name: Type-check + run: npx tsc --noEmit + + - name: Format check + run: npx prettier --check src/ diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..fcb4dbd --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require('@headlamp-k8s/eslint-config/prettier-config'); diff --git a/package.json b/package.json index 2c9d945..6b919d2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,11 @@ "start": "headlamp-plugin start", "build": "headlamp-plugin build", "package": "headlamp-plugin package", - "tsc": "tsc --noEmit" + "tsc": "tsc --noEmit", + "lint": "eslint --ext .ts,.tsx src/", + "lint:fix": "eslint --ext .ts,.tsx --fix src/", + "format": "prettier --write src/", + "format:check": "prettier --check src/" }, "devDependencies": { "@kinvolk/headlamp-plugin": "^0.13.0" diff --git a/src/api/polaris.ts b/src/api/polaris.ts index 1332df3..87b0f75 100644 --- a/src/api/polaris.ts +++ b/src/api/polaris.ts @@ -157,7 +157,7 @@ export function usePolarisData(refreshIntervalSeconds: number): PolarisDataState return; } const intervalId = window.setInterval(() => { - setTick((t) => t + 1); + setTick(t => t + 1); }, refreshIntervalSeconds * 1000); return () => window.clearInterval(intervalId); }, [refreshIntervalSeconds]); diff --git a/src/components/PolarisView.tsx b/src/components/PolarisView.tsx index bce8bd1..762f896 100644 --- a/src/components/PolarisView.tsx +++ b/src/components/PolarisView.tsx @@ -1,8 +1,4 @@ -import { - Loader, - SectionBox, - SectionHeader, -} from '@kinvolk/headlamp-plugin/lib/CommonComponents'; +import { Loader, SectionBox, SectionHeader } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; import { AuditData, @@ -20,19 +16,16 @@ const INTERVAL_OPTIONS = [ { label: '30 minutes', value: 1800 }, ]; -function RefreshSettings(props: { - interval: number; - onChange: (seconds: number) => void; -}) { +function RefreshSettings(props: { interval: number; onChange: (seconds: number) => void }) { return (