diff --git a/.github/workflows/lint-ratchet-decrease.yml b/.github/workflows/lint-ratchet-decrease.yml index c71af5a14bd..2c544f91fee 100644 --- a/.github/workflows/lint-ratchet-decrease.yml +++ b/.github/workflows/lint-ratchet-decrease.yml @@ -23,6 +23,7 @@ jobs: apps/design-system apps/ui-library apps/learn + apps/kb packages patches @@ -71,7 +72,7 @@ jobs: # Keep going past an app that regressed so the others still get decreased; # the job fails at the end if any app did. failed="" - APPS="www docs design-system ui-library learn" + APPS="www docs design-system ui-library learn kb" for app in $APPS; do pnpm --filter "./apps/$app" run lint:ratchet --decrease-baselines || failed="$failed $app" done diff --git a/.github/workflows/lint-ratchet.yml b/.github/workflows/lint-ratchet.yml index d2204ecbfd1..da98f84522f 100644 --- a/.github/workflows/lint-ratchet.yml +++ b/.github/workflows/lint-ratchet.yml @@ -41,6 +41,9 @@ jobs: learn: - *shared - 'apps/learn/**' + kb: + - *shared + - 'apps/kb/**' ratchet: needs: changes diff --git a/AGENTS.md b/AGENTS.md index 43ad1bb941c..5724e53b240 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,7 +42,7 @@ pnpm api:codegen # platform Management API types → packages/api-ty ## CI -Every PR must pass typecheck + lint (one workflow), Prettier, and a typos check. Other checks are path-filtered: Studio unit tests/build and the lint ratchet (ESLint warning count must not increase) run on `apps/studio/**` changes and the Tailwind class rules (`shadcn/*`) for `www`, `docs`, `design-system`, `ui-library`, and `learn`; app-specific test suites run on their own paths. +Every PR must pass typecheck + lint (one workflow), Prettier, and a typos check. Other checks are path-filtered: Studio unit tests/build and the lint ratchet (ESLint warning count must not increase) run on `apps/studio/**` changes and the Tailwind class rules (`shadcn/*`) for `www`, `docs`, `design-system`, `ui-library`, `learn`, and `kb`; app-specific test suites run on their own paths. Never hand-edit generated files: `packages/api-types/types/**`, `**/routeTree.gen.ts`, `**/__generated__/**`, `apps/docs/features/docs/generated/**`, `apps/www/.generated/**`, `supabase/functions/common/database-types.ts`, `apps/docs/content/_partials/access-control/scoped_pat_*.mdx` (run `make -C apps/docs/spec generate.partials.access-control`). diff --git a/apps/kb/.github/eslint-rule-baselines.json b/apps/kb/.github/eslint-rule-baselines.json new file mode 100644 index 00000000000..8e60b9b05cd --- /dev/null +++ b/apps/kb/.github/eslint-rule-baselines.json @@ -0,0 +1,18 @@ +{ + "rules": { + "shadcn/no-arbitrary-values": 3, + "shadcn/no-unknown-classes": 0, + "shadcn/no-raw-colors": 2 + }, + "ruleFiles": { + "shadcn/no-arbitrary-values": { + "src/components/AsciiHoverText.tsx": 1, + "src/components/Hero.tsx": 2 + }, + "shadcn/no-unknown-classes": {}, + "shadcn/no-raw-colors": { + "src/components/Footer.astro": 1, + "src/components/HeroGrid.tsx": 1 + } + } +} diff --git a/apps/kb/eslint.config.cjs b/apps/kb/eslint.config.cjs new file mode 100644 index 00000000000..5d727f9886d --- /dev/null +++ b/apps/kb/eslint.config.cjs @@ -0,0 +1,20 @@ +const { defineConfig } = require('eslint/config') +const tsparser = require('@typescript-eslint/parser') +const astroParser = require('astro-eslint-parser') +const shadcnConfig = require('eslint-config-supabase/shadcn') + +module.exports = defineConfig([ + { ignores: ['dist', '.astro'] }, + { + files: ['**/*.ts', '**/*.tsx'], + languageOptions: { parser: tsparser }, + }, + { + files: ['**/*.astro'], + languageOptions: { + parser: astroParser, + parserOptions: { parser: tsparser }, + }, + }, + { ...shadcnConfig, files: [...shadcnConfig.files, '**/*.astro'] }, +]) diff --git a/apps/kb/package.json b/apps/kb/package.json index f170d5f301d..e5c549ff9cb 100644 --- a/apps/kb/package.json +++ b/apps/kb/package.json @@ -12,7 +12,9 @@ "sync:troubleshooting-updates": "tsx ./scripts/federated-content/sync-troubleshooting-updates.ts", "preview": "astro preview", "astro": "astro", - "test": "vitest --run" + "test": "vitest --run", + "lint": "eslint .", + "lint:ratchet": "tsx node_modules/eslint-config-supabase/ratchet-eslint-rules.ts --rules-file node_modules/eslint-config-supabase/ratchet-rules.json" }, "dependencies": { "@astrojs/markdown-remark": "7.2.4", @@ -47,8 +49,11 @@ "@types/node": "catalog:", "@types/react": "catalog:", "@types/react-dom": "catalog:", + "@typescript-eslint/parser": "^8.48.0", + "astro-eslint-parser": "^1.4.0", "config": "workspace:*", "dotenv": "^16.5.0", + "eslint-config-supabase": "workspace:*", "lodash-es": "catalog:", "maybe-turbo": "workspace:*", "tailwindcss": "catalog:", diff --git a/packages/eslint-config-supabase/next.js b/packages/eslint-config-supabase/next.js index 4b78bb36dc8..f50202e7b16 100644 --- a/packages/eslint-config-supabase/next.js +++ b/packages/eslint-config-supabase/next.js @@ -1,10 +1,10 @@ const { defineConfig } = require('eslint/config') -const { plugin: shadcn } = require('@shadcn/lint') const prettierConfig = require('eslint-config-prettier/flat') const { default: turboConfig } = require('eslint-config-turbo/flat') const tanstackQuery = require('@tanstack/eslint-plugin-query') const tsparser = require('@typescript-eslint/parser') const nextCoreWebVitals = require('eslint-config-next/core-web-vitals') +const shadcnConfig = require('./shadcn') const NEXT_PLUGIN_FILES = ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'] @@ -66,22 +66,7 @@ module.exports = defineConfig([ { ignores: ['**/*.mts', '**/*.cts'] }, turboConfig, prettierConfig, - { - name: 'supabase/shadcn', - files: NEXT_PLUGIN_FILES, - plugins: { shadcn }, - settings: { - shadcn: { - componentImports: ['^ui(/|$)', '^ui-patterns(/|$)'], - }, - }, - rules: { - 'shadcn/no-unknown-classes': ['warn', { allow: ['not-prose'] }], - // a transition-[...] list names css properties, not a design value, so no token can replace it - 'shadcn/no-arbitrary-values': ['warn', { allow: ['layout', 'transition'] }], - 'shadcn/no-raw-colors': 'warn', - }, - }, + shadcnConfig, tanstackQuery.configs['flat/recommended'], { rules: { diff --git a/packages/eslint-config-supabase/shadcn.js b/packages/eslint-config-supabase/shadcn.js new file mode 100644 index 00000000000..61c86e345a4 --- /dev/null +++ b/packages/eslint-config-supabase/shadcn.js @@ -0,0 +1,18 @@ +const { plugin: shadcn } = require('@shadcn/lint') + +module.exports = { + name: 'supabase/shadcn', + files: ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'], + plugins: { shadcn }, + settings: { + shadcn: { + componentImports: ['^ui(/|$)', '^ui-patterns(/|$)'], + }, + }, + rules: { + 'shadcn/no-unknown-classes': ['warn', { allow: ['not-prose'] }], + // a transition-[...] list names css properties, not a design value, so no token can replace it + 'shadcn/no-arbitrary-values': ['warn', { allow: ['layout', 'transition'] }], + 'shadcn/no-raw-colors': 'warn', + }, +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 283c5e9833a..03c96f9ffb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -845,12 +845,21 @@ importers: '@types/react-dom': specifier: 'catalog:' version: 19.2.3(@types/react@19.2.14) + '@typescript-eslint/parser': + specifier: ^8.48.0 + version: 8.65.0(eslint@9.37.0(jiti@2.7.0)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.2) + astro-eslint-parser: + specifier: ^1.4.0 + version: 1.4.0(supports-color@8.1.1) config: specifier: workspace:* version: link:../../packages/config dotenv: specifier: ^16.5.0 version: 16.5.0 + eslint-config-supabase: + specifier: workspace:* + version: link:../../packages/eslint-config-supabase lodash-es: specifier: ^4.18.1 version: 4.18.1 @@ -865,7 +874,7 @@ importers: version: 4.22.4 vitest: specifier: 'catalog:' - version: 5.0.0(@opentelemetry/api@1.9.1)(@types/node@24.19.0)(@vitest/coverage-v8@5.0.0)(happy-dom@20.14.5)(jsdom@28.1.0(@noble/hashes@1.8.0)(supports-color@8.1.1))(msw@2.11.3(@types/node@24.19.0)(typescript@7.0.2))(vite@8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1)) + version: 5.0.0(@opentelemetry/api@1.9.1)(@types/node@24.19.0)(@vitest/coverage-v8@5.0.0)(@vitest/ui@5.0.5)(happy-dom@20.14.5)(jsdom@28.1.0(@noble/hashes@1.8.0)(supports-color@8.1.1))(msw@2.11.3(@types/node@24.19.0)(typescript@6.0.2))(vite@8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1)) apps/learn: dependencies: @@ -3324,6 +3333,9 @@ packages: resolution: {integrity: sha512-IvwYLB8t1M86rKO4oPdBi9GP4gzXcgrVlNgocjwos1jeeUuEIV8d9Crn1PvYD/5IKteWOxpIHomf7e8iYlkE+Q==} engines: {node: '>=22.12.0'} + '@astrojs/compiler@3.0.1': + resolution: {integrity: sha512-z97oYbdebO5aoWzuJ/8q5hLK232+17KcLZ7cJ8BCWk6+qNzVxn/gftC0KzMBUTD8WAaBkPpNSQK6PXLnNrZ0CA==} + '@astrojs/internal-helpers@0.10.4': resolution: {integrity: sha512-nozZSy/mKYLqe4YrqbKtdOszedAfXYCtw3wZ0d+CAjz4GqQ4L9rl1ltIL5BlgwmYVinJg/RZ0MgGuWOdlyRZlA==} @@ -6874,6 +6886,10 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} + '@pkgr/core@0.3.6': + resolution: {integrity: sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA==} + engines: {node: ^14.18.0 || >=16.0.0} + '@playwright/test@1.59.1': resolution: {integrity: sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==} engines: {node: '>=18'} @@ -10546,6 +10562,10 @@ packages: resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==} hasBin: true + astro-eslint-parser@1.4.0: + resolution: {integrity: sha512-+QDcgc7e+au6EZ0YjMmRRjNoQo5bDMlaR45aWDoFsuxQTCM9qmCHRoiKJPELgckJ8Wmr7vcfpa9eCDHBFh6G4w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + astro@7.4.2: resolution: {integrity: sha512-FAH4cdDlFaVnQGjazLTEIC5vJqGlo5XANc1wIbzQHIqAjJTll/RWTUs+SPNW1JdezG4YGxMZllaE5A41T2kzhA==} engines: {node: '>=22.23.4', npm: '>=9.6.5', pnpm: '>=7.1.0'} @@ -10556,6 +10576,12 @@ packages: '@astrojs/markdown-remark': optional: true + astrojs-compiler-sync@1.1.1: + resolution: {integrity: sha512-0mKvB9sDQRIZPsEJadw6OaFbGJ92cJPPR++ICca9XEyiUAZqgVuk25jNmzHPT0KF80rI94trSZrUR5iHFXGGOQ==} + engines: {node: ^18.18.0 || >=20.9.0} + peerDependencies: + '@astrojs/compiler': '>=0.27.0' + async-sema@3.1.1: resolution: {integrity: sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg==} @@ -17534,6 +17560,10 @@ packages: resolution: {integrity: sha512-tTw2sPVgJb/ZO+Uz5Cs1haWg7aL0cw+DvD8mXos+ws5YaelM3IBZ50M717T1+RD5Qq0TdeZ/EI/wVMnAdJA0Eg==} engines: {node: '>=22.12.0'} + synckit@0.11.13: + resolution: {integrity: sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg==} + engines: {node: ^14.18.0 || >=16.0.0} + tabbable@6.2.0: resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==} @@ -19161,6 +19191,8 @@ snapshots: dependencies: '@astrojs/compiler-binding': 0.5.2 + '@astrojs/compiler@3.0.1': {} + '@astrojs/internal-helpers@0.10.4': dependencies: '@types/hast': 3.0.5 @@ -23331,6 +23363,8 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true + '@pkgr/core@0.3.6': {} + '@playwright/test@1.59.1': dependencies: playwright: 1.59.1 @@ -26882,16 +26916,6 @@ snapshots: msw: 2.11.3(@types/node@24.19.0)(typescript@6.0.2) vite: 8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1) - '@vitest/mocker@5.0.0(msw@2.11.3(@types/node@24.19.0)(typescript@7.0.2))(vite@8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1))': - dependencies: - '@jridgewell/trace-mapping': 0.3.31 - '@vitest/spy': 5.0.0 - estree-walker: 3.0.3 - magic-string: 1.4.3 - optionalDependencies: - msw: 2.11.3(@types/node@24.19.0)(typescript@7.0.2) - vite: 8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1) - '@vitest/pretty-format@5.0.5': dependencies: tinyrainbow: 3.2.0 @@ -27546,6 +27570,23 @@ snapshots: astring@1.9.0: {} + astro-eslint-parser@1.4.0(supports-color@8.1.1): + dependencies: + '@astrojs/compiler': 3.0.1 + '@typescript-eslint/scope-manager': 8.72.0 + '@typescript-eslint/types': 8.72.0 + astrojs-compiler-sync: 1.1.1(@astrojs/compiler@3.0.1) + debug: 4.4.3(supports-color@8.1.1) + entities: 7.0.1 + eslint-scope: 8.4.0 + eslint-visitor-keys: 4.2.1 + espree: 10.4.0 + fast-glob: 3.3.3 + is-glob: 4.0.3 + semver: 7.8.5 + transitivePeerDependencies: + - supports-color + astro@7.4.2(@astrojs/markdown-remark@7.2.4(supports-color@8.1.1))(@types/node@24.19.0)(aws4fetch@1.0.20)(db0@0.4.1)(esbuild@0.28.1)(ioredis@5.11.1(supports-color@8.1.1))(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1): dependencies: '@astrojs/compiler-rs': 0.5.2 @@ -27636,6 +27677,11 @@ snapshots: - uploadthing - yaml + astrojs-compiler-sync@1.1.1(@astrojs/compiler@3.0.1): + dependencies: + '@astrojs/compiler': 3.0.1 + synckit: 0.11.13 + async-sema@3.1.1: {} async@3.2.4: {} @@ -33127,33 +33173,6 @@ snapshots: transitivePeerDependencies: - '@types/node' - msw@2.11.3(@types/node@24.19.0)(typescript@7.0.2): - dependencies: - '@bundled-es-modules/cookie': 2.0.1 - '@bundled-es-modules/statuses': 1.0.1 - '@inquirer/confirm': 5.1.21(@types/node@24.19.0) - '@mswjs/interceptors': 0.39.7 - '@open-draft/deferred-promise': 2.2.0 - '@types/cookie': 0.6.0 - '@types/statuses': 2.0.5 - graphql: 16.11.0 - headers-polyfill: 4.0.3 - is-node-process: 1.2.0 - outvariant: 1.4.3 - path-to-regexp: 6.3.0 - picocolors: 1.1.1 - rettime: 0.7.0 - strict-event-emitter: 0.5.1 - tough-cookie: 6.0.0 - type-fest: 4.30.0 - until-async: 3.0.2 - yargs: 17.7.2 - optionalDependencies: - typescript: 7.0.2 - transitivePeerDependencies: - - '@types/node' - optional: true - muggle-string@0.4.1: {} mustache@4.2.0: {} @@ -36293,6 +36312,10 @@ snapshots: timeout-signal: 2.0.0 whatwg-mimetype: 5.0.0 + synckit@0.11.13: + dependencies: + '@pkgr/core': 0.3.6 + tabbable@6.2.0: {} tagged-tag@1.0.0: {} @@ -37360,31 +37383,6 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.0(@opentelemetry/api@1.9.1)(@types/node@24.19.0)(@vitest/coverage-v8@5.0.0)(happy-dom@20.14.5)(jsdom@28.1.0(@noble/hashes@1.8.0)(supports-color@8.1.1))(msw@2.11.3(@types/node@24.19.0)(typescript@7.0.2))(vite@8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1)): - dependencies: - '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.0(msw@2.11.3(@types/node@24.19.0)(typescript@7.0.2))(vite@8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1)) - chai: 6.2.2 - es-module-lexer: 2.3.2 - expect-type: 1.4.0 - magic-string: 1.4.3 - obug: 2.1.4 - picomatch: 4.0.7 - std-env: 4.3.0 - tinybench: 6.1.4 - tinyexec: 1.3.0 - tinyglobby: 0.2.17 - vite: 8.3.5(@types/node@24.19.0)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.77.4)(terser@5.48.0)(tsx@4.22.4)(yaml@2.9.1) - why-is-node-running: 2.3.0 - optionalDependencies: - '@opentelemetry/api': 1.9.1 - '@types/node': 24.19.0 - '@vitest/coverage-v8': 5.0.0(vitest@5.0.0) - happy-dom: 20.14.5 - jsdom: 28.1.0(@noble/hashes@1.8.0)(supports-color@8.1.1) - transitivePeerDependencies: - - msw - vscode-languageserver-types@3.17.5: {} vue-bundle-renderer@2.4.0: