Take this code before formatting (generated by Typescript):
function has(obj, path, ownPropertiesOnly) {
if (ownPropertiesOnly === void 0) { ownPropertiesOnly = exports.defaultOptions.ownPropertiesOnly; }
if (isEmpty(obj, ownPropertiesOnly)) {
return false;
}
if (isNumber(path)) {
path = [path];
}
else if (isString(path)) {
path = path.split('.');
}
if (isEmpty(path, ownPropertiesOnly) || path.length === 0) {
return false;
}
for (var i = 0; i < path.length; i++) {
var j = path[i];
if (isObject(obj) || isArray(obj)) {
if (ownPropertiesOnly) {
if (_hasOwnProperty.call(obj, j)) {
obj = obj[j];
}
else {
return false;
}
}
else {
if (j in obj) {
obj = obj[j];
}
else {
return false;
}
}
}
else {
return false;
}
}
return true;
}
after formatting, it becomes:
function has (obj, path, ownPropertiesOnly) {
if (ownPropertiesOnly === void 0) { ownPropertiesOnly = exports.defaultOptions.ownPropertiesOnly; }
if (isEmpty(obj, ownPropertiesOnly)) {
return false
}
if (isNumber(path)) {
path = [path]
}
else if (isString(path)) {
path = path.split('.')
}
if (isEmpty(path, ownPropertiesOnly) || path.length === 0) {
return false
}
for (var i = 0; i < path.length; i++) {
var j = path[i]
if (isObject(obj) || isArray(obj)) {
if (ownPropertiesOnly) {
if (_hasOwnProperty.call(obj, j)) {
obj = obj[j]
} else {
return false
}
} else {
if (j in obj) {
obj = obj[j]
} else {
return false
}
}
} else {
return false
}
}
return true
}
it did manage to fix a couple of elses, but somehow left some behind. then it complains:
g:\www\object-path\index.js:37:101: Extra semicolon.
g:\www\object-path\index.js:44:10: Closing curly brace does not appear on the same line as the subsequent block.
Plus it's not removing the semicolon on the ownPropertiesOnly = exports.defaultOptions.ownPropertiesOnly;
Take this code before formatting (generated by Typescript):
after formatting, it becomes:
it did manage to fix a couple of elses, but somehow left some behind. then it complains:
Plus it's not removing the semicolon on the
ownPropertiesOnly = exports.defaultOptions.ownPropertiesOnly;