Indentation errors in template literals, regardless of ignoredNodes rule
See original GitHub issueTell us about your environment
- ESLint Version: 4.6.0
- Node Version: 8.4.0
- npm Version: yarn v0.27.5
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint 7.2.3 Please show your full configuration:
Configuration
module.exports = {
env: {
browser: true,
node: true,
commonjs: true,
es6: true,
},
globals: {
_: true,
sleep: 1,
},
plugins: ['json'],
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaVersion: 8,
allowImportExportEverywhere: true,
ecmaFeatures: {
modules: true,
},
},
extends: ['eslint:recommended'],
rules: {
'no-empty': 0,
'no-console': 0,
'no-empty-pattern': 0,
'no-cond-assign': 1,
// semi: 2,
camelcase: 0,
'comma-style': 2,
// 'comma-dangle': [2, 'always-multiline'],
indent: [
2,
2,
{ SwitchCase: 1, ignoredNodes: ['TemplateLiteral', 'TemplateElement'] },
],
// 'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
'no-trailing-spaces': [2, { skipBlankLines: true }],
'max-nested-callbacks': [2, 3],
// 'no-eval': 2,
'no-implied-eval': 2,
'no-new-func': 2,
// 'guard-for-in': 2,
eqeqeq: 1,
'no-else-return': 2,
'no-redeclare': 2,
'no-dupe-keys': 2,
radix: 2,
strict: [2, 'never'],
'no-shadow': 0,
'no-delete-var': 2,
'no-undef-init': 2,
'no-shadow-restricted-names': 2,
'handle-callback-err': 0,
'no-lonely-if': 2,
'keyword-spacing': 2,
'constructor-super': 2,
'no-this-before-super': 2,
'no-dupe-class-members': 2,
'no-const-assign': 2,
'prefer-spread': 2,
'no-useless-concat': 2,
'no-var': 2,
'object-shorthand': 2,
'prefer-arrow-callback': 2,
'no-multiple-empty-lines': [2, { max: 2 }],
quotes: [1, 'single', { allowTemplateLiterals: true }],
'no-unused-vars': [
2,
{
vars: 'all',
args: 'after-used',
argsIgnorePattern: '(^reject$|^_$|^req$)',
varsIgnorePattern: '(^_$)',
},
],
'no-unused-expressions': [
2,
{
allowTaggedTemplates: true,
allowShortCircuit: true,
allowTernary: false,
},
],
},
};
What did you do? Please include the actual source code causing the issue.
itemData = place => `
<h3>${place.name}</h3>
${place.address ? `<p>${place.address}</p>` : ``}
${place.city ? `<p>${place.city}</p>` : ``}
${place.country ? `<p class="mbs">${place.country}</p>` : ``}
${place.phone
? `<p><span class="c-box">T</span><a href="tel:${place.phone}">${place.phone}</a></p>`
: ``}
${place.email
? `<p><span class="c-box">E</span><a href="mailto:${place.email}">${place.email}</a></p>`
: ``}
${place.url
? `<p><span class="c-box">W</span><a href="${place.url}" target="_blank" rel="noopener noreferrer">${place.url}</a></p>`
: ``}
`;
What did you expect to happen?
There shouldn’t be any indentation errors in template literals due to ignoredNodes: ['TemplateLiteral', 'TemplateElement']
What actually happened? Please include the actual, raw output from ESLint.
[eslint] Expected indentation of 8 spaces but found 6. (indent)
The output after using --fix
:
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 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 >Ignore the indentation in a template literal, with the ESLint ...
To ignore all indentation and newline errors in ESLint inside a template literal, including function calls or deeply nested JS syntax, you can...
Read more >YAML Ain't Markup Language (YAML™) revision 1.2.2
For example, indentation may be used for structure, ... A YAML processor may recover from syntax errors, possibly by ignoring certain parts ...
Read more >XML function catalog
If $arg is an atomic value, the function returns the result of the expression $arg cast as xs:string (see ). In all other...
Read more >File: Cops Style — RuboCop master - Doc Index
bad sig do params( foo: string, ).void end def bar(foo) puts foo end ... the frozen string literal comment # to a file,...
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
Hi,
This is working as intended; that offset is coming from the ternary expressions, not the template literal itself.
If you want to ignore this case, you could use something like
ignoredNodes: ["TemplateLiteral > ConditionalExpression"]
Yes.