kristoff-it / superhtml

HTML Language Server & Templating Language Library
MIT License
721 stars 24 forks source link

Check for unrecognized elements #36

Open MarkTiedemann opened 1 month ago

MarkTiedemann commented 1 month ago
<!DOCTYPE html>
<abr></abr>

The above code is accepted even though it contains a typo: <abr> should be <abbr>.

I think it'd be helpful if this extension would check for unrecognized elements and show an error in case it encounters one.

Note that, if this were implemented, there'd have to be an escape hatch for custom elements (e. g. <my-button>), preferably using something like VS Code Custom Data.

nobkd commented 1 month ago

Just my opinion on this: I personally don't like this, because I work with projects, where there are custom components, which are used just like HTML elements. I wouldn't want to add each element in my project to some list, to not highlight some issue with it. If there would be an option to enable/disable checking for element names, I would be fine with the general idea.

MarkTiedemann commented 1 month ago

@nobkd Are your projects not using HTML Custom Data? If so, how do you get autocomplete for your custom elements?

I feel like HTML Custom Data is quite a solid standard for making web components easy to use for other developers.

Stencil, for example, can generate this data out of the box: https://stenciljs.com/docs/docs-vscode

nobkd commented 1 month ago

Yeah, you're probably right. Thanks for the links!

kristoff-it commented 2 weeks ago

Before thinking of editor specific integration, I would be open to adding a flag to the CLI to enable element name checking.

If anybody wants to work on it, feel free to ask for guidance in here.

For starters, I see three main modes:

Once this is in place, then we can consider how to implement custom setups where we add more restrictions on web components or enable support for specific frontend frameworks that define their own elements, etc.