Skip to content

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

Closed
@gyzerok

Description

@gyzerok

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

> svelte-eslint-bug@0.0.1 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions