indent issue with tagged template literals
See original GitHub issueTell us about your environment
- ESLint Version: 6.2.0
- Node Version: 10.16.3
- npm Version: 6.9.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"jest/globals": true
},
"plugins": ["jest"],
"rules": {
"indent": [
"error", 2, {
"SwitchCase": 1,
"VariableDeclarator": 1,
"outerIIFEBody": 1,
"FunctionDeclaration": {
"parameters": 1,
"body": 1
},
"FunctionExpression": {
"parameters": 1,
"body": 1
},
"CallExpression": {
"arguments": 1
},
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoredNodes": [
"JSXElement", "JSXElement > *", "JSXAttribute", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXSpreadAttribute", "JSXExpressionContainer", "JSXOpeningElement", "JSXClosingElement", "JSXText", "JSXEmptyExpression", "JSXSpreadChild"
],
"ignoreComments": false
}]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
describe('Indentation Bug', () => {
test.each`
a | b
${1} | ${1}
`('$a == $b', ({ a, b }) => {
expect(a).toBe(b); // error Expected indentation of 2 spaces but found 4 indent
}); // error Expected indentation of 0 spaces but found 2 indent
});
eslint .
What did you expect to happen? I would expect the code indentation to be valid.
What actually happened? Please include the actual, raw output from ESLint. Following eslint errors are displayed:
8:1 error Expected indentation of 2 spaces but found 4 indent
9:1 error Expected indentation of 0 spaces but found 2 indent
I’ve created a small repo where you can easily reproduce the issue. https://github.com/msvab/eslint-tagged-literal-indent-bug
Are you willing to submit a pull request to fix this bug? I can try, but I have zero knowledge on eslint internals.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Ignore the indentation in a template literal, with the ESLint ...
I know that ternary expressions, like used in this code, is a ConditionalExpression node, and it seems like a template literal node exists,...
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 >Prettify your JavaScript strings - Adam Coster
There is another common problem with strings in code: indentation in multiline strings. Template literals allow us to put breaks in our ...
Read more >Triple-backtick template literal with indentation support - TC39
Effectively, every tagged template literal function needs to build in dedent behaviour, or be ok with ugly code, or ugly outputs. Is it...
Read more >keywords:dedent - npm search
An ES6 string tag that strips indentation from multi-line strings ... ES2015 tagged template string for removing indent from strings.
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
It might take some time to get familiar with inner workings Eslint but I am interested in taking this up.
It’s still closed though 😉 I’d really like to get this fixed too, as I have to disable the indent rule on test-files otherwise…