From c33e255182e8d0fb0a446634b6dc68075e931d8f Mon Sep 17 00:00:00 2001 From: Colin Eberhardt Date: Mon, 5 Oct 2015 13:18:27 +0100 Subject: [PATCH] Enforced quote style and indentation --- .eslintrc | 6 +++--- src/CSharpTranspiler.js | 22 +++++++++++----------- src/JavaTranspiler.js | 10 +++++----- src/css-layout.js | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7d85b783..e379dfe7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -106,7 +106,7 @@ "no-undef-init": 2, "no-undef": 0, "no-undefined": 0, - "no-unused-vars": 0, + "no-unused-vars": 2, "no-use-before-define": 0, "handle-callback-err": 2, "no-mixed-requires": 2, @@ -123,7 +123,7 @@ "eol-last": 2, "func-names": 0, "func-style": 0, - "indent": 0, + "indent": [2, 2, {"SwitchCase": 1}], "key-spacing": 2, "linebreak-style": 2, "new-cap": 2, @@ -148,7 +148,7 @@ "operator-linebreak": 0, "padded-blocks": 0, "quote-props": 0, - "quotes": 0, + "quotes": [2, "single"], "semi-spacing": 2, "semi": 0, "sort-vars": 0, diff --git a/src/CSharpTranspiler.js b/src/CSharpTranspiler.js index 7aa3e0a7..d2576f55 100644 --- a/src/CSharpTranspiler.js +++ b/src/CSharpTranspiler.js @@ -57,7 +57,7 @@ function __transpileToCSharpCommon(code) { .replace(/(CSSConstants|CSSWrap|CSSJustify|CSSAlign|CSSPositionType)\.([_A-Z]+)/g, function (str, match1, match2) { - return match1 + "." + constantToPascalCase(match2); + return match1 + '.' + constantToPascalCase(match2); }); } @@ -71,33 +71,33 @@ function __transpileSingleTestToCSharp(code) { /(style|layout)\.position\[CSS_(LEFT|TOP|RIGHT|BOTTOM)\]/g, function (str, match1, match2) { return match1 + '.position[POSITION_' + match2 + ']'; - }) + }) .replace( // style.dimensions[CSS_WIDTH] => style.dimensions[CSSLayout.DIMENSION_WIDTH] /(style|layout)\.dimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.dimensions[DIMENSION_' + match2 + ']'; - }) + }) .replace( // style.maxDimensions[CSS_WIDTH] => style.maxWidth /(style|layout)\.maxDimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.max' + match2.substr(0, 1).toUpperCase() + match2.substr(1).toLowerCase(); - }) + }) .replace( // style.minDimensions[CSS_WIDTH] => style.minWidth /(style|layout)\.minDimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.min' + match2.substr(0, 1).toUpperCase() + match2.substr(1).toLowerCase(); - }) + }) .replace( // style.margin[CSS_TOP] = 12.3 => style.margin[Spacing.TOP].set(12.3) /style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT|START|END)\]\s+=\s+(-?[\.\d]+)/g, function (str, match1, match2, match3) { var propertyCap = match1.charAt(0).toUpperCase() + match1.slice(1); return 'set' + propertyCap + '(Spacing.' + match2 + ', ' + match3 + ')'; - }) + }) .replace( // style.margin[CSS_TOP] => style.margin[Spacing.TOP] /style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT|START|END)\]/g, function (str, match1, match2) { return 'style.' + match1 + '.get(Spacing.' + match2 + ')'; - }) + }) .replace(/get_child\(.*context\,\s([^\)]+)\)/g, 'getChildAt($1)') .replace(/init_css_node_children/g, 'addChildren') .replace(/css_node_t(\s)\*/g, 'TestCSSNode$1') @@ -107,14 +107,14 @@ function __transpileSingleTestToCSharp(code) { /style\.([^_\[\]\s]+)_(\w)(\w+)/g, function (str, match1, match2, match3) { return 'style.' + match1 + match2.toUpperCase() + match3; - }) + }) .replace(/(\w+)\.measure\s+=\s+.+/, '$1.setMeasureFunction(sTestMeasureFunction);') // additional case conversions .replace(/(CSSWrap|CSSFlexDirection)\.([_A-Z]+)/g, function (str, match1, match2) { - return match1 + "." + constantToPascalCase(match2); + return match1 + '.' + constantToPascalCase(match2); }); } @@ -162,8 +162,8 @@ var CSharpTranspiler = { var allTestsInCSharp = []; for (var i = 0; i < allTestsInC.length; i++) { allTestsInCSharp[i] = - " [Test]\n" + - " public void TestCase" + i + "()\n" + + ' [Test]\n' + + ' public void TestCase' + i + '()\n' + __transpileSingleTestToCSharp(allTestsInC[i]); } return allTestsInCSharp.join('\n\n'); diff --git a/src/JavaTranspiler.js b/src/JavaTranspiler.js index bf528424..b7f2d212 100644 --- a/src/JavaTranspiler.js +++ b/src/JavaTranspiler.js @@ -64,22 +64,22 @@ function __transpileSingleTestToJava(code) { /(style|layout)\.position\[CSS_(LEFT|TOP|RIGHT|BOTTOM)\]/g, function (str, match1, match2) { return match1 + '.position[POSITION_' + match2 + ']'; - }) + }) .replace( // style.dimensions[CSS_WIDTH] => style.dimensions[CSSLayout.DIMENSION_WIDTH] /(style|layout)\.dimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.dimensions[DIMENSION_' + match2 + ']'; - }) + }) .replace( // style.maxDimensions[CSS_WIDTH] => style.maxWidth /(style|layout)\.maxDimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.max' + match2.substr(0, 1).toUpperCase() + match2.substr(1).toLowerCase(); - }) + }) .replace( // style.minDimensions[CSS_WIDTH] => style.minWidth /(style|layout)\.minDimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { return match1 + '.min' + match2.substr(0, 1).toUpperCase() + match2.substr(1).toLowerCase(); - }) + }) .replace( // style.margin[CSS_TOP] = 12.3 => style.margin[Spacing.TOP].set(12.3) /style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT|START|END)\]\s+=\s+(-?[\.\d]+)/g, function (str, match1, match2, match3) { @@ -100,7 +100,7 @@ function __transpileSingleTestToJava(code) { /style\.([^_\[\]\s]+)_(\w)(\w+)/g, function (str, match1, match2, match3) { return 'style.' + match1 + match2.toUpperCase() + match3; - }) + }) .replace(/(\w+)\.measure\s+=\s+.+/, '$1.setMeasureFunction(sTestMeasureFunction);'); } diff --git a/src/css-layout.js b/src/css-layout.js index 46f37b10..bfa5c74f 100644 --- a/src/css-layout.js +++ b/src/css-layout.js @@ -22,5 +22,5 @@ return function(node) { computeLayout.fillNodes(node); computeLayout.computeLayout(node); - }; -})); + }; + }));