SvelteKit + Husky + lint-staged
Git pre-commit hook that lints and formats staged files. This page shows exactly what pickstack adds to a SvelteKit project for Husky + lint-staged: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.
$ npm create pickstack@latest my-app -- --framework sveltekit --modules eslint,husky-lint-staged --yesCustomize in the configurator
Packages it adds
| Package | Version | Type |
|---|---|---|
@eslint/js | ^10.0.1 | dev |
eslint | ^10.15.0 | dev |
eslint-plugin-svelte | ^3.24.1 | dev |
globals | ^17.14.0 | dev |
husky | ^9.1.7 | dev |
lint-staged | ^17.6.2 | dev |
typescript-eslint | ^8.74.0 | dev |
New files
lint-staged
import path from "node:path";
import js from "@eslint/js";
import { defineConfig, includeIgnoreFile } from "eslint/config";
import svelte from "eslint-plugin-svelte";
import globals from "globals";
import ts from "typescript-eslint";
const gitignorePath = path.resolve(import.meta.dirname, ".gitignore");
export default defineConfig(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
ts.configs.recommended,
svelte.configs.recommended,
{
languageOptions: {
parserOptions: { extraFileExtensions: [".svelte"] },
globals: { ...globals.browser, ...globals.node },
},
rules: {
// typescript-eslint recommends turning no-undef off in TypeScript projects:
// https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
"no-undef": "off",
},
},
{
files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"],
languageOptions: {
parserOptions: { projectService: true, parser: ts.parser },
},
},
);
Changes to existing files
<section class="page"> <h1 class="title">About</h1>+ <p class="text">+ Built with SvelteKit, Svelte 5, TypeScript, ESLint, Husky, lint-staged.+ </p>− <p class="text">Built with SvelteKit, Svelte 5, TypeScript.</p> </section>
Project files
.gitignore.husky/pre-commitREADME.mdeslint.config.jspackage.jsonsrc/app.d.tssrc/app.htmlsrc/lib/Counter.sveltesrc/lib/index.tssrc/routes/+layout.sveltesrc/routes/+layout.tssrc/routes/+page.sveltesrc/routes/about/+page.sveltesrc/routes/layout.cssstatic/robots.txttsconfig.jsonvite.config.ts