Skip to content

Migration from 3.1.0 to 3.2.1 yields *thousands* of svelte/no-unused-props errors #1136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
bfovez opened this issue Mar 17, 2025 · 1 comment · Fixed by #1135
Closed
2 tasks done

Migration from 3.1.0 to 3.2.1 yields *thousands* of svelte/no-unused-props errors #1136

bfovez opened this issue Mar 17, 2025 · 1 comment · Fixed by #1135

Comments

@bfovez
Copy link

bfovez commented Mar 17, 2025

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.22.0

What version of eslint-plugin-svelte are you using?

3.2.1

What did you do?

Configuration
import { sentrySvelteKit } from "@sentry/sveltekit"
import { enhancedImages } from "@sveltejs/enhanced-img"
import { sveltekit } from "@sveltejs/kit/vite"
import { svelteTesting } from "@testing-library/svelte/vite"
import { defineConfig, loadEnv } from "vite"
import { purgeCss } from "vite-plugin-tailwind-purgecss"

const TRUTHY: string[] = ["true", "yes", "y", "1"] as const

export default defineConfig(({ mode }) => {
	const envDir = process.cwd()
	const privateEnv = loadEnv(mode, envDir, "SENTRY")
	const publicEnv = loadEnv(mode, envDir, "PUBLIC_SENTRY")

	const activate = TRUTHY.includes((publicEnv.PUBLIC_SENTRY_ACTIVATE ?? "").trim().toLowerCase())
	const org = privateEnv.SENTRY_ORG
	const project = privateEnv.SENTRY_PROJECT
	const authToken = privateEnv.SENTRY_AUTH_TOKEN

	if (activate) {
		if (!org) console.error(`Vite config: missing environment variable SENTRY_ORG`)
		if (!project) console.error("Vite config: environment variable SENTRY_PROJECT")
		if (!authToken) console.error("Vite config: environment variable SENTRY_AUTH_TOKEN")
	}

	return {
		plugins: [
			sentrySvelteKit({ sourceMapsUploadOptions: { org, project, authToken } }),
			enhancedImages(),
			sveltekit(),
			purgeCss()
		],

		// For Sentry
		build: { sourcemap: "hidden" },

		test: {
			workspace: [
				{
					extends: "./vite.config.ts",
					plugins: [svelteTesting()],

					test: {
						name: "client",
						environment: "jsdom",
						clearMocks: true,
						include: ["src/**/*.svelte.{test,spec}.{js,ts}"],
						exclude: ["src/lib/server/**"],
						setupFiles: ["./vitest-setup-client.ts"]
					}
				},
				{
					extends: "./vite.config.ts",

					test: {
						name: "server",
						environment: "node",
						include: ["src/**/*.{test,spec}.{js,ts}"],
						exclude: ["src/**/*.svelte.{test,spec}.{js,ts}"]
					}
				}
			]
		}
	}
})
<!-- Paste your code here -->

What did you expect to happen?

0 warnings/errors, as version 3.1.0 did show on my code base.

What actually happened?

4893 svelte/no-unused-props errors.

For instance, this file:

<script lang="ts">
	import type { SVGAttributes } from "svelte/elements"
	import { SvgIcon, type IconProps } from "."

	let props:  {
	name?: string
	color?: string
	size?: number | string
	strokeWidth?: number | string
	absoluteStrokeWidth?: boolean
	class?: string
} & SVGAttributes<SVGSVGElement>= $props()
</script>

<SvgIcon viewBox="0 0 512 512" {...props}>
	<path
		d="M358.1 378.8L319.6 260L420.5 186.9H295.7l-38.6-118.7l-.01-.03h124.8l38.6 118.7v-.003l0.03-.02c22.4 68.8-.7 147 -62.4 192zm-201.9 0l-.036 .03L257.13 452.2L358.09 378.84L257.17 305.51ZM93.85 186.85c-23.57 72.57 3.79 149.46 62.36 192l0.01-.036L194.77 260.17L93.89 186.87H218.6L257.15 68.2L257.2 68.2H132.4Z"
		fill="currentColor"
	/>
</SvgIcon>

yields to:

C:\Users\xxx\src\lib\components\shared\icon\auth0.svelte
  4:6  error  'name' is an unused Props property                                       svelte/no-unused-props
  4:6  error  'color' is an unused Props property                                      svelte/no-unused-props
  4:6  error  'size' is an unused Props property                                       svelte/no-unused-props
  4:6  error  'strokeWidth' is an unused Props property                                svelte/no-unused-props
  4:6  error  'absoluteStrokeWidth' is an unused Props property                        svelte/no-unused-props
  4:6  error  'class' is an unused Props property                                      svelte/no-unused-props
  4:6  error  'className' is an unused Props property                                  svelte/no-unused-props
  4:6  error  'height' is an unused Props property                                     svelte/no-unused-props
  4:6  error  'id' is an unused Props property                                         svelte/no-unused-props
  4:6  error  'lang' is an unused Props property                                       svelte/no-unused-props
  
 and hundreds more.

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/bfovez/example

Additional comments

No response

@bfovez bfovez changed the title Migration from 3.1.0 to 3.2.1 yeolds *thousands* of Migration from 3.1.0 to 3.2.1 yeolds *thousands* of unused Props property errors Mar 17, 2025
@bfovez bfovez changed the title Migration from 3.1.0 to 3.2.1 yeolds *thousands* of unused Props property errors Migration from 3.1.0 to 3.2.1 yields *thousands* of unused Props property errors Mar 17, 2025
@bfovez bfovez changed the title Migration from 3.1.0 to 3.2.1 yields *thousands* of unused Props property errors Migration from 3.1.0 to 3.2.1 yields *thousands* of unused property errors Mar 17, 2025
@bfovez bfovez changed the title Migration from 3.1.0 to 3.2.1 yields *thousands* of unused property errors Migration from 3.1.0 to 3.2.1 yields *thousands* of svelte/no-unused-props errors Mar 17, 2025
@baseballyama
Copy link
Member

This bug is fixed in v3.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants