question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Ability to configure different indenting on template literals

See original GitHub issue

The version of ESLint you are using. 5.4.0 The problem you want to solve. Ability to configure indent rule for template literals

Your take on the correct solution to problem.

Right now, the following code:

const example = `This is a nice template literal ${1 + 1
  }. Like it?`;

module.exports = example;

throws this error:

/home/luis/tmp/index.js
  2:1  error  Expected indentation of 0 spaces but found 2  indent

I would like to be able to specify, for text literals, that I want to indent it to 2 (or any other configurable number of spaces) after the previous line.

I didn’t find a way to set in the documentation.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Oct 16, 2018

@kaicataldo I think the behavior you’re observing is a result of the indent rule never enforcing any indentation for the operator/RHS of binary expressions. It’s not related to template literals in particular.

0reactions
eslint-deprecated[bot]commented, Dec 11, 2018

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

indent issue with tagged template literals #12122 - GitHub
I would expect the code indentation to be valid. What actually happened? Please include the actual, raw output from ESLint. ... I've created...
Read more >
Getting Literal With ES6 Template Strings - Chrome Developers
Template Strings bring many important capabilities to JavaScript. These include better ways to do string & expression interpolation, multiline ...
Read more >
Multiline strings that don't break indentation - Stack Overflow
var a = dontIndent `This is a template string. Even though each line is indented to keep the code neat and tidy, the...
Read more >
Feature request: String interpolation - Change Proposals ...
Running show on an accumulated string breaks my memory; Difference between (2),(3),(4) is negligible - using fold with interp is ok here ...
Read more >
Text formatting
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found