ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
31 lines (30 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
var ManipulationSettings_1 = require("./../ManipulationSettings");
function fillDefaultFormatCodeSettings(settings, manipulationSettings) {
setValueIfUndefined(settings, "convertTabsToSpaces", manipulationSettings.getIndentationText() !== ManipulationSettings_1.IndentationText.Tab);
setValueIfUndefined(settings, "insertSpaceAfterCommaDelimiter", true);
setValueIfUndefined(settings, "insertSpaceAfterConstructor", false);
setValueIfUndefined(settings, "insertSpaceAfterSemicolonInForStatements", false);
setValueIfUndefined(settings, "insertSpaceAfterKeywordsInControlFlowStatements", true);
setValueIfUndefined(settings, "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", false);
setValueIfUndefined(settings, "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", false);
setValueIfUndefined(settings, "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", false);
setValueIfUndefined(settings, "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces", false);
setValueIfUndefined(settings, "insertSpaceBeforeFunctionParenthesis", false);
setValueIfUndefined(settings, "insertSpaceAfterSemicolonInForStatements", true);
setValueIfUndefined(settings, "insertSpaceBeforeAndAfterBinaryOperators", true);
setValueIfUndefined(settings, "newLineCharacter", manipulationSettings.getNewLineKind());
setValueIfUndefined(settings, "indentStyle", ts.IndentStyle.Smart);
setValueIfUndefined(settings, "indentSize", manipulationSettings.getIndentationText().length);
setValueIfUndefined(settings, "placeOpenBraceOnNewLineForFunctions", false);
setValueIfUndefined(settings, "placeOpenBraceOnNewLineForControlBlocks", false);
setValueIfUndefined(settings, "tabSize", manipulationSettings.getIndentationText().length);
setValueIfUndefined(settings, "ensureNewLineAtEndOfFile", true);
}
exports.fillDefaultFormatCodeSettings = fillDefaultFormatCodeSettings;
function setValueIfUndefined(obj, propertyName, defaultValue) {
if (typeof obj[propertyName] === "undefined")
obj[propertyName] = defaultValue;
}