stencil-community / stencil-eslint

ESLint rules specific to Stencil JS projects
MIT License
61 stars 34 forks source link

fix(reserved-member-names): improve reserved member check by using `HTMLElement` #101

Closed jcfranco closed 8 months ago

jcfranco commented 11 months ago

Related issue: #100

This PR aims to make the check for reserved member names more robust by creating list of reserved attributes/props from a local custom element (HTMLElement instance).

Additional changes

James-Wilkinson-git commented 9 months ago

What does this produce as a result of what is reserved? It should match https://www.w3schools.com/tags/ref_attributes.asp all of these different types of HTML components attribute are reserved if you use something like a web component in svelte

jcfranco commented 9 months ago

It should warn against property/method names that match global attributes and properties found on HTMLElement (see https://github.com/stencil-community/stencil-eslint/issues/100#issuecomment-1845846998 for additional context).

James-Wilkinson-git commented 9 months ago

This change will reduce the currently erroring names, this would break backwards compatibility for other users and ads I’ve stated in the linked issue we should actually be expanding this list to match all reserved html attributes of all elements.

jcfranco commented 9 months ago

The rule's documentation specifies it targets reserved global HTML attribute names for props and methods. My PR addresses false positives for non-global attributes like color, aligning with the rule's intent. Framework-specific quirks are outside the rule's scope.

James-Wilkinson-git commented 9 months ago

I can side with that but people already using the linter rule will now no longer have a guard so it would be a breaking change that should come with another option to replace what is being removed.

jcfranco commented 9 months ago

I don't agree it being a breaking change from the documentation perspective. The current behavior, which flags additional, unrelated properties, should be considered a bug.

In any case, could you provide a snippet or example use case along with the error/warning? I'm unfamiliar with Svelte and really trying to understand the issue. I don't get why Svelte would complain about the attribute/prop name of a 3rd-party custom element.

jcfranco commented 8 months ago

@raphaelpor Are there any additional steps needed from me to get this landed? This PR was approved a while back and I'm eager to help it progress. Thanks!

jcfranco commented 8 months ago

@raphaelpor Thanks for the merge! 🚀