-
-
Notifications
You must be signed in to change notification settings - Fork 681
Fix: no-invalid-template-root
has false positive about empty templates (fixes #41)
#44
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
{ | ||
filename: 'test.vue', | ||
code: '<template>\n</template>', | ||
errors: ['The template root requires exactly one element.'] | ||
code: '<template>\n</template>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty template seems also bad since users can simply skip the template section. I would like to see exactly one element warning back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think template root should be empty only if it is an external template reference.
Related: vuejs/vetur#272
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HerringtonDarkholme Could you know where the document about <template src="foo.html">
is? User guide seems to not say about <template src="foo.html">
. Also HTML spec does not have the src
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is listed in vue-loader's spec. http://vue-loader.vuejs.org/en/start/spec.html#src-imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HerringtonDarkholme Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's see how it works in practice. Merge when you're ready.
code: '<template><slot></slot></template>', | ||
errors: ["The template root disallows '<slot>' elements."] | ||
code: '<template src="foo.html">abc</template>', | ||
errors: ["The template root which has 'src' attribute requires empty."] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about amending this message to be: The template root with 'src' attribute is required to be empty.
@@ -6,16 +6,21 @@ This rule checks whether every template root is valid. | |||
|
|||
This rule reports the template root if the following cases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's out of the scope of this task, but if you're already on it maybe you could change if
to in
. We can also do a separate PR with copy updates though, so whatever..
Thank you for corrections! |
Fixes #41.
This PR removes the warnings about empty templates.