-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
New rule: require-strict-events
#345
Comments
Thanks for the rule suggestions. |
Hi, If they're experimental, though, the rule should be too. Thanks! |
Relevant PR: sveltejs/language-tools#1054 |
Hi, Do you mean just a warning in the readme and a separate section in the rule list? Thanks :) |
I think it would be nice to prefix the rule name with "experimental-". When it becomes GA, we will change the rule name and release it. |
Motivation
Hi,
when using TypeScript with svelte, component events aren't automatically typed - e. g. you can have an
on:nonexistent={() => {}}
handle for a non-existent event. However, svelte does check this, if the opening script tag of the child component has thestrictEvents
attribute. (<script lang="ts" strictEvents>
).I propose to add a rule that would enforce this.
Description
The rule should enforce that components have the
strictEvents
attribute present in their opening svelte tag.I propose several an option to choose for which components the attribute should be enforced:
Additional note: For some components that have event mixins, the
strictEvents
attribute does not work and you have to declare the$$Events
interface. In that case, I think the rule shouldn't fire - so effectively, it would require either thestrictEvents
attribute or a manually declared interface$$Events
for the component.Examples
Additional comments
The relevant RFC.
The text was updated successfully, but these errors were encountered: