Ver Fonte

Add keyword-spacing lint rule

Lutz Roeder há 3 anos atrás
pai
commit
284968cad6
12 ficheiros alterados com 16 adições e 15 exclusões
  1. 1 0
      package.json
  2. 1 1
      source/circle.js
  3. 1 1
      source/dagre.js
  4. 2 2
      source/hdf5.js
  5. 1 1
      source/index.js
  6. 4 4
      source/megengine.js
  7. 1 1
      source/python.js
  8. 1 1
      source/tengine.js
  9. 1 1
      source/tflite.js
  10. 1 1
      source/uff.js
  11. 1 1
      tools/flatc.js
  12. 1 1
      tools/protoc.js

+ 1 - 0
package.json

@@ -45,6 +45,7 @@
             "default-case": "error",
             "default-case-last": "error",
             "indent": [ "error", 4, { "SwitchCase": 1 } ],
+            "keyword-spacing": "error",
             "linebreak-style": "off",
             "no-await-in-loop": "error",
             "no-console": "error",

+ 1 - 1
source/circle.js

@@ -219,7 +219,7 @@ circle.Graph = class {
                     }
                     else if (contentProperties instanceof circle.schema.ImageProperties) {
                         denotation = 'Image';
-                        switch(contentProperties.color_space) {
+                        switch (contentProperties.color_space) {
                             case 0: denotation += '(Unknown)'; break;
                             case 1: denotation += '(RGB)'; break;
                             case 2: denotation += '(Grayscale)'; break;

+ 1 - 1
source/dagre.js

@@ -542,7 +542,7 @@ dagre.layout = (graph, options) => {
                     exchangeEdges(t, g, e, f);
                 }
             };
-            switch(g.options.ranker) {
+            switch (g.options.ranker) {
                 case 'tight-tree':
                     longestPath(g);
                     feasibleTree(g);

+ 2 - 2
source/hdf5.js

@@ -356,7 +356,7 @@ hdf5.Reader = class {
         const s = (value & 0x8000) >> 15;
         const e = (value & 0x7C00) >> 10;
         const f = value & 0x03FF;
-        if(e == 0) {
+        if (e == 0) {
             return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
         }
         else if (e == 0x1F) {
@@ -759,7 +759,7 @@ hdf5.DataObjectHeader = class {
     }
 
     _readMessage(reader, type, size, flags) {
-        switch(type) {
+        switch (type) {
             case 0x0000: // NIL
                 return false;
             case 0x0001: // Dataspace

+ 1 - 1
source/index.js

@@ -924,7 +924,7 @@ host.BrowserHost.BrowserFileContext = class {
                 e = e || this.window.event;
                 let message = '';
                 const error = e.target.error;
-                switch(error.code) {
+                switch (error.code) {
                     case error.NOT_FOUND_ERR:
                         message = "File not found '" + file + "'.";
                         break;

+ 4 - 4
source/megengine.js

@@ -387,7 +387,7 @@ megengine.Graph = class {
                 }
             }
         };
-        if(obj.argdef_graph_map) {
+        if (obj.argdef_graph_map) {
             const graph = Object.values(obj.argdef_graph_map)[0];
             loadGraph(obj, graph, new Map(), '', metadata, true);
             return;
@@ -409,7 +409,7 @@ megengine.Graph = class {
                 const data = tensor.data.byteLength !== 0 ? tensor.data.slice(0) : undefined;
                 const initializer = opr.type === 'Host2DeviceCopy' ? undefined : new megengine.Tensor('', type, data);
                 let quantization;
-                if(tensor.dtype.param) {
+                if (tensor.dtype.param) {
                     quantization = {scale: tensor.dtype.param.scale, zeroPoint: tensor.dtype.param.zero_point};
                 }
                 const argument = new megengine.Argument(name, type, initializer, quantization);
@@ -516,7 +516,7 @@ megengine.Argument = class {
         this._name = name;
         this._initializer = initializer;
         this._type = type;
-        if(quantization && this._type.dataType.startsWith('q')) {
+        if (quantization && this._type.dataType.startsWith('q')) {
             this._scale = quantization.scale;
             this._zeroPoint = quantization.zeroPoint;
         }
@@ -561,7 +561,7 @@ megengine.Node = class {
         this._chain = [];
         this._attributes = [];
 
-        if(item.inputs && item.outputs && item.param) {
+        if (item.inputs && item.outputs && item.param) {
             const inputSchemas = this._type && this._type.inputs ? [ ...this._type.inputs ] : [];
             for (let i = 0; i < item.inputs.length; i++) {
                 const inputOpr = allOprAndTensor.get(item.inputs[i]);

+ 1 - 1
source/python.js

@@ -1064,7 +1064,7 @@ python.Tokenizer = class {
     }
 
     static _isNewline(c) {
-        switch(c) {
+        switch (c) {
             case '\n':
             case '\r':
             case '\u2028': // 8232

+ 1 - 1
source/tengine.js

@@ -712,7 +712,7 @@ tengine.BinaryReader = class extends base.BinaryReader {
             this.seek(position);
             const size = this.uint32();
             this.seek(this.uint32());
-            for(let i = 0; i < size - 1; i++) {
+            for (let i = 0; i < size - 1; i++) {
                 content += String.fromCharCode(this._buffer[this._position++]);
             }
             this.seek(next);

+ 1 - 1
source/tflite.js

@@ -232,7 +232,7 @@ tflite.Graph = class {
                     }
                     else if (contentProperties instanceof tflite.schema.ImageProperties) {
                         denotation = 'Image';
-                        switch(contentProperties.color_space) {
+                        switch (contentProperties.color_space) {
                             case 0: denotation += '(Unknown)'; break;
                             case 1: denotation += '(RGB)'; break;
                             case 2: denotation += '(Grayscale)'; break;

+ 1 - 1
source/uff.js

@@ -278,7 +278,7 @@ uff.Attribute = class {
 
     constructor(metadata, name, value) {
         this._name = name;
-        switch(value.type) {
+        switch (value.type) {
             case 's': this._value = value.s; this._type = 'string'; break;
             case 's_list': this._value = value.s_list; this._type = 'string[]'; break;
             case 'd': this._value = value.d; this._type = 'float64'; break;

+ 1 - 1
tools/flatc.js

@@ -735,7 +735,7 @@ flatc.Parser.Tokenizer = class {
     }
 
     static _isNewline(c) {
-        switch(c) {
+        switch (c) {
             case '\n':
             case '\r':
             case '\u2028': // 8232

+ 1 - 1
tools/protoc.js

@@ -712,7 +712,7 @@ protoc.Parser = class {
         }
         const obj = new protoc.Enum(parent, token);
         this._ifBlock(obj, (token) => {
-            switch(token) {
+            switch (token) {
                 case "option":
                     this._parseOption(obj, token);
                     this._tokenizer.expect(";");