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

Add proper unknown attribute detection #1418

Closed
TheDutchCoder opened this issue Jun 7, 2022 · 2 comments
Closed

Add proper unknown attribute detection #1418

TheDutchCoder opened this issue Jun 7, 2022 · 2 comments

Comments

@TheDutchCoder
Copy link

As referenced in previous issues (e.g. #1386) Volar currently does not correctly detect all HTML attributes while simultaneously detecting invalid ones.

Example that will throw an error when experimentalSuppressUnknownJsxPropertyErrors is disabled:

<div data-test-id="root">
  Root
</div>

Example that doesn't (but should) throw an error when experimentalSuppressUnknownJsxPropertyErrors is enabled:

<div foo="bar">
  Root
</div>

The correct functionality would be only foo throwing an error:

<div data-test-id="root" foo="bar">
  Root
</div>
@johnsoncodehk
Copy link
Member

experimentalSuppressUnknownJsxPropertyErrors and experimentalSuppressInvalidJsxElementTypeErrors will be replace by strictTemplates in next version.

Volar currently does not correctly detect all HTML attributes while simultaneously detecting invalid ones.

When strictTemplates is true, all props / attrs is parse with Camel case as trade-off to avoid this problem, it mean you should always define props with Camel case on strict mode.

defineProps<{
-	'my-prop': string
+	myProp: string
}>

The correct functionality would be only foo throwing an error:

Volar will not special handle data-* to avoid #1413.

@johnsoncodehk
Copy link
Member

Replenish: you can define HTMLAttributes interface to allow data-*: #1077 (comment)

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

No branches or pull requests

2 participants