fix(variable-declarator): indent first variable in one-var scenario, fixes #2072 (#2095)

This commit is contained in:
Lucas Azzola authored and Christopher Chedeau committed 2017-06-10 21:19:50 -07:00
1 parent fdb7467de7
commit a79a444bac
3 files changed
+39 -1

No files matched your search

+9 -1
View File
@@ -1226,10 +1226,18 @@ function genericPrintNoParens(path, options, print, args) {
const hasValue = n.declarations.some(decl => decl.init);
let firstVariable;
if (printed.length === 1) {
firstVariable = printed[0];
} else if (printed.length > 1) {
// Indent first var to comply with eslint one-var rule
firstVariable = indent(printed[0]);
}
parts = [
isNodeStartingWithDeclare(n, options) ? "declare " : "",
n.kind,
printed.length ? concat([" ", printed[0]]) : "",
firstVariable ? concat([" ", firstVariable]) : "",
indent(
concat(
printed
@@ -13,6 +13,16 @@ var a, b, c;
let superSuperSuperLong1, superSuperSuperLong2, superSuperSuperLong3, superSuperSuperLong4;
for (var i = 0, len = arr.length; i < len; i++) {}
var templateTagsMapping = {
'%{itemIndex}': 'index',
'%{itemContentMetaTextViews}': 'views'
},
separator = '<span class="item__content__meta__separator">•</span>',
templateTagsList = $.map(templateTagsMapping, function(value, key) {
return key;
}),
data;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var assert = require("assert"),
lookup = require("../lookup");
@@ -30,6 +40,16 @@ let superSuperSuperLong1,
for (var i = 0, len = arr.length; i < len; i++) {}
var templateTagsMapping = {
"%{itemIndex}": "index",
"%{itemContentMetaTextViews}": "views"
},
separator = '<span class="item__content__meta__separator">•</span>',
templateTagsList = $.map(templateTagsMapping, function(value, key) {
return key;
}),
data;
`;
exports[`string.js 1`] = `
+10
View File
@@ -10,3 +10,13 @@ var a, b, c;
let superSuperSuperLong1, superSuperSuperLong2, superSuperSuperLong3, superSuperSuperLong4;
for (var i = 0, len = arr.length; i < len; i++) {}
var templateTagsMapping = {
'%{itemIndex}': 'index',
'%{itemContentMetaTextViews}': 'views'
},
separator = '<span class="item__content__meta__separator">•</span>',
templateTagsList = $.map(templateTagsMapping, function(value, key) {
return key;
}),
data;