From e15de7834733e597c8f0cf7a37487fd2e8ddaf9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 9 Jul 2016 14:32:01 +0200 Subject: [PATCH] Update JSHint and fix some some hinting errors. --- .jshintrc | 9 +++++---- package.json | 4 ++-- src/item/Item.js | 3 ++- src/path/Path.js | 29 ++++++++++++++++------------- src/svg/SvgImport.js | 4 ++-- src/view/View.js | 27 ++++++++++++--------------- 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/.jshintrc b/.jshintrc index 5e8108bf..01894348 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,16 +1,17 @@ { + "esversion": 5, "browser": true, "node": true, "wsh": true, "evil": true, - "trailing": false, - "smarttabs": false, - "sub": true, "supernew": true, "laxbreak": true, "eqeqeq": false, "eqnull": true, "loopfunc": true, "boss": true, - "shadow": true + "shadow": true, + "funcscope": false, + "latedef": "nofunc", + "freeze": true } diff --git a/package.json b/package.json index 3f3b0065..2873cab7 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "gulp-util": "^3.0.0", "gulp-webserver": "^0.9.1", "gulp-whitespace": "^0.1.0", - "gulp-zip": "^3.0.2", - "jshint": "2.8.x", + "gulp-zip": "^3.2.0", + "jshint": "^2.9.2", "jshint-summary": "^0.4.0", "merge-stream": "^1.0.0", "prepro": "^2.4.0", diff --git a/src/item/Item.js b/src/item/Item.js index 5e526262..8c56ba7c 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1893,6 +1893,7 @@ new function() { // Injection scope for hit-test functions shared with project || options.class && !(this instanceof options.class)), callback = options.match, that = this, + bounds, res; function match(hit) { @@ -1913,7 +1914,7 @@ new function() { // Injection scope for hit-test functions shared with project if (checkSelf && (options.center || options.bounds) && this._parent) { // Don't get the transformed bounds, check against transformed // points instead - var bounds = this.getInternalBounds(); + bounds = this.getInternalBounds(); if (options.center) { res = checkBounds('center', 'Center'); } diff --git a/src/path/Path.js b/src/path/Path.js index 517720b8..41666fac 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1285,6 +1285,13 @@ var Path = PathItem.extend(/** @lends Path# */{ // NOTE: Documentation is in PathItem#smooth() smooth: function(options) { + var that = this, + opts = options || {}, + type = opts.type || 'asymmetric', + segments = this._segments, + length = segments.length, + closed = this._closed; + // Helper method to pick the right from / to indices. // Supports numbers and segment objects. // For numbers, the `to` index is exclusive, while for segments and @@ -1313,15 +1320,10 @@ var Path = PathItem.extend(/** @lends Path# */{ : index < 0 ? index + length : index, length - 1); } - var that = this, - opts = options || {}, - type = opts.type || 'asymmetric', - segments = this._segments, - length = segments.length, - closed = this._closed, - loop = closed && opts.from === undefined && opts.to === undefined, + var loop = closed && opts.from === undefined && opts.to === undefined, from = getIndex(opts.from, 0), to = getIndex(opts.to, length - 1); + if (from > to) { if (closed) { from -= length; @@ -2048,7 +2050,9 @@ new function() { // Scope for drawing // performance. function drawHandles(ctx, segments, matrix, size) { - var half = size / 2; + var half = size / 2, + coords = new Array(6), + pX, pY; function drawHandle(index) { var hX = coords[index], @@ -2064,13 +2068,12 @@ new function() { // Scope for drawing } } - var coords = new Array(6); for (var i = 0, l = segments.length; i < l; i++) { - var segment = segments[i]; + var segment = segments[i], + selection = segment._selection; segment._transformCoordinates(matrix, coords); - var selection = segment._selection, - pX = coords[0], - pY = coords[1]; + pX = coords[0]; + pY = coords[1]; if (selection & /*#=*/SegmentSelection.HANDLE_IN) drawHandle(2); if (selection & /*#=*/SegmentSelection.HANDLE_OUT) diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index 7a8141e5..8a750375 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -19,7 +19,8 @@ new function() { // objects, dealing with baseVal, and item lists. // index is option, and if passed, causes a lookup in a list. - var rootSize; + var definitions = {}, + rootSize; function getValue(node, name, isString, allowNull, allowPercent) { // Interpret value as number. Never return NaN, but 0 instead. @@ -547,7 +548,6 @@ new function() { return item; } - var definitions = {}; function getDefinition(value) { // When url() comes from a style property, '#'' seems to be missing on // WebKit. We also get variations of quotes or no quotes, single or diff --git a/src/view/View.js b/src/view/View.js index 0cb9446b..278e14bd 100644 --- a/src/view/View.js +++ b/src/view/View.js @@ -1152,7 +1152,18 @@ new function() { // Injection scope for event handling on the browser fallbacks = { doubleclick: 'click', mousedrag: 'mousemove' - }; + }, + // Various variables required by #_handleMouseEvent() + wasInView = false, + overView, + downPoint, + lastPoint, + downItem, + overItem, + dragItem, + clickItem, + clickTime, + dblClick; // Returns true if event was prevented, false otherwise. function emitMouseEvent(obj, target, type, event, point, prevPoint, @@ -1248,20 +1259,6 @@ new function() { // Injection scope for event handling on the browser } }; - /** - * Various variables required by #_handleMouseEvent() - */ - var downPoint, - lastPoint, - downItem, - overItem, - dragItem, - clickItem, - clickTime, - dblClick, - overView, - wasInView = false; - return { _viewEvents: viewEvents,