]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Implement eslint changes proposed by @simonbrunel in code review 3308/head
authorZach Panzarino <zachary@panzarino.com>
Thu, 15 Sep 2016 12:49:11 +0000 (12:49 +0000)
committerZach Panzarino <zachary@panzarino.com>
Thu, 15 Sep 2016 12:49:11 +0000 (12:49 +0000)
.eslintrc
src/core/core.helpers.js
src/core/core.js
src/core/core.layoutService.js

index 7cae49e41578b188f4a24b7fc45895b0a7a6e992..991867f10ff7caea2d9115be7ae1526d327cd016 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -13,7 +13,7 @@ env:
 rules:
   # Possible Errors
   no-cond-assign: 2
-  no-console: 1
+  no-console: [2, {allow: [warn, error]}]
   no-constant-condition: 2
   no-control-regex: 2
   no-debugger: 2
@@ -112,7 +112,7 @@ rules:
   no-undef: 2
   no-undefined: 0
   no-unused-vars: 2
-  no-use-before-define: 1
+  no-use-before-define: 2
 
   # Node.js and CommonJS
   callback-return: 2
@@ -130,7 +130,7 @@ rules:
   block-spacing: 0
   brace-style: [2, 1tbs]
   camelcase: 2
-  comma-dangle: [2, never]
+  comma-dangle: [2, only-multiline]
   comma-spacing: 2
   comma-style: [2, last]
   computed-property-spacing: [2, never]
@@ -188,7 +188,7 @@ rules:
   operator-linebreak: 0
   padded-blocks: 0
   quote-props: [2, as-needed]
-  quotes: [2, single]
+  quotes: [2, single, {avoidEscape: true}]
   require-jsdoc: 0
   semi-spacing: 2
   semi: [2, always]
index 1593b72de0477e495c8a0272cfb6fdccc3b78af8..5364d191f8efafcfa21d1746f9619ee27ebe5163 100644 (file)
@@ -945,7 +945,7 @@ module.exports = function(Chart) {
        };
        helpers.color = function(c) {
                if (!color) {
-                       console.log('Color.js not found!');
+                       console.error('Color.js not found!');
                        return c;
                }
 
index c4f65e5cacd0295bc5c96e01d242243b6f27cc5d..577db878e16b2e69586bcde7b8729484b9a7359f 100755 (executable)
@@ -77,7 +77,7 @@ module.exports = function() {
                        onClick: null,
                        defaultColor: 'rgba(0,0,0,0.1)',
                        defaultFontColor: '#666',
-                       defaultFontFamily: '\'Helvetica Neue\', \'Helvetica\', \'Arial\', sans-serif',
+                       defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
                        defaultFontSize: 12,
                        defaultFontStyle: 'normal',
                        showLines: true,
index 1bb06fcf3654343a6ddbc425de7c78456f793921..7336deac0d24f3c3db6950a80030aced3d31bd15 100644 (file)
@@ -115,8 +115,6 @@ module.exports = function(Chart) {
                        var maxChartAreaHeight = chartHeight;
                        var minBoxSizes = [];
 
-                       helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
-
                        function getMinimumBoxSize(box) {
                                var minSize;
                                var isHorizontal = box.isHorizontal();
@@ -136,6 +134,8 @@ module.exports = function(Chart) {
                                });
                        }
 
+                       helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
+
                        // At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
                        // be if the axes are drawn at their minimum sizes.
 
@@ -145,20 +145,6 @@ module.exports = function(Chart) {
                        var totalTopBoxesHeight = yPadding;
                        var totalBottomBoxesHeight = yPadding;
 
-                       // Update, and calculate the left and right margins for the horizontal boxes
-                       helpers.each(leftBoxes.concat(rightBoxes), fitBox);
-
-                       helpers.each(leftBoxes, function(box) {
-                               totalLeftBoxesWidth += box.width;
-                       });
-
-                       helpers.each(rightBoxes, function(box) {
-                               totalRightBoxesWidth += box.width;
-                       });
-
-                       // Set the Left and Right margins for the horizontal boxes
-                       helpers.each(topBoxes.concat(bottomBoxes), fitBox);
-
                        // Function to fit a box
                        function fitBox(box) {
                                var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minBox) {
@@ -183,6 +169,20 @@ module.exports = function(Chart) {
                                }
                        }
 
+                       // Update, and calculate the left and right margins for the horizontal boxes
+                       helpers.each(leftBoxes.concat(rightBoxes), fitBox);
+
+                       helpers.each(leftBoxes, function(box) {
+                               totalLeftBoxesWidth += box.width;
+                       });
+
+                       helpers.each(rightBoxes, function(box) {
+                               totalRightBoxesWidth += box.width;
+                       });
+
+                       // Set the Left and Right margins for the horizontal boxes
+                       helpers.each(topBoxes.concat(bottomBoxes), fitBox);
+
                        // Figure out how much margin is on the top and bottom of the vertical boxes
                        helpers.each(topBoxes, function(box) {
                                totalTopBoxesHeight += box.height;
@@ -192,9 +192,6 @@ module.exports = function(Chart) {
                                totalBottomBoxesHeight += box.height;
                        });
 
-                       // Let the left layout know the final margin
-                       helpers.each(leftBoxes.concat(rightBoxes), finalFitVerticalBox);
-
                        function finalFitVerticalBox(box) {
                                var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minSize) {
                                        return minSize.box === box;
@@ -212,6 +209,9 @@ module.exports = function(Chart) {
                                }
                        }
 
+                       // Let the left layout know the final margin
+                       helpers.each(leftBoxes.concat(rightBoxes), finalFitVerticalBox);
+
                        // Recalculate because the size of each layout might have changed slightly due to the margins (label rotation for instance)
                        totalLeftBoxesWidth = xPadding;
                        totalRightBoxesWidth = xPadding;
@@ -268,15 +268,6 @@ module.exports = function(Chart) {
                        var left = xPadding;
                        var top = yPadding;
 
-                       helpers.each(leftBoxes.concat(topBoxes), placeBox);
-
-                       // Account for chart width and height
-                       left += maxChartAreaWidth;
-                       top += maxChartAreaHeight;
-
-                       helpers.each(rightBoxes, placeBox);
-                       helpers.each(bottomBoxes, placeBox);
-
                        function placeBox(box) {
                                if (box.isHorizontal()) {
                                        box.left = box.options.fullWidth ? xPadding : totalLeftBoxesWidth;
@@ -299,6 +290,15 @@ module.exports = function(Chart) {
                                }
                        }
 
+                       helpers.each(leftBoxes.concat(topBoxes), placeBox);
+
+                       // Account for chart width and height
+                       left += maxChartAreaWidth;
+                       top += maxChartAreaHeight;
+
+                       helpers.each(rightBoxes, placeBox);
+                       helpers.each(bottomBoxes, placeBox);
+
                        // Step 8
                        chartInstance.chartArea = {
                                left: totalLeftBoxesWidth,