Broken indent expectations in template literals within classes
See original GitHub issueTell 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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >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
oops, sorry for the delay!
it seems a bug to me, and I was able to repro it. cc @not-an-aardvark
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.