Skip to content

Commit

Permalink
Added eslint, jshint config. Fixes #99
Browse files Browse the repository at this point in the history
WIP #99 Updated code style violations
  • Loading branch information
brollb committed May 26, 2016
1 parent 289277a commit e7d5545
Show file tree
Hide file tree
Showing 33 changed files with 208 additions and 226 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/common/lua.js
src/visualizers/widgets/TextEditor/lib/*
src/common/js-yaml.min.js
src/visualizers/Visualizers.json
18 changes: 18 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
env:
browser: true
mocha: true
es6: true
extends: 'eslint:recommended'
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esversion": 6
}
38 changes: 11 additions & 27 deletions src/common/GraphChecker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals define */
define([
'deepforge/js-yaml.min'
], function(
Expand Down Expand Up @@ -148,28 +149,11 @@ define([

GraphChecker.prototype = new Importer();

// Check if two models are isomorphic
var modelMatches = function(gmeNodes, text) {
var nodes = convertNodes(gmeNodes),
soln = yaml.load(text);

nodes.concat(soln).forEach(node => {
node.next = node.next || [];
node.attributes = node.attributes || {};
});

return _modelMatches(nodes, soln);
};

//////////////// Operators ////////////////
// Check if two models are isomorphic
var _modelMatches = function(soln, nodes) {
var nodeMap = createMap(nodes),
solnMap = createMap(soln),
sInits, // soln start nodes
nInits, // 'nodes' start nodes
resMap = {}, // soln node id to node id
solnIds = soln.map(n => n.id),
nodeIds = nodes.map(n => n.id);
solnMap = createMap(soln);

if (nodes.length !== soln.length) {
return false;
Expand All @@ -187,8 +171,7 @@ define([
};

var getMostConstrained = function(soln, nodes) {
var options = soln.map(sn => [sn, nodes.filter(n => nodesMatch(sn, n))]),
startId;
var options = soln.map(sn => [sn, nodes.filter(n => nodesMatch(sn, n))]);

options.sort((a, b) => b[1].length < a[1].length);
return options[0];
Expand All @@ -199,8 +182,7 @@ define([
nodes = Object.keys(nodeMap).map(id => nodeMap[id]),
snode = solnMap[id],
options,
used,
node;
used;

mappings = mappings || {};

Expand Down Expand Up @@ -247,14 +229,16 @@ define([
snext.push(startId);
}

var inferNext = (prev, curr) => {
mappings2 = inferGraph(curr, solnMap, nodeMap, mappings2);
return prev && mappings;
};

for (var i = options.length; i--;) {
mappings[id] = options[i].id; // need to clone the object

mappings2 = clone(mappings);
result = snext.reduce((prev, curr) => {
mappings2 = inferGraph(curr, solnMap, nodeMap, mappings2);
return prev && mappings;
}, true);
result = snext.reduce(inferNext, true);

if (result) {
return mappings2;
Expand Down
2 changes: 1 addition & 1 deletion src/common/layer-args.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals define*/
define([
], function(
) {
Expand Down Expand Up @@ -25,7 +26,6 @@ define([
var createLayerDict = function(core, meta) {
var node,
names = Object.keys(meta),
attributes,
layers = {};

for (var i = names.length; i--;) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ define([

_.extend(OperationDecorator.prototype, DecoratorBase.prototype);

OperationDecorator.prototype.DECORATOR_ID = DECORATOR_ID;
OperationDecorator.prototype.expand = function() {
DecoratorBase.prototype.expand.call(this);
// Add the ports for data inputs/outputs
Expand All @@ -36,7 +37,7 @@ define([
//var outputs = this._node.outputs;
};

OperationDecorator.prototype._highlightPort = function(name) {
OperationDecorator.prototype._highlightPort = function(/*name*/) {
// Highlight port with the given name
// TODO
};
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/CreateExecution/CreateExecution.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ define([
}

return this.createExecution(this.activeNode)
.then(node => {
.then(() => {
this.result.setSuccess(true);
callback(null, this.result);
})
Expand Down Expand Up @@ -103,7 +103,7 @@ define([
);
})
.then(() => { // datamapping is set!
this.updateReferences(copies, dataMapping)
this.updateReferences(copies, dataMapping);
this.boxOperations(opTuples.map(o => o[0]), tgtNode);
return this.save(`Created execution of ${name}`);
})
Expand Down Expand Up @@ -152,8 +152,7 @@ define([
CreateExecution.prototype.sortIOByName = function (container) {
return container.sort((a, b) =>
// sort by name
this.core.getAttribute(a, 'name') < this.core.getAttribute(b, 'name')
? 1 : -1
this.core.getAttribute(a, 'name') < this.core.getAttribute(b, 'name') ? 1 : -1
);
};

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/CreateTorchMeta/CreateTorchMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ define([
CreateTorchMeta.prototype.main = function (callback) {
// Use self to access core, project, result, logger etc from PluginBase.
// These are all instantiated at this point.
var self = this,
nodeObject;
var self = this;

if (!this.META.Language) {
callback('"Language" container required to run plugin', this.result);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ExecutePipeline/Templates.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*globals define*/
define([
'text!./entry.ejs',
'text!./main.ejs',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/GenerateArchitecture/GenerateArchitecture.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
for (var i = 0; i < layers.length; i++) {
if (layers[i][Constants.NEXT].length > 1) {
// no support for
console.error('No support for parallel layers... yet');
this.logger.error('No support for parallel layers... yet');
break;
} else {
// args
Expand Down
1 change: 1 addition & 0 deletions src/plugins/GenerateArchitecture/dimensionality.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals define */
define([
'SimpleNodes/Constants',
'deepforge/lua'
Expand Down
18 changes: 7 additions & 11 deletions src/plugins/ImportTorch/nn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals define */
// This is the searcher for the mock library
define([
'deepforge/layer-args',
Expand All @@ -10,10 +11,10 @@ define([
) {
'use strict';

var nop = function() {};
var createSearcher = function(plugin) {
var core = plugin.core,
META = plugin.META,
logger = plugin.logger.fork('nn'),
parent = plugin.tgtNode,
LayerDict = createLayerDict(core, META);

Expand Down Expand Up @@ -41,8 +42,7 @@ define([
};

Layer.prototype._node = function() {
var attrs = this._attrs,
name,
var name,
node,
value;

Expand Down Expand Up @@ -83,20 +83,19 @@ define([
this._outputs = [];
};

Container.prototype.add = function(self, tlayer) {
console.error('Add is not overridden!');
Container.prototype.add = function() {
logger.error('Add is not overridden!');
};

var Sequential = function(attrs, args) {
var Sequential = function(/*attrs, args*/) {
Container.call(this);
};

Sequential.prototype = new Container();

Sequential.prototype.add = function(self, tlayer) {
var layer = tlayer.get('_node'),
nodes = layer._inputs,
conn;
nodes = layer._inputs;

// If this._inputs is empty, add the layer to the inputs list
if (this._inputs.length === 0) { // first node
Expand Down Expand Up @@ -146,15 +145,12 @@ define([
var CreateLayer = function(type) {
var res = luajs.newContext()._G,
attrs = [].slice.call(arguments, 1),
proto,
node;

if (LAYERS[type]) {
node = new LAYERS[type](LayerDict[type] || [], attrs);
proto = LAYERS[type].prototype;
} else { // Call generic Layer with type name
node = new Layer(type, LayerDict[type] || [], attrs);
proto = Layer.prototype;
}

res.set('_node', node);
Expand Down
86 changes: 43 additions & 43 deletions src/visualizers/Visualizers.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
[
{
"id": "AutoViz",
"title": "AutoViz",
"panel": "panels/AutoViz/AutoVizPanel",
"DEBUG_ONLY": false
},
{
"id": "EasyDAG",
"title": "EasyDAG",
"panel": "panels/EasyDAG/EasyDAGPanel",
"DEBUG_ONLY": false
},
{
"id": "ArchEditor",
"title": "ArchEditor",
"panel": "panels/ArchEditor/ArchEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "TextEditor",
"title": "TextEditor",
"panel": "panels/TextEditor/TextEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "OperationEditor",
"title": "OperationEditor",
"panel": "panels/OperationEditor/OperationEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "PipelineEditor",
"title": "PipelineEditor",
"panel": "panels/PipelineEditor/PipelineEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "ExecutionView",
"title": "ExecutionView",
"panel": "panels/ExecutionView/ExecutionViewPanel",
"DEBUG_ONLY": false
}
]
{
"id": "AutoViz",
"title": "AutoViz",
"panel": "panels/AutoViz/AutoVizPanel",
"DEBUG_ONLY": false
},
{
"id": "EasyDAG",
"title": "EasyDAG",
"panel": "panels/EasyDAG/EasyDAGPanel",
"DEBUG_ONLY": false
},
{
"id": "ArchEditor",
"title": "ArchEditor",
"panel": "panels/ArchEditor/ArchEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "TextEditor",
"title": "TextEditor",
"panel": "panels/TextEditor/TextEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "OperationEditor",
"title": "OperationEditor",
"panel": "panels/OperationEditor/OperationEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "PipelineEditor",
"title": "PipelineEditor",
"panel": "panels/PipelineEditor/PipelineEditorPanel",
"DEBUG_ONLY": false
},
{
"id": "ExecutionView",
"title": "ExecutionView",
"panel": "panels/ExecutionView/ExecutionViewPanel",
"DEBUG_ONLY": false
}
]
Loading

0 comments on commit e7d5545

Please sign in to comment.