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.

Broken indent expectations in template literals within classes

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.7.0
  • Node Version: 10.12.0
  • npm Version: 5.3.0

What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration:

Configuration
{
	"extends": "eslint:recommended",
	"env": {
		"node": true,
		"es6": true
	},
	"parserOptions": {
		"ecmaVersion": 2018
	},
	"rules": {
		"indent": ["error", "tab", { "SwitchCase": 1 }]
	}
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const reply = () => {
	// NoOp
};
const groups = [];

class Test {
	// Expected
	run() {
		return reply(`
			${groups.map(grp =>
				grp ? 'Enabled' : 'Disabled'
			)}
		`);
	}

	// Eslint Expects
	run2() {
		return reply(`
			${groups.map(grp =>
		grp ? 'Enabled' : 'Disabled'
	)}
		`);
	}
}

// Expected & Eslint Expects
reply(`
	${groups.map(grp =>
		grp ? 'Enabled' : 'Disabled'
	)}
`);

module.exports = Test;
eslint Test.js

What did you expect to happen? shown above in source code comments What actually happened? Please include the actual, raw output from ESLint. shown above in source code comments

C:\workspace\Test.js
  11:1  error  Expected indentation of 2 tabs but found 4  indent
  12:1  error  Expected indentation of 1 tab but found 3   indent

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
aladdin-addcommented, Dec 1, 2018

oops, sorry for the delay!

it seems a bug to me, and I was able to repro it. cc @not-an-aardvark

2reactions
eslint-deprecated[bot]commented, Jan 24, 2019

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 accepted issues failing to be implemented after 90 days tend to never be implemented, 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 doesn't work properly inside of template literals #10814
To the best of my knowledge, indent considers anything inside template literal as a single string, and completely skips any checks inside of...
Read more >
Remove indentation, but keep line breaks in template literal
Because this is happening the API I'm working with is treating the template literal as a single string with no line breaks.
Read more >
Template literals (Template strings) - JavaScript | MDN
Almost all characters are allowed literally, including line breaks and other whitespace characters. However, invalid escape sequences will cause ...
Read more >
keywords:dedent - npm search
An ES6 template string tag to replace newlines, indentation, and surrounding whitespace with a single space character. unindent · dedent · paragraph.
Read more >
Multiline template strings that don't break indentation
I'm wondering if there's a feasible solution that could allow us to keep our code indented across multiple lines without the formatting whitespace...
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