Feature Request: Ability to configure different indenting on template literals
See original GitHub issueThe 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:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
@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.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.