Skip to content

svelte/no-unused-props does not always respect aliases #1172

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
gyzerok opened this issue Mar 31, 2025 · 1 comment · Fixed by #1178
Closed
2 tasks done

svelte/no-unused-props does not always respect aliases #1172

gyzerok opened this issue Mar 31, 2025 · 1 comment · Fixed by #1178

Comments

@gyzerok
Copy link

gyzerok commented Mar 31, 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.23.0

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

3.4.0

What did you do?

When using aliases for props I get false positive from svelte/no-unused-props. See repro.

Configuration
export default ts.config(
	includeIgnoreFile(gitignorePath),
	js.configs.recommended,
	...ts.configs.recommended,
	...svelte.configs.recommended,
	prettier,
	...svelte.configs.prettier,
	{
		languageOptions: {
			globals: { ...globals.browser, ...globals.node }
		},
		rules: { 'no-undef': 'off' }
	},
	{
		files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
		ignores: ['eslint.config.js', 'svelte.config.js'],
		languageOptions: {
			parserOptions: {
				projectService: true,
				extraFileExtensions: ['.svelte'],
				parser: ts.parser,
				svelteConfig
			}
		}
	}
);

<script lang="ts">
	type Props = {
		test: string;
		'aria-label'?: string;
	};

	const { test, 'aria-label': ariaLabel }: Props = $props();
</script>

<h1>{test}</h1>
<div aria-label={ariaLabel}>svelte/no-unused-props does not always respect aliases</div>

What did you expect to happen?

0 lint errors

What actually happened?

❯ npm run lint

> [email protected] lint
> prettier --check . && eslint .

Checking formatting...
All matched files use Prettier code style!

svelte-eslint-bug/src/routes/Bug1.svelte
  7:8  error  'aria-label' is an unused Props property  svelte/no-unused-props

✖ 1 problem (1 error, 0 warnings)

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/gyzerok/svelte-eslint-bug

Additional comments

No response

@baseballyama
Copy link
Member

This issue is fixed in v3.5.0

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 a pull request may close this issue.

2 participants