-
Notifications
You must be signed in to change notification settings - Fork 28
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
Starting point of indent for @html-eslint/indent with HTML Javascript template literals #241
Comments
Hi @jpradelle Thanks for the reporting this issue.
This seems reasonable. let me fix it! |
Hi @jpradelle, It's fixed in |
Thanks a lot ! That changes a bit my habits, I usually write import {LitElement, html} from 'lit';
import {when} from 'lit/directives/when.js';
export class TestTest extends LitElement {
render() {
return html`
<p>test1</p>
${when(true, () => html`
<p>test2</p>
`)}
<p>test3</p>
`;
}
}
customElements.define('test-test', TestTest); It's requesting: import {LitElement, html} from 'lit';
import {when} from 'lit/directives/when.js';
export class TestTest extends LitElement {
render() {
return html`
<p>test1</p>
${when(true, () => html`
<p>test2</p>
`)}
<p>test3</p>
`;
}
}
customElements.define('test-test', TestTest); With 2 levels for My IDE tries to push me to do the way you did it too. I also have all multi line attributes indented with 2 levels of indent, for exemple <foo-bar
attr1
attr2="foo"></foo-bar> Linter requests only one level, do you think you could add an option so we can request 2 indent levels for multiple lines tags ? That follows 2nd and 3rd sample of google guidelines: https://google.github.io/styleguide/htmlcssguide.html#HTML_Line-Wrapping |
@jpradelle It would be nice to have separate options for the four attributes. I've created an issue. |
@jpradelle Starting with v0.31.0, you can adjust the indent depth of an Attribute separately.
|
Hi thanks a lot, works exactly as expected for attributes. About previous comment on template literal root base indent, sorry to bother you again do you think it could be updated or an option could be added: On this example: import {LitElement, html} from 'lit';
import {when} from 'lit/directives/when.js';
export class TestTest extends LitElement {
render() {
return html`
${when(true, () => html`
<foo-bar
.baz="${value => html`
<foo-baz
bar></foo-baz>
`}"></foo-bar>
`)}
`;
}
}
customElements.define('test-test', TestTest); Report is
Which means fixed version is import {LitElement, html} from 'lit';
import {when} from 'lit/directives/when.js';
export class TestTest extends LitElement {
render() {
return html`
${when(true, () => html`
<foo-bar
.baz="${value => html`
<foo-baz
bar></foo-baz>
`}"></foo-bar>
`)}
`;
}
}
customElements.define('test-test', TestTest); Indent base reference seems to be the opening curly brace
Could it be base indent of line on which template opening is
I think both can make sense, but currently in some complex cases, indent can increase a lot very fast |
@jpradelle oops!. In the current version, when tempalte literals are nested, the indents keep stacking up. This seems to be the cause, and I've raised a PR to fix it. #247
|
Awesome, works exactly as expected: applying this on my project reported no false positive, and it reported few issues as expected :) |
When using javascript HTML literals, it always requests to start at 0 for top level tag, do you think it could be updated to handle cases like this:
Current output is
I also see a bit more complex cases like that:
I think we would like initial indent reference to be something like start position of 1st non indent char of line containing html` + 1 indent level.
The text was updated successfully, but these errors were encountered: