chore: re-enable svelte-check in pre-commit for commit files only by ljodea · Pull Request #569 · svelteplot/svelteplot · GitHub
Skip to content

chore: re-enable svelte-check in pre-commit for commit files only - #569

Open
ljodea wants to merge 5 commits into
mainfrom
chore/svelte-check-staged-precommit
Open

chore: re-enable svelte-check in pre-commit for commit files only#569
ljodea wants to merge 5 commits into
mainfrom
chore/svelte-check-staged-precommit

Conversation

@ljodea

@ljodea ljodea commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Re-enables svelte-check in pre-commit without blocking commits due to legacy errors in untouched files.

  • Adds scripts/svelte-check-staged.mjs: runs full svelte-check, parses machine-verbose output (timestamp-prefixed JSON records), and only fails when errors appear in commit files
  • Untracks generated .svelte-kit/tsconfig.json (already gitignored) so svelte-kit sync does not dirty the index
  • Runs svelte-kit sync before type-aware oxlint in pre-commit and lint:oxlint so fresh checkouts work without the tracked tsconfig
  • CI still runs full pnpm check on every PR

Behavior

Scenario Result
Commit clean .ts file, legacy errors elsewhere Passes (note printed)
Commit file with svelte-check error Blocked
pre-commit run --all-files Checks all matched files, not just staged
Deleted-only staged paths Skips (exit 0)

Testing

  • pnpm test:scripts — 11 tests (parser, filtering, path normalization)
  • Manual: clean stack.ts passes; VoronoiMesh.svelte fails as expected
  • pre-commit run svelte-check-staged --files packages/svelteplot/src/transforms/stack.ts passes

ljodea added 2 commits June 22, 2026 14:36
Add scripts/svelte-check-staged.mjs to run full svelte-check but only
block commits when errors appear in staged paths. Parse machine-verbose
output with timestamp-prefixed JSON records, fail on tool errors, and
skip when all targets are deleted.

Untrack generated .svelte-kit/tsconfig.json so svelte-kit sync in the
hook does not dirty the index. CI still runs full pnpm check.
Address Codex review: fresh checkouts need generated tsconfig before
type-aware oxlint (pre-commit and lint:oxlint). Normalize diagnostic
filenames to posix slashes when matching staged targets.
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit 0b30411
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/6a399b445f658c0008f713bd
😎 Deploy Preview https://deploy-preview-569--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db9475cfa4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/svelte-check-staged.mjs Outdated

/** @param {string} filePath */
export function toPosixPath(filePath) {
return filePath.split(path.sep).join('/');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize backslashes in diagnostic filenames

When pnpm test:scripts is run on Linux/macOS, path.sep is /, so toPosixPath('packages\\svelteplot\\...') leaves the backslashes intact. The new Windows-path unit test consequently fails because filterDiagnostics returns no match, and the same normalization gap would cause any backslash-separated diagnostic filename to be ignored rather than blocking the commit. Normalize \\ explicitly instead of relying on the host separator.

Useful? React with 👍 / 👎.

@ljodea
ljodea requested a review from gka June 22, 2026 19:52
@ljodea
ljodea force-pushed the chore/svelte-check-staged-precommit branch from db9475c to 5c6892e Compare June 22, 2026 19:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c6892e0a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/svelte-check-staged.mjs Outdated
'exec',
'svelte-check',
'--tsconfig',
'./tsconfig.json',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use package tsconfig for package targets

When the hook is invoked for a package-only staged file such as packages/svelteplot/tests/areaY.test.ts (matched by .pre-commit-config.yaml:14), this always runs svelte-check against the root SvelteKit tsconfig. The --tsconfig docs say only files matched by that config's files/include/exclude are diagnosed, while packages/svelteplot/tsconfig.json:15 is the config that includes the package src and tests; package test files that are not imported by the docs app can therefore have svelte-check errors without ever appearing in parsed.errors, so the commit passes. Please dispatch package paths to the package tsconfig or narrow the hook's matched files.

Useful? React with 👍 / 👎.

Root SvelteKit tsconfig does not include packages/svelteplot/tests,
so svelte-check errors in package test files were invisible to the
staged hook. Partition targets and run the matching tsconfig per group.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70f23fe2f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


if (packageTargets.length > 0) {
plans.push({
tsconfig: PACKAGE_TSCONFIG,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve aliases when checking package tests

When a staged file is under packages/svelteplot/tests, this routes it to packages/svelteplot/tsconfig.json, but that config does not define the Vite aliases used by the tests. The tests import svelteplot/svelteplot/*, while packages/svelteplot/package.json points those package exports at dist, and no packages/svelteplot/dist is tracked, so a fresh checkout can fail svelte-check with module-resolution errors in the staged test before any real test change is checked. Please add equivalent paths for the package config or avoid applying this package plan to tests that rely on the package-name aliases.

Useful? React with 👍 / 👎.

Package tests import svelteplot via Vite aliases pointing at src, but
svelte-check used package exports to dist (missing in fresh checkouts).
Mirror the vite resolve aliases in compilerOptions.paths.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25c344cae1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .pre-commit-config.yaml Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict hook to files the checker can diagnose

This pattern now invokes the staged checker for any .js, .ts, .mts, or .cts file, but root targets are always checked with svelte-check --tsconfig ./tsconfig.json; the Svelte docs for --tsconfig say only files matched by that config's files/include/exclude are diagnosed, and the generated SvelteKit config inherited here covers the app/test/vite paths rather than root scripts such as screenshot-examples.js. If one of those matching-but-excluded files is staged, the hook runs but no diagnostic can ever match the staged file, so pre-commit run --all-files and normal commits give false confidence; narrow the regex or add a separate plan/tsconfig for those paths.

Useful? React with 👍 / 👎.

Root scripts like scripts/*.js are not in the SvelteKit tsconfig
include globs, so the staged hook could run without ever matching
diagnostics. Filter targets to diagnosable paths and narrow the
pre-commit files regex to the same scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant