Skip to content

@typescript-eslint/no-unused-vars: Do not report reserved interfaces #348

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
marekdedic opened this issue Jan 22, 2023 · 6 comments
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@marekdedic
Copy link
Contributor

Description

Hi, as per this RFC, the interface names $$Props, $$Events, $$Slots are reserved and have a special meaning inside a svelte component. Therefore, they probably shouldn't be reported by @typescript-eslint/no-unused-vars.

@marekdedic marekdedic added the enhancement New feature or request label Jan 22, 2023
@ota-meshi
Copy link
Member

Thank you for posting issue.

I think the parser needs to be fixed to make no-unused-vars work.

The RFC hasn't been merged yet, so I think it should be an option as an experimental feature.
sveltejs/rfcs#38

@ota-meshi ota-meshi added the help wanted Extra attention is needed label Jan 23, 2023
@devunt
Copy link

devunt commented Apr 15, 2023

For now I'm using following configuration in .eslintrc.cjs. This can provide a quick workaround before RFC lands.

        '@typescript-eslint/no-unused-vars': [
          'warn',
          { varsIgnorePattern: '^\\$\\$(Props|Events|Slots)$' },
        ],

@connerdassen
Copy link

What about $$Generic?
I get '$$Generic' is not defined eslint(no-undef).
This can be fixed by adding globals: {$$Generic: "readable"} to my eslint config, but it leads to problems further on because the type becomes "any", leading to a bunch of "any" usage related errors

@ota-meshi
Copy link
Member

Welcome pull request

@Razunter
Copy link

Razunter commented Nov 9, 2023

Not directly related, but how to handle imported stores?

This throws no-unused-vars:

import {store} from '@js/stores/globalStores'

$store = 'abc'

@marekdedic
Copy link
Contributor Author

I am closing this as it is irrelevant with Svelte 5 - generics are handled differently and slots and events are deprecated, so it probably isn't worth it supporting these...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants