-
-
Notifications
You must be signed in to change notification settings - Fork 680
html-indent: Wants to indent comments too deep after multiline tags #514
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
I did small testing for this one, and looks like its only affecting comments |
Yes, it only affects comments. The code handles comments specially (rather than as regular nodes) for a couple of reasons, but one of them is that it wants to allow a comment to be aligned as either a regular node, or aligned with the closing tag. That is, if the code were bug-free, it would consider both of these to be correct: <template>
<div>
<input type="text"
value="foo">
<!-- comment -->
</div>
</template> and <template>
<div>
<input type="text"
value="foo">
<!-- comment -->
</div>
</template> |
I'm sorry for my delay. Looks like a bug. On ESLint, comments are separated from AST (because comments don't change semantics). Therefore, we have to handle comments by the special way. Currently, our indentation rules adjust comments to the previous token or the next token. In this case, the previous token is HTMLTagClose ( We have to change the current strategy to fix this issue. |
This issue is also present in js/ts code class Foo {
prop = 2
// foo
} it wants to align it to 0 indent |
In that TypeScript case, the previous token is an unknown token (TypeScript's original AST), so it's ignored. As a result, the comment is adjusted to only the next token I think we can add TypeScript support to our indent rules. |
Tell us about your environment
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
There to be no problem with the file; no warnings/or errors.
What actually happened? Please include the actual, raw output from ESLint.
It wants to indent the comment too deep--as if it were inside of the
<input>
tag. This is because it is aligning to the previous line, not the previous... I'm not sure what word to use... "statement"?The text was updated successfully, but these errors were encountered: