[v4] indent expects the wrong indentation for expressions inside template literals
See original GitHub issueTell 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:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top 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 >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
@not-an-aardvark Would you mind giving an example how to use this rule specifically for dealing with template literals?
I think that would be covered by https://github.com/eslint/eslint/issues/8594.