Skip to content
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

feat: Added the experimental-require-strict-events rule #365

Merged
merged 12 commits into from
Feb 9, 2023
Merged

feat: Added the experimental-require-strict-events rule #365

merged 12 commits into from
Feb 9, 2023

Conversation

marekdedic
Copy link
Contributor

@marekdedic marekdedic commented Feb 7, 2023

Closes #345

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2023

🦋 Changeset detected

Latest commit: 99477b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@marekdedic marekdedic marked this pull request as ready for review February 8, 2023 00:50
@marekdedic
Copy link
Contributor Author

Hi @ota-meshi, there are some lint issues but I think they're unrelated to the PR...

@ota-meshi
Copy link
Member

there are some lint issues but I think they're unrelated to the PR...

I think merging or rebasing the current main branch will probably solve it. Could you try it?

@marekdedic
Copy link
Contributor Author

I think merging or rebasing the current main branch will probably solve it. Could you try it?

No luck :(

tools/render-rules.ts Outdated Show resolved Hide resolved
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!
I made two comments. Could you please check them out?

src/rules/experimental-require-strict-events.ts Outdated Show resolved Hide resolved
}
},
"Program:exit"() {
if (isTs && !hasAttribute && !hasInterface) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the strictEvents attribute should be given even if createEventDispatcher or on:click are not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do - the strictEvents attributes makes all "callers" of the component (i.e. components that contain it) have their on:something handlers checked as well - so even if a component has no events, the strictEvents attribute brings a benefit in that the callers will error if they try to add a handler to a non-existent event.

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@ota-meshi ota-meshi merged commit e61bbc3 into sveltejs:main Feb 9, 2023
@marekdedic
Copy link
Contributor Author

Great, I'll get #368 ready :)

@marekdedic marekdedic deleted the require-strict-events branch February 9, 2023 10:24
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 this pull request may close these issues.

New rule: require-strict-events
2 participants