diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a55d76..12d6afa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,11 +37,18 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - # Lint, typecheck, and test are not included yet: they currently fail in packages/tab-id-hook - # (no ESLint config or tsconfig). Add them once fixed. - name: Check formatting run: pnpm --recursive --if-present run format:check + - name: Lint + run: pnpm --recursive --if-present run lint:check + + - name: Typecheck + run: pnpm --recursive --if-present run typecheck + + - name: Test + run: pnpm --recursive --if-present run test:coverage + - name: Build run: pnpm --recursive --if-present run build diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..690c968 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,13 @@ +import js from "@eslint/js"; +import { defineConfig } from "eslint/config"; +import tseslint from "typescript-eslint"; + +export default defineConfig([ + { + ignores: ["**/build/**", "**/dist/**", "**/.react-router/**", "**/coverage/**"], + }, + { + files: ["**/*.{ts,tsx}"], + extends: [js.configs.recommended, tseslint.configs.recommended], + }, +]); diff --git a/examples/tab-id-hook/app/routes/home.tsx b/examples/tab-id-hook/app/routes/home.tsx index 468d537..03fb13c 100644 --- a/examples/tab-id-hook/app/routes/home.tsx +++ b/examples/tab-id-hook/app/routes/home.tsx @@ -1,8 +1,7 @@ import { Link } from "react-router"; import { Welcome } from "../welcome/welcome"; -import type { Route } from "./+types/home"; -export function meta({}: Route.MetaArgs) { +export function meta() { return [ { title: "New React Router App" }, { name: "description", content: "Welcome to React Router!" }, diff --git a/examples/tab-id-hook/package.json b/examples/tab-id-hook/package.json index 7a2c3f2..e88a7b0 100644 --- a/examples/tab-id-hook/package.json +++ b/examples/tab-id-hook/package.json @@ -6,6 +6,7 @@ "build": "react-router build", "dev": "react-router dev", "start": "react-router-serve ./build/server/index.js", + "lint:check": "eslint --cache --cache-location ./node_modules/.cache/eslint/ --ext .ts,.tsx ./", "typecheck": "react-router typegen && tsc" }, "dependencies": { diff --git a/packages/tab-id-hook/.prettierignore b/packages/tab-id-hook/.prettierignore index b30d7eb..5d40d58 100644 --- a/packages/tab-id-hook/.prettierignore +++ b/packages/tab-id-hook/.prettierignore @@ -1,2 +1,4 @@ # Release Please owns the generated changelog format. CHANGELOG.md +dist/ +coverage/ diff --git a/packages/tab-id-hook/package.json b/packages/tab-id-hook/package.json index e8e86d9..073fe9c 100644 --- a/packages/tab-id-hook/package.json +++ b/packages/tab-id-hook/package.json @@ -55,10 +55,10 @@ "exports:check": "attw --pack ./", "format:check": "prettier --cache --cache-location ./node_modules/.cache/prettier/ --check ./", "format:fix": "prettier --cache --cache-location ./node_modules/.cache/prettier/ --write ./", - "lint:check": "eslint --cache --cache-location: ./node_modules/.cache/eslint/ ./", - "lint:fix": "eslint --cache --cache-location: ./node_modules/.cache/eslint/ --fix ./", + "lint:check": "eslint --cache --cache-location ./node_modules/.cache/eslint/ --ext .ts,.tsx ./", + "lint:fix": "eslint --cache --cache-location ./node_modules/.cache/eslint/ --ext .ts,.tsx --fix ./", "test": "vitest", - "test:coverage": "vitest --coverage", + "test:coverage": "vitest run --coverage", "typecheck": "tsc" }, "devDependencies": { diff --git a/packages/tab-id-hook/src/client/use-tab-id.test.tsx b/packages/tab-id-hook/src/client/use-tab-id.test.tsx index 47c31df..04ab8d9 100644 --- a/packages/tab-id-hook/src/client/use-tab-id.test.tsx +++ b/packages/tab-id-hook/src/client/use-tab-id.test.tsx @@ -145,10 +145,9 @@ describe("use-tab-id()", () => { act(() => { window.dispatchEvent( - new StorageEvent("storage", { + new window.StorageEvent("storage", { key: "tab-id", newValue: "xx-9999", - storageArea: window.sessionStorage, }), ); }); diff --git a/packages/tab-id-hook/tsconfig.json b/packages/tab-id-hook/tsconfig.json new file mode 100644 index 0000000..f60a798 --- /dev/null +++ b/packages/tab-id-hook/tsconfig.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ES2022", + "moduleResolution": "bundler", + "jsx": "react-jsx", + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + }, + "include": ["src/**/*.ts", "src/**/*.tsx", "vitest.config.ts"] +}