From 4c763bff44345ff5bbf2acc97cbce8918fa5b055 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sat, 22 Jul 2017 14:13:09 +0200 Subject: [PATCH] Enforce spaces around infix/unary words operators (#4547) Enable ESLint `space-infix-ops` and `space-unary-ops` (for words only) rules. Also added `samples` to the linting task to match Code Climate expectations. http://eslint.org/docs/rules/space-infix-ops http://eslint.org/docs/rules/space-unary-ops --- .eslintrc | 4 ++-- gulpfile.js | 10 ++++---- samples/charts/area/analyser.js | 2 +- samples/utils.js | 16 ++++++------- src/controllers/controller.bar.js | 18 +++++++------- src/controllers/controller.line.js | 6 ++--- src/core/core.animation.js | 2 +- src/core/core.controller.js | 14 +++++------ src/core/core.datasetController.js | 10 ++++---- src/core/core.element.js | 6 ++--- src/core/core.helpers.js | 22 ++++++++--------- src/core/core.layoutService.js | 4 ++-- src/core/core.plugin.js | 2 +- src/core/core.scale.js | 14 +++++------ src/elements/element.point.js | 8 +++---- src/elements/element.rectangle.js | 14 +++++------ src/helpers/helpers.canvas.js | 12 +++++----- src/helpers/helpers.core.js | 16 ++++++------- src/helpers/helpers.options.js | 2 +- src/helpers/helpers.time.js | 4 ++-- src/platforms/platform.dom.js | 32 ++++++++++++------------- src/plugins/plugin.filler.js | 32 ++++++++++++------------- src/plugins/plugin.legend.js | 2 +- src/plugins/plugin.title.js | 2 +- src/scales/scale.logarithmic.js | 4 ++-- src/scales/scale.radialLinear.js | 2 +- src/scales/scale.time.js | 8 +++---- test/jasmine.matchers.js | 10 ++++---- test/jasmine.utils.js | 4 ++-- test/specs/controller.bubble.tests.js | 2 +- test/specs/core.controller.tests.js | 2 +- test/specs/global.deprecations.tests.js | 4 ++-- test/specs/helpers.core.tests.js | 2 +- test/specs/helpers.easing.tests.js | 4 ++-- test/specs/platform.dom.tests.js | 2 +- 35 files changed, 149 insertions(+), 149 deletions(-) diff --git a/.eslintrc b/.eslintrc index fdf1951dd66..aa4cdbb3b71 100644 --- a/.eslintrc +++ b/.eslintrc @@ -197,8 +197,8 @@ rules: space-before-blocks: [2, always] space-before-function-paren: [2, never] space-in-parens: [2, never] - space-infix-ops: 0 - space-unary-ops: 0 + space-infix-ops: 2 + space-unary-ops: [2, {words: true, nonwords: false}] spaced-comment: [2, always] unicode-bom: 0 wrap-regex: 2 diff --git a/gulpfile.js b/gulpfile.js index ff3cce5b655..2ae49d77d05 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,7 +23,6 @@ var package = require('./package.json'); var srcDir = './src/'; var outDir = './dist/'; -var testDir = './test/'; var header = "/*!\n" + " * Chart.js\n" + @@ -128,8 +127,9 @@ function packageTask() { function lintTask() { var files = [ - srcDir + '**/*.js', - testDir + '**/*.js' + 'samples/**/*.js', + 'src/**/*.js', + 'test/**/*.js' ]; // NOTE(SB) codeclimate has 'complexity' and 'max-statements' eslint rules way too strict @@ -174,8 +174,8 @@ function startTest() { './test/jasmine.index.js', './src/**/*.js', ].concat( - argv.inputs? - argv.inputs.split(';'): + argv.inputs ? + argv.inputs.split(';') : ['./test/specs/**/*.js'] ); } diff --git a/samples/charts/area/analyser.js b/samples/charts/area/analyser.js index f9d001af57e..e4ed8e90b24 100644 --- a/samples/charts/area/analyser.js +++ b/samples/charts/area/analyser.js @@ -20,7 +20,7 @@ return; } - for (i=0, ilen=datasets.length; i= 0; --i) { + for (var i = (me.data.datasets || []).length - 1; i >= 0; --i) { if (me.isDatasetVisible(i)) { me.drawDataset(i, easingValue); } @@ -652,7 +652,7 @@ module.exports = function(Chart) { getVisibleDatasetCount: function() { var count = 0; - for (var i = 0, ilen = this.data.datasets.length; i