Erroneous indentation warning in template literals contents
See original GitHub issueTell us about your environment
-
ESLint Version: 5.6.1
-
Node Version: 8.12.0
-
npm Version: 6.4.1
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
}
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
class ShopCart {
render () {
const { html, map } = this
return html`
<style>
:host { display: block; }
</style>
${map((item) =>
item++
)}
`
}
}
new ShopCart
./eslint.js -c config.js test.js
What did you expect to happen?
No errors
What actually happened? Please include the actual, raw output from ESLint.
I expected it to go through without any warnings. However, I got this output:
/home/merc/.atom/packages/linter-eslint/node_modules/eslint/bin/test.js
9:1 error Expected indentation of 4 spaces but found 8 indent
10:1 error Expected indentation of 2 spaces but found 6 indent
✖ 2 problems (2 errors, 0 warnings)
2 errors and 0 warnings potentially fixable with the `--fix` option.
Please note that the right indentation for that item++
is 8, not 4. Same applies to the closing of the map() function.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 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 >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 >indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >21 Using template literals and tagged templates - Exploring JS
If we put multiline text in template literals, two goals are in conflict: On one hand, the template literal should be indented to...
Read more >Appendix: YAML Techniques - Helm
Because Latte is incorrectly indented, we'd get an error like this: ... But notice that the content of our string was followed with...
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
OK – will try that. I have to ask though… what are the chances of this getting looked at? Please realise that it’s giving the wrong warnings for template literals; I humbly ask you to consider to turn this into a bug, rather than an enhancement. It makes it painful to use libraries that use template literals as template engines (HyperHTML, Lit-html, etc.)
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 issues failing to reach accepted status after 21 days tend to never be accepted, 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.