Browse Source

chore(lint): added support for eslint (#2695)

timelineLocalsFrEs
AoDev 7 years ago
committed by Alexander Wunschik
parent
commit
e6ed962238
8 changed files with 34 additions and 14 deletions
  1. +22
    -2
      .eslintrc
  2. +1
    -0
      .travis.yml
  3. +4
    -6
      lib/graph3d/Graph3d.js
  4. +0
    -1
      lib/network/modules/LayoutEngine.js
  5. +0
    -1
      lib/timeline/DateUtil.js
  6. +2
    -2
      lib/timeline/component/ItemSet.js
  7. +2
    -2
      lib/timeline/component/item/Item.js
  8. +3
    -0
      package.json

+ 22
- 2
.eslintrc View File

@ -1,6 +1,26 @@
{ {
"env": {
"browser": true,
"es6": true,
"node": true,
"mocha": true
},
"parser": "babel-eslint",
"extends": "eslint:recommended",
"rules": { "rules": {
"complexity": [2, 50],
"max-statements": [2, 100]
"complexity": [2, 55],
"max-statements": [2, 115],
"no-console": 0,
"no-empty": 0,
"no-extra-semi": 0,
"no-fallthrough": 0,
"no-inner-declarations": 0,
"no-mixed-spaces-and-tabs": 0,
"no-redeclare": 0,
"no-unreachable": 1,
"no-unused-vars": 0,
} }
} }

+ 1
- 0
.travis.yml View File

@ -1,6 +1,7 @@
language: node_js language: node_js
node_js: "6" node_js: "6"
before_script: before_script:
- npm run lint
- npm install -g gulp - npm install -g gulp
script: script:
- gulp - gulp

+ 4
- 6
lib/graph3d/Graph3d.js View File

@ -12,13 +12,13 @@ var Settings = require('./Settings');
/// enumerate the available styles /// enumerate the available styles
Graph3d.STYLE = Settings.STYLE;
Graph3d.STYLE = Settings.STYLE;
/** /**
* Following label is used in the settings to describe values which should be * Following label is used in the settings to describe values which should be
* determined by the code while running, from the current data and graph style. * determined by the code while running, from the current data and graph style.
*
*
* Using 'undefined' directly achieves the same thing, but this is more * Using 'undefined' directly achieves the same thing, but this is more
* descriptive by describing the intent. * descriptive by describing the intent.
*/ */
@ -524,7 +524,7 @@ Graph3d.prototype._dataInitialize = function (rawData, style) {
} }
} }
// set the scale dependent on the ranges. // set the scale dependent on the ranges.
this._setScale(); this._setScale();
}; };
@ -699,7 +699,6 @@ Graph3d.prototype.create = function () {
var onclick = function(event) {me._onClick(event);}; var onclick = function(event) {me._onClick(event);};
// TODO: these events are never cleaned up... can give a 'memory leakage' // TODO: these events are never cleaned up... can give a 'memory leakage'
util.addEventListener(this.frame.canvas, 'keydown', onkeydown);
util.addEventListener(this.frame.canvas, 'mousedown', onmousedown); util.addEventListener(this.frame.canvas, 'mousedown', onmousedown);
util.addEventListener(this.frame.canvas, 'touchstart', ontouchstart); util.addEventListener(this.frame.canvas, 'touchstart', ontouchstart);
util.addEventListener(this.frame.canvas, 'mousewheel', onmousewheel); util.addEventListener(this.frame.canvas, 'mousewheel', onmousewheel);
@ -902,7 +901,6 @@ Graph3d.prototype.setPointDrawingMethod = function() {
default: default:
throw new Error('Can not determine point drawing method ' throw new Error('Can not determine point drawing method '
+ 'for graph style \'' + this.style + '\''); + 'for graph style \'' + this.style + '\'');
break;
} }
this._pointDrawingMethod = method; this._pointDrawingMethod = method;
@ -1338,7 +1336,7 @@ Graph3d.prototype._redrawAxis = function() {
if (this.showYAxis) { if (this.showYAxis) {
xText = (armVector.y > 0) ? xRange.min : xRange.max; xText = (armVector.y > 0) ? xRange.min : xRange.max;
point3d = new Point3d(xText, y, zRange.min); point3d = new Point3d(xText, y, zRange.min);
var msg = ' ' + this.yValueLabel(y) + ' ';
var msg = ' ' + this.yValueLabel(y) + ' ';
this.drawAxisLabelY(ctx, point3d, msg, armAngle, textMargin); this.drawAxisLabelY(ctx, point3d, msg, armAngle, textMargin);
} }

+ 0
- 1
lib/network/modules/LayoutEngine.js View File

@ -327,7 +327,6 @@ class LayoutEngine {
// if the user defined some levels but not all, alert and run without hierarchical layout // if the user defined some levels but not all, alert and run without hierarchical layout
if (undefinedLevel === true && definedLevel === true) { if (undefinedLevel === true && definedLevel === true) {
throw new Error('To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.'); throw new Error('To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.');
return;
} }
else { else {
// define levels if undefined by the users. Based on hubsize. // define levels if undefined by the users. Based on hubsize.

+ 0
- 1
lib/timeline/DateUtil.js View File

@ -500,7 +500,6 @@ exports.isHidden = function(time, hiddenDates) {
if (time >= startDate && time < endDate) { // if the start is entering a hidden zone if (time >= startDate && time < endDate) { // if the start is entering a hidden zone
return {hidden: true, startDate: startDate, endDate: endDate}; return {hidden: true, startDate: startDate, endDate: endDate};
break;
} }
} }
return {hidden: false, startDate: startDate, endDate: endDate}; return {hidden: false, startDate: startDate, endDate: endDate};

+ 2
- 2
lib/timeline/component/ItemSet.js View File

@ -1828,8 +1828,8 @@ ItemSet.prototype._onGroupDragEnd = function (event) {
var switchGroup = dataset.get(newOrder[curPos]); var switchGroup = dataset.get(newOrder[curPos]);
var shouldBeGroup = dataset.get(origOrder[curPos]); var shouldBeGroup = dataset.get(origOrder[curPos]);
me.options.groupOrderSwap(switchGroup, shouldBeGroup, dataset); me.options.groupOrderSwap(switchGroup, shouldBeGroup, dataset);
groupsData.update(switchGroup);
groupsData.update(shouldBeGroup);
dataset.update(switchGroup);
dataset.update(shouldBeGroup);
var switchGroupId = newOrder[curPos]; var switchGroupId = newOrder[curPos];
newOrder[curPos] = origOrder[curPos]; newOrder[curPos] = origOrder[curPos];

+ 2
- 2
lib/timeline/component/item/Item.js View File

@ -18,7 +18,7 @@ function Item (data, conversion, options) {
this.data = data; this.data = data;
this.dom = null; this.dom = null;
this.conversion = conversion || {}; this.conversion = conversion || {};
this.options = options || {};
this.options = options || {};
this.selected = false; this.selected = false;
this.displayed = false; this.displayed = false;
this.groupShowing = true; this.groupShowing = true;
@ -85,7 +85,7 @@ Item.prototype.setData = function(data) {
remove: this.data.editable remove: this.data.editable
} }
} }
else if(typeof options.editable === 'object') {
else if(typeof this.options.editable === 'object') {
this.editable = {}; this.editable = {};
util.selectiveExtend(['updateTime', 'updateGroup', 'remove'], this.editable, data.editable); util.selectiveExtend(['updateTime', 'updateGroup', 'remove'], this.editable, data.editable);
} }

+ 3
- 0
package.json View File

@ -25,6 +25,7 @@
"scripts": { "scripts": {
"test": "mocha", "test": "mocha",
"build": "gulp", "build": "gulp",
"lint": "eslint lib",
"watch": "gulp watch", "watch": "gulp watch",
"watch-dev": "gulp watch --bundle" "watch-dev": "gulp watch --bundle"
}, },
@ -45,8 +46,10 @@
}, },
"devDependencies": { "devDependencies": {
"async": "^2.1.4", "async": "^2.1.4",
"babel-eslint": "^7.1.1",
"babelify": "^7.3.0", "babelify": "^7.3.0",
"clean-css": "^4.0.2", "clean-css": "^4.0.2",
"eslint": "^3.15.0",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-clean-css": "^2.3.2", "gulp-clean-css": "^2.3.2",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",

Loading…
Cancel
Save