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

feat: Improve indent in template literals #553

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

remziatay
Copy link
Contributor

Description

Fixes #551

Codebases using some kind of html templating like lit will have template literals like this all over

html`
    <article
      test="test"
      class=${clsx('container', {
        hide: 'shouldHide',
        empty: 'isCollapsed',
      })}
    >
      <div class="header"></div>
    </article>
`

In current state, this is not linted correctly as reported in the issue. The proposed solution is assuming that indentation should be based on the line with ${ even if it doesn't include only spaces and tabs

One exception is such usages, they are untouched

`
  expression starting with new line ${
      'and'} ending on the same line
`

Linked Issues

#551

Additional context

Copy link

codecov bot commented Oct 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.44%. Comparing base (ff69053) to head (039f22b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #553   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files         120      120           
  Lines       19563    19568    +5     
  Branches     4649     4652    +3     
=======================================
+ Hits        19064    19069    +5     
  Misses        497      497           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antfu antfu added this pull request to the merge queue Oct 5, 2024
Merged via the queue into eslint-stylistic:main with commit 9130c94 Oct 5, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

indent: Wrong indentation in template literal expressions
2 participants