html-indent: Wants to indent comments too deep after multiline tags
See original GitHub issueTell us about your environment
- ESLint Version: 4.19.1
- eslint-plugin-vue Version: 4.5.0
- Node Version: 10.3.0
Please show your full configuration:
module.exports = {
root: true,
plugins: ["vue"],
extends: [
"eslint:recommended",
"plugin:vue/recommended",
],
rules: {
"vue/max-attributes-per-line": ["warn", {
"multiline": {"allowFirstLine": true}
}],
}
}
What did you do? Please include the actual source code causing the issue.
<template>
<div>
<input type="text"
value="foo">
<!-- comment -->
</div>
</template>
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.
$ ./node_modules/.bin/eslint test.vue
/home/lukeshu/testcase/test.vue
5:1 error Expected indentation of 11 spaces but found 4 spaces vue/html-indent
✖ 1 problem (1 error, 0 warnings)
1 error, 0 warnings potentially fixable with the `--fix` option.
$ ./node_modules/.bin/eslint --fix test.vue
$ cat test.vue
<template>
<div>
<input type="text"
value="foo">
<!-- comment -->
</div>
</template>
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”?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
HTML Indentation, Spacing, and Comments
The first debate is on whether we should use spaces or tabs to indent our code. The second is on whether our indents...
Read more >How to indent a few lines in Markdown markup?
Wrapped lines in long text are not indented which you may not want in your layout. Resize your rendered view to test. Also,...
Read more >How To Put a Multi-Line Indent on a Styled Blockquote
This brief and easy tutorial provides a method to indent multiple lines of text around a background image on a styled <blockquote> element....
Read more >Comments and indentation | PracticalSeries: Web Development
Understand the importance of commenting HTML, CSS and Java script. Learn how to minimise HTML and CSS and understand the concept of indentation....
Read more >Reindent command breaks on (multiline) comments #1271
Selecting an entire document that contains comments that span multiple lines, and using the Edit -> Line -> Reindent command, stops indenting at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
This issue is also present in js/ts code
it wants to align it to 0 indent