@rsvelte/svelte-check
v0.5.28
Published
Rust-powered svelte-check CLI — type-checks and diagnoses Svelte projects
Maintainers
Readme
@rsvelte/svelte-check
A Rust-powered drop-in replacement for svelte-check. Type-checks .svelte, .svelte.ts / .svelte.js, and the surrounding .ts / .js files in a Svelte project, and reports compiler warnings, A11y warnings, CSS warnings, and TypeScript diagnostics from a single CLI.
⚠️ Early stage. Output and flags are stabilising. Not yet recommended for production CI gates without a fallback to the official
svelte-check.
Install
npm install -D @rsvelte/svelte-check
# pnpm add -D @rsvelte/svelte-check
# yarn add -D @rsvelte/svelte-checkThe package ships a small loader that resolves the right prebuilt native binary for your platform via optionalDependencies. Supported targets:
| OS | Architecture | |---|---| | macOS | arm64, x64 | | Linux | x64 (glibc ≥ 2.35), arm64 (glibc ≥ 2.35) | | Windows | x64 (MSVC) |
If your platform isn't listed, please open an issue.
Usage
From your project root:
# Svelte + TypeScript diagnostics (uses the workspace's own tsc)
npx rsvelte-check
# Type-check with the TypeScript 7 native compiler instead.
# Requires TypeScript 7 in the workspace:
# npm install --save-dev typescript@~6 @typescript/native@npm:typescript@7
npx rsvelte-check --tsgo
# Compiler + A11y + CSS diagnostics only (fast — no TypeScript)
npx rsvelte-check --no-type-check
# Watch mode with incremental cache
npx rsvelte-check --watch --incrementalAdd it to your package.json:
{
"scripts": {
"check": "rsvelte-check --tsgo",
"check:watch": "rsvelte-check --tsgo --watch --incremental"
}
}CLI flags
| Flag | Description |
|---|---|
| --workspace <dir> | Project root to scan. Defaults to the current directory. |
| --output <format> | human, human-verbose (default), machine, machine-verbose, or github-actions. |
| --ignore <list> | Comma-separated path components to skip while walking the workspace. |
| --fail-on-warnings | Exit non-zero when any warning is reported (default: errors only). |
| --tsgo | Type-check with the TypeScript 7 native compiler (@typescript/native, else @typescript/native-preview) instead of the workspace's own tsc. Errors when TypeScript 7 is not installed. |
| --no-type-check | Skip TypeScript entirely — Svelte compiler / A11y / CSS diagnostics only. |
| --tsconfig <path> | Base tsconfig.json for the overlay to extends. |
| --no-tsconfig | Ignore any project tsconfig/jsconfig (no --tsconfig extends, no discovery) — check only the Svelte files. |
| --config <path> | Use a non-standard svelte.config.* / vite.config.* path for the diagnostic-relevant compilerOptions (and kit.files) instead of discovering one under the workspace. |
| --emit-overlay | Materialise .tsx shadow files + an overlay tsconfig under <workspace>/.svelte-check/ without running a type-checker. Useful for inspecting what gets handed to TS. |
| --compiler-warnings <list> | Per-code overrides, e.g. --compiler-warnings css-unused-selector:ignore,a11y-no-noninteractive-element-to-interactive-role:error. |
| --diagnostic-sources <list> | Restrict output to any subset of svelte, ts / js, css. |
| --threshold <level> | Filter the diagnostics that are printed: error shows only errors, warning (default) shows warnings and errors. Counts and exit code are unaffected. |
| --incremental | Reuse <workspace>/.svelte-check/manifest.json between runs — unchanged files skip the overlay regeneration step. |
| --watch | Stay alive and re-check on file changes. Composes with --incremental. |
| --preserveWatchOutput | In watch mode, don't clear the terminal between runs. (--preserve-watch-output is accepted as an alias.) |
Upstream flag compatibility
rsvelte-check accepts every flag the official svelte-check CLI exposes. Names match upstream, with two exceptions noted below.
| Upstream flag | rsvelte-check | Notes |
|---|---|---|
| --workspace | ✅ | |
| --output | ✅ | Plus the rsvelte-only github-actions format. |
| --watch | ✅ | |
| --preserveWatchOutput | ✅ | Canonical name; --preserve-watch-output kept as an alias. |
| --incremental | ✅ | |
| --tsgo | ✅ | |
| --tsgo-experimental-api | ✅ (alias) | rsvelte has a single native tsgo backend, so this behaves exactly like --tsgo. |
| --tsconfig | ✅ | |
| --config | ✅ | Overrides the config source for the diagnostic-relevant compilerOptions / kit.files. |
| --no-tsconfig | ✅ | |
| --ignore | ✅ | Always active as a walker skip-list (rsvelte does not gate it behind --no-tsconfig). |
| --fail-on-warnings | ✅ | |
| --compiler-warnings | ✅ | |
| --diagnostic-sources | ✅ | |
| --threshold | ✅ | |
| --color / --no-color | ✅ (no-op) | Accepted for compatibility; rsvelte-check output is not colorized. |
Run rsvelte-check --help for the authoritative list.
How it works
rsvelte-check walks your project, parses every .svelte file with the rsvelte compiler, and reports compiler / A11y / CSS warnings directly. For TypeScript diagnostics, it generates .tsx shadow files (via @rsvelte/svelte2tsx) plus an overlay tsconfig.json under .svelte-check/, then hands the overlay to tsc (or tsgo with --tsgo). Diagnostics are remapped back onto the original .svelte source via high-resolution source maps so error positions point at the line and column you actually wrote.
Highlights:
- SvelteKit-aware. Honours
svelte.config.js'skit.filesoverrides; injects SvelteKit-generated kit-file augmentations for both.ts(real TS annotations) and.js(JSDoc) files. warningFiltersupport. A functioncompilerOptions.warningFilterinsvelte.config.jsis honoured. The native compiler can't run the JS predicate itself, so the run's compiler warnings are collected and passed once to a small Node sidecar (bundled with this package) that imports your config and applies the function — equivalent to Svelte's emit-time filter since it's a pure per-warning predicate. If Node is unavailable or the config can't be imported, every warning is shown and a one-time note is printed (the filter never silently drops a warning). Projects without a functionwarningFilterpay nothing — the sidecar is never spawned.- Incremental. A per-file overlay manifest and a per-file warning cache (
<cacheDir>/warnings.json) make warm runs near-instant. - Parallel compile. Files are compiled across rayon workers; the TS pass is the long pole.
- Watch mode. Composes with
--incrementalfor an editor-like inner loop.
Compatibility status
- Compiler / A11y / CSS warnings — full coverage; matches the official
svelte-check's set. - TypeScript diagnostics via tsgo — covered for the standard project shapes (plain Svelte 5, SvelteKit). Edge cases around custom preprocessors are still being shaken out.
- LSP integration (editor hover / completion) — out of scope for this package. Wait on the upstream
tsgotsservermode before assuming editor support.
If you hit a diagnostic the official svelte-check produces and this one doesn't (or vice-versa), please open an issue with a minimal repro.
Known limitations
- Same-name
Foo.svelte.ts/Foo.svelte.jscompanion next toFoo.svelte(#800). When a module file shares a component's base name,import … from './Foo.svelte'resolves to the companion instead of the component, so the component's default export and<script module>named exports are reported missing (has no default export,Circular definition of import alias,declares 'X' locally, but it is not exported). This is standard TypeScript relative-module resolution —tscandtsgobehave identically — and the officialsvelte-checkonly avoids it via a TypeScript language-server plugin (resolveModuleNameLiterals) that the nativetsgobinary does not support. Workaround: don't put a same-name companion next to a component — give shared module-context code a distinct name (e.g.foo-helpers.ts), or import the component's<script module>exports directly from./Foo.svelte. Thersvelte_lintlinter ships an opt-insvelte/no-companion-module-shadowrule (off by default) that flags this pattern so you catch it before it surprises you.
Performance
rsvelte-check is part of the rsvelte project. On a 500-file workspace the Svelte-side check runs ~71× faster multi-threaded than the official svelte-check (live benchmark). The TypeScript pass via tsc / tsgo dominates wall-clock time on most projects; the Svelte side rarely registers.
License
MIT
