Просмотр исходного кода

Add no-unmodified-loop-condition lint rule

Lutz Roeder 4 лет назад
Родитель
Сommit
6627fa0a38
3 измененных файлов с 10 добавлено и 5 удалено
  1. 4 3
      package.json
  2. 2 1
      source/xml.js
  3. 4 1
      source/zip.js

+ 4 - 3
package.json

@@ -38,13 +38,14 @@
         },
         "rules": {
             "brace-style": [ "error", "stroustrup", { "allowSingleLine": true } ],
+            "curly": "error",
             "indent": [ "error", 4, { "SwitchCase": 1 } ],
             "linebreak-style": "off",
-            "no-trailing-spaces": "error",
             "no-console": "error",
+            "no-trailing-spaces": "error",
+            "no-unmodified-loop-condition": "error",
             "prefer-const": [ "error", { "destructuring": "all" } ],
-            "semi": [ "error", "always" ],
-            "curly": "error"
+            "semi": [ "error", "always" ]
         },
         "globals": {
             "flatbuffers": "readonly",

+ 2 - 1
source/xml.js

@@ -581,13 +581,14 @@ xml.TextReader = class {
     _nmtoken() {
         const position = this._position;
         const name = [];
-        const c = this._char.codePointAt(0);
+        let c = this._char.codePointAt(0);
         while (this._nameCharRegExp.test(this._char) || (c >= 0x300 && c <= 0x36f) || (c >= 0x203F && c <= 0x2040)) {
             name.push(this._char);
             this._next();
             if (this._char === undefined) {
                 break;
             }
+            c = this._char.codePointAt(0);
         }
         if (name.length > 0) {
             return name.join('');

+ 4 - 1
source/zip.js

@@ -29,8 +29,11 @@ zip.Archive = class {
                             return true;
                         }
                     }
+                    if (!signature) {
+                        break;
+                    }
                 }
-                while (position > 0 && signature);
+                while (position > 0);
                 return false;
             };
             if (!seek([ 0x50, 0x4B, 0x05, 0x06 ])) {