Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.

Add option allowedSuperNames for extends-correct-class #38

Merged
merged 4 commits into from
Feb 23, 2022

Conversation

mbullington
Copy link
Contributor

Closes #32

Description

This adds an option allowedSuperNames to the extends-correct-class rule that an Autonomous custom element may extend. It is assumed that by using this option, any allowed super name must extend HTMLElement in its prototype chain.

@mbullington mbullington changed the title feat: ✨ Option allowedSuperNames for extends-correct-class feat: ✨ Option allowedSuperNames for extends-correct-class Feb 8, 2022
@mbullington mbullington changed the title feat: ✨ Option allowedSuperNames for extends-correct-class Add option allowedSuperNames for extends-correct-class Feb 8, 2022
Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Generally this change looks great! Some small nits:

allowedSuperNames = [builtInTagMap[extendsTag]]
} else {
allowedSuperNames = [...((context.options[0] || {}).allowedSuperNames || [])]
// Make sure to treat this like a set.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we'd like to treat this like a Set, does it make sense to just make it a Set?

Copy link
Contributor Author

@mbullington mbullington Feb 11, 2022

Choose a reason for hiding this comment

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

I think changing it to a Set also works!

To stringify with the changes, would we need to convert back to an array?

Never mind tried this out, also works with an iterable! I made the change, thanks for the speedy reviews.

mbullington and others added 2 commits February 11, 2022 16:40
This works great! I'll pull down and update the unit tests.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

This looks great to me! @koddsson for a second set of eyes on this.

Copy link
Contributor

@koddsson koddsson left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for this ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom-elements/extends-correct-class should check if the parent class extends HTMLElement
3 participants