ESLint: Added quotes rule (#2835)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329
diff --git a/.eslintrc.js b/.eslintrc.js
index 0f868d9..d9782df 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -3,6 +3,9 @@ module.exports = {
root: true,
extends: 'eslint:recommended',
rules: {
+ // stylistic rules
+ 'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
+
// I turned this rule off because we use `hasOwnProperty` in a lot of places
// TODO: Think about re-enabling this rule
'no-prototype-builtins': 'off',
diff --git a/assets/code.js b/assets/code.js
index 1b8cccc..70c42b5 100644
--- a/assets/code.js
+++ b/assets/code.js
@@ -186,7 +186,7 @@ for (var id in themes) {
$u.element.create('input', {
properties: {
type: 'radio',
- name: "theme",
+ name: 'theme',
id: 'theme=' + id,
checked: current === id,
value: id,
@@ -261,7 +261,7 @@ Prism && Prism.hooks.add('complete', function (env) {
// transfer margin of pre to wrapper
wrapper.style.margin = window.getComputedStyle(pre).margin;
- pre.style.margin = "0";
+ pre.style.margin = '0';
});
});
diff --git a/assets/download.js b/assets/download.js
index fba5920..a7bbd87 100644
--- a/assets/download.js
+++ b/assets/download.js
@@ -194,7 +194,7 @@ for (var category in components) {
for (var alias in lang.aliasTitles)
if (lang.aliasTitles.hasOwnProperty(alias))
titles.push(lang.aliasTitles[alias]);
- return titles.join(" + ");
+ return titles.join(' + ');
}
var label = $u.element.create('label', {
@@ -506,18 +506,18 @@ function generateCode(){
$u.element.contents(error, errors);
}
- var redownloadUrl = window.location.href.split("#")[0] + "#";
+ var redownloadUrl = window.location.href.split('#')[0] + '#';
for (var category in redownload) {
- redownloadUrl += category + "=" + redownload[category].join('+') + "&";
+ redownloadUrl += category + '=' + redownload[category].join('+') + '&';
}
- redownloadUrl = redownloadUrl.replace(/&$/,"");
+ redownloadUrl = redownloadUrl.replace(/&$/,'');
window.location.replace(redownloadUrl);
- var versionComment = "/* PrismJS " + version + "\n" + redownloadUrl + " */";
+ var versionComment = '/* PrismJS ' + version + '\n' + redownloadUrl + ' */';
for (var type in code) {
(function (type) {
- var text = versionComment + "\n" + code[type];
+ var text = versionComment + '\n' + code[type];
var fileName = 'prism.' + type;
var codeElement = $('#download-' + type + ' code');
@@ -533,7 +533,7 @@ function generateCode(){
$('#download-' + type + ' .download-button').onclick = function () {
- saveAs(new Blob([text], { type: "application/octet-stream;charset=utf-8" }), fileName);
+ saveAs(new Blob([text], { type: 'application/octet-stream;charset=utf-8' }), fileName);
};
})(type);
}
@@ -562,7 +562,7 @@ function buildCode(promises) {
var toSortMap = {};
promises.forEach(function (p) {
- if (p.category == "core" || p.category == "themes") {
+ if (p.category == 'core' || p.category == 'themes') {
finalPromises.push(p);
} else {
var infos = toSortMap[p.id];
@@ -576,7 +576,7 @@ function buildCode(promises) {
// this assumes that the ids in `toSortMap` are complete under transitive requirements
getLoader(components, Object.keys(toSortMap)).getIds().forEach(function (id) {
if (!toSortMap[id]) {
- console.error(id + " not found.");
+ console.error(id + ' not found.');
}
finalPromises.push.apply(finalPromises, toSortMap[id]);
});
diff --git a/assets/examples.js b/assets/examples.js
index ccf1607..4ce38bc 100644
--- a/assets/examples.js
+++ b/assets/examples.js
@@ -232,7 +232,7 @@ function getDependenciesOfLanguage(lang) {
return [];
}
- return ($u.type(components.languages[lang].require) === "array")
+ return ($u.type(components.languages[lang].require) === 'array')
? components.languages[lang].require
: [components.languages[lang].require];
}
diff --git a/components/prism-abap.js b/components/prism-abap.js
index e598cce..64ae744 100644
--- a/components/prism-abap.js
+++ b/components/prism-abap.js
@@ -32,17 +32,17 @@ Prism.languages.abap = {
pattern: /(\s)&&?(?=\s)/,
lookbehind: true,
/* The official editor highlights */
- alias: "keyword"
+ alias: 'keyword'
},
'token-operator' : [{
/* Special operators used to access structure components, class methods/attributes, etc. */
pattern: /(\w)(?:->?|=>|[~|{}])(?=\w)/,
lookbehind: true,
- alias: "punctuation"
+ alias: 'punctuation'
}, {
/* Special tokens used do delimit string templates */
pattern: /[|{}]/,
- alias: "punctuation"
+ alias: 'punctuation'
}],
'punctuation' : /[,.:()]/
};
\ No newline at end of file
diff --git a/components/prism-aspnet.js b/components/prism-aspnet.js
index 2e0f17a..590e31e 100644
--- a/components/prism-aspnet.js
+++ b/components/prism-aspnet.js
@@ -28,7 +28,7 @@ Prism.languages.aspnet.tag.pattern = /<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:(
// match directives of attribute value foo="<% Bar %>"
Prism.languages.insertBefore('inside', 'punctuation', {
'directive': Prism.languages.aspnet['directive']
-}, Prism.languages.aspnet.tag.inside["attr-value"]);
+}, Prism.languages.aspnet.tag.inside['attr-value']);
Prism.languages.insertBefore('aspnet', 'comment', {
'asp-comment': {
diff --git a/components/prism-autoit.js b/components/prism-autoit.js
index 0dfb63d..553d7cf 100644
--- a/components/prism-autoit.js
+++ b/components/prism-autoit.js
@@ -1,5 +1,5 @@
Prism.languages.autoit = {
- "comment": [
+ 'comment': [
/;.*/,
{
// The multi-line comments delimiters can actually be commented out with ";"
@@ -7,28 +7,28 @@ Prism.languages.autoit = {
lookbehind: true
}
],
- "url": {
+ 'url': {
pattern: /(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m,
lookbehind: true
},
- "string": {
+ 'string': {
pattern: /(["'])(?:\1\1|(?!\1)[^\r\n])*\1/,
greedy: true,
inside: {
- "variable": /([%$@])\w+\1/
+ 'variable': /([%$@])\w+\1/
}
},
- "directive": {
+ 'directive': {
pattern: /(^\s*)#\w+/m,
lookbehind: true,
alias: 'keyword'
},
- "function": /\b\w+(?=\()/,
+ 'function': /\b\w+(?=\()/,
// Variables and macros
- "variable": /[$@]\w+/,
- "keyword": /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i,
- "number": /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i,
- "boolean": /\b(?:True|False)\b/i,
- "operator": /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i,
- "punctuation": /[\[\]().,:]/
+ 'variable': /[$@]\w+/,
+ 'keyword': /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i,
+ 'number': /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i,
+ 'boolean': /\b(?:True|False)\b/i,
+ 'operator': /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i,
+ 'punctuation': /[\[\]().,:]/
};
diff --git a/components/prism-bash.js b/components/prism-bash.js
index 7f0f9e4..9487408 100644
--- a/components/prism-bash.js
+++ b/components/prism-bash.js
@@ -15,7 +15,7 @@
var insideString = {
'bash': commandAfterHeredoc,
'environment': {
- pattern: RegExp("\\$" + envVars),
+ pattern: RegExp('\\$' + envVars),
alias: 'constant'
},
'variable': [
@@ -55,7 +55,7 @@
'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
'punctuation': /[\[\]]/,
'environment': {
- pattern: RegExp("(\\{)" + envVars),
+ pattern: RegExp('(\\{)' + envVars),
lookbehind: true,
alias: 'constant'
}
@@ -105,7 +105,7 @@
pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
inside: {
'environment': {
- pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
+ pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
lookbehind: true,
alias: 'constant'
}
@@ -155,7 +155,7 @@
}
],
'environment': {
- pattern: RegExp("\\$?" + envVars),
+ pattern: RegExp('\\$?' + envVars),
alias: 'constant'
},
'variable': insideString.variable,
diff --git a/components/prism-diff.js b/components/prism-diff.js
index 12a06f1..eadf697 100644
--- a/components/prism-diff.js
+++ b/components/prism-diff.js
@@ -35,8 +35,8 @@
if (!/^\w+$/.test(name)) { // "deleted-sign" -> "deleted"
alias.push(/\w+/.exec(name)[0]);
}
- if (name === "diff") {
- alias.push("bold");
+ if (name === 'diff') {
+ alias.push('bold');
}
Prism.languages.diff[name] = {
diff --git a/components/prism-jexl.js b/components/prism-jexl.js
index a2dda2b..b539287 100644
--- a/components/prism-jexl.js
+++ b/components/prism-jexl.js
@@ -2,7 +2,7 @@ Prism.languages.jexl = {
'string': /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
'transform': {
pattern: /(\|\s*)[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*/,
- alias: "function",
+ alias: 'function',
lookbehind: true
},
'function': /[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*\s*(?=\()/,
diff --git a/components/prism-kotlin.js b/components/prism-kotlin.js
index 3ade990..8e57a3e 100644
--- a/components/prism-kotlin.js
+++ b/components/prism-kotlin.js
@@ -20,7 +20,7 @@
'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
});
- delete Prism.languages.kotlin["class-name"];
+ delete Prism.languages.kotlin['class-name'];
Prism.languages.insertBefore('kotlin', 'string', {
'raw-string': {
diff --git a/components/prism-less.js b/components/prism-less.js
index 5be11e0..67c968f 100644
--- a/components/prism-less.js
+++ b/components/prism-less.js
@@ -39,7 +39,7 @@ Prism.languages.insertBefore('less', 'property', {
{
pattern: /@[\w-]+\s*:/,
inside: {
- "punctuation": /:/
+ 'punctuation': /:/
}
},
diff --git a/components/prism-naniscript.js b/components/prism-naniscript.js
index 406d17e..7d797d9 100644
--- a/components/prism-naniscript.js
+++ b/components/prism-naniscript.js
@@ -122,7 +122,7 @@
/** @type {(Token | string)[]} */
var tokens = env.tokens;
tokens.forEach(function (token) {
- if (typeof token !== "string" && token.type === 'generic-text') {
+ if (typeof token !== 'string' && token.type === 'generic-text') {
var content = getTextContent(token);
if (!isBracketsBalanced(content)) {
token.type = 'bad-line';
@@ -137,7 +137,7 @@
* @returns {boolean}
*/
function isBracketsBalanced(input) {
- var brackets = "[]{}";
+ var brackets = '[]{}';
var stack = [];
for (var i = 0; i < input.length; i++) {
var bracket = input[i];
diff --git a/components/prism-pascaligo.js b/components/prism-pascaligo.js
index 5e5eed0..ab9f15e 100644
--- a/components/prism-pascaligo.js
+++ b/components/prism-pascaligo.js
@@ -55,7 +55,7 @@
return accum;
}, {});
- pascaligo["class-name"].forEach(function (p) {
+ pascaligo['class-name'].forEach(function (p) {
p.inside = classNameInside;
});
diff --git a/components/prism-peoplecode.js b/components/prism-peoplecode.js
index b7db0f7..16f93e7 100644
--- a/components/prism-peoplecode.js
+++ b/components/prism-peoplecode.js
@@ -8,7 +8,7 @@ Prism.languages.peoplecode = {
/<\*(?:[^<*]|\*(?!>)|<(?!\*)|<\*(?:(?!\*>)[\s\S])*\*>)*\*>/.source,
// /+ +/ comments
/\/\+[\s\S]*?\+\//.source,
- ].join("|")),
+ ].join('|')),
'string': {
pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/,
greedy: true
diff --git a/components/prism-smarty.js b/components/prism-smarty.js
index 3cd6ded..658f04d 100644
--- a/components/prism-smarty.js
+++ b/components/prism-smarty.js
@@ -37,11 +37,11 @@
// Value is made optional because it may have already been tokenized
pattern: /\w+\s*=\s*(?:(?!\d)\w+)?/,
inside: {
- "variable": {
+ 'variable': {
pattern: /(=\s*)(?!\d)\w+/,
lookbehind: true
},
- "operator": /=/
+ 'operator': /=/
}
},
'punctuation': [
diff --git a/components/prism-vbnet.js b/components/prism-vbnet.js
index 464c9e1..5878e3a 100644
--- a/components/prism-vbnet.js
+++ b/components/prism-vbnet.js
@@ -1,4 +1,4 @@
-Prism.languages.vbnet = Prism.languages.extend("basic", {
+Prism.languages.vbnet = Prism.languages.extend('basic', {
'comment': [
{
pattern: /(?:!|REM\b).+/i,
diff --git a/components/prism-xeora.js b/components/prism-xeora.js
index 7fafe58..fec952b 100644
--- a/components/prism-xeora.js
+++ b/components/prism-xeora.js
@@ -107,7 +107,7 @@
Prism.languages.insertBefore('inside', 'punctuation', {
'variable': Prism.languages.xeora['function-inline'].inside['variable']
- }, Prism.languages.xeora["function-block"]);
+ }, Prism.languages.xeora['function-block']);
Prism.languages.xeoracube = Prism.languages.xeora;
diff --git a/components/prism-xquery.js b/components/prism-xquery.js
index d5a02ff..8541263 100644
--- a/components/prism-xquery.js
+++ b/components/prism-xquery.js
@@ -4,7 +4,7 @@
'xquery-comment': {
pattern: /\(:[\s\S]*?:\)/,
greedy: true,
- alias: "comment"
+ alias: 'comment'
},
'string': {
pattern: /(["'])(?:\1\1|(?!\1)[\s\S])*\1/,
diff --git a/dangerfile.js b/dangerfile.js
index 8063393..76f4d15 100644
--- a/dangerfile.js
+++ b/dangerfile.js
@@ -56,7 +56,7 @@ const formatBytes = (bytes, decimals = 2) => {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
-const maybePlus = (from, to) => from < to ? "+" : "";
+const maybePlus = (from, to) => from < to ? '+' : '';
const absDiff = (from, to) => {
if (from === to) {
diff --git a/dependencies.js b/dependencies.js
index 7eeb8d1..a9e25c3 100644
--- a/dependencies.js
+++ b/dependencies.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
/**
* @typedef {Object<string, ComponentCategory>} Components
diff --git a/gulpfile.js/changelog.js b/gulpfile.js/changelog.js
index 9e88d7c..984dc67 100644
--- a/gulpfile.js/changelog.js
+++ b/gulpfile.js/changelog.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { src, dest } = require('gulp');
@@ -230,7 +230,7 @@ async function changes() {
if (change.mode === 'A' && change.file.startsWith('components/prism-')) {
const lang = change.file.match(/prism-([\w-]+)\.js$/)[1];
const entry = languages[lang] || {
- title: "REMOVED LANGUAGE " + lang,
+ title: 'REMOVED LANGUAGE ' + lang,
};
const titles = [entry.title];
if (entry.aliasTitles) {
diff --git a/gulpfile.js/docs.js b/gulpfile.js/docs.js
index b239564..1e5b1c8 100644
--- a/gulpfile.js/docs.js
+++ b/gulpfile.js/docs.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { src, dest, series } = require('gulp');
const replace = require('gulp-replace');
diff --git a/gulpfile.js/index.js b/gulpfile.js/index.js
index 048b290..93b61b1 100644
--- a/gulpfile.js/index.js
+++ b/gulpfile.js/index.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { src, dest, series, parallel, watch } = require('gulp');
@@ -45,7 +45,7 @@ function inlineRegexSource() {
}
return '\\\\' + g1;
} else {
- return "[^]";
+ return '[^]';
}
});
// escape single quotes
diff --git a/gulpfile.js/paths.js b/gulpfile.js/paths.js
index 1d5b7a3..9ce69ed 100644
--- a/gulpfile.js/paths.js
+++ b/gulpfile.js/paths.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
module.exports = {
componentsFile: 'components.json',
diff --git a/plugins/autoloader/prism-autoloader.js b/plugins/autoloader/prism-autoloader.js
index 7134d82..2da746f 100644
--- a/plugins/autoloader/prism-autoloader.js
+++ b/plugins/autoloader/prism-autoloader.js
@@ -4,6 +4,8 @@
return;
}
+ /* eslint-disable */
+
/**
* The dependencies map is built automatically with gulp.
*
@@ -240,6 +242,8 @@
"yml": "yaml"
}/*]*/;
+ /* eslint-enable */
+
/**
* @typedef LangDataItem
* @property {{ success?: () => void, error?: () => void }[]} callbacks
diff --git a/plugins/command-line/prism-command-line.js b/plugins/command-line/prism-command-line.js
index f63bb1f..31a3fc6 100644
--- a/plugins/command-line/prism-command-line.js
+++ b/plugins/command-line/prism-command-line.js
@@ -8,7 +8,7 @@
var PROMPT_CLASS = 'command-line-prompt';
/** @type {(str: string, prefix: string) => boolean} */
- var startsWith = "".startsWith
+ var startsWith = ''.startsWith
? function (s, p) { return s.startsWith(p); }
: function (s, p) { return s.indexOf(p) === 0; };
@@ -22,7 +22,7 @@
* @returns {string}
*/
function repeat(str, times) {
- var s = "";
+ var s = '';
for (var i = 0; i < times; i++) {
s += str;
}
diff --git a/plugins/copy-to-clipboard/prism-copy-to-clipboard.js b/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
index 7b1aa2b..04d69c8 100644
--- a/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
+++ b/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
@@ -31,13 +31,13 @@
/** @param {CopyInfo} copyInfo */
function fallbackCopyTextToClipboard(copyInfo) {
- var textArea = document.createElement("textarea");
+ var textArea = document.createElement('textarea');
textArea.value = copyInfo.getText();
// Avoid scrolling to bottom
- textArea.style.top = "0";
- textArea.style.left = "0";
- textArea.style.position = "fixed";
+ textArea.style.top = '0';
+ textArea.style.left = '0';
+ textArea.style.position = 'fixed';
document.body.appendChild(textArea);
textArea.focus();
diff --git a/plugins/highlight-keywords/prism-highlight-keywords.js b/plugins/highlight-keywords/prism-highlight-keywords.js
index 5143b4b..8743094 100644
--- a/plugins/highlight-keywords/prism-highlight-keywords.js
+++ b/plugins/highlight-keywords/prism-highlight-keywords.js
@@ -5,7 +5,7 @@ if (typeof Prism === 'undefined') {
}
Prism.hooks.add('wrap', function(env) {
- if (env.type !== "keyword") {
+ if (env.type !== 'keyword') {
return;
}
env.classes.push('keyword-' + env.content);
diff --git a/plugins/jsonp-highlight/prism-jsonp-highlight.js b/plugins/jsonp-highlight/prism-jsonp-highlight.js
index 81d2833..605ee33 100644
--- a/plugins/jsonp-highlight/prism-jsonp-highlight.js
+++ b/plugins/jsonp-highlight/prism-jsonp-highlight.js
@@ -29,7 +29,7 @@
*/
function registerAdapter(adapter, name) {
name = name || adapter.name;
- if (typeof adapter === "function" && !getAdapter(adapter) && !getAdapter(name)) {
+ if (typeof adapter === 'function' && !getAdapter(adapter) && !getAdapter(name)) {
adapters.push({ adapter: adapter, name: name });
}
}
@@ -42,14 +42,14 @@
* @returns {Adapter} A registered adapter or `null`.
*/
function getAdapter(adapter) {
- if (typeof adapter === "function") {
+ if (typeof adapter === 'function') {
for (var i = 0, item; item = adapters[i++];) {
if (item.adapter.valueOf() === adapter.valueOf()) {
return item.adapter;
}
}
}
- else if (typeof adapter === "string") {
+ else if (typeof adapter === 'string') {
// eslint-disable-next-line no-redeclare
for (var i = 0, item; item = adapters[i++];) {
if (item.name === adapter) {
@@ -66,10 +66,10 @@
* @param {string|Function} adapter The adapter itself or the name of an adapter.
*/
function removeAdapter(adapter) {
- if (typeof adapter === "string") {
+ if (typeof adapter === 'string') {
adapter = getAdapter(adapter);
}
- if (typeof adapter === "function") {
+ if (typeof adapter === 'function') {
var index = adapters.findIndex(function (item) {
return item.adapter === adapter;
});
@@ -82,12 +82,12 @@
registerAdapter(function github(rsp) {
if (rsp && rsp.meta && rsp.data) {
if (rsp.meta.status && rsp.meta.status >= 400) {
- return "Error: " + (rsp.data.message || rsp.meta.status);
+ return 'Error: ' + (rsp.data.message || rsp.meta.status);
}
- else if (typeof (rsp.data.content) === "string") {
- return typeof (atob) === "function"
- ? atob(rsp.data.content.replace(/\s/g, ""))
- : "Your browser cannot decode base64";
+ else if (typeof (rsp.data.content) === 'string') {
+ return typeof (atob) === 'function'
+ ? atob(rsp.data.content.replace(/\s/g, ''))
+ : 'Your browser cannot decode base64';
}
}
return null;
@@ -95,11 +95,11 @@
registerAdapter(function gist(rsp, el) {
if (rsp && rsp.meta && rsp.data && rsp.data.files) {
if (rsp.meta.status && rsp.meta.status >= 400) {
- return "Error: " + (rsp.data.message || rsp.meta.status);
+ return 'Error: ' + (rsp.data.message || rsp.meta.status);
}
var files = rsp.data.files;
- var filename = el.getAttribute("data-filename");
+ var filename = el.getAttribute('data-filename');
if (filename == null) {
// Maybe in the future we can somehow render all files
// But the standard <script> include for gists does that nicely already,
@@ -115,12 +115,12 @@
if (files[filename] !== undefined) {
return files[filename].content;
}
- return "Error: unknown or missing gist file " + filename;
+ return 'Error: unknown or missing gist file ' + filename;
}
return null;
}, 'gist');
registerAdapter(function bitbucket(rsp) {
- if (rsp && rsp.node && typeof (rsp.data) === "string") {
+ if (rsp && rsp.node && typeof (rsp.data) === 'string') {
return rsp.data;
}
return null;
diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.js b/plugins/normalize-whitespace/prism-normalize-whitespace.js
index 46aa590..13683fe 100644
--- a/plugins/normalize-whitespace/prism-normalize-whitespace.js
+++ b/plugins/normalize-whitespace/prism-normalize-whitespace.js
@@ -40,7 +40,7 @@ NormalizeWhitespace.prototype = {
for (var name in settings) {
var methodName = toCamelCase(name);
- if (name !== "normalize" && methodName !== 'setDefaults' &&
+ if (name !== 'normalize' && methodName !== 'setDefaults' &&
settings[name] && this[methodName]) {
input = this[methodName].call(this, input, settings[name]);
}
@@ -172,7 +172,7 @@ Prism.hooks.add('before-sanity-check', function (env) {
if (node == env.element) {
codeFound = true;
- } else if (node.nodeName === "#text") {
+ } else if (node.nodeName === '#text') {
if (codeFound) {
after += node.nodeValue;
} else {
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js
index 7ca0237..649f74d 100644
--- a/plugins/show-language/prism-show-language.js
+++ b/plugins/show-language/prism-show-language.js
@@ -10,6 +10,8 @@
return;
}
+ /* eslint-disable */
+
// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{
"none": "Plain text",
@@ -236,6 +238,8 @@
"yang": "YANG"
}/*]*/;
+ /* eslint-enable */
+
Prism.plugins.toolbar.registerButton('show-language', function (env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
diff --git a/tests/aliases-test.js b/tests/aliases-test.js
index 2b562f7..d62c61a 100644
--- a/tests/aliases-test.js
+++ b/tests/aliases-test.js
@@ -1,6 +1,6 @@
-"use strict";
+'use strict';
-const { assert } = require("chai");
+const { assert } = require('chai');
const PrismLoader = require('./helper/prism-loader');
const { languages } = require('./../components.json');
diff --git a/tests/core/greedy.js b/tests/core/greedy.js
index d7fc9fb..4794bea 100644
--- a/tests/core/greedy.js
+++ b/tests/core/greedy.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { assert } = require('chai');
const PrismLoader = require('../helper/prism-loader');
@@ -30,8 +30,8 @@ describe('Greedy matching', function () {
},
code: '// /*\n/* comment */',
expected: [
- ["comment", "// /*"],
- ["comment", "/* comment */"]
+ ['comment', '// /*'],
+ ['comment', '/* comment */']
]
});
});
@@ -49,9 +49,9 @@ describe('Greedy matching', function () {
},
code: 'foo "bar" \'baz\'',
expected: [
- ["b", "foo"],
- ["b", "\"bar\""],
- ["a", "'baz'"]
+ ['b', 'foo'],
+ ['b', '"bar"'],
+ ['a', "'baz'"]
]
});
});
@@ -73,14 +73,14 @@ describe('Greedy matching', function () {
},
code: `<'> '' ''\n<"> "" ""`,
expected: [
- ["c", "<'>"],
+ ['c', "<'>"],
" '",
- ["a", "' '"],
+ ['a', "' '"],
"'\n",
- ["c", "<\">"],
- ["b", "\"\""],
- ["b", "\"\""],
+ ['c', '<">'],
+ ['b', '""'],
+ ['b', '""'],
]
});
});
@@ -98,9 +98,9 @@ describe('Greedy matching', function () {
},
code: 'bab',
expected: [
- ["b", "b"],
- ["a", "a"],
- "b"
+ ['b', 'b'],
+ ['a', 'a'],
+ 'b'
]
});
});
diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js
index 7839539..7988f11 100644
--- a/tests/dependencies-test.js
+++ b/tests/dependencies-test.js
@@ -283,18 +283,18 @@ describe('components.json', function () {
}
const entryProperties = [
- "title",
- "description",
- "alias",
- "aliasTitles",
- "owner",
-
- "require",
- "optional",
- "modify",
-
- "noCSS",
- "option"
+ 'title',
+ 'description',
+ 'alias',
+ 'aliasTitles',
+ 'owner',
+
+ 'require',
+ 'optional',
+ 'modify',
+
+ 'noCSS',
+ 'option'
];
it('- should be valid', function () {
@@ -363,7 +363,7 @@ describe('components.json', function () {
it('- should not have single-element or empty arrays', function () {
/** @type {keyof import("../dependencies").ComponentEntry} */
- const properties = ["alias", "optional", "require", "modify"];
+ const properties = ['alias', 'optional', 'require', 'modify'];
forEachEntry((entry, id) => {
for (const prop of properties) {
diff --git a/tests/helper/checks.js b/tests/helper/checks.js
index 68425cb..69fd17e 100644
--- a/tests/helper/checks.js
+++ b/tests/helper/checks.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
function testFunction(name, object, tester) {
const func = object[name];
@@ -87,7 +87,7 @@ module.exports = (Prism) => {
const oldClone = Prism.util.clone;
Prism.util.clone = obj => {
const clone = oldClone(obj);
- if (clone && typeof clone === "object") {
+ if (clone && typeof clone === 'object') {
Object.defineProperty(clone, '__cloned', { value: true });
}
return clone;
@@ -97,7 +97,7 @@ module.exports = (Prism) => {
function extendTest(id, redef) {
let redefStr;
if (Prism.util.type(redef) === 'Object') {
- redefStr = "{\n";
+ redefStr = '{\n';
for (const key in redef) {
const element = redef[key];
let elementStr;
@@ -134,7 +134,7 @@ module.exports = (Prism) => {
}
// rest property check
- if ("rest" in redef) {
+ if ('rest' in redef) {
throw new Error(`The redef object is not allowed to contain a "rest" property.` + details);
}
diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js
index 5c34048..a3a0c1d 100644
--- a/tests/helper/prism-loader.js
+++ b/tests/helper/prism-loader.js
@@ -1,8 +1,8 @@
-"use strict";
+'use strict';
-const fs = require("fs");
-const components = require("../../components.json");
-const getLoader = require("../../dependencies");
+const fs = require('fs');
+const components = require('../../components.json');
+const getLoader = require('../../dependencies');
const languagesCatalog = components.languages;
const coreChecks = require('./checks');
@@ -82,7 +82,7 @@ module.exports = {
*/
createEmptyPrism() {
if (!coreSupplierFunction) {
- const source = this.loadComponentSource("core");
+ const source = this.loadComponentSource('core');
// Core exports itself in 2 ways:
// 1) it uses `module.exports = Prism` which what we'll use
// 2) it uses `global.Prism = Prism` which we want to sabotage to prevent leaking
@@ -109,7 +109,7 @@ module.exports = {
* @returns {string}
*/
loadComponentSource(name) {
- return this.loadFileSource(__dirname + "/../../components/prism-" + name + ".js");
+ return this.loadFileSource(__dirname + '/../../components/prism-' + name + '.js');
},
/**
@@ -122,7 +122,7 @@ module.exports = {
loadFileSource(src) {
let content = fileSourceCache.get(src);
if (content === undefined) {
- fileSourceCache.set(src, content = fs.readFileSync(src, "utf8"));
+ fileSourceCache.set(src, content = fs.readFileSync(src, 'utf8'));
}
return content;
}
diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js
index acc75f2..184d6c1 100644
--- a/tests/helper/test-case.js
+++ b/tests/helper/test-case.js
@@ -1,9 +1,9 @@
-"use strict";
+'use strict';
-const fs = require("fs");
-const { assert } = require("chai");
-const PrismLoader = require("./prism-loader");
-const TokenStreamTransformer = require("./token-stream-transformer");
+const fs = require('fs');
+const { assert } = require('chai');
+const PrismLoader = require('./prism-loader');
+const TokenStreamTransformer = require('./token-stream-transformer');
/**
* @typedef {import("./token-stream-transformer").TokenStream} TokenStream
@@ -163,19 +163,19 @@ module.exports = {
* @returns {{languages: string[], mainLanguage: string}}
*/
parseLanguageNames(languageIdentifier) {
- let languages = languageIdentifier.split("+");
+ let languages = languageIdentifier.split('+');
let mainLanguage = null;
languages = languages.map(
function (language) {
- const pos = language.indexOf("!");
+ const pos = language.indexOf('!');
if (-1 < pos) {
if (mainLanguage) {
- throw "There are multiple main languages defined.";
+ throw 'There are multiple main languages defined.';
}
- mainLanguage = language.replace("!", "");
+ mainLanguage = language.replace('!', '');
return mainLanguage;
}
@@ -209,11 +209,11 @@ module.exports = {
* @property {string} comment
*/
parseTestCaseFile(filePath) {
- const testCaseSource = fs.readFileSync(filePath, "utf8");
+ const testCaseSource = fs.readFileSync(filePath, 'utf8');
const testCaseParts = testCaseSource.split(/^-{10,}[ \t]*$/m);
if (testCaseParts.length > 3) {
- throw new Error("Invalid test case format: Too many sections.");
+ throw new Error('Invalid test case format: Too many sections.');
}
const code = testCaseParts[0].trim();
diff --git a/tests/helper/test-discovery.js b/tests/helper/test-discovery.js
index 99896bd..053039a 100644
--- a/tests/helper/test-discovery.js
+++ b/tests/helper/test-discovery.js
@@ -1,7 +1,7 @@
-"use strict";
+'use strict';
-const fs = require("fs");
-const path = require("path");
+const fs = require('fs');
+const path = require('path');
module.exports = {
diff --git a/tests/helper/token-stream-transformer.js b/tests/helper/token-stream-transformer.js
index db0c6ac..c405b6e 100644
--- a/tests/helper/token-stream-transformer.js
+++ b/tests/helper/token-stream-transformer.js
@@ -185,16 +185,16 @@ function prettyFormat(prettyStream, indentationWidth) {
return g
.map(item => {
if (isToken(item)) {
- if (typeof item === "string") {
- return ", ".length + JSON.stringify(item).length;
+ if (typeof item === 'string') {
+ return ', '.length + JSON.stringify(item).length;
} else {
- return ", ".length + JSON.stringify(item).length + " ".length;
+ return ', '.length + JSON.stringify(item).length + ' '.length;
}
} else {
return 0;
}
})
- .reduce((a, b) => a + b, 0) - ", ".length;
+ .reduce((a, b) => a + b, 0) - ', '.length;
} else {
// we don't really care about the print width of a single-token line
return 1;
@@ -433,7 +433,7 @@ function prettyCountTokens(prettyStream, recursive) {
*/
function prettyGlueTogether(prettyStream, prev, next) {
// strings may appear more than once in the stream, so we have to search for tokens.
- if (typeof prev !== "string") {
+ if (typeof prev !== 'string') {
let index = prettyStream.indexOf(prev);
if (index === -1 || prettyStream[index + 1] !== next) {
throw new Error('Cannot glue: At least one of the tokens is not part of the given token stream.');
diff --git a/tests/identifier-test.js b/tests/identifier-test.js
index 680f0aa..e69c027 100644
--- a/tests/identifier-test.js
+++ b/tests/identifier-test.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { assert } = require('chai');
const PrismLoader = require('./helper/prism-loader');
@@ -157,7 +157,7 @@ function getOptions(lang) {
* @property {string | Token | (string | Token)[]} content
*/
function isNotBroken(token) {
- if (typeof token === "string") {
+ if (typeof token === 'string') {
return true;
} else if (Array.isArray(token)) {
return token.length === 1 && isNotBroken(token[0]);
diff --git a/tests/pattern-tests.js b/tests/pattern-tests.js
index 5dbdaa2..7fa80ad 100644
--- a/tests/pattern-tests.js
+++ b/tests/pattern-tests.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
const { assert } = require('chai');
const PrismLoader = require('./helper/prism-loader');
@@ -231,7 +231,7 @@ function testPatterns(Prism) {
* @returns {boolean}
*/
function underAStar(node) {
- if (node.type === "Quantifier" && node.max > 10) {
+ if (node.type === 'Quantifier' && node.max > 10) {
return true;
} else if (node.parent) {
return underAStar(node.parent);
@@ -417,13 +417,13 @@ function testPatterns(Prism) {
function toNFA(element) {
let { expression, maxCharacter } = parser.parseElement(element, {
maxBackreferenceWords: 1000,
- backreferences: "disable"
+ backreferences: 'disable'
});
// try to remove assertions
expression = transform(transformer, expression);
- return NFA.fromRegex(expression, { maxCharacter }, { assertions: "disable" });
+ return NFA.fromRegex(expression, { maxCharacter }, { assertions: 'disable' });
}
/**
@@ -470,7 +470,7 @@ function testPatterns(Prism) {
onCapturingGroupLeave: checkDisjointAlternatives,
onGroupLeave: checkDisjointAlternatives,
onAssertionLeave(node) {
- if (node.kind === "lookahead" || node.kind === "lookbehind") {
+ if (node.kind === 'lookahead' || node.kind === 'lookbehind') {
checkDisjointAlternatives(node);
}
},
@@ -479,7 +479,7 @@ function testPatterns(Prism) {
if (node.max < 10) {
return; // not a star
}
- if (node.element.type !== "CapturingGroup" && node.element.type !== "Group") {
+ if (node.element.type !== 'CapturingGroup' && node.element.type !== 'Group') {
return; // not a group
}
@@ -589,7 +589,7 @@ function testPatterns(Prism) {
+ `\n`
+ `\nFull pattern:`
+ `\n${patternStr}`
- + `\n${indent(rangeHighlight, " ".repeat(rangeOffset))}`
+ + `\n${indent(rangeHighlight, ' '.repeat(rangeOffset))}`
+ `\n`
+ `\n` + (fixed ? `Fixed:\n/${fixed.source}/${fixed.flags}` : `Fix not available.`)
);
diff --git a/tests/plugins/keep-markup/test.js b/tests/plugins/keep-markup/test.js
index d3f168e..af2f006 100644
--- a/tests/plugins/keep-markup/test.js
+++ b/tests/plugins/keep-markup/test.js
@@ -42,7 +42,7 @@ describe('Prism Keep Markup Plugin', function () {
const afterHighlight = Prism.hooks.all['after-highlight'][0]
const env = {
element: new JSDOM(code).window.document.getElementsByTagName('code')[0],
- language: "javascript"
+ language: 'javascript'
}
beforeHighlight(env)
afterHighlight(env)
diff --git a/tests/run.js b/tests/run.js
index ace86f0..d3e38e6 100644
--- a/tests/run.js
+++ b/tests/run.js
@@ -1,16 +1,16 @@
// @ts-check
-"use strict";
+'use strict';
-const TestDiscovery = require("./helper/test-discovery");
-const TestCase = require("./helper/test-case");
-const path = require("path");
-const { argv } = require("yargs");
+const TestDiscovery = require('./helper/test-discovery');
+const TestCase = require('./helper/test-case');
+const path = require('path');
+const { argv } = require('yargs');
const testSuite =
(argv.language)
- ? TestDiscovery.loadSomeTests(__dirname + "/languages", argv.language)
+ ? TestDiscovery.loadSomeTests(__dirname + '/languages', argv.language)
// load complete test suite
- : TestDiscovery.loadAllTests(__dirname + "/languages");
+ : TestDiscovery.loadAllTests(__dirname + '/languages');
const insert = !!argv.accept || !!argv.insert;
const update = !!argv.update;
@@ -30,7 +30,7 @@ for (const language in testSuite) {
it("– should pass test case '" + fileName + "'", function () {
if (path.extname(filePath) === '.test') {
- TestCase.runTestCase(language, filePath, update ? "update" : insert ? "insert" : "none");
+ TestCase.runTestCase(language, filePath, update ? 'update' : insert ? 'insert' : 'none');
} else {
TestCase.runTestsWithHooks(language, require(filePath));
}
diff --git a/tests/testrunner-tests.js b/tests/testrunner-tests.js
index 2faaf81..a7ca237 100644
--- a/tests/testrunner-tests.js
+++ b/tests/testrunner-tests.js
@@ -1,36 +1,36 @@
-"use strict";
+'use strict';
-const { assert } = require("chai");
-const TokenStreamTransformer = require("./helper/token-stream-transformer");
-const TestCase = require("./helper/test-case");
+const { assert } = require('chai');
+const TokenStreamTransformer = require('./helper/token-stream-transformer');
+const TestCase = require('./helper/test-case');
-describe("The token stream transformer", function () {
+describe('The token stream transformer', function () {
- it("should handle all kinds of simple transformations", function () {
+ it('should handle all kinds of simple transformations', function () {
const tokens = [
- { type: "type", content: "content" },
- "string"
+ { type: 'type', content: 'content' },
+ 'string'
];
const expected = [
- ["type", "content"],
- "string"
+ ['type', 'content'],
+ 'string'
];
assert.deepEqual(TokenStreamTransformer.simplify(tokens), expected);
});
- it("should handle nested structures", function () {
+ it('should handle nested structures', function () {
const tokens = [
{
- type: "type",
+ type: 'type',
content: [
{
- type: "insideType",
+ type: 'insideType',
content: [
- { type: "insideInsideType", content: "content" }
+ { type: 'insideInsideType', content: 'content' }
]
}
]
@@ -38,9 +38,9 @@ describe("The token stream transformer", function () {
];
const expected = [
- ["type", [
- ["insideType", [
- ["insideInsideType", "content"]
+ ['type', [
+ ['insideType', [
+ ['insideInsideType', 'content']
]]
]]
];
@@ -49,12 +49,12 @@ describe("The token stream transformer", function () {
});
- it("should strip empty tokens", function () {
+ it('should strip empty tokens', function () {
const tokenStream = [
- "",
- "\r\n",
- "\t",
- " "
+ '',
+ '\r\n',
+ '\t',
+ ' '
];
const expectedSimplified = [];
@@ -63,22 +63,22 @@ describe("The token stream transformer", function () {
});
- it("should strip empty token tree branches", function () {
+ it('should strip empty token tree branches', function () {
const tokenStream = [
{
- type: "type",
+ type: 'type',
content: [
- "",
- { type: "nested", content: [""] },
- ""
+ '',
+ { type: 'nested', content: [''] },
+ ''
]
},
- ""
+ ''
];
const expectedSimplified = [
- ["type", [
- ["nested", []]
+ ['type', [
+ ['nested', []]
]]
];
@@ -86,58 +86,58 @@ describe("The token stream transformer", function () {
});
- it("should ignore all properties in tokens except value and content", function () {
+ it('should ignore all properties in tokens except value and content', function () {
const tokenStream = [
- { type: "type", content: "content", alias: "alias" }
+ { type: 'type', content: 'content', alias: 'alias' }
];
const expectedSimplified = [
- ["type", "content"]
+ ['type', 'content']
];
assert.deepEqual(TokenStreamTransformer.simplify(tokenStream), expectedSimplified);
});
});
-describe("The language name parsing", function () {
+describe('The language name parsing', function () {
- it("should use the last language as the main language if no language is specified", function () {
+ it('should use the last language as the main language if no language is specified', function () {
assert.deepEqual(
- TestCase.parseLanguageNames("a"),
+ TestCase.parseLanguageNames('a'),
{
- languages: ["a"],
- mainLanguage: "a"
+ languages: ['a'],
+ mainLanguage: 'a'
}
);
assert.deepEqual(
- TestCase.parseLanguageNames("a+b+c"),
+ TestCase.parseLanguageNames('a+b+c'),
{
- languages: ["a", "b", "c"],
- mainLanguage: "c"
+ languages: ['a', 'b', 'c'],
+ mainLanguage: 'c'
}
);
});
- it("should use the specified language as main language", function () {
+ it('should use the specified language as main language', function () {
assert.deepEqual(
- TestCase.parseLanguageNames("a+b!+c"),
+ TestCase.parseLanguageNames('a+b!+c'),
{
- languages: ["a", "b", "c"],
- mainLanguage: "b"
+ languages: ['a', 'b', 'c'],
+ mainLanguage: 'b'
}
);
});
- it("should throw an error if there are multiple main languages", function () {
+ it('should throw an error if there are multiple main languages', function () {
assert.throw(
() => {
- TestCase.parseLanguageNames("a+b!+c!");
+ TestCase.parseLanguageNames('a+b!+c!');
},
- "There are multiple main languages defined."
+ 'There are multiple main languages defined.'
);
});
});