소스 검색

fix(eslint): Add no-loop-func rule

dev1
hristoterezov 8 년 전
부모
커밋
774ee4b2b0
4개의 변경된 파일19개의 추가작업 그리고 12개의 파일을 삭제
  1. 1
    0
      .eslintrc.js
  2. 3
    1
      modules/connectivity/ConnectionQuality.js
  3. 14
    11
      modules/transcription/transcriber.js
  4. 1
    0
      modules/xmpp/SDP.js

+ 1
- 0
.eslintrc.js 파일 보기

97
         'no-iterator': 2,
97
         'no-iterator': 2,
98
         'no-labels': 2,
98
         'no-labels': 2,
99
         'no-lone-blocks': 2,
99
         'no-lone-blocks': 2,
100
+        'no-loop-func': 2,
100
         'no-magic-numbers': 0,
101
         'no-magic-numbers': 0,
101
         'no-multi-spaces': 2,
102
         'no-multi-spaces': 2,
102
         'no-multi-str': 2,
103
         'no-multi-str': 2,

+ 3
- 1
modules/connectivity/ConnectionQuality.js 파일 보기

89
             // Sum the target fields from all simulcast layers for the given
89
             // Sum the target fields from all simulcast layers for the given
90
             // resolution (e.g. 720p + 360p + 180p).
90
             // resolution (e.g. 720p + 360p + 180p).
91
             for (height = simulcastFormat.height; height >= 180; height /= 2) {
91
             for (height = simulcastFormat.height; height >= 180; height /= 2) {
92
+                const targetHeight = height;
93
+
92
                 simulcastFormat
94
                 simulcastFormat
93
-                    = kSimulcastFormats.find(f => f.height == height);
95
+                    = kSimulcastFormats.find(f => f.height == targetHeight);
94
                 if (simulcastFormat) {
96
                 if (simulcastFormat) {
95
                     target += simulcastFormat.target;
97
                     target += simulcastFormat.target;
96
                 } else {
98
                 } else {

+ 14
- 11
modules/transcription/transcriber.js 파일 보기

191
     arrays.forEach(array => pushWordToSortedArray(potentialWords, array));
191
     arrays.forEach(array => pushWordToSortedArray(potentialWords, array));
192
 
192
 
193
     // keep adding words to transcription until all arrays are exhausted
193
     // keep adding words to transcription until all arrays are exhausted
194
-    let lowestWordArray;
195
-    let wordToAdd;
196
-    let foundSmaller;
197
-
198
     while (hasPopulatedArrays(arrays)) {
194
     while (hasPopulatedArrays(arrays)) {
199
         // first select the lowest array;
195
         // first select the lowest array;
200
-        lowestWordArray = arrays[0];
196
+        let lowestWordArray = arrays[0];
197
+
201
         arrays.forEach(wordArray => {
198
         arrays.forEach(wordArray => {
202
             if (wordArray[0].begin < lowestWordArray[0].begin) {
199
             if (wordArray[0].begin < lowestWordArray[0].begin) {
203
                 lowestWordArray = wordArray;
200
                 lowestWordArray = wordArray;
205
         });
202
         });
206
 
203
 
207
         // put the word in the transcription
204
         // put the word in the transcription
208
-        wordToAdd = lowestWordArray.shift();
205
+        let wordToAdd = lowestWordArray.shift();
206
+
209
         this.updateTranscription(wordToAdd, lowestWordArray.name);
207
         this.updateTranscription(wordToAdd, lowestWordArray.name);
210
 
208
 
211
         // keep going until a word in another array has a smaller time
209
         // keep going until a word in another array has a smaller time
212
         // or the array is empty
210
         // or the array is empty
213
-        while (!foundSmaller && lowestWordArray.length > 0) {
211
+        while (lowestWordArray.length > 0) {
212
+            let foundSmaller = false;
213
+            const wordToCompare = lowestWordArray[0].begin;
214
+
214
             arrays.forEach(wordArray => {
215
             arrays.forEach(wordArray => {
215
-                if (wordArray[0].begin < lowestWordArray[0].begin) {
216
+                if (wordArray[0].begin < wordToCompare) {
216
                     foundSmaller = true;
217
                     foundSmaller = true;
217
                 }
218
                 }
218
             });
219
             });
219
 
220
 
220
             // add next word if no smaller time has been found
221
             // add next word if no smaller time has been found
221
-            if (!foundSmaller) {
222
-                wordToAdd = lowestWordArray.shift();
223
-                this.updateTranscription(wordToAdd, null);
222
+            if (foundSmaller) {
223
+                break;
224
             }
224
             }
225
+
226
+            wordToAdd = lowestWordArray.shift();
227
+            this.updateTranscription(wordToAdd, null);
225
         }
228
         }
226
 
229
 
227
     }
230
     }

+ 1
- 0
modules/xmpp/SDP.js 파일 보기

270
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
270
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
271
 
271
 
272
                 if (ssrclines.length > 0) {
272
                 if (ssrclines.length > 0) {
273
+                    // eslint-disable-next-line no-loop-func
273
                     ssrclines.forEach(line => {
274
                     ssrclines.forEach(line => {
274
                         const idx = line.indexOf(' ');
275
                         const idx = line.indexOf(' ');
275
                         const linessrc = line.substr(0, idx).substr(7);
276
                         const linessrc = line.substr(0, idx).substr(7);

Loading…
취소
저장