Skip to content

fix: format all created project files so fresh projects pass lint#1170

Closed
mvanhorn wants to merge 2 commits into
sveltejs:version-1from
mvanhorn:fix/1134-format-created-project-files
Closed

fix: format all created project files so fresh projects pass lint#1170
mvanhorn wants to merge 2 commits into
sveltejs:version-1from
mvanhorn:fix/1134-format-created-project-files

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Closes #1134

Description

sv create now formats all files of the generated project, not just the add-on-modified ones, so npm run lint passes immediately on a fresh project. Previously a SvelteKit demo + TypeScript + prettier/eslint project failed lint out of the box because src/routes/sverdle/+page.svelte was left unformatted.

The root cause (per the maintainer on the issue): the ts / js-doc / js template variants are generated from one shared source by stripping types and JSDoc, which leaves formatting artifacts, and this is "not properly solvable" at the template-source level. The agreed fix is to format all created project files after creation rather than only the add-on-modified files. Dropping prettier --check from the lint script was rejected because CI users rely on lint.

After project creation, the formatter now runs over the full generated project (when prettier is part of the selected add-ons) instead of only the files the add-ons touched, so stripping-induced formatting artifacts are cleaned up before the user's first lint. Generated the reported combination (SvelteKit demo template + TypeScript + prettier + eslint) and confirmed npm run lint passes; a project without prettier is unaffected.

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (included)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 11, 2026

Copy link
Copy Markdown

Install the latest version of sv from 1de3368:

pnpm add https://pkg.svelte.dev/sv/c/1de33685a2aaef3a235e11bdd155c95cae761bd4

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/cli/pr/1170

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1de3368

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
sv Major
@sveltejs/sv-utils Major
svelte-migrate Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sacrosanctic

Copy link
Copy Markdown
Contributor

should wait for #1138, it also has formatting logic.

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Makes sense, happy to wait for #1138. Once it lands I'll rebase this on top and adapt it to use its formatting logic so there's a single code path.

@sacrosanctic

Copy link
Copy Markdown
Contributor

It's merged!

@jycouet

jycouet commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

We should bring this to main... And then to version-1 (where we will fix a few issues maybe)

@jycouet
jycouet changed the base branch from main to version-1 July 24, 2026 07:34
@jycouet jycouet closed this Jul 24, 2026
@jycouet jycouet reopened this Jul 24, 2026
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Brought it to main: #1192.

It's a port rather than a cherry-pick — packages/sv/src/cli/create.ts has diverged between the branches and main also has packages/sv/src/core/formatFiles.ts, so the change is reworked against main's shape. Verified there: vitest run packages/sv/src/create/tests/check.ts → 29 passed, including a new test that scaffolds a demo project with prettier + eslint, plants a static/ignored.json, and asserts formatting leaves it alone.

Happy to leave this one open for the version-1 follow-up once #1192 lands, or close it in favour of #1192 — whichever you prefer.

@jycouet jycouet closed this Jul 25, 2026
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.

Linting fails on a freshly created SvelteKit Demo project

3 participants