Unintended indent for multiline template string argument combined with another multiline argument
See original GitHub issueTell us about your environment
- ESLint Version: 4.3.0
- Node Version: 8.1.3
- npm Version: 5.0.3
What parser (default, Babel-ESLint, etc.) are you using?
I tried both default and babel-eslint. They’re giving me same result.
Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended"
],
"rules": {
"indent": ["error", 4]
}
}
What did you do? Please include the actual source code causing the issue.
const f = (first, second) => {
return second;
};
// works for multiline template strings
f(`
multiline
template
string
`, `
multiline
template
string
`);
// works for multiline objects
f({
foo: 'foo',
bar: 'bar',
}, {
foo: 'foo',
bar: 'bar',
});
// doesn't work for multiline template string and multiline object
f(`
multiline
template
string
`, {
foo: 'foo',
bar: 'bar',
});
What did you expect to happen?
I expected all of the three examples will pass.
What actually happened? Please include the actual, raw output from ESLint.
31:1 error Expected indentation of 8 spaces but found 4 indent
32:1 error Expected indentation of 8 spaces but found 4 indent
33:1 error Expected indentation of 4 spaces but found 0 indent
I believe the eslint fix is incorrect
const f = (first, second) => {
return second;
};
// works for multiline template strings
f(`
multiline
template
string
`, `
multiline
template
string
`);
// works for multiline objects
f({
foo: 'foo',
bar: 'bar',
}, {
foo: 'foo',
bar: 'bar',
});
// doesn't work for multiline template string and multiline object
f(`
multiline
template
string
`, {
- foo: 'foo',
- bar: 'bar',
-});
+ foo: 'foo',
+ bar: 'bar',
+ });
Could you please confirm this is an unintended behaviour? Thank you.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Proper indentation for multiline strings? - python
Docstrings are treated specially: any indent of the first line is removed; the smallest common indent taken over all other non-blank lines is...
Read more >Multiline template strings that don't break indentation
Solution 1: Ignore all space and tab characters following a newline until the first non-space or tab character. The problem with this is...
Read more >Strings and Templates - Configuration Language | Terraform
String literals and template sequences interpolate values and manipulate text. Learn about both quoted and heredoc string syntax.
Read more >String.dedent details - ECMAScript Proposals
Problem. The current syntax forces users to choose between strange-looking unindented template literals, template literals containing unwanted indentation, or ...
Read more >Google JavaScript Style Guide
To save space, you may wrap as close to 80 as possible, or put each argument on its own line to enhance readability....
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 Where are we at on this issue?
We actually have a test asserting the current behavior, so I think this is working as intended. I don’t recall if there was a specific reason why I added that test, though. I think I agree that your proposed behavior makes more sense.