Browse Source

Add ESLint

Lutz Roeder 7 years ago
parent
commit
ec14664755
35 changed files with 476 additions and 409 deletions
  1. 19 0
      .eslintrc.json
  2. 4 0
      Makefile
  3. 6 3
      package.json
  4. 14 12
      src/app.js
  5. 5 5
      src/base.js
  6. 5 3
      src/caffe.js
  7. 5 4
      src/caffe2.js
  8. 27 28
      src/cntk.js
  9. 37 29
      src/coreml.js
  10. 4 4
      src/darknet.js
  11. 8 7
      src/gzip.js
  12. 12 11
      src/hdf5.js
  13. 7 5
      src/keras.js
  14. 46 41
      src/mxnet.js
  15. 2 1
      src/numpy.js
  16. 6 5
      src/onnx.js
  17. 10 10
      src/openvino.js
  18. 4 3
      src/paddle.js
  19. 3 2
      src/pickle.js
  20. 10 7
      src/pytorch.js
  21. 7 6
      src/sklearn.js
  22. 1 1
      src/tar.js
  23. 9 12
      src/tf.js
  24. 2 1
      src/tflite-schema.js
  25. 3 2
      src/tflite.js
  26. 109 112
      src/torch.js
  27. 7 5
      src/view-browser.js
  28. 24 20
      src/view-electron.js
  29. 9 8
      src/view-grapher.js
  30. 11 13
      src/view-sidebar.js
  31. 17 16
      src/view.js
  32. 5 3
      src/zip.js
  33. 29 24
      test/test.js
  34. 2 1
      tools/tflite
  35. 7 5
      tools/update_pbjs.js

+ 19 - 0
.eslintrc.json

@@ -0,0 +1,19 @@
+{
+    "env": {
+        "es6": true,
+        "browser": true,
+        "node": true
+    },
+    "extends": "eslint:recommended",
+    "parserOptions": {
+        "ecmaVersion": 2015,
+        "sourceType": "module"
+    },
+    "rules": {
+        "indent": [ "error", 4 ],
+        "linebreak-style": [ "error", "unix" ]
+    },
+    "globals": {
+        "protobuf": "readonly"
+    }
+}

+ 4 - 0
Makefile

@@ -20,6 +20,10 @@ build_electron:
 	npx electron-builder install-app-deps
 	npx electron-builder --mac --linux --win
 
+lint:
+	@[ -d node_modules ] || npm install
+	npx eslint src/*.js test/*.js
+
 start:
 	@[ -d node_modules ] || npm install
 	npx electron .

+ 6 - 3
package.json

@@ -11,11 +11,12 @@
     "repository": "lutzroeder/netron",
     "main": "src/app.js",
     "scripts": {
+        "pull": "git pull --prune",
         "start": "[ -d node_modules ] || npm install && npx electron .",
         "server": "[ -d node_modules ] || npm install && rm -rf build/python && python setup.py --quiet build && PYTHONPATH=build/python/lib python -c 'import netron; netron.main()' $@",
-        "test": "[ -d node_modules ] || npm install && node ./test/test.js",
+        "clean": "rm -rf ./build ./node_modules ./third_party",
         "update": "[ -d node_modules ] || npm install && ./tools/update",
-        "reset": "git fetch -p && git reset --hard origin/$(git rev-parse --abbrev-ref HEAD)"
+        "test": "[ -d node_modules ] || npm install && node ./test/test.js"
     },
     "dependencies": {
         "d3": "latest",
@@ -23,16 +24,18 @@
         "electron-updater": "^4.0.0",
         "flatbuffers": "latest",
         "handlebars": "latest",
+        "long": "latest",
         "marked": "latest",
         "npm-font-open-sans": "latest",
         "pako": "latest",
-        "long": "latest",
         "protobufjs": "lutzroeder/protobuf.js#pbtxt",
         "universal-analytics": "latest"
     },
     "devDependencies": {
         "electron": "latest",
         "electron-builder": "latest",
+        "eslint": "latest",
+        "jshint": "latest",
         "xmldom": "latest"
     }
 }

+ 14 - 12
src/app.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 const electron = require('electron');
 const updater = require('electron-updater');
@@ -37,7 +38,7 @@ class Application {
             }
         });
 
-        electron.ipcMain.on('open-file-dialog', (e, data) => {
+        electron.ipcMain.on('open-file-dialog', () => {
             this._openFileDialog();
         });
 
@@ -100,10 +101,10 @@ class Application {
             this._views.openView();
         }
         this._resetMenu();
-        this._views.on('active-view-changed', (e) => {
+        this._views.on('active-view-changed', () => {
             this._updateMenu();
         });
-        this._views.on('active-view-updated', (e) => {
+        this._views.on('active-view-updated', () => {
             this._updateMenu();
         });
     }
@@ -229,7 +230,7 @@ class Application {
         }
         var autoUpdater = updater.autoUpdater;
         autoUpdater.autoDownload = false;
-        autoUpdater.on('update-available', (info) => {
+        autoUpdater.on('update-available', () => {
             var owner = electron.BrowserWindow.getFocusedWindow();
             var messageBoxOptions = {
                 icon: path.join(__dirname, 'icon.png'),
@@ -608,10 +609,10 @@ class View {
             electron.ipcMain.removeListener('update', this._updateCallback);
             this._owner.closeView(this);
         });
-        this._window.on('focus', (e) => {
+        this._window.on('focus', () => {
             this._raise('activated');
         });
-        this._window.on('blur', (e) => {
+        this._window.on('blur', () => {
             this._raise('deactivated');
         });
         this._window.webContents.on('dom-ready', () => {
@@ -742,10 +743,10 @@ class ViewCollection {
             this._activeView = sender;
             this._raise('active-view-changed', { activeView: this._activeView });
         });
-        view.on('updated', (sender) => {
+        view.on('updated', () => {
             this._raise('active-view-updated', { activeView: this._activeView });
         });
-        view.on('deactivated', (sender) => {
+        view.on('deactivated', () => {
             this._activeView = null;
             this._raise('active-view-changed', { activeView: this._activeView });
         });
@@ -894,11 +895,12 @@ class MenuService {
                 if (command.enabled) {
                     menuItem.enabled = command.enabled(context);
                 }
+                /*
                 if (command.label) {
                     if (menuItem.label != command.label(context)) {
-
                     }
-                }
+                } 
+                */
             }
         });
     }
@@ -909,4 +911,4 @@ class MenuService {
     }
 }
 
-var application = new Application();
+global.application = new Application();

+ 5 - 5
src/base.js

@@ -1,4 +1,4 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
 
 var base = base || {};
 
@@ -27,7 +27,7 @@ if (!DataView.prototype.getFloat16) {
         9: 1/64, 10: 1/32, 11: 1/16, 12: 1/8, 13: 1/4, 14: 1/2, 15: 1, 16: 2, 
         17: 4, 18: 8, 19: 16, 20: 32, 21: 64, 22: 128, 23: 256, 24: 512,
         25: 1024, 26: 2048, 27: 4096, 28: 8192, 29: 16384, 30: 32768, 31: 65536 
-        };
+    };
 }
 
 if (!DataView.prototype.setFloat16) {
@@ -66,7 +66,7 @@ if (!DataView.prototype.setFloat16) {
 }
 
 if (!DataView.prototype.getBits) {
-    DataView.prototype.getBits = function(offset, bits, signed) {
+    DataView.prototype.getBits = function(offset, bits /*, signed */) {
         offset = offset * bits;
         var available = (this.byteLength << 3) - offset;
         if (bits > available) {
@@ -77,8 +77,8 @@ if (!DataView.prototype.getBits) {
         while (index < bits) {
             var remainder = offset & 7;
             var size = Math.min(bits - index, 8 - remainder);
-			value <<= size;
-			value |= (this.getUint8(offset >> 3) >> (8 - size - remainder)) & ~(0xff << size);
+            value <<= size;
+            value |= (this.getUint8(offset >> 3) >> (8 - size - remainder)) & ~(0xff << size);
             offset += size;
             index += size;
         }

+ 5 - 3
src/caffe.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var caffe = caffe || {};
 var long = long || { Long: require('long') };
@@ -7,7 +8,7 @@ var marked = marked || require('marked');
 
 caffe.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         var tags = null;
@@ -29,7 +30,7 @@ caffe.ModelFactory = class {
     }
 
     open(context, host, callback) { 
-        host.require('./caffe-proto', (err, module) => {
+        host.require('./caffe-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -70,6 +71,7 @@ caffe.ModelFactory = class {
                             }
                         }
                         catch (error) {
+                            // continue regardless of error
                         }
                     }
                     this._openNetParameterText(metadata, context.identifier, context.text, host, callback);

+ 5 - 4
src/caffe2.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var caffe2 = caffe2 || {};
 var protobuf = protobuf || require('protobufjs');
@@ -6,7 +7,7 @@ var marked = marked || require('marked');
 
 caffe2.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier.toLowerCase();
         var extension = identifier.split('.').pop().toLowerCase();
         var tags = null;
@@ -56,7 +57,7 @@ caffe2.ModelFactory = class {
     }    
 
     open(context, host, callback) {
-        host.require('./caffe2-proto', (err, module) => {
+        host.require('./caffe2-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -100,6 +101,7 @@ caffe2.ModelFactory = class {
                             init = caffe2.proto.NetDef.decode(data);
                         }
                         catch (error) {
+                            // continue regardless of error
                         }
                     }
 
@@ -184,7 +186,6 @@ caffe2.Graph = class {
                             dataType = 'int8';
                             break;
                         default:
-                            debugger;
                             break;
                     }
                     if (dataType) {

+ 27 - 28
src/cntk.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var cntk = cntk || {};
 var long = long || { Long: require('long') };
@@ -9,7 +10,7 @@ var cntk_v2 = null;
 
 cntk.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         var buffer = null;
         if (extension == 'model' || extension == 'cmf' || extension == 'dnn' || extension == 'cntk') {
@@ -30,7 +31,7 @@ cntk.ModelFactory = class {
     }
 
     open(context, host, callback) { 
-        host.require('./cntk-proto', (err, module) => {
+        host.require('./cntk-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -567,7 +568,7 @@ cntk.Attribute = class {
                     if (defaultValue.length > 1 && defaultValue[defaultValue.length - 1] == null) {
                         defaultValue.pop();
                         while (defaultValue.length < value.length) {
-                           defaultValue.push(defaultValue[defaultValue.length - 1]); 
+                            defaultValue.push(defaultValue[defaultValue.length - 1]); 
                         }
                     }
                     if (value.every((item, index) => { return item == defaultValue[index]; })) {
@@ -861,18 +862,18 @@ cntk_v1.ComputationNetwork = class {
         var numNodes = reader.uint64();
         reader.assert('BNodeList');
         var op = {};
-        op.Minus = function(reader) {};
-        op.Plus = function(reader) {};
-        op.GreaterEqual = function(reader) {};
-        op.Equal = function(reader) {};
-        op.NotEqual = function(reader) {};
-        op.GreaterEqual = function(reader) {};
-        op.Exp = function(reader) {};
-        op.Log = function(reader) {};
-        op.Reciprocal = function(reader) {};
-        op.ElementTimes = function(reader) {};
-        op.ClassificationError = function(reader) {};
-        op.RectifiedLinear = function(reader) {};
+        op.Minus = function() {};
+        op.Plus = function() {};
+        op.GreaterEqual = function() {};
+        op.Equal = function() {};
+        op.NotEqual = function() {};
+        op.GreaterEqual = function() {};
+        op.Exp = function() {};
+        op.Log = function() {};
+        op.Reciprocal = function() {};
+        op.ElementTimes = function() {};
+        op.ClassificationError = function() {};
+        op.RectifiedLinear = function() {};
         op.InputValue = function(reader) {
             this.rows = reader.uint64();
             this.cols = reader.uint64();
@@ -955,8 +956,8 @@ cntk_v1.ComputationNetwork = class {
                 this.poolKind = 'None';
                 this.convolution2D = true;
                 this.sharing = [ true ];
-                m_lowerPad = new cntk_v1.TensorShape([ 0 ]);
-                m_upperPad = new cntk_v1.TensorShape([ 0 ]);
+                this.lowerPad = new cntk_v1.TensorShape([ 0 ]);
+                this.upperPad = new cntk_v1.TensorShape([ 0 ]);
             }
             else {
                 this.convolution2D = reader.bool();
@@ -1060,11 +1061,11 @@ cntk_v1.ComputationNetwork = class {
                 this.convertRunningVariancePending = true;
             }
         };
-        op.Tanh = function(reader) {};
-        op.Sigmoid = function(reader) {};
-        op.Logistic = function(reader) {};
-        op.SquareError = function(reader) {};
-        op.ErrorPrediction = function(reader) {};
+        op.Tanh = function() {};
+        op.Sigmoid = function() {};
+        op.Logistic = function() {};
+        op.SquareError = function() {};
+        op.ErrorPrediction = function() {};
         op.RowStack = function(reader) {
             this.spliceDim = (reader.version >= 3) ? reader.int32() : 1;
         };
@@ -1332,12 +1333,10 @@ cntk_v1.Reader = class {
 
     string() {
         var text = '';
-        while (true) {
-            var c = this.uint16();
-            if (c == 0) {
-                break;
-            }
+        var c = this.uint16();
+        while (c != 0) {
             text += String.fromCharCode(c);
+            c = this.uint16();
         }
         return text;
     }

+ 37 - 29
src/coreml.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var coreml = coreml || {};
 var base = base || require('./base');
@@ -8,13 +9,13 @@ var marked = marked || require('marked');
 
 coreml.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         return extension == 'mlmodel';
     }
 
     open(context, host, callback) { 
-        host.require('./coreml-proto', (err, module) => {
+        host.require('./coreml-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -63,7 +64,7 @@ coreml.Model = class {
                 this._license = properties.license;
             }
             if (metadata.userDefined && Object.keys(properties.userDefined).length > 0) {
-                debugger;
+                /* empty */
             }
         }
     }
@@ -183,7 +184,6 @@ coreml.Graph = class {
             });
             var preprocessorOutput = preprocessingInput;
             var preprocessorIndex = 0;
-            var nodes = [];
             preprocessing.forEach((preprocessing) => {
                 var operator = preprocessing.preprocessor;
                 var input = preprocessing.featureName ? preprocessing.featureName : preprocessorOutput;
@@ -247,9 +247,11 @@ coreml.Graph = class {
         }
         else if (model.glmClassifier) {
             this._createNode(scope, group, 'glmClassifier', null, 
-                { classEncoding: model.glmClassifier.classEncoding, 
-                  offset: model.glmClassifier.offset, 
-                  weights: model.glmClassifier.weights }, 
+                {
+                    classEncoding: model.glmClassifier.classEncoding, 
+                    offset: model.glmClassifier.offset, 
+                    weights: model.glmClassifier.weights 
+                }, 
                 [ model.description.input[0].name ],
                 [ model.description.predictedProbabilitiesName ]);
             this._updateClassifierOutput(group, model.glmClassifier);
@@ -270,8 +272,8 @@ coreml.Graph = class {
         }
         else if (model.featureVectorizer) {
             this._createNode(scope, group, 'featureVectorizer', null, model.featureVectorizer, 
-            coreml.Graph._formatFeatureDescriptionList(model.description.input),
-            [ model.description.output[0].name ]);
+                coreml.Graph._formatFeatureDescriptionList(model.description.input),
+                [ model.description.output[0].name ]);
             return 'Feature Vectorizer';
         }
         else if (model.treeEnsembleClassifier) {
@@ -289,14 +291,16 @@ coreml.Graph = class {
         }
         else if (model.supportVectorClassifier) {
             this._createNode(scope, group, 'supportVectorClassifier', null, 
-                { coefficients: model.supportVectorClassifier.coefficients, 
-                  denseSupportVectors: model.supportVectorClassifier.denseSupportVectors,
-                  kernel: model.supportVectorClassifier.kernel,
-                  numberOfSupportVectorsPerClass: model.supportVectorClassifier.numberOfSupportVectorsPerClass,
-                  probA: model.supportVectorClassifier.probA,
-                  probB: model.supportVectorClassifier.probB,
-                  rho: model.supportVectorClassifier.rho,
-                  supportVectors: model.supportVectorClassifier.supportVectors }, 
+                {   
+                    coefficients: model.supportVectorClassifier.coefficients, 
+                    denseSupportVectors: model.supportVectorClassifier.denseSupportVectors,
+                    kernel: model.supportVectorClassifier.kernel,
+                    numberOfSupportVectorsPerClass: model.supportVectorClassifier.numberOfSupportVectorsPerClass,
+                    probA: model.supportVectorClassifier.probA,
+                    probB: model.supportVectorClassifier.probB,
+                    rho: model.supportVectorClassifier.rho,
+                    supportVectors: model.supportVectorClassifier.supportVectors 
+                }, 
                 [ model.description.input[0].name ],
                 [ model.description.output[0].name ]);
             this._updateClassifierOutput(group, model.supportVectorClassifier);
@@ -304,10 +308,12 @@ coreml.Graph = class {
         }
         else if (model.supportVectorRegressor) {
             this._createNode(scope, group, 'supportVectorRegressor', null, 
-                { coefficients: model.supportVectorRegressor.coefficients, 
-                  kernel: model.supportVectorRegressor.kernel,
-                  rho: model.supportVectorRegressor.rho,
-                  supportVectors: model.supportVectorRegressor.supportVectors }, 
+                {
+                    coefficients: model.supportVectorRegressor.coefficients, 
+                    kernel: model.supportVectorRegressor.kernel,
+                    rho: model.supportVectorRegressor.rho,
+                    supportVectors: model.supportVectorRegressor.supportVectors 
+                }, 
                 [ model.description.input[0].name ],
                 [ model.description.output[0].name ]);
             return 'Support Vector Regressor';
@@ -353,10 +359,12 @@ coreml.Graph = class {
             this._createNode(scope, group, 'wordTagger', null, 
                 model.wordTagger,
                 [ model.description.input[0].name ],
-                [ model.wordTagger.tokensOutputFeatureName,
-                  model.wordTagger.tokenTagsOutputFeatureName,
-                  model.wordTagger.tokenLocationsOutputFeatureName,
-                  model.wordTagger.tokenLengthsOutputFeatureName ]);
+                [ 
+                    model.wordTagger.tokensOutputFeatureName,
+                    model.wordTagger.tokenTagsOutputFeatureName,
+                    model.wordTagger.tokenLocationsOutputFeatureName,
+                    model.wordTagger.tokenLengthsOutputFeatureName 
+                ]);
             return 'Word Tagger';
         }
         else if (model.textClassifier) {
@@ -702,7 +710,7 @@ coreml.Node = class {
                 data.modelParameterData = Array.from(data.modelParameterData);
                 data.stringClassLabels = this._convertVector(data.stringClassLabels);
                 return {};
-            }
+        }
         return {};
     }
 
@@ -979,7 +987,7 @@ coreml.TensorShape = class {
 
 coreml.MapType = class {
 
-    constructor(keyType, valueType, denotation) {
+    constructor(keyType, valueType) {
         this._keyType = keyType;
         this._valueType = valueType;
     }
@@ -1006,7 +1014,7 @@ coreml.ImageType = class {
                 this._colorSpace = 'Grayscale';
                 break;
             case coreml.proto.ImageFeatureType.ColorSpace.RGB:
-                    this._colorSpace = 'RGB';
+                this._colorSpace = 'RGB';
                 break;
             case coreml.proto.ImageFeatureType.ColorSpace.BGR:
                 this._colorSpace = 'BGR';

+ 4 - 4
src/darknet.js

@@ -1,12 +1,12 @@
-
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var darknet = darknet || {};
 var base = base || require('./base');
 
 darknet.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         if (extension == 'cfg') {
             return true;
@@ -488,7 +488,7 @@ darknet.CfgReader = class {
                         item[key] = value;
                     }
                     else {
-                        throw new darknet.Error("Invalid cfg \'" + line + "\' at line " + (this._line + 1).toString() + ".");
+                        throw new darknet.Error("Invalid cfg '" + line + "' at line " + (this._line + 1).toString() + ".");
                     }
                 }
             }

+ 8 - 7
src/gzip.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* global pako */
 
 var gzip = gzip || {};
 
@@ -31,7 +32,7 @@ gzip.Entry = class {
         }
         var flags = reader.byte();
         reader.uint32(); // MTIME
-        var xflags = reader.byte();
+        reader.byte();
         reader.byte(); // OS
         if ((flags & 4) != 0) {
             var xlen = reader.uint16();
@@ -108,14 +109,14 @@ gzip.Reader = class {
 
     skip(size) {
         if (this._position + size > this._end) {
-            throw new zip.Error('Data not available.');
+            throw new gzip.Error('Data not available.');
         }
         this._position += size;
     }
 
     bytes(size) {
         if (this._position + size > this._end) {
-            throw new zip.Error('Data not available.');
+            throw new gzip.Error('Data not available.');
         }
         size = size === undefined ? this._end : size;
         var data = this._buffer.subarray(this._position, this._position + size);
@@ -125,7 +126,7 @@ gzip.Reader = class {
 
     byte() {
         if (this._position + 1 > this._end) {
-            throw new zip.Error('Data not available.');
+            throw new gzip.Error('Data not available.');
         }
         var value = this._buffer[this._position];
         this._position++;
@@ -134,7 +135,7 @@ gzip.Reader = class {
 
     uint16() {
         if (this._position + 2 > this._end) {
-            throw new zip.Error('Data not available.');
+            throw new gzip.Error('Data not available.');
         }
         var value = this._buffer[this._position] | (this._buffer[this._position + 1] << 8);
         this._position += 2;
@@ -149,7 +150,7 @@ gzip.Reader = class {
         var result = '';
         var end = this._buffer.indexOf(0x00, this._position);
         if (end < 0) {
-            throw new zip.Error('End of string not found.');
+            throw new gzip.Error('End of string not found.');
         }
         while (this._position < end) {
             result += String.fromCharCode(this._buffer[this._position++]);

+ 12 - 11
src/hdf5.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 // Experimental H5/HDF5 JavaScript reader
 
@@ -219,7 +220,7 @@ hdf5.Reader = class {
         }
     }
 
-    initialize(offsetSize, lengthSize) {
+    initialize() {
         this._offsetSize = this.byte();
         this._lengthSize = this.byte();
     }
@@ -362,7 +363,7 @@ hdf5.Reader = class {
     offset() { 
         switch (this._offsetSize) {
             case 8:
-               return this.uint64();
+                return this.uint64();
             case 4:
                 return this.uint32(); 
         }
@@ -372,7 +373,7 @@ hdf5.Reader = class {
     length() {
         switch (this._lengthSize) {
             case 8:
-               return this.uint64();
+                return this.uint64();
             case 4:
                 return this.uint32(); 
         }
@@ -525,8 +526,8 @@ hdf5.DataObjectHeader = class {
             reader.uint32();
         }
         if ((flags & 0x10) != 0) {
-            var maxCompactAttributes = reader.uint16();
-            var minDenseAttributes = reader.uint16();
+            reader.uint16();
+            reader.uint16();
         }
         var size = reader.uint(flags & 0x03);
         var next = true;
@@ -537,7 +538,7 @@ hdf5.DataObjectHeader = class {
             var messageFlags = reader.byte();
             if (reader.position < end) {
                 if ((flags & 0x04) != 0) {
-                    var messageCreationOrder = reader.uint16();
+                    reader.uint16();
                 }
                 next = this.readMessage(reader, messageType, messageSize, messageFlags);
             } 
@@ -1051,12 +1052,12 @@ hdf5.Tree = class {
         var type = reader.byte();
         var level = reader.byte();
         var entriesUsed = reader.uint16();
-        var leftSiblingAddress = reader.offset();
-        var rightSiblingAddress = reader.offset();
+        reader.offset();
+        reader.offset();
         this.nodes = [];
         if (type == 0) {
             for (var i = 0; i < entriesUsed; i++) {
-                var objectNameOffset = reader.length();
+                reader.length();
                 var childPointer = reader.offset();
                 if (level == 0) {
                     this.nodes.push(new hdf5.SymbolTableNode(reader.move(childPointer)));
@@ -1165,7 +1166,7 @@ hdf5.GlobalHeapCollection = class {
 hdf5.GlobalHeapObject = class {
 
     constructor(reader) {
-        var referenceCount = reader.uint16();
+        reader.uint16();
         reader.seek(4);
         var size = reader.length();
         this.data = reader.bytes(size);

+ 7 - 5
src/keras.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var keras = keras || {};
 var base = base || require('./base');
@@ -6,7 +7,7 @@ var marked = marked || require('marked');
 
 keras.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         if (extension == 'keras' || extension == 'h5' || extension == 'hdf5') {
@@ -20,11 +21,11 @@ keras.ModelFactory = class {
         }
         if (extension == 'json' && !identifier.endsWith('-symbol.json')) {
             var json = context.text;
-            if (json.indexOf('\"mxnet_version\":', 0) == -1) {
+            if (json.indexOf('"mxnet_version":', 0) == -1) {
                 try {
                     var root = JSON.parse(json);
                     if (root && root.nodes && root.arg_nodes && root.heads) {
-                       return false;
+                        return false;
                     }
                     if (root && root.modelTopology && root.modelTopology.model_config) {
                         root = root.modelTopology.model_config;
@@ -34,6 +35,7 @@ keras.ModelFactory = class {
                     }
                 }
                 catch (err) {
+                    // continue regardless of error
                 }
             }
         }
@@ -1018,7 +1020,7 @@ keras.Group = class {
             if (this._group.attribute(name + '0')) {
                 var index = 0;
                 value = [];
-                while (true) {
+                for (;;) {
                     var chunk = this._group.attribute(name + index.toString());
                     if (!chunk) {
                         break;

+ 46 - 41
src/mxnet.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var mxnet = mxnet || {};
 var marked = marked || require('marked');
@@ -7,7 +8,7 @@ var zip = zip || require('./zip');
 
 mxnet.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         if (extension == 'model') {
             var buffer = context.buffer;
@@ -17,7 +18,7 @@ mxnet.ModelFactory = class {
         }
         if (extension == 'json') {
             var json = context.text;
-            if (json.indexOf('\"nodes\":', 0) != -1) {
+            if (json.indexOf('"nodes":', 0) != -1) {
                 try {
                     var symbol = JSON.parse(json);
                     if (symbol && symbol.nodes && symbol.arg_nodes && symbol.heads) {
@@ -25,6 +26,7 @@ mxnet.ModelFactory = class {
                     }
                 }
                 catch (err) {
+                    // continue regardless of error
                 }
             }
         }
@@ -144,6 +146,7 @@ mxnet.ModelFactory = class {
             }
         }
         catch (err) {
+            // continue regardless of error
         }
 
         var params = null;
@@ -156,6 +159,7 @@ mxnet.ModelFactory = class {
             }
         }
         catch (err) {
+            // continue regardless of error
         }
 
         var identifier = context.identifier;
@@ -193,6 +197,7 @@ mxnet.ModelFactory = class {
                     });
                 }
                 catch (error) {
+                    // continue regardless of error
                 }
             }
             try {
@@ -520,9 +525,10 @@ mxnet.Node = class {
                         if (argument.attrs && argument.attrs.__dtype__ && argument.attrs.__shape__) {
                             try {
                                 dataType = parseInt(argument.attrs.__dtype__);
-                                shape = JSON.parse('[' + argument.attrs.__shape__.replace('(', '').replace(')', '').split(' ').join('').split(',').map((dimension => dimension || '\"?\"' )).join(',') + ']');
+                                shape = JSON.parse('[' + argument.attrs.__shape__.replace('(', '').replace(')', '').split(' ').join('').split(',').map((dimension => dimension || '"?"' )).join(',') + ']');
                             }
                             catch (err) {
+                                // continue regardless of error
                             }
                         }
                         this._initializers[id] = new mxnet.Tensor('Initializer', argument.name, dataType, shape, null);
@@ -624,7 +630,6 @@ mxnet.Node = class {
         if (schema && schema.outputs) {
             schema.outputs.forEach((outputDef) => {
                 if (index < outputs.length || outputDef.option != 'optional') {
-                    var output = {};
                     var connections = [];
                     var count = (outputDef.option == 'variadic') ? (outputs.length - index) : 1;
                     outputs.slice(index, index + count).forEach((input) => {
@@ -636,7 +641,7 @@ mxnet.Node = class {
             });
         }
         if (index < outputs.length) {
-                outputs.slice(index).forEach((output) => {
+            outputs.slice(index).forEach((output) => {
                 var name = index.toString();
                 var connection = new mxnet.Connection('[' + output.join(',') + ']', null, null);
                 args.push(new mxnet.Argument(name, [ connection ]));
@@ -682,18 +687,18 @@ mxnet.Attribute = class {
                 case 'int32[]':
                     if (this._value.length > 2 && this._value.startsWith('(') && this._value.endsWith(')')) {
                         var array = [];
-                        var items = this._value.substring(1, this._value.length - 1).split(',');
-                        items = items.map((item) => item.trim());
-                        items = items.map((item) => item.endsWith('L') ? item.substring(0, item.length - 1) : item);
-                        items = items.map((item) => {
-                            var intValue = Number.parseInt(item, 10);
-                            if (Number.isNaN(item - intValue)) {
-                                array = null;
-                            }
-                            else if (array != null) {
-                                array.push(intValue);
-                            }        
-                        });
+                        this._value.substring(1, this._value.length - 1).split(',')
+                            .map((item) => item.trim())
+                            .map((item) => item.endsWith('L') ? item.substring(0, item.length - 1) : item)
+                            .forEach((item) => {
+                                var intValue = Number.parseInt(item, 10);
+                                if (Number.isNaN(item - intValue)) {
+                                    array = null;
+                                }
+                                else if (array != null) {
+                                    array.push(intValue);
+                                }
+                            });
                         if (array != null) {
                             this._value = array;
                         }
@@ -716,7 +721,7 @@ mxnet.Attribute = class {
                     if (defaultValue.length > 1 && defaultValue[defaultValue.length - 1] == null) {
                         defaultValue.pop();
                         while (defaultValue.length < this._value.length) {
-                           defaultValue.push(defaultValue[defaultValue.length - 1]); 
+                            defaultValue.push(defaultValue[defaultValue.length - 1]); 
                         }
                     }
                     if (this._value.every((item, index) => { return item == defaultValue[index]; })) {
@@ -1022,14 +1027,14 @@ ndarray.Stream = class {
         }
 
         var data = [];
-        for (var dataSize = reader.readUint64(); dataSize > 0; dataSize--) {
+        for (var dataSize = reader.uint64(); dataSize > 0; dataSize--) {
             data.push(new ndarray.Array(reader));
         }
 
         var decoder = new TextDecoder('ascii');
         var names = [];
-        for (var namesSize = reader.readUint64(); namesSize > 0; namesSize--) {
-            var length = reader.readUint64();
+        for (var namesSize = reader.uint64(); namesSize > 0; namesSize--) {
+            var length = reader.uint64();
             var name = decoder.decode(reader.read(length));
             names.push(name);
         }
@@ -1067,23 +1072,23 @@ ndarray.Array = class {
     }
 
     _loadV2(reader) {
-        var stype = reader.readUint32();
+        var stype = reader.uint32();
         var num_aux_data = 0;
         switch (stype) {
             case 0: num_aux_data = 0; break; // kDefaultStorage
             case 1: num_aux_data = 1; break; // kRowSparseStorage
             case 2: num_aux_data = 2; break; // kCSRStorage
         }
-        var sshape = null;
+        this.sshape = null;
         if (num_aux_data > 0) {
-            sshape = new ndarray.Shape(reader, true);
+            this.sshape = new ndarray.Shape(reader, true);
         }
         this._shape = new ndarray.Shape(reader, true);
         if (this._shape.dimensions.length == 0) {
             return;
         }
-        var context = new ndarray.Context(reader);
-        this._dataType = reader.readUint32();
+        this._context = new ndarray.Context(reader);
+        this._dataType = reader.uint32();
         if (num_aux_data > 0) {
             throw new ndarray.Error('Not implemented.');
         }
@@ -1097,8 +1102,8 @@ ndarray.Array = class {
         if (this._shape.dimensions.length == 0) {
             return;
         }
-        var context = new ndarray.Context(reader);
-        this._dataType = reader.readUint32();
+        this._context = new ndarray.Context(reader);
+        this._dataType = reader.uint32();
         var dataTypeSize = (this._dataType < ndarray.Array._dataTypeSizeTable.length) ? ndarray.Array._dataTypeSizeTable[this._dataType] : 0;
         var size = dataTypeSize * this._shape.size();
         this._data = reader.read(size);
@@ -1106,8 +1111,8 @@ ndarray.Array = class {
 
     _loadV0(reader) {
         this._shape = new ndarray.Shape(reader, false);
-        var context = new ndarray.Context(reader);
-        this._dataType = reader.readUint32();
+        this._context = new ndarray.Context(reader);
+        this._dataType = reader.uint32();
         var dataTypeSize = (this._dataType < ndarray.Array._dataTypeSizeTable.length) ? ndarray.Array._dataTypeSizeTable[this._dataType] : 0;
         var size = dataTypeSize * this._shape.size();
         this._data = reader.read(size);
@@ -1129,10 +1134,10 @@ ndarray.Array = class {
 ndarray.Shape = class {
 
     constructor(reader, uint64) {
-        var ndim = reader.readUint32();
+        var ndim = reader.uint32();
         this._dimensions = [];
         for (var i = 0; i < ndim; i++) {
-            this._dimensions.push(uint64 ? reader.readUint64() : reader.readUint32());
+            this._dimensions.push(uint64 ? reader.uint64() : reader.uint32());
         }
     }
 
@@ -1152,8 +1157,8 @@ ndarray.Shape = class {
 ndarray.Context = class {
 
     constructor(reader) {
-        this._deviceType = reader.readUint32();
-        this._deviceId = reader.readUint32();
+        this._deviceType = reader.uint32();
+        this._deviceId = reader.uint32();
     }
 };
 
@@ -1186,7 +1191,7 @@ ndarray.Reader = class {
         return data;
     }
 
-    readUint16() {
+    uint16() {
         if (this._position + 2 > this._end) {
             throw new ndarray.Error('Data not available.');
         }
@@ -1195,13 +1200,13 @@ ndarray.Reader = class {
         return value;
     }
 
-    readUint32() {
-        return this.readUint16() | (this.readUint16() << 16);
+    uint32() {
+        return this.uint16() | (this.uint16() << 16);
     }
 
-    readUint64() {
-        var value = this.readUint32();
-        if (this.readUint32() != 0) {
+    uint64() {
+        var value = this.uint32();
+        if (this.uint32() != 0) {
             throw new ndarray.Error('Large int64 value.');
         }
         return value;

+ 2 - 1
src/numpy.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var numpy = numpy || {};
 

+ 6 - 5
src/onnx.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var onnx = onnx || {};
 var base = base || require('./base');
@@ -8,7 +9,7 @@ var marked = marked || require('marked');
 
 onnx.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         if (extension == 'onnx') {
@@ -65,7 +66,7 @@ onnx.ModelFactory = class {
     }
 
     open(context, host, callback) { 
-        host.require('./onnx-proto', (err, module) => {
+        host.require('./onnx-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -613,7 +614,7 @@ onnx.Attribute = class {
             }
         }
         else if (attribute.graphs && attribute.graphs.length > 0) {
-            this._value = arg.graphs.map((graph) => new onnx.Graph(metadata, imageFormat, graph));
+            this._value = attribute.graphs.map((graph) => new onnx.Graph(metadata, imageFormat, graph));
             this._type = 'graph[]';
         }
         else if (attribute.s && attribute.s.length > 0) {
@@ -1137,7 +1138,7 @@ onnx.MapType = class {
 
 onnx.OpaqueType = class {
 
-    constructor(domain, name, parameters) {
+    constructor(domain, name) {
         this._domain = domain;
         this._name = name;
     }

+ 10 - 10
src/openvino.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var openvino = openvino || {};
 var marked = marked || require('marked');
@@ -19,7 +20,7 @@ openvino.ModelFactory = class {
         openvino.Metadata.open(host, (err, metadata) => {
             try {
                 var errors = false;
-                var parser = new DOMParser({ errorHandler: (level, message) => { errors = true; } });
+                var parser = new DOMParser({ errorHandler: () => { errors = true; } });
                 var xml = parser.parseFromString(context.text, 'text/xml');
                 if (errors || xml.documentElement == null || xml.getElementsByTagName('parsererror').length > 0) {
                     callback(new openvino.Error('File format is not OpenVINO XML.'), null);
@@ -44,8 +45,8 @@ openvino.ModelFactory = class {
 
 openvino.Model = class {
 
-    constructor(metadata, net, init) {
-        var graph = new openvino.Graph(metadata, net, init);
+    constructor(metadata, net) {
+        var graph = new openvino.Graph(metadata, net);
         this._graphs = [ graph ];
     }
 
@@ -61,7 +62,7 @@ openvino.Model = class {
 
 openvino.Graph = class {
 
-    constructor(metadata, net, init) {
+    constructor(metadata, net) {
         this._metadata = metadata;
         this._name = net.getAttribute('name') || '';
         this._batch = net.getAttribute('batch') || '';
@@ -109,7 +110,7 @@ openvino.Graph = class {
                     this._inputs.push(new openvino.Argument(name, connections));
                     break;
                 default:
-                    this._nodes.push(new openvino.Node(this, this._metadata, layer, this._version, edgeMap, layers));
+                    this._nodes.push(new openvino.Node(this, this._metadata, layer, edgeMap));
                     break;
             }
         });
@@ -157,7 +158,7 @@ openvino.Graph = class {
 
 openvino.Node = class {
 
-    constructor(graph, metadata, layer, version, edgeMap, layers) {
+    constructor(graph, metadata, layer, edgeMap) {
         this._metadata = metadata;
         this._type = layer.getAttribute('type');
         this._name = layer.getAttribute('name') || '';
@@ -367,9 +368,8 @@ openvino.Attribute = class {
                     case 'int32[]':
                         if (this._value.length > 2) {
                             var array = [];
-                            var items = this._value.split(',');
-                            items = items.map((item) => item.trim());
-                            items = items.map((item) => {
+                            this._value.split(',').map((item) => {
+                                item = item.trim();
                                 var intValue = Number.parseInt(item, 10);
                                 if (Number.isNaN(item - intValue)) {
                                     array = null;

+ 4 - 3
src/paddle.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var paddle = paddle || {};
 var protobuf = protobuf || require('protobufjs');
@@ -6,7 +7,7 @@ var base = base || require('./base');
 
 paddle.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         if (identifier == '__model__' || extension == 'paddle') {
@@ -16,7 +17,7 @@ paddle.ModelFactory = class {
     }
 
     open(context, host, callback) {
-        host.require('./paddle-proto', (err, module) => {
+        host.require('./paddle-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;

+ 3 - 2
src/pickle.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var pickle = pickle || {};
 
@@ -354,7 +355,7 @@ pickle.Unpickler = class {
                         }
                         break;
                 }
-           }
+            }
         }
         return a.slice(0, o);
     }

+ 10 - 7
src/pytorch.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 // Experimental
 
@@ -6,10 +7,11 @@ var pytorch = pytorch || {};
 var base = base || require('./base');
 var long = long || { Long: require('long') };
 var tar = tar || require('./tar');
+var marked = marked || require('marked');
 
 pytorch.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier; 
         var extension = identifier.split('.').pop().toLowerCase();
         if (extension == 'pt' || extension == 'pth' || extension == 'pkl' || extension == 'h5' || 
@@ -369,10 +371,10 @@ pytorch.ModelFactory = class {
                 }
                 throw new pytorch.Error("Unknown scalar type '" + dtype.name + "'.");
             };
-            functionTable['_codecs.encode'] = function(obj, econding) {
+            functionTable['_codecs.encode'] = function(obj /*, econding */) {
                 return obj;
             };
-            functionTable['collections.defaultdict'] = function(default_factory) {
+            functionTable['collections.defaultdict'] = function(/* default_factory */) {
                 return {};
             };
 
@@ -410,7 +412,7 @@ pytorch.ModelFactory = class {
                     case 'storage':
                         var data_type = data.shift();
                         var root_key = data.shift();
-                        var location = data.shift();
+                        data.shift(); // location
                         var size = data.shift();
                         var view_metadata = data.shift();
                         var storage = deserialized_objects[root_key];
@@ -420,8 +422,8 @@ pytorch.ModelFactory = class {
                         }
                         if (view_metadata) {
                             var view_key = view_metadata.shift();
-                            var view_offset = view_metadata.shift();
-                            var view_size = view_metadata.shift();
+                            view_metadata.shift(); // view_offset
+                            view_metadata.shift(); // view_size
                             var view = deserialized_objects[view_key];
                             if (!view) {
                                 view = null; // storage.slice(view_offset, view_offset + view_size);
@@ -494,6 +496,7 @@ pytorch.ModelFactory = class {
             }
         }
         catch (err) {
+            // continue regardless of error
         }
         return false;
     }

+ 7 - 6
src/sklearn.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 // Experimental
 
@@ -8,7 +9,7 @@ var marked = marked || require('marked');
 
 sklearn.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         if (extension == 'pkl' || extension == 'joblib') {
             var buffer = context.buffer;
@@ -128,7 +129,7 @@ sklearn.ModelFactory = class {
                         return array;
                     };
                 };
-                constructorTable['joblib.numpy_pickle.NumpyArrayWrapper'] = function(subtype, shape, dtype) {
+                constructorTable['joblib.numpy_pickle.NumpyArrayWrapper'] = function(/* subtype, shape, dtype */) {
                     this.__setstate__ = function(state) {
                         this.subclass = state.subclass;
                         this.dtype = state.dtype;
@@ -251,7 +252,7 @@ sklearn.ModelFactory = class {
                     }
                     throw new sklearn.Error("Unknown scalar type '" + dtype.name + "'.");
                 };
-                functionTable['numpy.ma.core._mareconstruct'] = function(subtype, baseclass, baseshape, basetype) {
+                functionTable['numpy.ma.core._mareconstruct'] = function(subtype /* , baseclass, baseshape, basetype */) {
                     // _data = ndarray.__new__(baseclass, baseshape, basetype)
                     // _mask = ndarray.__new__(ndarray, baseshape, make_mask_descr(basetype))
                     // return subtype.__new__(subtype, _data, mask=_mask, dtype=basetype,)
@@ -259,10 +260,10 @@ sklearn.ModelFactory = class {
                     obj.__type__ = subtype;
                     return obj;
                 };
-                functionTable['_codecs.encode'] = function(obj, econding) {
+                functionTable['_codecs.encode'] = function(obj /*, econding */) {
                     return obj;
                 };
-                functionTable['collections.defaultdict'] = function(default_factory) {
+                functionTable['collections.defaultdict'] = function(/* default_factory */) {
                     return {};
                 };
                 functionTable['__builtin__.bytearray'] = function(data, encoding) {

+ 1 - 1
src/tar.js

@@ -1,4 +1,4 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
 
 var tar = tar || {};
 

+ 9 - 12
src/tf.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 // Experimental
 
@@ -9,7 +10,7 @@ var marked = marked || require('marked');
 
 tf.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         var tags = null;
@@ -61,7 +62,7 @@ tf.ModelFactory = class {
     }
 
     open(context, host, callback) { 
-        host.require('./tf-proto', (err, module) => {
+        host.require('./tf-proto', (err) => {
             if (err) {
                 callback(err, null);
                 return;
@@ -227,7 +228,7 @@ tf.Graph = class {
             if (metaGraph.meta_info_def && metaGraph.meta_info_def.tags) {
                 this._tags = metaGraph.meta_info_def.tags.join(', ');
             }
-                graph.node.forEach((node) => {
+            graph.node.forEach((node) => {
                 this._operators[node.op] = (this._operators[node.op] || 0) + 1;
             });
         }
@@ -603,7 +604,7 @@ tf.Node = class {
                         description = description ? (allowedValues + ' ' + description) : allowedValues;
                     }
                     if (attribute.defaultValue) {
-                        var defaultValue = ƒ._formatAttributeValue(attribute.defaultValue);
+                        var defaultValue = tf.GraphMetadata._formatAttributeValue(attribute.defaultValue);
                         defaultValue = Array.isArray(defaultValue) ? defaultValue : [ defaultValue ];
                         defaultValue = defaultValue.map((item) => '`' + item + '`').join(', ');
                         defaultValue = 'Defaults to ' + defaultValue + '.';
@@ -657,7 +658,7 @@ tf.Attribute = class {
         if (value.hasOwnProperty('type')) {
             this._type = 'type';
             this._value = () => tf.Tensor.formatDataType(value.type);
-         }
+        }
         else if (value.hasOwnProperty('i')) {
             this._value = value.i;
         }
@@ -881,7 +882,7 @@ tf.Tensor = class {
                 break;
             case tf.proto.DataType.DT_STRING:
                 if (this._tensor.tensor_content && this._tensor.tensor_content.length > 0) {
-                    result.state = 'Tensor data type is not implemented.';
+                    context.state = 'Tensor data type is not implemented.';
                 }
                 else if (this._tensor.string_val && this._tensor.string_val.length == context.size) {
                     context.data = this._tensor.string_val;
@@ -1058,14 +1059,10 @@ tf.TensorShape = class {
 
 tf.GraphMetadata = class {
 
-    constructor(metadata, meta_info_def) {
+    constructor(metadata) {
         this._metadata = metadata;
         this._map = {};
         this._attributeCache = {};
-        if (meta_info_def && meta_info_def.strippedOpList && meta_info_def.strippedOpList.op) {
-            meta_info_def.strippedOpList.op.forEach((opDef) => {
-            });
-        }
     }
 
     getSchema(operator) {

+ 2 - 1
src/tflite-schema.js

@@ -1,3 +1,4 @@
+/* eslint 'indent': [ 'error', 2 ] */
 // automatically generated by the FlatBuffers compiler, do not modify
 
 /**
@@ -9171,5 +9172,5 @@ tflite_schema.Model.createModel = function(builder, version, operatorCodesOffset
 }
 
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {
-    module.exports = tflite_schema;
+  module.exports = tflite_schema;
 }

+ 3 - 2
src/tflite.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var tflite = tflite || {};
 var base = base || require('./base');
@@ -7,7 +8,7 @@ var long = long || { Long: require('long') };
 
 tflite.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         return extension == 'tflite' || extension == 'lite';
     }

+ 109 - 112
src/torch.js

@@ -1,12 +1,12 @@
-
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var torch = torch || {};
 var base = base || require('./base');
 
 torch.ModelFactory = class {
 
-    match(context, host) {
+    match(context) {
         var extension = context.identifier.split('.').pop().toLowerCase();
         if (extension == 't7') {
             var buffer = context.buffer;
@@ -323,9 +323,6 @@ torch.Node = class {
             case 'nn.SpatialReplicationPadding':
                 this._updateBox(module, 'pad');
                 break;
-            case 'nn.SpatialFullConvolution':
-                delete module.ones;
-                break;
             case 'nn.Dropout':
                 delete module.noise;
                 break;
@@ -663,110 +660,110 @@ torch.T7Reader = class {
         this._memo = {};
 
         this._registry = {};
-        this._registry['bnn.Binary'] = function(reader, version) { reader.nn(this); };
-        this._registry['bnn.SpatialConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.BatchNormalization'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SpatialConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.ReLU'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.Sigmoid'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SoftMax'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SpatialAveragePooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SpatialBatchNormalization'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SpatialFullConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.SpatialMaxPooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['cudnn.Tanh'] = function(reader, version) { reader.nn(this); };
-        this._registry['inn.SpatialMaxPooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.BinActiveZ'] = function(reader, version) { reader.nn(this); }; // allenai/XNOR-Net
-        this._registry['nn.CAddTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.CDivTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.CSubTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Concat'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Copy'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.ConcatTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.DepthConcat'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Dropout'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.GenNoise'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Identity'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Inception'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.InstanceNormalization'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.JoinTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.LeakyReLU'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Linear'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.LogSoftMax'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Mean'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.MulConstant'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.MM'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Normalize'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.NoiseFill'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Parallel'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.ParallelTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.PReLU'] = function(reader, version) { reader.nn(this); }; 
-        this._registry['nn.ReLU'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Replicate'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Reshape'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.ShaveImage'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SelectTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Sequential'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Sigmoid'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SoftMax'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialAveragePooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialBatchNormalization'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialConvolutionMM'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialCrossMapLRN'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialDilatedConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialDropout'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialFractionalMaxPooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialFullConvolution'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialLPPooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialMaxPooling'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialReflectionPadding'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialReplicationPadding'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialSubtractiveNormalization'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialUpSamplingBilinear'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialUpSamplingNearest'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.SpatialZeroPadding'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Square'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Sqrt'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.Tanh'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.TotalVariation'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.View'] = function(reader, version) { reader.nn(this); };
-        this._registry['nn.gModule'] = function(reader, version) { reader.nn(this); };
-        this._registry['nngraph.Node'] = function(reader, version) { reader.nn(this); };
-        this._registry['graph.Edge'] = function(reader, version) { reader.nn(this); };
-        this._registry['graph.Graph'] = function(reader, version) { reader.nn(this); };
-        this._registry['torch.ByteTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.CharTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.ShortTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.IntTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.LongTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.FloatTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.DoubleTensor'] = function(reader, version) { reader.tensor(this); };
-        this._registry['torch.CudaByteTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaCharTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaShortTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaIntTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaLongTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.CudaDoubleTensor'] = function(reader, version) {reader.tensor(this); };
-        this._registry['torch.ByteStorage'] = function(reader, version) { reader.storage(this, 'uint8', 1); };
-        this._registry['torch.CharStorage'] = function(reader, version) { reader.storage(this, 'int8', 1); };
-        this._registry['torch.ShortStorage'] = function(reader, version) { reader.storage(this, 'int16', 2); };
-        this._registry['torch.IntStorage'] = function(reader, version) { reader.storage(this, 'int32', 4); };
-        this._registry['torch.LongStorage'] = function(reader, version) { reader.storage(this, 'int64', 8); };
-        this._registry['torch.FloatStorage'] = function(reader, version) { reader.storage(this, 'float32', 4); };
-        this._registry['torch.DoubleStorage'] = function(reader, version) { reader.storage(this, 'float64', 8); };
-        this._registry['torch.CudaByteStorage'] = function(reader, version) { reader.storage(this, 'uint8', 1); };
-        this._registry['torch.CudaCharStorage'] = function(reader, version) { reader.storage(this, 'int8', 1); };
-        this._registry['torch.CudaShortStorage'] = function(reader, version) { reader.storage(this, 'int16', 2); };
-        this._registry['torch.CudaIntStorage'] = function(reader, version) { reader.storage(this, 'int32', 4); };
-        this._registry['torch.CudaLongStorage'] = function(reader, version) { reader.storage(this, 'int64', 8); };
-        this._registry['torch.CudaIntStorage'] = function(reader, version) { reader.storage(this, 'int32', 4); };
-        this._registry['torch.CudaStorage'] = function(reader, version) { reader.storage(this, 'float32', 4); };
-        this._registry['torch.CudaFloatStorage'] = function(reader, version) { reader.storage(this, 'float64', 8); };
-        this._registry['w2nn.AuxiliaryLossTable'] = function(reader, version) { reader.nn(this); };
-        this._registry['w2nn.InplaceClip01'] = function(reader, version) { reader.nn(this); };
-        this._registry['w2nn.ScaleTable'] = function(reader, version) { reader.nn(this); };
+        this._registry['bnn.Binary'] = function(reader) { reader.nn(this); };
+        this._registry['bnn.SpatialConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.BatchNormalization'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SpatialConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.ReLU'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.Sigmoid'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SoftMax'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SpatialAveragePooling'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SpatialBatchNormalization'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SpatialFullConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.SpatialMaxPooling'] = function(reader) { reader.nn(this); };
+        this._registry['cudnn.Tanh'] = function(reader) { reader.nn(this); };
+        this._registry['inn.SpatialMaxPooling'] = function(reader) { reader.nn(this); };
+        this._registry['nn.BinActiveZ'] = function(reader) { reader.nn(this); }; // allenai/XNOR-Net
+        this._registry['nn.CAddTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.CDivTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.CSubTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Concat'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Copy'] = function(reader) { reader.nn(this); };
+        this._registry['nn.ConcatTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.DepthConcat'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Dropout'] = function(reader) { reader.nn(this); };
+        this._registry['nn.GenNoise'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Identity'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Inception'] = function(reader) { reader.nn(this); };
+        this._registry['nn.InstanceNormalization'] = function(reader) { reader.nn(this); };
+        this._registry['nn.JoinTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.LeakyReLU'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Linear'] = function(reader) { reader.nn(this); };
+        this._registry['nn.LogSoftMax'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Mean'] = function(reader) { reader.nn(this); };
+        this._registry['nn.MulConstant'] = function(reader) { reader.nn(this); };
+        this._registry['nn.MM'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Normalize'] = function(reader) { reader.nn(this); };
+        this._registry['nn.NoiseFill'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Parallel'] = function(reader) { reader.nn(this); };
+        this._registry['nn.ParallelTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.PReLU'] = function(reader) { reader.nn(this); }; 
+        this._registry['nn.ReLU'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Replicate'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Reshape'] = function(reader) { reader.nn(this); };
+        this._registry['nn.ShaveImage'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SelectTable'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Sequential'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Sigmoid'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SoftMax'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialAveragePooling'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialBatchNormalization'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialConvolutionMM'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialCrossMapLRN'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialDilatedConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialDropout'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialFractionalMaxPooling'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialFullConvolution'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialLPPooling'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialMaxPooling'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialReflectionPadding'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialReplicationPadding'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialSubtractiveNormalization'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialUpSamplingBilinear'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialUpSamplingNearest'] = function(reader) { reader.nn(this); };
+        this._registry['nn.SpatialZeroPadding'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Square'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Sqrt'] = function(reader) { reader.nn(this); };
+        this._registry['nn.Tanh'] = function(reader) { reader.nn(this); };
+        this._registry['nn.TotalVariation'] = function(reader) { reader.nn(this); };
+        this._registry['nn.View'] = function(reader) { reader.nn(this); };
+        this._registry['nn.gModule'] = function(reader) { reader.nn(this); };
+        this._registry['nngraph.Node'] = function(reader) { reader.nn(this); };
+        this._registry['graph.Edge'] = function(reader) { reader.nn(this); };
+        this._registry['graph.Graph'] = function(reader) { reader.nn(this); };
+        this._registry['torch.ByteTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.CharTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.ShortTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.IntTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.LongTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.FloatTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.DoubleTensor'] = function(reader) { reader.tensor(this); };
+        this._registry['torch.CudaByteTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaCharTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaShortTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaIntTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaLongTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.CudaDoubleTensor'] = function(reader) {reader.tensor(this); };
+        this._registry['torch.ByteStorage'] = function(reader) { reader.storage(this, 'uint8', 1); };
+        this._registry['torch.CharStorage'] = function(reader) { reader.storage(this, 'int8', 1); };
+        this._registry['torch.ShortStorage'] = function(reader) { reader.storage(this, 'int16', 2); };
+        this._registry['torch.IntStorage'] = function(reader) { reader.storage(this, 'int32', 4); };
+        this._registry['torch.LongStorage'] = function(reader) { reader.storage(this, 'int64', 8); };
+        this._registry['torch.FloatStorage'] = function(reader) { reader.storage(this, 'float32', 4); };
+        this._registry['torch.DoubleStorage'] = function(reader) { reader.storage(this, 'float64', 8); };
+        this._registry['torch.CudaByteStorage'] = function(reader) { reader.storage(this, 'uint8', 1); };
+        this._registry['torch.CudaCharStorage'] = function(reader) { reader.storage(this, 'int8', 1); };
+        this._registry['torch.CudaShortStorage'] = function(reader) { reader.storage(this, 'int16', 2); };
+        this._registry['torch.CudaIntStorage'] = function(reader) { reader.storage(this, 'int32', 4); };
+        this._registry['torch.CudaLongStorage'] = function(reader) { reader.storage(this, 'int64', 8); };
+        this._registry['torch.CudaIntStorage'] = function(reader) { reader.storage(this, 'int32', 4); };
+        this._registry['torch.CudaStorage'] = function(reader) { reader.storage(this, 'float32', 4); };
+        this._registry['torch.CudaFloatStorage'] = function(reader) { reader.storage(this, 'float64', 8); };
+        this._registry['w2nn.AuxiliaryLossTable'] = function(reader) { reader.nn(this); };
+        this._registry['w2nn.InplaceClip01'] = function(reader) { reader.nn(this); };
+        this._registry['w2nn.ScaleTable'] = function(reader) { reader.nn(this); };
 
         if (buffer.length == 0) {
             throw new torch.Error('File is empty.');
@@ -1070,7 +1067,7 @@ torch.TextReader = class {
         return this.int32() == 1;
     }
 
-    bytes(size) {
+    bytes(/* size */) {
         throw new torch.Error('Byte array not supported in ASCII mode.');
     }
 
@@ -1144,7 +1141,7 @@ torch.TextReader = class {
         return text;
     }
 
-    storage(size, itemSize) {
+    storage(size /*, itemSize */) {
         var data = size > 0 ? this.line(Number.MAX_SAFE_INTEGER) : new Uint8Array(0);
         return new torch.TextReader(data, 0x20);
     }

+ 7 - 5
src/view-browser.js

@@ -1,4 +1,7 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
+/* eslint "no-global-assign": ["error", {"exceptions": [ "TextDecoder", "TextEncoder" ] } ] */
+/* global view */
 
 var host = host || {};
 
@@ -80,7 +83,7 @@ host.BrowserHost = class {
         var openFileButton = document.getElementById('open-file-button');
         var openFileDialog = document.getElementById('open-file-dialog');
         if (openFileButton && openFileDialog) {
-            openFileButton.addEventListener('click', (e) => {
+            openFileButton.addEventListener('click', () => {
                 openFileDialog.value = '';
                 openFileDialog.click();
             });
@@ -195,7 +198,7 @@ host.BrowserHost = class {
             var description = [];
             description.push((err && err.name ? (err.name + ': ') : '') + (err && err.message ? err.message : '(null)'));
             if (err.stack) {
-                var match = err.stack.match(/\n    at (.*)\((.*)\)/);
+                var match = err.stack.match(/\n {4}at (.*)\((.*)\)/);
                 if (match) {
                     description.push(match[1] + '(' + match[2].split('/').pop() + ')');
                 }
@@ -252,7 +255,7 @@ host.BrowserHost = class {
 
     _getQueryParameter(name) {
         var url = window.location.href;
-        name = name.replace(/[\[\]]/g, "\\$&");
+        name = name.replace(/[[\]]/g, "\\$&");
         var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
         var results = regex.exec(url);
         if (!results) {
@@ -353,7 +356,6 @@ host.BrowserHost = class {
     }
 
     _openBuffer(file, callback) {
-        var size = file.size;
         var reader = new FileReader();
         reader.onload = (e) => {
             var buffer = new Uint8Array(e.target.result);

+ 24 - 20
src/view-electron.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var host = host || {};
 
@@ -67,56 +68,56 @@ host.ElectronHost = class {
         this._view = view;
         this._view.show('Welcome');
 
-        electron.ipcRenderer.on('open', (event, data) => {
+        electron.ipcRenderer.on('open', (_, data) => {
             this._openFile(data.file);
         });
-        electron.ipcRenderer.on('export', (event, data) => {
+        electron.ipcRenderer.on('export', (_, data) => {
             this._view.export(data.file);
         });
-        electron.ipcRenderer.on('cut', (event, data) => {
+        electron.ipcRenderer.on('cut', () => {
             this._view.cut();
         });
-        electron.ipcRenderer.on('copy', (event, data) => {
+        electron.ipcRenderer.on('copy', () => {
             this._view.copy();
         });
-        electron.ipcRenderer.on('paste', (event, data) => {
+        electron.ipcRenderer.on('paste', () => {
             this._view.paste();
         });
-        electron.ipcRenderer.on('selectall', (event, data) => {
+        electron.ipcRenderer.on('selectall', () => {
             this._view.selectAll();
         });
-        electron.ipcRenderer.on('toggle-attributes', (event, data) => {
+        electron.ipcRenderer.on('toggle-attributes', () => {
             this._view.toggleAttributes();
             this._update('show-attributes', this._view.showAttributes);
         });
-        electron.ipcRenderer.on('toggle-initializers', (event, data) => {
+        electron.ipcRenderer.on('toggle-initializers', () => {
             this._view.toggleInitializers();
             this._update('show-initializers', this._view.showInitializers);
         });
-        electron.ipcRenderer.on('toggle-names', (event, data) => {
+        electron.ipcRenderer.on('toggle-names', () => {
             this._view.toggleNames();
             this._update('show-names', this._view.showNames);
         });
-        electron.ipcRenderer.on('zoom-in', (event, data) => {
+        electron.ipcRenderer.on('zoom-in', () => {
             document.getElementById('zoom-in-button').click();
         });
-        electron.ipcRenderer.on('zoom-out', (event, data) => {
+        electron.ipcRenderer.on('zoom-out', () => {
             document.getElementById('zoom-out-button').click();
         });
-        electron.ipcRenderer.on('reset-zoom', (event, data) => {
+        electron.ipcRenderer.on('reset-zoom', () => {
             this._view.resetZoom();
         });
-        electron.ipcRenderer.on('show-properties', (event, data) => {
+        electron.ipcRenderer.on('show-properties', () => {
             document.getElementById('model-properties-button').click();
         });
-        electron.ipcRenderer.on('find', (event, data) => {
+        electron.ipcRenderer.on('find', () => {
             this._view.find();
         });
 
         var openFileButton = document.getElementById('open-file-button');
         if (openFileButton) {
             openFileButton.style.opacity = 1;
-            openFileButton.addEventListener('click', (e) => {
+            openFileButton.addEventListener('click', () => {
                 electron.ipcRenderer.send('open-file-dialog', {});
             });
         }
@@ -237,7 +238,7 @@ host.ElectronHost = class {
                 var description = [];
                 description.push((err && err.name ? (err.name + ': ') : '') + (err && err.message ? err.message : '(null)'));
                 if (err.stack) {
-                    var match = err.stack.match(/\n    at (.*)\((.*)\)/);
+                    var match = err.stack.match(/\n {4}at (.*)\((.*)\)/);
                     if (match) {
                         description.push(match[1] + '(' + match[2].split('/').pop().split('\\').pop() + ')');
                     }
@@ -248,9 +249,10 @@ host.ElectronHost = class {
                     applicationVersion: this.version,
                     userAgentOverride: navigator.userAgent
                 };
-                this._telemetry.exception(description.join(' @ '), fatal, params, (err) => { });
+                this._telemetry.exception(description.join(' @ '), fatal, params, () => { });
             }
             catch (e) {
+                // continue regardless of error
             }
         }
     }
@@ -261,9 +263,10 @@ host.ElectronHost = class {
                 var params = {
                     userAgentOverride: navigator.userAgent
                 };
-                this._telemetry.screenview(name, this.type, this.version, null, null, params, (err) => { });
+                this._telemetry.screenview(name, this.type, this.version, null, null, params, () => { });
             }
             catch (e) {
+                // continue regardless of error
             }
         }
     }
@@ -276,9 +279,10 @@ host.ElectronHost = class {
                     applicationVersion: this.version,
                     userAgentOverride: navigator.userAgent
                 };
-                this._telemetry.event(category, action, label, value, params, (err) => { });
+                this._telemetry.event(category, action, label, value, params, () => { });
             }
             catch (e) {
+                // continue regardless of error
             }
         }
     }

+ 9 - 8
src/view-grapher.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var grapher = grapher || {};
 
@@ -189,11 +190,11 @@ grapher.Renderer = class {
         var sx;
         var sy;
         if (Math.abs(dy) * w > Math.abs(dx) * h) {
-        if (dy < 0) {
-            h = -h;
-        }
-        sx = dy === 0 ? 0 : h * dx / dy;
-        sy = h;
+            if (dy < 0) {
+                h = -h;
+            }
+            sx = dy === 0 ? 0 : h * dx / dy;
+            sy = h;
         }
         else {
             if (dx < 0) {
@@ -203,7 +204,7 @@ grapher.Renderer = class {
             sy = dx === 0 ? 0 : w * dy / dx;
         }      
         return {x: x + sx, y: y + sy};
-      }    
+    }    
 };
 
 grapher.NodeElement = class {
@@ -304,7 +305,7 @@ grapher.NodeElement.Header = class {
         this._elements = [];
         var x = 0;
         var y = 0;
-        this._items.forEach((item, index) => {
+        this._items.forEach((item) => {
             var yPadding = 4;
             var xPadding = 7;
             var element = this.createElement('g');

+ 11 - 13
src/view-sidebar.js

@@ -1,14 +1,15 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
+/* global view */
 
 var sidebar = sidebar || {};
-
 var Handlebars = Handlebars || require('handlebars');
 
 sidebar.Sidebar = class {
-    
+
     constructor(host) {
         this._host = host;
-        this._closeSidebarHandler = (e) => {
+        this._closeSidebarHandler = () => {
             this.close();
         };
         this._closeSidebarKeyDownHandler = (e) => {
@@ -17,7 +18,7 @@ sidebar.Sidebar = class {
                 this.close();
             }
         };
-        this._resizeSidebarHandler = (e) => {
+        this._resizeSidebarHandler = () => {
             var contentElement = this._host.document.getElementById('sidebar-content');
             if (contentElement) {
                 contentElement.style.height = window.innerHeight - 60;
@@ -95,7 +96,7 @@ sidebar.NodeSidebar = class {
             var documentationButton = document.createElement('a');
             documentationButton.className = 'sidebar-view-title-button';
             documentationButton.innerText = '?';
-            documentationButton.addEventListener('click', (e) => {
+            documentationButton.addEventListener('click', () => {
                 this._raise('show-documentation', null);
             });
             operatorElement.appendChild(documentationButton);
@@ -284,7 +285,7 @@ class NodeAttributeView {
             this._expander = document.createElement('div');
             this._expander.className = 'sidebar-view-item-value-expander';
             this._expander.innerText = '+';
-            this._expander.addEventListener('click', (e) => {
+            this._expander.addEventListener('click', () => {
                 this.toggle();
             });
             this._element.appendChild(this._expander);
@@ -411,7 +412,7 @@ sidebar.ConnectionView = class {
             this._expander = document.createElement('div');
             this._expander.className = 'sidebar-view-item-value-expander';
             this._expander.innerText = '+';
-            this._expander.addEventListener('click', (e) => {
+            this._expander.addEventListener('click', () => {
                 this.toggle();
             });
             this._element.appendChild(this._expander);
@@ -458,9 +459,6 @@ sidebar.ConnectionView = class {
                 var type = '?';
                 var denotation = null;
                 if (this._connection.type) {
-                    if (typeof this._connection.type == 'string') {
-                        debugger;
-                    }
                     type = this._connection.type.toString();
                     denotation = this._connection.type.denotation || null;
                 }
@@ -509,7 +507,7 @@ sidebar.ConnectionView = class {
                         this._saveButton = document.createElement('div');
                         this._saveButton.className = 'sidebar-view-item-value-expander';
                         this._saveButton.innerHTML = '&#x1F4BE;';
-                        this._saveButton.addEventListener('click', (e) => {
+                        this._saveButton.addEventListener('click', () => {
                             this._raise('export-tensor', initializer);
                         });
                         this._element.appendChild(this._saveButton);
@@ -715,7 +713,7 @@ sidebar.GraphOperatorListView = class {
         this._expander = document.createElement('div');
         this._expander.className = 'sidebar-view-item-value-expander';
         this._expander.innerText = '+';
-        this._expander.addEventListener('click', (e) => {
+        this._expander.addEventListener('click', () => {
             this.toggle();
         });
 

+ 17 - 16
src/view.js

@@ -1,4 +1,5 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
 
 var view = view || {};
 
@@ -6,6 +7,7 @@ var long = long || { Long: require('long') };
 var zip = zip || require('./zip');
 var gzip = gzip || require('./gzip');
 var tar = tar || require('./tar');
+var protobuf = protobuf || require('protobufjs');
 
 var d3 = d3 || require('d3');
 var dagre = dagre || require('dagre');
@@ -26,16 +28,15 @@ view.View = class {
         this._showNames = false;
         this._searchText = '';
         this._modelFactoryService = new view.ModelFactoryService(this._host);
-        var document = this._host.document;
         this._host.document.documentElement.style.overflow = 'hidden';
         this._host.document.body.scroll = 'no';
-        this._host.document.getElementById('model-properties-button').addEventListener('click', (e) => {
+        this._host.document.getElementById('model-properties-button').addEventListener('click', () => {
             this.showModelProperties();
         });
-        this._host.document.getElementById('zoom-in-button').addEventListener('click', (e) => {
+        this._host.document.getElementById('zoom-in-button').addEventListener('click', () => {
             this.zoomIn();
         });
-        this._host.document.getElementById('zoom-out-button').addEventListener('click', (e) => {
+        this._host.document.getElementById('zoom-out-button').addEventListener('click', () => {
             this.zoomOut();
         });
         this._host.document.getElementById('toolbar').addEventListener('mousewheel', (e) => {
@@ -44,7 +45,7 @@ view.View = class {
         this._host.document.getElementById('sidebar').addEventListener('mousewheel', (e) => {
             this.preventZoom(e);
         });
-        this._host.document.addEventListener('keydown', (e) => {
+        this._host.document.addEventListener('keydown', () => {
             this.clearSelection();
         });
         if (this._host.environment('zoom') == 'scroll') {
@@ -252,8 +253,8 @@ view.View = class {
     _mouseWheelHandler(e) {
         if (e.shiftKey || e.ctrlKey) {
             if (this._zoom) {
-                var oldWidth = this._width * this._zoom;
-                var oldHeight = this._height * this._zoom;
+                // var oldWidth = this._width * this._zoom;
+                // var oldHeight = this._height * this._zoom;
                 this._zoom = this._zoom + (e.wheelDelta * 1.0 / 6000.0);
                 if (this._zoom < 0.1) { this._zoom = 0.1; }
                 if (this._zoom > 2) { this._zoom = 2; }
@@ -355,7 +356,7 @@ view.View = class {
             if (graph) {
                 this.show('Spinner');
                 setTimeout(() => {
-                    this.updateGraph(model, graph, (err, model) => {
+                    this.updateGraph(model, graph, (err /*, model */) => {
                         if (err) {
                             this.error('Graph update failed.', err);
                         }
@@ -487,7 +488,7 @@ view.View = class {
 
                         if (node.function) {
                             header.add(null, [ 'node-item-function' ], '+', null, () => {
-                                debugger;
+                                // debugger;
                             });
                         }
 
@@ -752,7 +753,7 @@ view.View = class {
                     this._zoom = d3.zoom();
                     this._zoom(svg);
                     this._zoom.scaleExtent([0.1, 2]);
-                    this._zoom.on('zoom', (e) => {
+                    this._zoom.on('zoom', () => {
                         originElement.setAttribute('transform', d3.event.transform.toString());
                     });
                     this._zoom.transform(svg, d3.zoomIdentity);
@@ -932,7 +933,7 @@ view.View = class {
     showNodeProperties(node, input) {
         if (node) {
             var view = new sidebar.NodeSidebar(node, this._host);
-            view.on('show-documentation', (sender, e) => {
+            view.on('show-documentation', (/* sender, e */) => {
                 this.showOperatorDocumentation(node);
             });
             view.on('export-tensor', (sender, tensor) => {
@@ -1044,7 +1045,7 @@ class ArchiveContext {
             return;
         }
         var data = entry.data;
-        if (type != null) {
+        if (data != null) {
             data = new TextDecoder(encoding).decode(data);
         }
         callback(null, data);
@@ -1176,7 +1177,7 @@ view.ModelFactoryService = class {
                             return;
                         }
                         var modelFactory = new module.ModelFactory(); 
-                        if (!modelFactory.match(context, this._host)) {
+                        if (!modelFactory.match(context)) {
                             nextModule();
                             return;
                         }
@@ -1309,7 +1310,7 @@ view.ModelFactoryService = class {
                                             callback(new ArchiveError("Failed to load module '" + id + "'.", null), null);
                                         }
                                         var factory = new module.ModelFactory();
-                                        if (factory.match(context, this._host)) {
+                                        if (factory.match(context)) {
                                             matches.push(entry);
                                             modules = [];
                                         }
@@ -1346,7 +1347,7 @@ view.ModelFactoryService = class {
             return;
         }
         catch (error) {
-            callback(new ArchiveError(err.message), null);
+            callback(new ArchiveError(error.message), null);
             return;
         }
     }

+ 5 - 3
src/zip.js

@@ -1,4 +1,6 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
+/* global pako */
 
 var zip = zip || {};
 
@@ -274,7 +276,7 @@ zip.Inflater = class {
         var buffer = output.buffer;
         var position = output.position;
         var start = position;
-        while (true) {
+        for (;;) {
             if (position > 62464) {
                 output.position = position;
                 output.push(new Uint8Array(buffer.subarray(start, position)));
@@ -390,7 +392,7 @@ zip.BitReader = class {
 
     bytes(size) {
         var value = this.buffer.subarray(this.position, this.position + size);
-        reader.position += size;
+        this.position += size;
         return value;
     }
 

+ 29 - 24
test/test.js

@@ -1,10 +1,11 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
+/* eslint "no-console": off */
 
 const fs = require('fs');
 const path = require('path');
 const process = require('process');
 const child_process = require('child_process');
-const vm = require('vm');
 const http = require('http');
 const https = require('https');
 const url = require('url');
@@ -62,7 +63,7 @@ class TestHost {
         this.document = new HTMLDocument();
     }
 
-    initialize(view) {
+    initialize(/* view */) {
     }
 
     environment(name) {
@@ -72,7 +73,7 @@ class TestHost {
         return null;
     }
 
-    screen(name) {
+    screen(/* name */) {
     }
 
     require(id, callback) {
@@ -105,10 +106,10 @@ class TestHost {
         });
     }
 
-    event(category, action, label, value) {
+    event(/* category, action, label, value */) {
     }
 
-    exception(err, fatal) {
+    exception(err /*, fatal */) {
         this._exceptions.push(err);
     }
 
@@ -125,11 +126,11 @@ class HTMLDocument {
         this.body = new HTMLBodyElement();
     }
 
-    createElementNS(namespace, name) {
+    createElementNS(/* namespace, name */) {
         return new HTMLHtmlElement();
     }
 
-    createTextNode(text) {
+    createTextNode(/* text */) {
         return new HTMLHtmlElement();
     }
 
@@ -142,37 +143,39 @@ class HTMLDocument {
         return element;
     }
 
-    addEventListener(event, callback) {
+    addEventListener(/* event, callback */) {
     }
 
-    removeEventListener(event, callback) {
+    removeEventListener(/* event, callback */) {
     }
 }
 
 class HTMLHtmlElement {
 
     constructor() {
+        this._attributes = {};
         this.style = new CSSStyleDeclaration();
     }
 
-    appendChild(node) {
+    appendChild(/* node */) {
     }
 
     setAttribute(name, value) {
+        this._attributes[name] = value;
     }
 
     getBBox() {
         return { x: 0, y: 0, width: 10, height: 10 };
     }
     
-    getElementsByClassName(name) {
+    getElementsByClassName(/* name */) {
         return null;
     }
 
-    addEventListener(event, callback) {
+    addEventListener(/* event, callback */) {
     }
 
-    removeEventListener(event, callback) {
+    removeEventListener(/* event, callback */) {
     }
 }
 
@@ -182,17 +185,19 @@ class HTMLBodyElement {
         this.style = new CSSStyleDeclaration();
     }
 
-    addEventListener(event, callback) {
+    addEventListener(/* event, callback */) {
     }
 }
 
 class CSSStyleDeclaration {
 
-    setProperty(name, value) {
+    constructor() {
+        this._properties = {};
     }
-}
 
-class SVGElement {
+    setProperty(name, value) {
+        this._properties[name] = value;
+    }
 }
 
 class TestContext {
@@ -277,11 +282,11 @@ function makeDir(dir) {
 
 function decompress(buffer, identifier) {
     var archive = null;
-    extension = identifier.split('.').pop().toLowerCase();
+    var extension = identifier.split('.').pop().toLowerCase();
     if (extension == 'gz' || extension == 'tgz') {
         archive = new gzip.Archive(buffer);
         if (archive.entries.length == 1) {
-            entry = archive.entries[0];
+            var entry = archive.entries[0];
             if (entry.name) {
                 identifier = entry.name;
             }
@@ -416,7 +421,7 @@ function download(folder, targets, sources, completed, callback) {
             process.stdout.write('  decompress...\r');
             var archive = decompress(data, source.split('/').pop());
             // console.log(archive);
-            sourceFiles.forEach((file, index) => {
+            sourceFiles.forEach((file) => {
                 if (process.stdout.clearLine) {
                     process.stdout.clearLine();
                 }
@@ -498,8 +503,8 @@ function loadModel(target, item, callback) {
                     });
                 });
                 graph.nodes.forEach((node) => {
-                    var documentation = node.documentation;
-                    var category = node.category;
+                    node.documentation;
+                    node.category;
                     node.attributes.forEach((attribute) => {
                         var value = view.View.formatAttributeValue(attribute.value, attribute.type)
                         if (value && value.length > 1000) {
@@ -513,7 +518,7 @@ function loadModel(target, item, callback) {
                                 connection.type.toString();
                             }
                             if (connection.initializer) {
-                                var value = connection.initializer.toString();
+                                connection.initializer.toString();
                             }
                         });
                     });

+ 2 - 1
tools/tflite

@@ -74,9 +74,10 @@ schema() {
     rm ${tools}/tflite.schema.fbs
 cat <<EOT >> ${src}/tflite-schema.js
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {
-    module.exports = tflite_schema;
+  module.exports = tflite_schema;
 }
 EOT
+    echo "/* eslint 'indent': [ 'error', 2 ] */" | cat - ${src}/tflite-schema.js > ${src}/tflite-schema_2.js && mv ${src}/tflite-schema_2.js ${src}/tflite-schema.js
 }
 
 visualize() {

+ 7 - 5
tools/update_pbjs.js

@@ -1,4 +1,6 @@
-/*jshint esversion: 6 */
+/* jshint esversion: 6 */
+/* eslint "indent": [ "error", 4, { "SwitchCase": 1 } ] */
+/* eslint "no-console": off */
 
 const fs = require('fs');
 const process = require('process');
@@ -37,12 +39,12 @@ var replace = '';
 
 switch (pattern) {
     case 'array':
-search = `if ((tag & 7) === 2) {
+        search = `if ((tag & 7) === 2) {
     var end2 = reader.uint32() + reader.pos;
     while (reader.pos < end2)
         message.$(variable).push(reader.$(type)());
 } else`;
-replace = `if ((tag & 7) === 2) {
+        replace = `if ((tag & 7) === 2) {
     var end2 = reader.uint32() + reader.pos;
     if (message.$(variable).length == 0 && (end2 - reader.pos) > 1048576) {
         var $(variable)Length = end2 - reader.pos;
@@ -63,7 +65,7 @@ replace = `if ((tag & 7) === 2) {
         break;
 
     case 'enumeration':
-search = `if (!(message.$(variable) && message.$(variable).length))
+        search = `if (!(message.$(variable) && message.$(variable).length))
     message.$(variable) = [];
 if ((tag & 7) === 2) {
     var end2 = reader.uint32() + reader.pos;
@@ -73,7 +75,7 @@ if ((tag & 7) === 2) {
     message.$(variable).push(reader.$(type)());
 break;`;
 
-replace = `if (!(message.$(variable) && message.$(variable).length)) {
+        replace = `if (!(message.$(variable) && message.$(variable).length)) {
     if (message.$(variable) != -1) {
         message.$(variable) = [];
         message.$(variable)Count = 0;