Skip to content
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

Incorrect indentation on line starting with   #120

Closed
reidab opened this issue Oct 20, 2016 · 6 comments · Fixed by #850
Closed

Incorrect indentation on line starting with   #120

reidab opened this issue Oct 20, 2016 · 6 comments · Fixed by #850
Labels

Comments

@reidab
Copy link
Contributor

reidab commented Oct 20, 2016

Linting a template with a segment like the following incorrectly flags the indentation:

{{#if foo}}
   bar
{{/if}}

with

block-indentation: Incorrect indentation for `   bar
` beginning at L2:C0. Expected `   bar
` to be at an indentation of 2 but was found at 3. (thedyrt-ui/templates/components/at-trip):
`{{#if foo}}
   bar
{{/if}}`
@rwjblue rwjblue added the bug label Nov 5, 2016
@duggiefresh
Copy link
Contributor

What would be the expectation here? Thanks!

@reidab
Copy link
Contributor Author

reidab commented Nov 7, 2016

It's looking like ember-template-lint is treating the   string as a space for the purpose of calculating source code indentation, instead of treating the & as the first character of that line's source.

I'd expect both of the following to pass linting, but currently only the second one does:

{{#if foo}}
   bar
{{/if}}
{{#if foo}}
  →bar
{{/if}}

@rwjblue
Copy link
Member

rwjblue commented Nov 7, 2016

Agreed. I am unsure why   is being treated differently than → off the top of my head.

@rwjblue
Copy link
Member

rwjblue commented Jan 23, 2017

@reidab - Can you double check if this is still an issue, and open a failing test case for this (basically like this one) if it is still an issue?

reidab added a commit to reidab/ember-template-lint that referenced this issue Feb 27, 2017
…emplate-lint#120)

- ` ` followed by text (` Hello`) seems to interpret the ` ` as a space and fails: `Expected '   Hello\n' to be at an indentation of 2 but was found at 3."`
- `&nbsp;` followed by HTML (`&nbsp;<div></div>`) seems to interpret the `&nbsp;` as six separate whitespace characters and fails: `Expected '<div>' to be at an indentation of 2 but was found at 8.`
@reidab
Copy link
Contributor Author

reidab commented Feb 27, 2017

Confirmed that it's still happening on the latest version and submitted failing tests in #184.

bjornharrtell pushed a commit to bjornharrtell/ember-template-lint that referenced this issue Jun 11, 2019
@rwjblue
Copy link
Member

rwjblue commented Jun 27, 2019

We can fix it now! We need to update our usage of @glimmer/compiler to use the new mode: 'codemod' and it will opt-out of converting HTML entities to their underlying thing.

See glimmerjs/glimmer-vm#938 for background on that new parsing mode.

rwjblue pushed a commit to reidab/ember-template-lint that referenced this issue Nov 3, 2019
…emplate-lint#120)

- `&nbsp;` followed by text (`&nbsp;Hello`) seems to interpret the `&nbsp;` as a space and fails: `Expected '   Hello\n' to be at an indentation of 2 but was found at 3."`
- `&nbsp;` followed by HTML (`&nbsp;<div></div>`) seems to interpret the `&nbsp;` as six separate whitespace characters and fails: `Expected '<div>' to be at an indentation of 2 but was found at 8.`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants