Skip to content

Commit 0572484

Browse files
committed
Add eslint.
1 parent 59198b6 commit 0572484

26 files changed

+312
-270
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
node_modules/
3+
test/

.eslintrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"parser": "babel-eslint",
4+
"env": {
5+
"browser": true,
6+
"node": true
7+
},
8+
"rules": {
9+
"no-console": 0,
10+
"new-cap": 0,
11+
"strict": 0,
12+
"no-underscore-dangle": 0,
13+
"no-use-before-define": 0,
14+
"eol-last": 0,
15+
"quotes": [2, "single", "avoid-escape"]
16+
}
17+
}

app/app.config.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import startTemplate from './components/start/start.html';
2+
import settingsTemplate from './components/settings/settings.html';
3+
import graphTemplate from './components/graph/graph.html';
4+
15
export default function routing($httpProvider, $routeProvider) {
26

37
// set up http interceptor
@@ -9,19 +13,19 @@ export default function routing($httpProvider, $routeProvider) {
913
$routeProvider
1014
.when('/', {
1115
title: 'Start',
12-
templateUrl: 'components/start/start.html',
16+
template: startTemplate,
1317
controller: 'StartCtrl',
1418
controllerAs: 'start'
1519
})
1620
.when('/settings', {
1721
title: 'Settings',
18-
templateUrl: 'components/settings/settings.html',
22+
template: settingsTemplate,
1923
controller: 'SettingsCtrl',
2024
controllerAs: 'vm'
2125
})
2226
.when('/graph', {
2327
title: 'Graph',
24-
templateUrl: 'components/graph/graph.html',
28+
template: graphTemplate,
2529
controller: 'GraphCtrl',
2630
controllerAs: 'vm'
2731
})

app/app.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import angular from 'angular';
2+
13
// import dependencies
24
import components from './components/components.module';
35
import filters from './filters/index';

app/app.run.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ runBlock.$inject = ['$rootScope'];
22

33
function runBlock($rootScope) {
44

5-
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
5+
$rootScope.$on('$routeChangeSuccess', function (event, current) {
66
$rootScope.title = current.$$route.title;
77
});
88

app/components/graph/graph.ctrl.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ graphCtrl.$inject = ['$scope', '$q', '$log', 'Filters', 'ClassExtractor', 'Rela
66
function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor, TypeExtractor, DetailExtractor,
77
RequestConfig, Requests, Prefixes) {
88

9+
/* jshint validthis: true */
910
var vm = this;
1011

1112
vm.numberOfProps = 5;
@@ -49,7 +50,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
4950
});
5051
};
5152

52-
$scope.$on("pending-requests-changed", function(event, pending) {
53+
$scope.$on('pending-requests-changed', function(event, pending) {
5354
$scope.pendingRequests = pending;
5455
$scope.successfulRequests = Requests.getSuccessfulRequests();
5556
$scope.failedRequests = Requests.getFailedRequests();
@@ -92,7 +93,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
9293
vm.loadLoops = function () {
9394
for (var i = 0; i < vm.classes.length; i++) {
9495
var currentClass = vm.classes[i];
95-
if (currentClass.class !== undefined && currentClass.class.hasOwnProperty("value")) {
96+
if (currentClass.class !== undefined && currentClass.class.hasOwnProperty('value')) {
9697
RelationExtractor.requestClassClassRelation(currentClass.class.value, currentClass);
9798
}
9899
}
@@ -108,7 +109,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
108109

109110
// merge existing and new classes
110111
if (newClasses.length === 0) {
111-
$log.debug("[Graph] No new classes!");
112+
$log.debug('[Graph] No new classes!');
112113
} else {
113114
for (var i = 0; i < newClasses.length; i++) {
114115
vm.classes.push(newClasses[i]);
@@ -125,7 +126,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
125126
// after class equality is checked for all pairs, types and relations can be loaded
126127
$q.allSettled(promises).then(function (data) {
127128

128-
$log.debug("[Graph] Now all should be settled!");
129+
$log.debug('[Graph] Now all should be settled!');
129130

130131
// remove merged class for class list to avoid further request for these classes
131132
for (var i = 0; i < data.length; i++) {
@@ -155,7 +156,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
155156
* Load referring types for each class.
156157
*/
157158
vm.loadTypes = function () {
158-
$log.debug("[Graph] Loading types..." + vm.classes.length);
159+
$log.debug('[Graph] Loading types...' + vm.classes.length);
159160
for (var i = 0; i < vm.classes.length; i++) {
160161
TypeExtractor.requestReferringTypes(vm.classes[i]);
161162
}
@@ -166,7 +167,7 @@ function graphCtrl($scope, $q, $log, Filters, ClassExtractor, RelationExtractor,
166167
*/
167168
vm.loadRelations = function () {
168169

169-
$log.debug("[Graph] Send requests for relations...");
170+
$log.debug('[Graph] Send requests for relations...');
170171

171172
// for each pair of classes search relation and check equality
172173
for (var end = 0; end < vm.classes.length; end++) {

app/components/graph/nodelink-graph.drv.js

+48-48
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
3131
var margin = parseInt(attrs.margin) || 20;
3232
var height = parseInt(attrs.height) || $window.innerHeight;
3333

34-
var colorRange = [d3.rgb("#3366CC"), d3.rgb('#EE2867')];
34+
var colorRange = [d3.rgb('#3366CC'), d3.rgb('#EE2867')];
3535

3636
var defaultRadius = 20;
3737

@@ -41,7 +41,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
4141
.append('svg')
4242
.style('width', '100%');
4343

44-
var root = svg.append("g");
44+
var root = svg.append('g');
4545

4646
var lastUpdate = null;
4747

@@ -77,7 +77,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
7777
'prefixes': Prefixes.getPrefixes(),
7878
'showTypes': Filters.getIncludeLiterals(),
7979
'showLoops': Filters.getIncludeLoops(),
80-
"showDisjointNode": Filters.getIncludeDisjointNode()
80+
'showDisjointNode': Filters.getIncludeDisjointNode()
8181
};
8282

8383
scope.$watch(function () {
@@ -87,7 +87,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
8787
});
8888

8989
scope.$watch('data.nodes.size', function () {
90-
$log.debug("[Graph] Number of nodes has changed!");
90+
$log.debug('[Graph] Number of nodes has changed!');
9191
return scope.render(scope.data);
9292
});
9393

@@ -181,7 +181,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
181181

182182
scope.getMarkerEnd = function (type, value) {
183183
var size = parseInt(Math.min(Math.log2(value + 2), 5));
184-
return "url(#" + type + 'Arrow' + size + ")";
184+
return 'url(#' + type + 'Arrow' + size + ')';
185185
};
186186

187187
scope.calcRadius = function (element) {
@@ -279,33 +279,33 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
279279
* @param linkContainer
280280
*/
281281
scope.createArrowHeads = function (linkContainer) {
282-
linkContainer.append("defs").selectAll("marker")
282+
linkContainer.append('defs').selectAll('marker')
283283
.data(scope.getArrowHeads())
284-
.enter().append("marker")
285-
.attr("id", function (d) {
284+
.enter().append('marker')
285+
.attr('id', function (d) {
286286
return d.id;
287287
})
288-
.attr("class", function (d) {
288+
.attr('class', function (d) {
289289
return d.class;
290290
})
291-
.attr("viewBox", function (d) {
292-
return "-1 " + ((d.size + 1) * (-1)) + " " + ((d.size + 1) * 2) + " " + ((d.size + 1) * 2);
291+
.attr('viewBox', function (d) {
292+
return '-1 ' + ((d.size + 1) * (-1)) + ' ' + ((d.size + 1) * 2) + ' ' + ((d.size + 1) * 2);
293293
})
294-
.attr("refX", function (d) {
294+
.attr('refX', function (d) {
295295
return d.size * 2;
296296
})
297-
.attr("refY", 0)
298-
.attr("markerWidth", function (d) {
297+
.attr('refY', 0)
298+
.attr('markerWidth', function (d) {
299299
return d.size;
300300
})
301-
.attr("markerHeight", function (d) {
301+
.attr('markerHeight', function (d) {
302302
return d.size;
303303
})
304-
.attr("orient", "auto")
305-
.style("stroke", function (d) {
304+
.attr('orient', 'auto')
305+
.style('stroke', function (d) {
306306
return (d.class === 'hovered') ? 'red' : scope.arrowColor(d.size);
307307
})
308-
.style("fill", function (d) {
308+
.style('fill', function (d) {
309309
if (d.class === 'hovered') {
310310
return 'red';
311311
} else if (d.class === 'subclass') {
@@ -314,9 +314,9 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
314314
return scope.arrowColor(d.size);
315315
}
316316
})
317-
.append("path")
318-
.attr("d", function (d) {
319-
return "M0," + (d.size * -1) + "L" + (d.size * 2) + ",0L0," + d.size + "Z";
317+
.append('path')
318+
.attr('d', function (d) {
319+
return 'M0,' + (d.size * -1) + 'L' + (d.size * 2) + ',0L0,' + d.size + 'Z';
320320
});
321321
};
322322

@@ -349,18 +349,18 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
349349
scope.cardinalSpline = d3.svg.line()
350350
.x(function (d) { return (d !== undefined) ? d.x : 0; })
351351
.y(function(d) { return (d !== undefined) ? d.y : 0; })
352-
.interpolate("cardinal");
352+
.interpolate('cardinal');
353353

354354
scope.loopSpline = d3.svg.line()
355355
.x(function (d) { return d.x; })
356356
.y(function (d) { return d.y; })
357-
.interpolate("cardinal")
357+
.interpolate('cardinal')
358358
.tension(0);
359359

360360
scope.linearLine = d3.svg.line()
361361
.x(function (d) { return d.x; })
362362
.y(function (d) { return d.y; })
363-
.interpolate("linear");
363+
.interpolate('linear');
364364

365365
// draw a ring for equivalent classes
366366
nodeContainer.selectAll('.equivalent')
@@ -371,12 +371,12 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
371371
nodeContainer.selectAll('.class')
372372
.append('circle')
373373
.classed('clazz', true)
374-
.attr('r', function (d) { return d.radius + "px"; })
374+
.attr('r', function (d) { return d.radius + 'px'; })
375375
.on('click', scope.updateActive)
376376
.on('mouseover', function () {
377377
d3.select(this).style('fill', 'red');
378378
})
379-
.on('mouseout', function (d) {
379+
.on('mouseout', function () {
380380
d3.select(this).style('fill', '#acf');
381381
})
382382
.append('title')
@@ -487,39 +487,39 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
487487

488488
scope.createArrowHeads(linkContainer);
489489

490-
var links1 = scope.link = linkContainer.selectAll("g.link")
490+
var links1 = scope.link = linkContainer.selectAll('g.link')
491491
.data(bilinks);
492492

493493
var linksG = links1.enter()
494-
.append("g")
495-
.attr("class", "link")
496-
.style("stroke", function (d) { return scope.lineColor(d.value); });
494+
.append('g')
495+
.attr('class', 'link')
496+
.style('stroke', function (d) { return scope.lineColor(d.value); });
497497

498-
scope.link = linksG.append("path")
499-
.attr("class", "link-line")
498+
scope.link = linksG.append('path')
499+
.attr('class', 'link-line')
500500
.classed('subClassProperty', function (d) { return d.type === 'subClassProperty'; });
501501

502502
links1.exit().remove();
503503

504504
linkContainer.selectAll('.link-line')
505-
.attr("marker-end", function(d) { return scope.getMarkerEnd('', d.value); })
506-
.style("stroke-width", function (d) {
505+
.attr('marker-end', function(d) { return scope.getMarkerEnd('', d.value); })
506+
.style('stroke-width', function (d) {
507507
return Math.min(Math.log2(d.value + 2), 5);
508508
})
509509
.on('mouseover', function () {
510-
d3.select(this).attr("stroke", "red");
511-
d3.select(this).attr("marker-end", function (d) { return scope.getMarkerEnd('hovered', d.value); });
510+
d3.select(this).attr('stroke', 'red');
511+
d3.select(this).attr('marker-end', function (d) { return scope.getMarkerEnd('hovered', d.value); });
512512
})
513-
.on("mouseout", function () {
514-
d3.select(this).attr("stroke", function (d) { return scope.lineColor(d.value); });
515-
d3.select(this).attr("marker-end", function (d) { return scope.getMarkerEnd('', d.value); });
513+
.on('mouseout', function () {
514+
d3.select(this).attr('stroke', function (d) { return scope.lineColor(d.value); });
515+
d3.select(this).attr('marker-end', function (d) { return scope.getMarkerEnd('', d.value); });
516516
});
517517

518518
linkContainer.selectAll('.subClassProperty')
519-
.attr("marker-end", function(d) { return scope.getMarkerEnd('subclass', d.value); })
520-
.on("mouseout", function () {
521-
d3.select(this).attr("stroke", function (d) { return scope.lineColor(d.value); });
522-
d3.select(this).attr("marker-end", function (d) { return scope.getMarkerEnd('subclass', d.value); });
519+
.attr('marker-end', function(d) { return scope.getMarkerEnd('subclass', d.value); })
520+
.on('mouseout', function () {
521+
d3.select(this).attr('stroke', function (d) { return scope.lineColor(d.value); });
522+
d3.select(this).attr('marker-end', function (d) { return scope.getMarkerEnd('subclass', d.value); });
523523
})
524524
.style('stroke-dasharray', '5, 5');
525525
};
@@ -530,14 +530,14 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
530530
scope.directLink = linkContainer.selectAll('.direct-link')
531531
.data(directLinks)
532532
.enter()
533-
.append("g")
533+
.append('g')
534534
.style('stroke', '#000')
535-
.append("path")
535+
.append('path')
536536
.style('stroke-width', 1)
537537
.classed('disjointProperty', function (d) { return d.type === 'disjointProperty'; });
538538

539539
linkContainer.selectAll('.disjointProperty')
540-
.attr("marker-end", 'none')
540+
.attr('marker-end', 'none')
541541
.style('stroke-dasharray', '5, 5');
542542
};
543543

@@ -628,7 +628,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
628628
var zoom = d3.behavior.zoom()
629629
.duration(150)
630630
.scaleExtent([0.1,2.0])
631-
.on("zoom", scope.redraw);
631+
.on('zoom', scope.redraw);
632632
svg.call(zoom);
633633

634634
scope.maxValue = 0;
@@ -773,7 +773,7 @@ function NodeLinkGraph($window, $log, Properties, Nodes, Prefixes, Filters, Geom
773773
scope.force.on('tick', function() {
774774
scope.link.attr('d', scope.recalculateLines);
775775
scope.directLink.attr('d', scope.recalculateDirectLines);
776-
scope.node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
776+
scope.node.attr('transform', function(d) { return 'translate(' + d.x + ',' + d.y + ')'; });
777777
});
778778
}; // end of scope.render()
779779
} // end of link()

app/components/settings/settings.ctrl.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ settingsCtrl.$inject = ['PREFIX', 'PROPERTY_BLACKLIST', 'CLASS_BLACKLIST', 'Requ
77
function settingsCtrl(PREFIX, PROPERTY_BLACKLIST, CLASS_BLACKLIST, RequestConfig, Nodes, Properties, Requests,
88
ClassExtractor, RelationExtractor) {
99

10+
/* jshint validthis: true */
1011
var vm = this;
1112

1213
//TODO move default settings into a constant
1314
vm.currentLanguage = RequestConfig.getLabelLanguage() || 'en';
1415
vm.currentLimit = RequestConfig.getLimit();
1516

16-
vm.langPreferences = "en, de";
17+
vm.langPreferences = 'en, de';
1718

1819
vm.propsOrdered = true;
1920

2021
vm.propertyBlacklistInput = '';
2122
vm.classBlacklistInput = '';
2223

23-
vm.separator = ", \n";
24+
vm.separator = ', \n';
2425

2526
vm.initialize = function () {
2627
var classItems = ClassExtractor.getBlacklist();
@@ -45,7 +46,7 @@ function settingsCtrl(PREFIX, PROPERTY_BLACKLIST, CLASS_BLACKLIST, RequestConfig
4546
*/
4647
vm.save = function () {
4748

48-
var input = vm.propertyBlacklistInput.replace(/(\r\n|\n|\r|\s)/gm,"");
49+
var input = vm.propertyBlacklistInput.replace(/(\r\n|\n|\r|\s)/gm,'');
4950
var items = input.split(',');
5051

5152
// update blacklist in extractor

0 commit comments

Comments
 (0)