From 13ab970b74c1963f3c7090088f7fcf1fcfb83675 Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Wed, 18 Nov 2026 17:14:50 +0100 Subject: [PATCH 1/2] chore: render the shared Copier template at v1.3.1 over the repository copier copy --overwrite --vcs-ref v1.3.1 https://github.com/whatsaaaa/template.git with form-builder's answers, as rendered: the next commit puts back the project lines and removes the package tsconfigs the template renders for a packages/form-builder that form-builder does not have. --- .copier-answers.yml | 20 ++ .editorconfig | 12 +- .gitattributes | 10 + .github/workflows/ci.yml | 218 +-------------------- .github/workflows/pages.yml | 14 +- .github/workflows/release.yml | 4 +- .gitignore | 46 ++--- .oxlintrc.json | 10 +- .vscode/extensions.json | 4 +- apps/docs/tsconfig.json | 25 +-- eslint.config.ts | 225 +--------------------- oxfmt.config.ts | 19 +- packages/form-builder/tsconfig.build.json | 12 ++ packages/form-builder/tsconfig.json | 7 + pnpm-workspace.yaml | 55 +----- tsconfig.json | 25 +-- 16 files changed, 92 insertions(+), 614 deletions(-) create mode 100644 .copier-answers.yml create mode 100644 packages/form-builder/tsconfig.build.json create mode 100644 packages/form-builder/tsconfig.json diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 0000000..8b12e58 --- /dev/null +++ b/.copier-answers.yml @@ -0,0 +1,20 @@ +# Written by Copier: never edit this file by hand. `copier update` reads it. +_commit: v1.3.1 +_src_path: https://github.com/whatsaaaa/template.git +agents_md: false +brand_kit: form-builder +browser_tests: false +copyright_year: 2026 +description: Define Formisch forms in JSON, render them with your own components, + or compile them to typed Valibot code. +design_system: false +framework: vue +kind: library +license: MIT +name: form-builder +pages: true +publish: true +stack: typescript +starter: false +visibility: public +workspace: monorepo diff --git a/.editorconfig b/.editorconfig index 3b510aa..2dc5c9d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,8 +1,16 @@ -[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}] +root = true + +[*] charset = utf-8 +end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true -end_of_line = lf + +[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,astro,css,html,json,jsonc,yml,yaml,sh}] max_line_length = 100 + +# Two trailing spaces are a line break in Markdown +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 6313b56..599c19d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,11 @@ * text=auto eol=lf +*.sh text eol=lf + +*.png binary +*.jpg binary +*.gif binary +*.webp binary +*.ico binary +*.pdf binary +*.woff binary +*.woff2 binary diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f2ab63..951dcb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,223 +11,9 @@ permissions: concurrency: group: ci-${{ github.ref }} - # A run on main uploads that commit's coverage, which Codecov compares pull requests against. - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: true jobs: - # The checks are named `ci / check`, which the main ruleset requires: format:check, lint with - # the guard against what it auto-fixed, type-check, test and build. + # The checks are named `ci / check`, which the main ruleset requires ci: uses: whatsaaaa/template/.github/workflows/node-ci.yml@v1 - - # The schema, affects, fills and adapter tests again with coverage, which vitest.config.ts holds - # to its thresholds, and the coverage uploaded to Codecov. - coverage: - runs-on: ubuntu-latest - permissions: - contents: read - # Codecov takes the coverage uploads by OIDC, with no token. - id-token: write - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - run: pnpm install --frozen-lockfile - - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter @whatsaaaa/form-builder-vue --filter @whatsaaaa/form-builder-react test:coverage - # Codecov maps each flag to its package by path, so every lcov path must start with that - # package's directory. - - name: Check the lcov paths are from the repo root - run: | - for package in packages/schema packages/affects packages/fills frameworks/vue frameworks/react; do - report="$package/coverage/lcov.info" - grep -q '^SF:' "$report" || { echo "$report has no SF lines"; exit 1; } - if grep '^SF:' "$report" | grep -v "^SF:$package/"; then - echo "$report has paths outside $package/" - exit 1 - fi - done - - name: Upload schema coverage to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 - with: - use_oidc: true - flags: schema - files: packages/schema/coverage/lcov.info - disable_search: true - # Coverage is a report, not a gate: the thresholds in vitest.config.ts are. - fail_ci_if_error: false - - name: Upload affects coverage to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 - with: - use_oidc: true - flags: affects - files: packages/affects/coverage/lcov.info - disable_search: true - fail_ci_if_error: false - - name: Upload fills coverage to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 - with: - use_oidc: true - flags: fills - files: packages/fills/coverage/lcov.info - disable_search: true - fail_ci_if_error: false - - name: Upload vue coverage to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 - with: - use_oidc: true - flags: vue - files: frameworks/vue/coverage/lcov.info - disable_search: true - fail_ci_if_error: false - - name: Upload react coverage to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 - with: - use_oidc: true - flags: react - files: frameworks/react/coverage/lcov.info - disable_search: true - fail_ci_if_error: false - - # The generated reference pages are up to date, and the docs site builds. - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - run: pnpm install --frozen-lockfile - - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter docs docs:gen - - name: Fail if the generated files are out of date - run: git diff --exit-code - - run: pnpm docs:build - - # The published packages: publint and Are the Types Wrong on what each one packs, and their size. - packages: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - run: pnpm install --frozen-lockfile - - run: pnpm build - - run: pnpm -r --filter "./packages/*" --filter "./frameworks/*" lint:pkg - - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter @whatsaaaa/form-builder-react size - - # The schema, affects and fills tests again, with the lowest Valibot and @valibot/to-json-schema the - # peer ranges allow. - valibot-min: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - name: Install with Valibot 1.3.0 and @valibot/to-json-schema 1.6.0 - run: | - for package in packages/schema packages/affects packages/fills; do - (cd "$package" && npm pkg set devDependencies.valibot=1.3.0 devDependencies.@valibot/to-json-schema=1.6.0) - done - pnpm install --no-frozen-lockfile - - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills test:coverage - - # The React adapter's tests and types again, with React 18, the lowest major its peer range allows. - react-18: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - name: Install with React 18 - working-directory: frameworks/react - run: | - npm pkg set devDependencies.react=18.3.1 devDependencies.react-dom=18.3.1 - npm pkg set devDependencies.@types/react=^18.3.0 devDependencies.@types/react-dom=^18.3.0 - pnpm install --no-frozen-lockfile - - run: pnpm --filter @whatsaaaa/form-builder-react test:coverage - - run: pnpm --filter @whatsaaaa/form-builder-react type-check - - # Each adapter's tests and types again, with the lowest Formisch, Valibot and Vue its peer ranges - # allow. The overrides make every package in the workspace use that one copy. - adapters-min: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - adapter: vue - overrides: '{ vue: 3.5.2, "@formisch/vue": 1.1.1, valibot: 1.4.1 }' - - adapter: react - overrides: '{ "@formisch/react": 1.2.0, valibot: 1.4.1 }' - name: adapters-min (${{ matrix.adapter }}) - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - name: Install with the lowest peers - run: | - echo 'overrides: ${{ matrix.overrides }}' >> pnpm-workspace.yaml - pnpm install --no-frozen-lockfile - - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} ls --depth 0 - - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} test - - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} type-check - - # The schema, affects and fills tests on Node 22, the lowest Node Vitest supports, as they run on - # servers. The ci / check job runs them on Node 24. pnpm installs with Node 24, and the tests run - # on 22. - node-22: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - run: pnpm install --frozen-lockfile - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 22 - - run: node --version - - working-directory: packages/schema - run: node node_modules/vitest/vitest.mjs run - - working-directory: packages/affects - run: node node_modules/vitest/vitest.mjs run - - working-directory: packages/fills - run: node node_modules/vitest/vitest.mjs run - - # The packed packages in a new npm project, with the lowest TypeScript and peers they support: - # a type-check of their published types with skipLibCheck off, then an ES import, a server render - # with each adapter and a CommonJS require() on Node 24 and on Node 20.19, the lowest Node that - # requires ES modules without a flag. latest-peers.yml runs it with the latest peers. - consumer-smoke-min: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 20.19.0 - - run: echo "NODE_20=$(command -v node)" >> "$GITHUB_ENV" - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 - with: - node-version: 24 - cache: pnpm - - run: pnpm install --frozen-lockfile - - run: consumer-smoke/run.sh min node "$NODE_20" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9799f48..43c9752 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,20 +1,13 @@ -# Builds the VitePress site in apps/docs and deploys it to GitHub Pages at -# https://whatsaaaa.github.io/form-builder/, through the shared pages workflow. name: Pages on: push: branches: [main] - paths: - - apps/docs/** - # The framework pages show these renderers as they are. - - integration/examples/** - - .github/workflows/pages.yml workflow_dispatch: permissions: {} -# One deployment at a time, and an in-progress deployment is never cancelled. +# One deployment at a time, and an in-progress deployment is never cancelled concurrency: group: pages cancel-in-progress: false @@ -27,7 +20,4 @@ jobs: pages: write id-token: write with: - build-script: docs:build - artifact-path: apps/docs/.vitepress/dist - # lastUpdated reads each page's time from the git history. - fetch-depth: 0 + artifact-path: apps/docs/dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4ca464c..dd58faa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,7 @@ jobs: release: uses: whatsaaaa/template/.github/workflows/changesets-release.yml@v1 # The version job starts ci.yml on the Version Packages pull request, through its - # workflow_dispatch trigger, since GitHub starts no pull_request run for it. The publish job - # runs in the npm environment, which the trusted publisher names, and each package's prepack - # builds it. Pre mode (.changeset/pre.json) picks the rc dist-tag. + # workflow_dispatch trigger, since GitHub starts no pull_request run for it permissions: actions: write # starts CI on the Version Packages pull request contents: write # Version Packages pull request, git tags and GitHub releases diff --git a/.gitignore b/.gitignore index 90dd21d..60260f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,46 +1,22 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules .DS_Store -dist -dist-ssr -coverage +Thumbs.db +*.log *.local +.env +.env.* +!.env.example # Editor directories and files .vscode/* !.vscode/extensions.json .idea -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? +node_modules +dist +coverage *.tsbuildinfo - -.eslintcache - -# Cypress -/cypress/videos/ -/cypress/screenshots/ - -# Vitest -__screenshots__/ - -# Vite -*.timestamp-*-*.mjs - *.tgz -.attw/ +.eslintcache -# VitePress -**/.vitepress/cache -**/.vitepress/dist +# Packed by lint:package for attw to check +.attw diff --git a/.oxlintrc.json b/.oxlintrc.json index 030d3de..57f43ec 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -1,13 +1,5 @@ { "$schema": "./node_modules/oxlint/configuration_schema.json", "extends": ["./node_modules/@whatsaaaa/oxlint-config/vue.json"], - "overrides": [ - { - // The shared config adds Node's globals; the code here has only ever had the browser's. - "files": ["**/*"], - "env": { - "node": false - } - } - ] + "ignorePatterns": ["**/dist"] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 55ad03c..3f11023 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,8 @@ { "recommendations": [ - "Vue.volar", + "oxc.oxc-vscode", "dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", - "oxc.oxc-vscode" + "Vue.volar" ] } diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index 19fefdb..307da99 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -1,26 +1,7 @@ -// TSConfig for the code that runs in Node.js: the VitePress config, the generator and the tests. -// The theme, which runs in the browser, has its own project in .vitepress/theme, and the snippets -// the pages show have a project each in snippets/. { "extends": "@whatsaaaa/tsconfig/bundler.json", - "include": [".vitepress/config.ts", "scripts", "tests"], "compilerOptions": { - // What Node 24 runs, as @tsconfig/node24 set it before. - "target": "es2024", - "lib": [ - "es2024", - "esnext.array", - "esnext.collection", - "esnext.error", - "es2025.iterator", - "es2025.promise" - ], - "types": ["node"], - // The shared config turns these on; this code has never been held to them. - "allowImportingTsExtensions": false, - "noUncheckedIndexedAccess": false, - "verbatimModuleSyntax": false, - "isolatedModules": false, - "erasableSyntaxOnly": false - } + "types": ["vite/client", "node"] + }, + "include": ["src", "*.config.ts"] } diff --git a/eslint.config.ts b/eslint.config.ts index c933036..6785f90 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,226 +1,3 @@ import whatsaaaa from '@whatsaaaa/eslint-config' -import pluginBoundaries from 'eslint-plugin-boundaries' -import pluginReactHooks from 'eslint-plugin-react-hooks' -// The feature folders under each package's src/, and the features each one may import. -// A feature missing from this list can't be imported by any other feature. -const packageFeatures: Record> = { - schema: { - shared: [], - errors: ['shared'], - kinds: ['shared'], - definition: ['shared', 'errors'], - rules: ['shared', 'definition'], - 'field-types': ['shared', 'kinds', 'definition', 'errors'], - render: ['shared', 'definition', 'errors'], - extensions: ['shared', 'errors', 'kinds', 'definition'], - visibility: ['shared', 'errors', 'definition', 'render', 'extensions'], - fills: ['shared', 'errors', 'kinds', 'definition', 'render', 'extensions', 'visibility'], - builder: [ - 'shared', - 'errors', - 'kinds', - 'definition', - 'rules', - 'field-types', - 'render', - 'extensions', - 'visibility', - 'fills', - ], - 'json-schema': ['shared', 'definition', 'rules', 'field-types', 'extensions'], - }, - affects: { - definition: [], - evaluate: ['definition'], - check: ['definition', 'evaluate'], - }, - fills: { - definition: [], - values: ['definition'], - check: ['definition', 'values'], - }, -} - -// The packages each package builds on, by their public entry, like an app uses them. -const packageDependencies: Record = { - affects: ['schema'], - fills: ['schema'], -} - -// UI frameworks belong in frameworks/ and apps/, never in the core packages. -const uiFrameworks = ['vue', '@vue/*', 'react', 'react-dom', 'react/*', '@angular/*', 'svelte'] - -export default whatsaaaa( - { vue: true, ignores: ['**/dist-ssr/**', '**/.vitepress/cache/**'] }, - - { - name: 'app/vue', - rules: { - // An optional TypeScript prop is undefined when it's left out; no default to set. - 'vue/require-default-prop': 'off', - }, - }, - - { - name: 'app/vue-tests', - files: ['packages/*/tests/**', 'frameworks/*/tests/**', 'integration/**'], - rules: { - // Tests define the small components they mount next to the test that uses them. - 'vue/one-component-per-file': 'off', - }, - }, - - { - // The rules of hooks and the React Compiler's checks, for the React code. - ...pluginReactHooks.configs.flat.recommended, - name: 'app/react', - files: ['frameworks/react/**/*.{ts,tsx}', 'integration/tests/react*.tsx'], - rules: { - ...pluginReactHooks.configs.flat.recommended.rules, - 'react-hooks/exhaustive-deps': 'error', - }, - }, - - { - name: 'app/boundaries', - plugins: { boundaries: pluginBoundaries }, - settings: { - 'import/resolver': { - typescript: { project: '**/tsconfig*.json', noWarnOnMultipleProjects: true }, - }, - 'boundaries/elements': [ - { type: 'app', pattern: 'apps/*', capture: ['app'] }, - { type: 'framework', pattern: 'frameworks/*', capture: ['framework'] }, - { type: 'package-feature', pattern: 'packages/*/src/*', capture: ['pkg', 'feature'] }, - // Files directly in src/ (index.ts) that are not inside a feature folder. - { type: 'package-entry', pattern: 'packages/*/src', capture: ['pkg'] }, - { type: 'package-tests', pattern: 'packages/*/tests', capture: ['pkg'] }, - // Tests that run the packages in Formisch's own bindings, the way an app uses them. - { type: 'integration', pattern: 'integration' }, - // Sample JSON forms that tests and apps share. - { type: 'fixtures', pattern: 'fixtures' }, - ], - }, - rules: { - 'boundaries/dependencies': [ - 'error', - { - default: 'disallow', - checkAllOrigins: true, - policies: [ - { allow: { to: { module: { origin: ['external', 'core'] } } } }, - { - from: { element: { type: 'app' } }, - allow: { - to: [ - { - element: { type: 'app', captured: { app: '{{ from.element.captured.app }}' } }, - }, - { element: { types: ['framework', 'package-entry'] } }, - ], - }, - }, - { - from: { element: { type: 'framework' } }, - allow: { - to: [ - { - element: { - type: 'framework', - captured: { framework: '{{ from.element.captured.framework }}' }, - }, - }, - { element: { type: 'package-entry' } }, - ], - }, - }, - { - from: { element: { type: 'package-entry' } }, - allow: { - to: { - element: { - type: 'package-feature', - captured: { pkg: '{{ from.element.captured.pkg }}' }, - }, - }, - }, - }, - ...Object.entries(packageFeatures).flatMap(([pkg, features]) => - Object.entries(features).map(([feature, imports]) => ({ - from: { element: { type: 'package-feature', captured: { pkg, feature } } }, - allow: { - to: { - element: { - type: 'package-feature', - captured: { pkg, feature: [feature, ...imports] }, - }, - }, - }, - })), - ), - ...Object.entries(packageDependencies).map(([pkg, dependencies]) => ({ - from: { - element: { - types: ['package-entry', 'package-feature', 'package-tests'], - captured: { pkg }, - }, - }, - allow: { - to: { element: { type: 'package-entry', captured: { pkg: dependencies } } }, - }, - })), - { - from: { element: { type: 'package-tests' } }, - allow: { - to: { - element: { - types: ['package-entry', 'package-tests'], - captured: { pkg: '{{ from.element.captured.pkg }}' }, - }, - }, - }, - }, - { - from: { element: { type: 'integration' } }, - allow: { - to: { element: { types: ['integration', 'framework', 'package-entry'] } }, - }, - }, - { - from: { element: { types: ['app', 'framework', 'package-tests', 'integration'] } }, - allow: { to: { element: { type: 'fixtures' } } }, - }, - { - from: { element: { types: ['package-entry', 'package-feature'] } }, - disallow: { - to: [ - { module: { origin: 'core' } }, - { module: { origin: 'external', source: uiFrameworks } }, - ], - }, - }, - ], - }, - ], - }, - }, - - { - name: 'app/package-tests', - files: ['packages/*/tests/**', 'frameworks/*/tests/**', 'integration/**'], - rules: { - 'no-restricted-imports': [ - 'error', - { - patterns: [ - { - group: ['**/src', '**/src/**'], - message: 'Import the package by its name, the way its users do.', - }, - ], - }, - ], - }, - }, -) +export default whatsaaaa({ vue: true }) diff --git a/oxfmt.config.ts b/oxfmt.config.ts index 47654e3..67174ef 100644 --- a/oxfmt.config.ts +++ b/oxfmt.config.ts @@ -3,22 +3,5 @@ import whatsaaaa from '@whatsaaaa/format-config/oxfmt' export default defineConfig({ ...whatsaaaa, - ignorePatterns: [ - 'packages/schema/definition.schema.json', - 'apps/docs/api/schema/field-types.md', - 'apps/docs/api/schema/rules.md', - 'packages/affects/definition.schema.json', - 'apps/docs/public/schema/v1/definition.schema.json', - 'apps/docs/public/schema/v1/affects/definition.schema.json', - 'packages/fills/definition.schema.json', - 'apps/docs/public/schema/v1/fills/definition.schema.json', - ], - overrides: [ - { - files: ['apps/docs/**/*.md', 'apps/docs/snippets/**'], - options: { - printWidth: 76, - }, - }, - ], + ignorePatterns: ['pnpm-lock.yaml', '.github/assets'], }) diff --git a/packages/form-builder/tsconfig.build.json b/packages/form-builder/tsconfig.build.json new file mode 100644 index 0000000..b238b54 --- /dev/null +++ b/packages/form-builder/tsconfig.build.json @@ -0,0 +1,12 @@ +// The build: the package's source, compiled to dist/ with its type declarations +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "declaration": true, + "rewriteRelativeImportExtensions": true, + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"] +} diff --git a/packages/form-builder/tsconfig.json b/packages/form-builder/tsconfig.json new file mode 100644 index 0000000..40ba7b6 --- /dev/null +++ b/packages/form-builder/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "@whatsaaaa/tsconfig/bundler.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["src", "src/**/*.vue", "tests", "*.config.ts"] +} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 1624894..8330363 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,54 +1,11 @@ packages: - - apps/* - - frameworks/* - - integration - packages/* + - apps/* -# Install scripts that may run. The postinstalls of unrs-resolver and esbuild (used by -# size-limit), and of @parcel/watcher, lmdb and msgpackr-extract (used by @angular/build in the -# integration tests), only re-download, check or build the native binding, which pnpm already -# installs through their optional platform packages. -allowBuilds: - '@parcel/watcher': false - esbuild: false - lmdb: false - msgpackr-extract: false - unrs-resolver: false - -# Versions shared by more than one workspace package. Reference them with `catalog:`. -catalog: - '@types/node': ^24.13.4 - '@whatsaaaa/tsconfig': ^1.0.0 - typescript: ~6.0.3 - valibot: ^1.5.0 - vue-tsc: ^3.3.11 - -# @qwik.dev/core wants Vitest below 5 for its own test helpers, which the integration tests don't -# use. They render with Qwik's render() in jsdom. -peerDependencyRules: - allowedVersions: - '@qwik.dev/core>vitest': '5' - # @angular/build's WebAssembly build of oxc-parser, which only loads where there's no native - # one, brings an @emnapi prerelease that @napi-rs/wasm-runtime's range leaves out. - '@napi-rs/wasm-runtime>@emnapi/core': '2.0.0-alpha.6' - '@napi-rs/wasm-runtime>@emnapi/runtime': '2.0.0-alpha.6' - # The docs install React only to type-check their React snippets. The site uses VitePress's - # local search, so DocSearch's React UI, which wants React below 19, never loads. - '@docsearch/react>react': '19' - '@docsearch/react>react-dom': '19' - '@docsearch/react>@types/react': '19' - -# @formisch/react's types import React's but it doesn't list @types/react, so they'd resolve to -# whichever version is hoisted. As a peer, each install sees its own, as the React 18 CI job needs. -packageExtensions: - '@formisch/react': - peerDependencies: - '@types/react': '*' - peerDependenciesMeta: - '@types/react': - optional: true - -# The docs theme's design-system release was installed before it was a day old, pnpm's minimum -# release age. +# pnpm installs no package younger than a day (minimumReleaseAge). Our own packages are let in +# as soon as they are published, so a project can take a release of them right away. minimumReleaseAgeExclude: - '@whatsaaaa/*' + +# A dependency's install script runs only when allowBuilds lists it: true to run it, false to +# skip it, each with a comment that says why. diff --git a/tsconfig.json b/tsconfig.json index 534a40a..4ccbe94 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,5 @@ -// TSConfig for workspace-level config files (e.g. eslint.config.ts). -// Each workspace package has its own tsconfig and is type-checked separately. +// The configs and the tests at the root. Each package has its own. { - "extends": "@whatsaaaa/tsconfig/bundler.json", - "include": ["*.config.*"], - "compilerOptions": { - // What Node 24 runs, as @tsconfig/node24 set it before. - "target": "es2024", - "lib": [ - "es2024", - "esnext.array", - "esnext.collection", - "esnext.error", - "es2025.iterator", - "es2025.promise" - ], - "types": ["node"], - // The shared config turns these on; the config files have never been held to them. - "noUncheckedIndexedAccess": false, - "verbatimModuleSyntax": false, - "isolatedModules": false, - "erasableSyntaxOnly": false - } + "extends": "@whatsaaaa/tsconfig/node.json", + "include": ["tests", "*.config.ts"] } From d0b7cacace11f2b4ec4f26cdffe2cfcecc392979 Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Wed, 18 Nov 2026 17:15:02 +0100 Subject: [PATCH 2/2] chore: put back form-builder's project lines after the template render Keeps the template's managed files and restores only what form-builder needs: - pnpm-workspace.yaml: the frameworks/* and integration workspaces, the allowBuilds entries with their reason, the catalog, peerDependencyRules and packageExtensions. - .gitignore: the VitePress cache and build output of the docs site. - .oxlintrc.json: the override that keeps Node's globals off. - oxfmt.config.ts: the generated files it leaves alone and the docs' 76-column width, and .copier-answers.yml, which Copier writes in a style oxfmt would change. - eslint.config.ts: form-builder's own config (the boundaries rules, the React hooks and the Vue and test blocks). - tsconfig.json and apps/docs/tsconfig.json: form-builder's own, which type-check the root configs and the VitePress app as before. - ci.yml: the coverage, docs, packages, peer-floor, node-22 and consumer-smoke jobs, and cancel-in-progress off on main for Codecov; release.yml: the npm environment and pre mode comment; pages.yml: the docs paths, docs:build, the VitePress output and full history. Removes the tsconfigs the template renders for a package at packages/form-builder, which form-builder does not have: its packages are schema, affects, fills and the two frameworks. A copier update does not add back a managed file the project deleted. --- .github/workflows/ci.yml | 215 ++++++++++++++++++++- .github/workflows/pages.yml | 12 +- .github/workflows/release.yml | 4 +- .gitignore | 4 + .oxlintrc.json | 11 +- apps/docs/tsconfig.json | 25 ++- eslint.config.ts | 225 +++++++++++++++++++++- oxfmt.config.ts | 23 ++- packages/form-builder/tsconfig.build.json | 12 -- packages/form-builder/tsconfig.json | 7 - pnpm-workspace.yaml | 45 +++++ tsconfig.json | 25 ++- 12 files changed, 577 insertions(+), 31 deletions(-) delete mode 100644 packages/form-builder/tsconfig.build.json delete mode 100644 packages/form-builder/tsconfig.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 951dcb2..69f1f84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,222 @@ permissions: concurrency: group: ci-${{ github.ref }} - cancel-in-progress: true + # A run on main uploads that commit's coverage, which Codecov compares pull requests against. + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: # The checks are named `ci / check`, which the main ruleset requires ci: uses: whatsaaaa/template/.github/workflows/node-ci.yml@v1 + + # The schema, affects, fills and adapter tests again with coverage, which vitest.config.ts holds + # to its thresholds, and the coverage uploaded to Codecov. + coverage: + runs-on: ubuntu-latest + permissions: + contents: read + # Codecov takes the coverage uploads by OIDC, with no token. + id-token: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter @whatsaaaa/form-builder-vue --filter @whatsaaaa/form-builder-react test:coverage + # Codecov maps each flag to its package by path, so every lcov path must start with that + # package's directory. + - name: Check the lcov paths are from the repo root + run: | + for package in packages/schema packages/affects packages/fills frameworks/vue frameworks/react; do + report="$package/coverage/lcov.info" + grep -q '^SF:' "$report" || { echo "$report has no SF lines"; exit 1; } + if grep '^SF:' "$report" | grep -v "^SF:$package/"; then + echo "$report has paths outside $package/" + exit 1 + fi + done + - name: Upload schema coverage to Codecov + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 + with: + use_oidc: true + flags: schema + files: packages/schema/coverage/lcov.info + disable_search: true + # Coverage is a report, not a gate: the thresholds in vitest.config.ts are. + fail_ci_if_error: false + - name: Upload affects coverage to Codecov + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 + with: + use_oidc: true + flags: affects + files: packages/affects/coverage/lcov.info + disable_search: true + fail_ci_if_error: false + - name: Upload fills coverage to Codecov + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 + with: + use_oidc: true + flags: fills + files: packages/fills/coverage/lcov.info + disable_search: true + fail_ci_if_error: false + - name: Upload vue coverage to Codecov + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 + with: + use_oidc: true + flags: vue + files: frameworks/vue/coverage/lcov.info + disable_search: true + fail_ci_if_error: false + - name: Upload react coverage to Codecov + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 + with: + use_oidc: true + flags: react + files: frameworks/react/coverage/lcov.info + disable_search: true + fail_ci_if_error: false + + # The generated reference pages are up to date, and the docs site builds. + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter docs docs:gen + - name: Fail if the generated files are out of date + run: git diff --exit-code + - run: pnpm docs:build + + # The published packages: publint and Are the Types Wrong on what each one packs, and their size. + packages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm build + - run: pnpm -r --filter "./packages/*" --filter "./frameworks/*" lint:pkg + - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills --filter @whatsaaaa/form-builder-react size + + # The schema, affects and fills tests again, with the lowest Valibot and @valibot/to-json-schema the + # peer ranges allow. + valibot-min: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - name: Install with Valibot 1.3.0 and @valibot/to-json-schema 1.6.0 + run: | + for package in packages/schema packages/affects packages/fills; do + (cd "$package" && npm pkg set devDependencies.valibot=1.3.0 devDependencies.@valibot/to-json-schema=1.6.0) + done + pnpm install --no-frozen-lockfile + - run: pnpm --filter @whatsaaaa/form-builder-schema --filter @whatsaaaa/form-builder-affects --filter @whatsaaaa/form-builder-fills test:coverage + + # The React adapter's tests and types again, with React 18, the lowest major its peer range allows. + react-18: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - name: Install with React 18 + working-directory: frameworks/react + run: | + npm pkg set devDependencies.react=18.3.1 devDependencies.react-dom=18.3.1 + npm pkg set devDependencies.@types/react=^18.3.0 devDependencies.@types/react-dom=^18.3.0 + pnpm install --no-frozen-lockfile + - run: pnpm --filter @whatsaaaa/form-builder-react test:coverage + - run: pnpm --filter @whatsaaaa/form-builder-react type-check + + # Each adapter's tests and types again, with the lowest Formisch, Valibot and Vue its peer ranges + # allow. The overrides make every package in the workspace use that one copy. + adapters-min: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - adapter: vue + overrides: '{ vue: 3.5.2, "@formisch/vue": 1.1.1, valibot: 1.4.1 }' + - adapter: react + overrides: '{ "@formisch/react": 1.2.0, valibot: 1.4.1 }' + name: adapters-min (${{ matrix.adapter }}) + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - name: Install with the lowest peers + run: | + echo 'overrides: ${{ matrix.overrides }}' >> pnpm-workspace.yaml + pnpm install --no-frozen-lockfile + - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} ls --depth 0 + - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} test + - run: pnpm --filter @whatsaaaa/form-builder-${{ matrix.adapter }} type-check + + # The schema, affects and fills tests on Node 22, the lowest Node Vitest supports, as they run on + # servers. The ci / check job runs them on Node 24. pnpm installs with Node 24, and the tests run + # on 22. + node-22: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 22 + - run: node --version + - working-directory: packages/schema + run: node node_modules/vitest/vitest.mjs run + - working-directory: packages/affects + run: node node_modules/vitest/vitest.mjs run + - working-directory: packages/fills + run: node node_modules/vitest/vitest.mjs run + + # The packed packages in a new npm project, with the lowest TypeScript and peers they support: + # a type-check of their published types with skipLibCheck off, then an ES import, a server render + # with each adapter and a CommonJS require() on Node 24 and on Node 20.19, the lowest Node that + # requires ES modules without a flag. latest-peers.yml runs it with the latest peers. + consumer-smoke-min: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 # use the latest major + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 20.19.0 + - run: echo "NODE_20=$(command -v node)" >> "$GITHUB_ENV" + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: consumer-smoke/run.sh min node "$NODE_20" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 43c9752..8ed0366 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,8 +1,15 @@ +# Builds the VitePress site in apps/docs and deploys it to GitHub Pages at +# https://whatsaaaa.github.io/form-builder/, through the shared pages workflow. name: Pages on: push: branches: [main] + paths: + - apps/docs/** + # The framework pages show these renderers as they are. + - integration/examples/** + - .github/workflows/pages.yml workflow_dispatch: permissions: {} @@ -20,4 +27,7 @@ jobs: pages: write id-token: write with: - artifact-path: apps/docs/dist + build-script: docs:build + artifact-path: apps/docs/.vitepress/dist + # lastUpdated reads each page's time from the git history. + fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd58faa..4ca464c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,9 @@ jobs: release: uses: whatsaaaa/template/.github/workflows/changesets-release.yml@v1 # The version job starts ci.yml on the Version Packages pull request, through its - # workflow_dispatch trigger, since GitHub starts no pull_request run for it + # workflow_dispatch trigger, since GitHub starts no pull_request run for it. The publish job + # runs in the npm environment, which the trusted publisher names, and each package's prepack + # builds it. Pre mode (.changeset/pre.json) picks the rc dist-tag. permissions: actions: write # starts CI on the Version Packages pull request contents: write # Version Packages pull request, git tags and GitHub releases diff --git a/.gitignore b/.gitignore index 60260f3..9489669 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ coverage # Packed by lint:package for attw to check .attw + +# VitePress +**/.vitepress/cache +**/.vitepress/dist diff --git a/.oxlintrc.json b/.oxlintrc.json index 57f43ec..35d4158 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -1,5 +1,14 @@ { "$schema": "./node_modules/oxlint/configuration_schema.json", "extends": ["./node_modules/@whatsaaaa/oxlint-config/vue.json"], - "ignorePatterns": ["**/dist"] + "ignorePatterns": ["**/dist"], + "overrides": [ + { + // The shared config adds Node's globals; the code here has only ever had the browser's. + "files": ["**/*"], + "env": { + "node": false + } + } + ] } diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index 307da99..19fefdb 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -1,7 +1,26 @@ +// TSConfig for the code that runs in Node.js: the VitePress config, the generator and the tests. +// The theme, which runs in the browser, has its own project in .vitepress/theme, and the snippets +// the pages show have a project each in snippets/. { "extends": "@whatsaaaa/tsconfig/bundler.json", + "include": [".vitepress/config.ts", "scripts", "tests"], "compilerOptions": { - "types": ["vite/client", "node"] - }, - "include": ["src", "*.config.ts"] + // What Node 24 runs, as @tsconfig/node24 set it before. + "target": "es2024", + "lib": [ + "es2024", + "esnext.array", + "esnext.collection", + "esnext.error", + "es2025.iterator", + "es2025.promise" + ], + "types": ["node"], + // The shared config turns these on; this code has never been held to them. + "allowImportingTsExtensions": false, + "noUncheckedIndexedAccess": false, + "verbatimModuleSyntax": false, + "isolatedModules": false, + "erasableSyntaxOnly": false + } } diff --git a/eslint.config.ts b/eslint.config.ts index 6785f90..c933036 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,3 +1,226 @@ import whatsaaaa from '@whatsaaaa/eslint-config' +import pluginBoundaries from 'eslint-plugin-boundaries' +import pluginReactHooks from 'eslint-plugin-react-hooks' -export default whatsaaaa({ vue: true }) +// The feature folders under each package's src/, and the features each one may import. +// A feature missing from this list can't be imported by any other feature. +const packageFeatures: Record> = { + schema: { + shared: [], + errors: ['shared'], + kinds: ['shared'], + definition: ['shared', 'errors'], + rules: ['shared', 'definition'], + 'field-types': ['shared', 'kinds', 'definition', 'errors'], + render: ['shared', 'definition', 'errors'], + extensions: ['shared', 'errors', 'kinds', 'definition'], + visibility: ['shared', 'errors', 'definition', 'render', 'extensions'], + fills: ['shared', 'errors', 'kinds', 'definition', 'render', 'extensions', 'visibility'], + builder: [ + 'shared', + 'errors', + 'kinds', + 'definition', + 'rules', + 'field-types', + 'render', + 'extensions', + 'visibility', + 'fills', + ], + 'json-schema': ['shared', 'definition', 'rules', 'field-types', 'extensions'], + }, + affects: { + definition: [], + evaluate: ['definition'], + check: ['definition', 'evaluate'], + }, + fills: { + definition: [], + values: ['definition'], + check: ['definition', 'values'], + }, +} + +// The packages each package builds on, by their public entry, like an app uses them. +const packageDependencies: Record = { + affects: ['schema'], + fills: ['schema'], +} + +// UI frameworks belong in frameworks/ and apps/, never in the core packages. +const uiFrameworks = ['vue', '@vue/*', 'react', 'react-dom', 'react/*', '@angular/*', 'svelte'] + +export default whatsaaaa( + { vue: true, ignores: ['**/dist-ssr/**', '**/.vitepress/cache/**'] }, + + { + name: 'app/vue', + rules: { + // An optional TypeScript prop is undefined when it's left out; no default to set. + 'vue/require-default-prop': 'off', + }, + }, + + { + name: 'app/vue-tests', + files: ['packages/*/tests/**', 'frameworks/*/tests/**', 'integration/**'], + rules: { + // Tests define the small components they mount next to the test that uses them. + 'vue/one-component-per-file': 'off', + }, + }, + + { + // The rules of hooks and the React Compiler's checks, for the React code. + ...pluginReactHooks.configs.flat.recommended, + name: 'app/react', + files: ['frameworks/react/**/*.{ts,tsx}', 'integration/tests/react*.tsx'], + rules: { + ...pluginReactHooks.configs.flat.recommended.rules, + 'react-hooks/exhaustive-deps': 'error', + }, + }, + + { + name: 'app/boundaries', + plugins: { boundaries: pluginBoundaries }, + settings: { + 'import/resolver': { + typescript: { project: '**/tsconfig*.json', noWarnOnMultipleProjects: true }, + }, + 'boundaries/elements': [ + { type: 'app', pattern: 'apps/*', capture: ['app'] }, + { type: 'framework', pattern: 'frameworks/*', capture: ['framework'] }, + { type: 'package-feature', pattern: 'packages/*/src/*', capture: ['pkg', 'feature'] }, + // Files directly in src/ (index.ts) that are not inside a feature folder. + { type: 'package-entry', pattern: 'packages/*/src', capture: ['pkg'] }, + { type: 'package-tests', pattern: 'packages/*/tests', capture: ['pkg'] }, + // Tests that run the packages in Formisch's own bindings, the way an app uses them. + { type: 'integration', pattern: 'integration' }, + // Sample JSON forms that tests and apps share. + { type: 'fixtures', pattern: 'fixtures' }, + ], + }, + rules: { + 'boundaries/dependencies': [ + 'error', + { + default: 'disallow', + checkAllOrigins: true, + policies: [ + { allow: { to: { module: { origin: ['external', 'core'] } } } }, + { + from: { element: { type: 'app' } }, + allow: { + to: [ + { + element: { type: 'app', captured: { app: '{{ from.element.captured.app }}' } }, + }, + { element: { types: ['framework', 'package-entry'] } }, + ], + }, + }, + { + from: { element: { type: 'framework' } }, + allow: { + to: [ + { + element: { + type: 'framework', + captured: { framework: '{{ from.element.captured.framework }}' }, + }, + }, + { element: { type: 'package-entry' } }, + ], + }, + }, + { + from: { element: { type: 'package-entry' } }, + allow: { + to: { + element: { + type: 'package-feature', + captured: { pkg: '{{ from.element.captured.pkg }}' }, + }, + }, + }, + }, + ...Object.entries(packageFeatures).flatMap(([pkg, features]) => + Object.entries(features).map(([feature, imports]) => ({ + from: { element: { type: 'package-feature', captured: { pkg, feature } } }, + allow: { + to: { + element: { + type: 'package-feature', + captured: { pkg, feature: [feature, ...imports] }, + }, + }, + }, + })), + ), + ...Object.entries(packageDependencies).map(([pkg, dependencies]) => ({ + from: { + element: { + types: ['package-entry', 'package-feature', 'package-tests'], + captured: { pkg }, + }, + }, + allow: { + to: { element: { type: 'package-entry', captured: { pkg: dependencies } } }, + }, + })), + { + from: { element: { type: 'package-tests' } }, + allow: { + to: { + element: { + types: ['package-entry', 'package-tests'], + captured: { pkg: '{{ from.element.captured.pkg }}' }, + }, + }, + }, + }, + { + from: { element: { type: 'integration' } }, + allow: { + to: { element: { types: ['integration', 'framework', 'package-entry'] } }, + }, + }, + { + from: { element: { types: ['app', 'framework', 'package-tests', 'integration'] } }, + allow: { to: { element: { type: 'fixtures' } } }, + }, + { + from: { element: { types: ['package-entry', 'package-feature'] } }, + disallow: { + to: [ + { module: { origin: 'core' } }, + { module: { origin: 'external', source: uiFrameworks } }, + ], + }, + }, + ], + }, + ], + }, + }, + + { + name: 'app/package-tests', + files: ['packages/*/tests/**', 'frameworks/*/tests/**', 'integration/**'], + rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['**/src', '**/src/**'], + message: 'Import the package by its name, the way its users do.', + }, + ], + }, + ], + }, + }, +) diff --git a/oxfmt.config.ts b/oxfmt.config.ts index 67174ef..58c41c1 100644 --- a/oxfmt.config.ts +++ b/oxfmt.config.ts @@ -3,5 +3,26 @@ import whatsaaaa from '@whatsaaaa/format-config/oxfmt' export default defineConfig({ ...whatsaaaa, - ignorePatterns: ['pnpm-lock.yaml', '.github/assets'], + ignorePatterns: [ + 'pnpm-lock.yaml', + '.github/assets', + // Copier writes it, and wraps the long description in a style oxfmt would change. + '.copier-answers.yml', + 'packages/schema/definition.schema.json', + 'apps/docs/api/schema/field-types.md', + 'apps/docs/api/schema/rules.md', + 'packages/affects/definition.schema.json', + 'apps/docs/public/schema/v1/definition.schema.json', + 'apps/docs/public/schema/v1/affects/definition.schema.json', + 'packages/fills/definition.schema.json', + 'apps/docs/public/schema/v1/fills/definition.schema.json', + ], + overrides: [ + { + files: ['apps/docs/**/*.md', 'apps/docs/snippets/**'], + options: { + printWidth: 76, + }, + }, + ], }) diff --git a/packages/form-builder/tsconfig.build.json b/packages/form-builder/tsconfig.build.json deleted file mode 100644 index b238b54..0000000 --- a/packages/form-builder/tsconfig.build.json +++ /dev/null @@ -1,12 +0,0 @@ -// The build: the package's source, compiled to dist/ with its type declarations -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": false, - "declaration": true, - "rewriteRelativeImportExtensions": true, - "rootDir": "src", - "outDir": "dist" - }, - "include": ["src"] -} diff --git a/packages/form-builder/tsconfig.json b/packages/form-builder/tsconfig.json deleted file mode 100644 index 40ba7b6..0000000 --- a/packages/form-builder/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@whatsaaaa/tsconfig/bundler.json", - "compilerOptions": { - "types": ["node"] - }, - "include": ["src", "src/**/*.vue", "tests", "*.config.ts"] -} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8330363..68dc980 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,6 +1,8 @@ packages: - packages/* - apps/* + - frameworks/* + - integration # pnpm installs no package younger than a day (minimumReleaseAge). Our own packages are let in # as soon as they are published, so a project can take a release of them right away. @@ -9,3 +11,46 @@ minimumReleaseAgeExclude: # A dependency's install script runs only when allowBuilds lists it: true to run it, false to # skip it, each with a comment that says why. +allowBuilds: + # The postinstalls of unrs-resolver and esbuild (used by size-limit), and of @parcel/watcher, + # lmdb and msgpackr-extract (used by @angular/build in the integration tests), only + # re-download, check or build the native binding, which pnpm already installs through their + # optional platform packages + '@parcel/watcher': false + esbuild: false + lmdb: false + msgpackr-extract: false + unrs-resolver: false + +# Versions shared by more than one workspace package. Reference them with `catalog:`. +catalog: + '@types/node': ^24.13.4 + '@whatsaaaa/tsconfig': ^1.0.0 + typescript: ~6.0.3 + valibot: ^1.5.0 + vue-tsc: ^3.3.11 + +# @qwik.dev/core wants Vitest below 5 for its own test helpers, which the integration tests don't +# use. They render with Qwik's render() in jsdom. +peerDependencyRules: + allowedVersions: + '@qwik.dev/core>vitest': '5' + # @angular/build's WebAssembly build of oxc-parser, which only loads where there's no native + # one, brings an @emnapi prerelease that @napi-rs/wasm-runtime's range leaves out. + '@napi-rs/wasm-runtime>@emnapi/core': '2.0.0-alpha.6' + '@napi-rs/wasm-runtime>@emnapi/runtime': '2.0.0-alpha.6' + # The docs install React only to type-check their React snippets. The site uses VitePress's + # local search, so DocSearch's React UI, which wants React below 19, never loads. + '@docsearch/react>react': '19' + '@docsearch/react>react-dom': '19' + '@docsearch/react>@types/react': '19' + +# @formisch/react's types import React's but it doesn't list @types/react, so they'd resolve to +# whichever version is hoisted. As a peer, each install sees its own, as the React 18 CI job needs. +packageExtensions: + '@formisch/react': + peerDependencies: + '@types/react': '*' + peerDependenciesMeta: + '@types/react': + optional: true diff --git a/tsconfig.json b/tsconfig.json index 4ccbe94..534a40a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,24 @@ -// The configs and the tests at the root. Each package has its own. +// TSConfig for workspace-level config files (e.g. eslint.config.ts). +// Each workspace package has its own tsconfig and is type-checked separately. { - "extends": "@whatsaaaa/tsconfig/node.json", - "include": ["tests", "*.config.ts"] + "extends": "@whatsaaaa/tsconfig/bundler.json", + "include": ["*.config.*"], + "compilerOptions": { + // What Node 24 runs, as @tsconfig/node24 set it before. + "target": "es2024", + "lib": [ + "es2024", + "esnext.array", + "esnext.collection", + "esnext.error", + "es2025.iterator", + "es2025.promise" + ], + "types": ["node"], + // The shared config turns these on; the config files have never been held to them. + "noUncheckedIndexedAccess": false, + "verbatimModuleSyntax": false, + "isolatedModules": false, + "erasableSyntaxOnly": false + } }