diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autoformat.yml new file mode 100644 index 0000000000..9610aab77d --- /dev/null +++ b/.github/workflows/autoformat.yml @@ -0,0 +1,136 @@ +name: Autoformat & Linting + +# Note: For pull requests, GitHub Actions automatically creates a merge commit +# between your branch and the target branch (usually main), then runs checks on +# that merged state. This ensures the code will be properly formatted after merge. +# If this check fails, you may need to merge main into your branch first. + +on: + push: + branches: ['main'] + paths-ignore: + - 'website/**' + - '**/README.md' + pull_request: + paths-ignore: + - 'website/**' + - '**/README.md' + +permissions: + contents: read + +jobs: + typescript_formatting: + name: TypeScript formatting and linting + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.tool-versions' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check Prettier formatting + run: pnpm run format:check + continue-on-error: true + id: prettier_check + + - name: Show formatting help message + if: steps.prettier_check.outcome == 'failure' + run: | + echo "::error::Prettier formatting check failed" + echo "" + echo "Note: For pull requests, this check runs on a merge commit between" + echo "your branch and main. If this fails but your branch is formatted correctly," + echo "you may need to merge or rebase main into your branch first." + echo "" + echo "To fix formatting issues, run: pnpm run format" + exit 1 + + - name: Check ESLint (all packages) + run: pnpm run stylecheck-all + continue-on-error: true + id: eslint_check + + - name: Show ESLint help message + if: steps.eslint_check.outcome == 'failure' + run: | + echo "::error::ESLint check failed" + echo "" + echo "Note: For pull requests, this check runs on a merge commit between" + echo "your branch and main. If this fails but your branch passes linting," + echo "you may need to merge or rebase main into your branch first." + exit 1 + + elixir_formatting: + name: Elixir formatting and linting + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/sync-service + env: + MIX_ENV: test + MIX_OS_DEPS_COMPILE_PARTITION_COUNT: 4 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Elixir + uses: erlef/setup-beam@v1 + with: + version-type: strict + version-file: '.tool-versions' + + - name: Restore dependencies cache + uses: actions/cache/restore@v4 + with: + path: packages/sync-service/deps + key: "${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}" + restore-keys: | + ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }} + ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}- + ${{ runner.os }}-sync-service-deps- + + - name: Install dependencies + run: mix deps.get + + - name: Check Elixir formatting + run: mix format --check-formatted + continue-on-error: true + id: elixir_format_check + + - name: Show Elixir formatting help message + if: steps.elixir_format_check.outcome == 'failure' + run: | + echo "::error::Elixir formatting check failed" + echo "" + echo "Note: For pull requests, this check runs on a merge commit between" + echo "your branch and main. If this fails but your branch is formatted correctly," + echo "you may need to merge or rebase main into your branch first." + echo "" + echo "To fix formatting issues, run: mix format" + exit 1 + + - name: Check Elixir compiles without warnings + run: mix compile --force --all-warnings --warnings-as-errors + continue-on-error: true + id: elixir_compile_check + + - name: Show Elixir compilation help message + if: steps.elixir_compile_check.outcome == 'failure' + run: | + echo "::error::Elixir compilation warnings check failed" + echo "" + echo "Note: For pull requests, this check runs on a merge commit between" + echo "your branch and main. If this fails but your branch compiles cleanly," + echo "you may need to merge or rebase main into your branch first." + exit 1 diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 655675d861..6e9386ad4d 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -136,38 +136,3 @@ jobs: # Upload all PR test results to single branch - requires overriding branch and commit override_branch: ${{ github.event_name == 'pull_request' && 'codecov/pr-test-aggregation' || '' }} override_commit: ${{ github.event_name == 'pull_request' && env.DUMMY_COMMIT_SHA || '' }} - - formatting: - name: Check formatting for sync-service - runs-on: ubuntu-latest - defaults: - run: - working-directory: packages/sync-service - env: - MIX_ENV: test - MIX_OS_DEPS_COMPILE_PARTITION_COUNT: 4 - steps: - - uses: actions/checkout@v4 - - - uses: erlef/setup-beam@v1 - with: - version-type: strict - version-file: '.tool-versions' - - - name: Restore dependencies cache - uses: actions/cache/restore@v4 - with: - path: packages/sync-service/deps - key: "${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}" - restore-keys: | - ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }} - ${{ runner.os }}-sync-service-deps-${{ env.MIX_ENV }}- - ${{ runner.os }}-sync-service-deps- - - - run: mix deps.get - - - name: Check formatting - run: mix format --check-formatted - - - name: Compiles without warnings - run: mix compile --force --all-warnings --warnings-as-errors diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 7910b7ec3d..a589fe5058 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -60,7 +60,7 @@ jobs: working-directory: packages/sync-service - name: Compile - run: mix compile --force --all-warnings --warnings-as-errors + run: mix compile working-directory: packages/sync-service - name: Setup lux diff --git a/.github/workflows/ts_test.yml b/.github/workflows/ts_test.yml index 80e23b4aee..ca4f798b3c 100644 --- a/.github/workflows/ts_test.yml +++ b/.github/workflows/ts_test.yml @@ -54,10 +54,7 @@ jobs: cache: 'pnpm' - run: pnpm install --frozen-lockfile - run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build - - run: pnpm run stylecheck - run: pnpm run typecheck - - run: pnpm run format:check - working-directory: . build_and_test_packages: name: Test TS packages against sync-service @@ -182,4 +179,3 @@ jobs: - run: pnpm --if-present run typecheck - run: pnpm --if-present run build - run: pnpm --if-present run test - - run: pnpm --if-present run stylecheck diff --git a/.prettierignore b/.prettierignore index c7a9833913..27edb74650 100644 --- a/.prettierignore +++ b/.prettierignore @@ -19,6 +19,9 @@ website/**/*.md # Ignore CSS file with unstable Prettier formatting website/.vitepress/theme/custom.css +# Ignore website partials (documentation code snippets) +website/src/partials/** + # Ignore Elixir projects packages/sync-service packages/elixir-client diff --git a/eslint.config.mjs b/eslint.config.mjs index 247ff29b5e..60e88d5e0c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -16,6 +16,7 @@ export default [ `**/.vitepress/dist/**`, `**/sst-env.d.ts`, `**/sst.config.ts`, + `website/src/partials/**`, ], }, { diff --git a/examples/tanstack-db-expo-starter/api/index.ts b/examples/tanstack-db-expo-starter/api/index.ts index b78d332454..2d1ec441ea 100644 --- a/examples/tanstack-db-expo-starter/api/index.ts +++ b/examples/tanstack-db-expo-starter/api/index.ts @@ -138,7 +138,7 @@ app.get(`/api/todos`, async (req, res) => { const response = await fetch(electricUrl) if (!response.ok) { - const errorText = await response.text() + const _errorText = await response.text() res.writeHead(response.status, { 'Content-Type': `application/json` }) res.end(JSON.stringify({ error: `Electric error: ${response.status}` })) return diff --git a/examples/tanstack-db-web-starter/src/lib/electric-proxy.ts b/examples/tanstack-db-web-starter/src/lib/electric-proxy.ts index a80af10e8b..320b32270b 100644 --- a/examples/tanstack-db-web-starter/src/lib/electric-proxy.ts +++ b/examples/tanstack-db-web-starter/src/lib/electric-proxy.ts @@ -24,10 +24,7 @@ export function prepareElectricUrl(requestUrl: string): URL { // Add Electric Cloud authentication if configured if (process.env.ELECTRIC_SOURCE_ID && process.env.ELECTRIC_SOURCE_SECRET) { originUrl.searchParams.set(`source_id`, process.env.ELECTRIC_SOURCE_ID) - originUrl.searchParams.set( - `secret`, - process.env.ELECTRIC_SOURCE_SECRET - ) + originUrl.searchParams.set(`secret`, process.env.ELECTRIC_SOURCE_SECRET) } return originUrl diff --git a/examples/tanstack-db-web-starter/src/start.tsx b/examples/tanstack-db-web-starter/src/start.tsx index 7726a0627e..6cdde1d7c8 100644 --- a/examples/tanstack-db-web-starter/src/start.tsx +++ b/examples/tanstack-db-web-starter/src/start.tsx @@ -1,5 +1,4 @@ // src/start.tsx -import * as React from "react" import { createStart } from "@tanstack/react-start" export const startInstance = createStart(() => {