Skip to content

bug: no-unused-props's option checkImportedTypes doesn't work #1133

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
baseballyama opened this issue Mar 17, 2025 · 6 comments · Fixed by #1135
Closed

bug: no-unused-props's option checkImportedTypes doesn't work #1133

baseballyama opened this issue Mar 17, 2025 · 6 comments · Fixed by #1135

Comments

@baseballyama
Copy link
Member

Copied from #1028 (comment)

Then the checkImportedTypes option does not seem to work correctly. In the example below the svelte-component imports the TaskViewModel-type, but it still reports errors due to some of its attributes not being used

Image

@shumadrid
Copy link

shumadrid commented Mar 17, 2025

My issue is still here on v3.2.1. This is how i define the string, this might be irrelevant because i get the errors for all primitive types passed as props:

interface Properties {
    currentDayCommitHash: string;
    // ...
  }

  const {
    currentDayCommitHash,
    // ...
  }: Properties = $props();

My eslint.config.mjs:

export default typescriptEslint.config(
  eslint.configs.recommended,
  ...typescriptEslint.configs.recommendedTypeChecked,
  ...svelte.configs['flat/recommended'],
  ...svelte.configs['flat/prettier'],
  eslintPluginUnicorn.configs.recommended,
  devUtilsConfigs,
  eslintConfigPrettier,
  {
    files: ['**/*.{js,ts}'],
    languageOptions: {
      parser: typescriptEslint.parser,
      parserOptions: {
        projectService: true
      }
    }
  },
  {
    files: ['**/*.svelte'],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        parser: typescriptEslint.parser,
        extraFileExtensions: ['.svelte'],
        projectService: true
      }
    },
    rules: {
      'svelte/require-each-key': 'off'
      // 'svelte/no-unused-props': 'off'
    }
  }
// ...
}

@baseballyama
Copy link
Member Author

baseballyama commented Mar 17, 2025

@shumadrid @AndersRobstad Could you please install the following package and confirm if it resolves your issue? I’d like to verify that the fix is correct before releasing it.

npm i https://pkg.pr.new/eslint-plugin-svelte@1135

@shumadrid
Copy link

Yes, it's fixed for me.

@MarcusCaspeco
Copy link

MarcusCaspeco commented Mar 17, 2025

That one works for me as well, this is the case I have, it was previously complaining that properties inside this item was not used:

<script lang="ts">
	import Component from "./component.svelte"
	import type { Item } from "../types/item"

	interface Props {
		item: Item;
		// ...
	}
	
	let { item /* ... */ }: Props = $props();
</script>

<Component {item} />

@baseballyama
Copy link
Member Author

Nice! Thanks for reviewing! @shumadrid @MarcusCaspeco
I’ll do a self-review and release it.

@baseballyama
Copy link
Member Author

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
3 participants