-
-
Notifications
You must be signed in to change notification settings - Fork 681
Wrong detect of Parsing error: invalid-first-character-of-tag-name
in expression.
#370
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
Comments
Thank you for the report. This is a correct error as according to HTML spec:
To make valid HTML, you should use |
No this is NOT html, it's in |
It's still in HTML. |
Thanks for reply. So what should I do to compare two numbers and use conditional operator correctly in vue template? |
The expression |
To be valid HTML, But HTML spec allows |
Oh? |
Full file
You can try this code. |
I know that HTML syntax is very tolerant. Browsers/Parsers work fine even if HTML parse error. But HTML parse errors still exist, so the rule reports it and has the options which are to ignore HTML parse errors. OK, I opened an issue to add option which ignores HTML syntax errors in mustaches in |
I re-thought about this, I decided that I don't add that option. It messes the code easily by removing a space. Inside of mustaches is still HTML. <!-- Oops, this is not a mustache, there is `<fireDistance>` tag. -->
{{ scope.distance <fireDistance ? 'Pull to refresh' : 'Release to refresh' }} I'd like to recommend to use Thank you. |
Thanks, I'll use |
By that logic, anything inside of a Interpolated JS should absolutely not be treated as HTML. Being able to use |
Exactly. So the following code is syntax error since the script ends at the first <script>
document.body.innerHTML += "</script>"
</script> As same, |
So wouldn't it follow that |
Not quite what I'm talking about. https://jsfiddle.net/krvftv74/2/ It's kind of funny that my example is throwing HTML linter errors, but my point is the Vue linter should know better. |
@mysticatea Please disable as default, its really annoying :( For reference, add this to your eslintrc.js (eslint config) file to remove notice:
|
This is still a thing, and it is absurd. The contents of {{ }} is executed as a JavaScript expression. It isn't HTML by any stretch of the imagination. Having to escape html reserved characters is very unnatural in what is essentially a script. Let JavaScript expressions be expressions. Fix this bug. |
I completely agree with @Smilebags - Vue template is something more than a pure HTML and the linter should obey this fact. Everything inside a mustache and the mustache itself is and should be practically and theoretically invisible for the HTML parser. |
I think we can all agree there are no HTML tags in Either the warning is valid or it isn't. And seeing how there aren't any tags in that statement, the warning is not valid. I think we all understand the situation that leads to the warning being generated today, but the why doesn't really change the should. |
Is the rule |
when can fix it ? |
LOL, still a problem |
still a problem |
Can we please get someone to re-evaluate this ticket? Based on the responses from @mysticatea it's quite evident that they either have a fundamental misunderstanding of how string interpolation works in Vue, or the purpose behind string interpolation in Vue. |
Indeed, the problem is in vue-eslint-parser and not in eslint-plugin-vue. Here is the patch to fix the problem |
You can use the following options: {
// ...
"rules": {
// ...
"vue/no-parsing-error": ["error", {"invalid-first-character-of-tag-name": false}]
// ...
}
// ...
} You can check with DEMO. |
This is broken if you are using
throws an error. but this works perfectly fine
or even with lodash
I think the argument that everything inside |
@mysticatea can you reopen this issue? It's affecting other cases which will bring back the same discussion again |
No. the inside of This is just a fact. I don't think the reopen makes sense. In Vue.js 3 support, this behavior will change, I think. Because the inside of |
Go in packages.json and add this code |
It is not |
use <!-- will pass -->
<div v-text="a < b ? 'c' : 'd'"></div> <!-- will fail -->
<div>{{ a < b ? 'c' : 'd' }}</div> |
@bumprat Are you sure your |
check v-text documentation
|
@mysticatea Just run into the issue with Vue.js 3. Is it possible to reopen the issue? |
same problem here. It can be fixed by add "vue/no-parsing-error": [2, { "invalid-first-character-of-tag-name": false }]" in .eslintrc.js . |
All other arguments about syntax aside, if JavaScript expressions (be them ternary or otherwise) are supported and encouraged by VueJS, it should probably not throw an error in a VueJS linter. |
still have this issue with Vue3 in 2021. I think this issue should be open. |
You need to set https://github.com/vuejs/vue-eslint-parser#parseroptionsvuefeaturesinterpolationasnonhtml |
Tell us about your environment
4.16.0
4.2.2
v8.1.3
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
No error.
What actually happened? Please include the actual, raw output from ESLint.

The text was updated successfully, but these errors were encountered: