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.

[v4] indent expects the wrong indentation for expressions inside template literals

See original GitHub issue

Tell us about your environment

ESLint Version: 4.1.1 Node Version: 8.1.3 npm Version: yarn 0.27.5

What parser (default, Babel-ESLint, etc.) are you using? default and babel-eslint

Please show your full configuration:

Configuration
{
  "env": {
    "browser": false,
    "node": true,
    "jest": true
  },
  "extends" : [
    "standard",
    "plugin:flowtype/recommended"
  ],
  "parser": "babel-eslint",
  "rules": {
    "brace-style": [2, "stroustrup"],
    "comma-dangle": [1, "only-multiline"],
    "indent": [2, "tab", { "SwitchCase": 1 }],
    "no-multiple-empty-lines": [1, {"max": 4}],
    "no-tabs": [0],
    "padded-blocks": [0],
    "quotes": [2, "single"],
    "semi": [2, "always"],
    "strict": [2, "never"]
  },
  "plugins": [
    "flowtype"
  ]
}

What did you do? Please include the actual source code causing the issue.

const fields = [
	'foo',
	() => 'bar'
];

const query = `
	SELECT
		${fields.map((f) => typeof condition === 'function'
			? f()
			: f
		).join(',')}
	FROM foo
`;

console.log(query);

What did you expect to happen? No errors.

What actually happened? Please include the actual, raw output from ESLint.

   9:1  error  Expected indentation of 2 tabs but found 3  indent
  10:1  error  Expected indentation of 2 tabs but found 3  indent
  11:1  error  Expected indentation of 1 tab but found 2   indent

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
skylizecommented, Oct 7, 2017

I think that would be covered by #8594.

@not-an-aardvark Would you mind giving an example how to use this rule specifically for dealing with template literals?

1reaction
not-an-aardvarkcommented, Jul 5, 2017

I think that would be covered by https://github.com/eslint/eslint/issues/8594.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore the indentation in a template literal, with the ESLint ` ...
1. I got a warning from eslint using this config, specifically since it expects ignoredNodes to be an array. · I didn't get...
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Java Text Blocks
In this tutorial, we'll see in detail how to use the Java 15 text blocks feature to declare multi-line strings most efficiently.
Read more >
Prettier 2.1: new --embedded-language-formatting option ...
The new version recognizes only multiline footnotes indented with 4 spaces. This change isn't considered breaking as the syntax is non-standard, ...
Read more >
Configuration · Scalafmt
This parameter controls indentation within control expressions ... def function( parameter1: Type1 // indented by 4 ): ReturnType ... Expect changes.
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