Browse Source

Set eslint rule comma-dangle to always-multiline and apply it

tags/2.6.0
Nathanaël Jourdane 4 months ago
parent
commit
dec5ca1148
2 changed files with 75 additions and 74 deletions
  1. 2
    1
      .eslintrc
  2. 73
    73
      src/js/easymde.js

+ 2
- 1
.eslintrc View File

@@ -9,7 +9,8 @@
9 9
         "semi": [
10 10
             "error",
11 11
             "always"
12
-        ]
12
+        ],
13
+        "comma-dangle": ["error", "always-multiline"]
13 14
     },
14 15
     "env": {
15 16
         "browser": true,

+ 73
- 73
src/js/easymde.js View File

@@ -42,7 +42,7 @@ var bindings = {
42 42
     'undo': undo,
43 43
     'redo': redo,
44 44
     'toggleSideBySide': toggleSideBySide,
45
-    'toggleFullScreen': toggleFullScreen
45
+    'toggleFullScreen': toggleFullScreen,
46 46
 };
47 47
 
48 48
 var shortcuts = {
@@ -59,7 +59,7 @@ var shortcuts = {
59 59
     'toggleCodeBlock': 'Cmd-Alt-C',
60 60
     'togglePreview': 'Cmd-P',
61 61
     'toggleSideBySide': 'F9',
62
-    'toggleFullScreen': 'F11'
62
+    'toggleFullScreen': 'F11',
63 63
 };
64 64
 
65 65
 var getBindingName = function (f) {
@@ -321,11 +321,11 @@ function toggleCodeBlock(editor) {
321 321
         line = line || cm.getLineHandle(line_num);
322 322
         firstTok = firstTok || cm.getTokenAt({
323 323
             line: line_num,
324
-            ch: 1
324
+            ch: 1,
325 325
         });
326 326
         lastTok = lastTok || (!!line.text && cm.getTokenAt({
327 327
             line: line_num,
328
-            ch: line.text.length - 1
328
+            ch: line.text.length - 1,
329 329
         }));
330 330
         var types = firstTok.type ? firstTok.type.split(' ') : [];
331 331
         if (lastTok && token_state(lastTok).indentedCode) {
@@ -358,10 +358,10 @@ function toggleCodeBlock(editor) {
358 358
         _replaceSelection(cm, false, [repl_start, repl_end]);
359 359
         cm.setSelection({
360 360
             line: start_line_sel,
361
-            ch: 0
361
+            ch: 0,
362 362
         }, {
363 363
             line: end_line_sel,
364
-            ch: 0
364
+            ch: 0,
365 365
         });
366 366
     }
367 367
 
@@ -370,7 +370,7 @@ function toggleCodeBlock(editor) {
370 370
         cur_end = cm.getCursor('end'),
371 371
         tok = cm.getTokenAt({
372 372
             line: cur_start.line,
373
-            ch: cur_start.ch || 1
373
+            ch: cur_start.ch || 1,
374 374
         }), // avoid ch 0 which is a cursor pos but not token
375 375
         line = cm.getLineHandle(cur_start.line),
376 376
         is_code = code_type(cm, cur_start.line, line, tok);
@@ -382,10 +382,10 @@ function toggleCodeBlock(editor) {
382 382
             end = line.text.slice(cur_start.ch).replace('`', '');
383 383
         cm.replaceRange(start + end, {
384 384
             line: cur_start.line,
385
-            ch: 0
385
+            ch: 0,
386 386
         }, {
387 387
             line: cur_start.line,
388
-            ch: 99999999999999
388
+            ch: 99999999999999,
389 389
         });
390 390
         cur_start.ch--;
391 391
         if (cur_start !== cur_end) {
@@ -406,7 +406,7 @@ function toggleCodeBlock(editor) {
406 406
             }
407 407
             var fencedTok = cm.getTokenAt({
408 408
                 line: block_start,
409
-                ch: 1
409
+                ch: 1,
410 410
             });
411 411
             var fence_chars = token_state(fencedTok).fencedChars;
412 412
             var start_text, start_line;
@@ -443,25 +443,25 @@ function toggleCodeBlock(editor) {
443 443
                 // end line first, so that line numbers don't change
444 444
                 cm.replaceRange(end_text, {
445 445
                     line: end_line,
446
-                    ch: 0
446
+                    ch: 0,
447 447
                 }, {
448 448
                     line: end_line + (end_text ? 0 : 1),
449
-                    ch: 0
449
+                    ch: 0,
450 450
                 });
451 451
                 cm.replaceRange(start_text, {
452 452
                     line: start_line,
453
-                    ch: 0
453
+                    ch: 0,
454 454
                 }, {
455 455
                     line: start_line + (start_text ? 0 : 1),
456
-                    ch: 0
456
+                    ch: 0,
457 457
                 });
458 458
             });
459 459
             cm.setSelection({
460 460
                 line: start_line + (start_text ? 1 : 0),
461
-                ch: 0
461
+                ch: 0,
462 462
             }, {
463 463
                 line: end_line + (start_text ? 1 : -1),
464
-                ch: 0
464
+                ch: 0,
465 465
             });
466 466
             cm.focus();
467 467
         } else {
@@ -496,17 +496,17 @@ function toggleCodeBlock(editor) {
496 496
             cm.operation(function () {
497 497
                 cm.replaceRange('', {
498 498
                     line: block_start,
499
-                    ch: 0
499
+                    ch: 0,
500 500
                 }, {
501 501
                     line: block_start + 1,
502
-                    ch: 0
502
+                    ch: 0,
503 503
                 });
504 504
                 cm.replaceRange('', {
505 505
                     line: block_end - 1,
506
-                    ch: 0
506
+                    ch: 0,
507 507
                 }, {
508 508
                     line: block_end,
509
-                    ch: 0
509
+                    ch: 0,
510 510
                 });
511 511
             });
512 512
             cm.focus();
@@ -552,13 +552,13 @@ function toggleCodeBlock(editor) {
552 552
         var next_line = cm.getLineHandle(block_end + 1),
553 553
             next_line_last_tok = next_line && cm.getTokenAt({
554 554
                 line: block_end + 1,
555
-                ch: next_line.text.length - 1
555
+                ch: next_line.text.length - 1,
556 556
             }),
557 557
             next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
558 558
         if (next_line_indented) {
559 559
             cm.replaceRange('\n', {
560 560
                 line: block_end + 1,
561
-                ch: 0
561
+                ch: 0,
562 562
             });
563 563
         }
564 564
 
@@ -850,7 +850,7 @@ function _replaceSelection(cm, active, startEnd, url) {
850 850
         end = text.slice(startPoint.ch);
851 851
         cm.replaceRange(start + end, {
852 852
             line: startPoint.line,
853
-            ch: 0
853
+            ch: 0,
854 854
         });
855 855
     } else {
856 856
         text = cm.getSelection();
@@ -925,10 +925,10 @@ function _toggleHeading(cm, direction, size) {
925 925
 
926 926
             cm.replaceRange(text, {
927 927
                 line: i,
928
-                ch: 0
928
+                ch: 0,
929 929
             }, {
930 930
                 line: i,
931
-                ch: 99999999999999
931
+                ch: 99999999999999,
932 932
             });
933 933
         })(i);
934 934
     }
@@ -949,14 +949,14 @@ function _toggleLine(cm, name) {
949 949
     var repl = {
950 950
         'quote': /^(\s*)>\s+/,
951 951
         'unordered-list': listRegexp,
952
-        'ordered-list': listRegexp
952
+        'ordered-list': listRegexp,
953 953
     };
954 954
 
955 955
     var _getChar = function (name, i) {
956 956
         var map = {
957 957
             'quote': '>',
958 958
             'unordered-list': '*',
959
-            'ordered-list': '%%i.'
959
+            'ordered-list': '%%i.',
960 960
         };
961 961
 
962 962
         return map[name].replace('%%i', i);
@@ -966,7 +966,7 @@ function _toggleLine(cm, name) {
966 966
         var map = {
967 967
             'quote': '>',
968 968
             'unordered-list': '*',
969
-            'ordered-list': 'd+.'
969
+            'ordered-list': 'd+.',
970 970
         };
971 971
         var rt = new RegExp(map[name]);
972 972
 
@@ -994,10 +994,10 @@ function _toggleLine(cm, name) {
994 994
             }
995 995
             cm.replaceRange(text, {
996 996
                 line: i,
997
-                ch: 0
997
+                ch: 0,
998 998
             }, {
999 999
                 line: i,
1000
-                ch: 99999999999999
1000
+                ch: 99999999999999,
1001 1001
             });
1002 1002
         })(i);
1003 1003
     }
@@ -1035,10 +1035,10 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
1035 1035
         }
1036 1036
         cm.replaceRange(start + end, {
1037 1037
             line: startPoint.line,
1038
-            ch: 0
1038
+            ch: 0,
1039 1039
         }, {
1040 1040
             line: startPoint.line,
1041
-            ch: 99999999999999
1041
+            ch: 99999999999999,
1042 1042
         });
1043 1043
 
1044 1044
         if (type == 'bold' || type == 'strikethrough') {
@@ -1087,10 +1087,10 @@ function _cleanBlock(cm) {
1087 1087
 
1088 1088
         cm.replaceRange(text, {
1089 1089
             line: line,
1090
-            ch: 0
1090
+            ch: 0,
1091 1091
         }, {
1092 1092
             line: line,
1093
-            ch: 99999999999999
1093
+            ch: 99999999999999,
1094 1094
         });
1095 1095
     }
1096 1096
 }
@@ -1147,125 +1147,125 @@ var toolbarBuiltInButtons = {
1147 1147
         action: toggleBold,
1148 1148
         className: 'fa fa-bold',
1149 1149
         title: 'Bold',
1150
-        default: true
1150
+        default: true,
1151 1151
     },
1152 1152
     'italic': {
1153 1153
         name: 'italic',
1154 1154
         action: toggleItalic,
1155 1155
         className: 'fa fa-italic',
1156 1156
         title: 'Italic',
1157
-        default: true
1157
+        default: true,
1158 1158
     },
1159 1159
     'strikethrough': {
1160 1160
         name: 'strikethrough',
1161 1161
         action: toggleStrikethrough,
1162 1162
         className: 'fa fa-strikethrough',
1163
-        title: 'Strikethrough'
1163
+        title: 'Strikethrough',
1164 1164
     },
1165 1165
     'heading': {
1166 1166
         name: 'heading',
1167 1167
         action: toggleHeadingSmaller,
1168 1168
         className: 'fa fa-header fa-heading',
1169 1169
         title: 'Heading',
1170
-        default: true
1170
+        default: true,
1171 1171
     },
1172 1172
     'heading-smaller': {
1173 1173
         name: 'heading-smaller',
1174 1174
         action: toggleHeadingSmaller,
1175 1175
         className: 'fa fa-header fa-heading header-smaller',
1176
-        title: 'Smaller Heading'
1176
+        title: 'Smaller Heading',
1177 1177
     },
1178 1178
     'heading-bigger': {
1179 1179
         name: 'heading-bigger',
1180 1180
         action: toggleHeadingBigger,
1181 1181
         className: 'fa fa-header fa-heading header-bigger',
1182
-        title: 'Bigger Heading'
1182
+        title: 'Bigger Heading',
1183 1183
     },
1184 1184
     'heading-1': {
1185 1185
         name: 'heading-1',
1186 1186
         action: toggleHeading1,
1187 1187
         className: 'fa fa-header fa-heading header-1',
1188
-        title: 'Big Heading'
1188
+        title: 'Big Heading',
1189 1189
     },
1190 1190
     'heading-2': {
1191 1191
         name: 'heading-2',
1192 1192
         action: toggleHeading2,
1193 1193
         className: 'fa fa-header fa-heading header-2',
1194
-        title: 'Medium Heading'
1194
+        title: 'Medium Heading',
1195 1195
     },
1196 1196
     'heading-3': {
1197 1197
         name: 'heading-3',
1198 1198
         action: toggleHeading3,
1199 1199
         className: 'fa fa-header fa-heading header-3',
1200
-        title: 'Small Heading'
1200
+        title: 'Small Heading',
1201 1201
     },
1202 1202
     'separator-1': {
1203
-        name: 'separator-1'
1203
+        name: 'separator-1',
1204 1204
     },
1205 1205
     'code': {
1206 1206
         name: 'code',
1207 1207
         action: toggleCodeBlock,
1208 1208
         className: 'fa fa-code',
1209
-        title: 'Code'
1209
+        title: 'Code',
1210 1210
     },
1211 1211
     'quote': {
1212 1212
         name: 'quote',
1213 1213
         action: toggleBlockquote,
1214 1214
         className: 'fa fa-quote-left',
1215 1215
         title: 'Quote',
1216
-        default: true
1216
+        default: true,
1217 1217
     },
1218 1218
     'unordered-list': {
1219 1219
         name: 'unordered-list',
1220 1220
         action: toggleUnorderedList,
1221 1221
         className: 'fa fa-list-ul',
1222 1222
         title: 'Generic List',
1223
-        default: true
1223
+        default: true,
1224 1224
     },
1225 1225
     'ordered-list': {
1226 1226
         name: 'ordered-list',
1227 1227
         action: toggleOrderedList,
1228 1228
         className: 'fa fa-list-ol',
1229 1229
         title: 'Numbered List',
1230
-        default: true
1230
+        default: true,
1231 1231
     },
1232 1232
     'clean-block': {
1233 1233
         name: 'clean-block',
1234 1234
         action: cleanBlock,
1235 1235
         className: 'fa fa-eraser',
1236
-        title: 'Clean block'
1236
+        title: 'Clean block',
1237 1237
     },
1238 1238
     'separator-2': {
1239
-        name: 'separator-2'
1239
+        name: 'separator-2',
1240 1240
     },
1241 1241
     'link': {
1242 1242
         name: 'link',
1243 1243
         action: drawLink,
1244 1244
         className: 'fa fa-link',
1245 1245
         title: 'Create Link',
1246
-        default: true
1246
+        default: true,
1247 1247
     },
1248 1248
     'image': {
1249 1249
         name: 'image',
1250 1250
         action: drawImage,
1251 1251
         className: 'fa fa-image',
1252 1252
         title: 'Insert Image',
1253
-        default: true
1253
+        default: true,
1254 1254
     },
1255 1255
     'table': {
1256 1256
         name: 'table',
1257 1257
         action: drawTable,
1258 1258
         className: 'fa fa-table',
1259
-        title: 'Insert Table'
1259
+        title: 'Insert Table',
1260 1260
     },
1261 1261
     'horizontal-rule': {
1262 1262
         name: 'horizontal-rule',
1263 1263
         action: drawHorizontalRule,
1264 1264
         className: 'fa fa-minus',
1265
-        title: 'Insert Horizontal Line'
1265
+        title: 'Insert Horizontal Line',
1266 1266
     },
1267 1267
     'separator-3': {
1268
-        name: 'separator-3'
1268
+        name: 'separator-3',
1269 1269
     },
1270 1270
     'preview': {
1271 1271
         name: 'preview',
@@ -1273,7 +1273,7 @@ var toolbarBuiltInButtons = {
1273 1273
         className: 'fa fa-eye',
1274 1274
         noDisable: true,
1275 1275
         title: 'Toggle Preview',
1276
-        default: true
1276
+        default: true,
1277 1277
     },
1278 1278
     'side-by-side': {
1279 1279
         name: 'side-by-side',
@@ -1282,7 +1282,7 @@ var toolbarBuiltInButtons = {
1282 1282
         noDisable: true,
1283 1283
         noMobile: true,
1284 1284
         title: 'Toggle Side by Side',
1285
-        default: true
1285
+        default: true,
1286 1286
     },
1287 1287
     'fullscreen': {
1288 1288
         name: 'fullscreen',
@@ -1291,10 +1291,10 @@ var toolbarBuiltInButtons = {
1291 1291
         noDisable: true,
1292 1292
         noMobile: true,
1293 1293
         title: 'Toggle Fullscreen',
1294
-        default: true
1294
+        default: true,
1295 1295
     },
1296 1296
     'separator-4': {
1297
-        name: 'separator-4'
1297
+        name: 'separator-4',
1298 1298
     },
1299 1299
     'guide': {
1300 1300
         name: 'guide',
@@ -1302,43 +1302,43 @@ var toolbarBuiltInButtons = {
1302 1302
         className: 'fa fa-question-circle',
1303 1303
         noDisable: true,
1304 1304
         title: 'Markdown Guide',
1305
-        default: true
1305
+        default: true,
1306 1306
     },
1307 1307
     'separator-5': {
1308
-        name: 'separator-5'
1308
+        name: 'separator-5',
1309 1309
     },
1310 1310
     'undo': {
1311 1311
         name: 'undo',
1312 1312
         action: undo,
1313 1313
         className: 'fa fa-undo',
1314 1314
         noDisable: true,
1315
-        title: 'Undo'
1315
+        title: 'Undo',
1316 1316
     },
1317 1317
     'redo': {
1318 1318
         name: 'redo',
1319 1319
         action: redo,
1320 1320
         className: 'fa fa-repeat fa-redo',
1321 1321
         noDisable: true,
1322
-        title: 'Redo'
1323
-    }
1322
+        title: 'Redo',
1323
+    },
1324 1324
 };
1325 1325
 
1326 1326
 var insertTexts = {
1327 1327
     link: ['[', '](#url#)'],
1328 1328
     image: ['![](', '#url#)'],
1329 1329
     table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text     | Text     | Text     |\n\n'],
1330
-    horizontalRule: ['', '\n\n-----\n\n']
1330
+    horizontalRule: ['', '\n\n-----\n\n'],
1331 1331
 };
1332 1332
 
1333 1333
 var promptTexts = {
1334 1334
     link: 'URL for the link:',
1335
-    image: 'URL of the image:'
1335
+    image: 'URL of the image:',
1336 1336
 };
1337 1337
 
1338 1338
 var blockStyles = {
1339 1339
     'bold': '**',
1340 1340
     'code': '```',
1341
-    'italic': '*'
1341
+    'italic': '*',
1342 1342
 };
1343 1343
 
1344 1344
 /**
@@ -1426,7 +1426,7 @@ function EasyMDE(options) {
1426 1426
 
1427 1427
     // Set default options for parsing config
1428 1428
     options.parsingConfig = extend({
1429
-        highlightFormatting: true // needed for toggleCodeBlock to detect types of code
1429
+        highlightFormatting: true, // needed for toggleCodeBlock to detect types of code
1430 1430
     }, options.parsingConfig || {});
1431 1431
 
1432 1432
 
@@ -1568,7 +1568,7 @@ EasyMDE.prototype.render = function (el) {
1568 1568
         backdrop.gitHubSpice = false;
1569 1569
 
1570 1570
         CodeMirrorSpellChecker({
1571
-            codeMirrorInstance: CodeMirror
1571
+            codeMirrorInstance: CodeMirror,
1572 1572
         });
1573 1573
     } else {
1574 1574
         mode = options.parsingConfig;
@@ -1579,7 +1579,7 @@ EasyMDE.prototype.render = function (el) {
1579 1579
     // eslint-disable-next-line no-unused-vars
1580 1580
     function configureMouse(cm, repeat, event) {
1581 1581
         return {
1582
-            addNew: false
1582
+            addNew: false,
1583 1583
         };
1584 1584
     }
1585 1585
 
@@ -1597,7 +1597,7 @@ EasyMDE.prototype.render = function (el) {
1597 1597
         allowDropFileTypes: ['text/plain'],
1598 1598
         placeholder: options.placeholder || el.getAttribute('placeholder') || '',
1599 1599
         styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(),
1600
-        configureMouse: configureMouse
1600
+        configureMouse: configureMouse,
1601 1601
     });
1602 1602
 
1603 1603
     this.codemirror.getScrollerElement().style.minHeight = options.minHeight;
@@ -1897,7 +1897,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
1897 1897
             items.push({
1898 1898
                 className: status[i].className,
1899 1899
                 defaultValue: status[i].defaultValue,
1900
-                onUpdate: status[i].onUpdate
1900
+                onUpdate: status[i].onUpdate,
1901 1901
             });
1902 1902
         } else {
1903 1903
             var name = status[i];
@@ -1935,7 +1935,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
1935 1935
             items.push({
1936 1936
                 className: name,
1937 1937
                 defaultValue: defaultValue,
1938
-                onUpdate: onUpdate
1938
+                onUpdate: onUpdate,
1939 1939
             });
1940 1940
         }
1941 1941
     }

Loading…
Cancel
Save