Best JavaScript code snippet using storybook-root
checkstyleUtil.js
Source:checkstyleUtil.js
1checkstyleUtil = {2 errors: [],3 4 commentNames: ["summary", "description", "example", "tags", "this"]5};6checkstyleUtil.applyRules = function(fileName, contents){7 // Do not process JSON files8 if(contents.charAt(0) == "{"){9 return;10 }11 12 // Mark all the characters that are in comments.13 var comments = checkstyleUtil.getComments(contents);14 15 // Apply all the rules to the file16 for(var ruleName in checkstyleUtil.rules){17 checkstyleUtil.rules[ruleName](fileName, contents, comments);18 }19};20// Calculate the characters in a file that are in comment fields21// These will be ignored by the checkstyle rules.22checkstyleUtil.getComments = function(contents){23 var comments = [];24 25 var i;26 27 // Initialize the array to false values.28 for(i = 0; i < contents.length; i++){29 comments[i] = 0;30 }31 32 var sep = "\n";33 34 function markRange(start, stop){35 for(var i = start; i < stop; i++){36 comments[i] = 1;37 }38 }39 function markRegexs() {40 var idx = contents.indexOf("/g");41 var i;42 while(idx > -1) {43 if(!comments[idx] && contents.charAt(idx - 1) != "*"){44 // Look back until either a forward slash45 // or a new line is found46 var prevChar = contents.charAt(idx - 1);47 i = idx;48 while(prevChar != "\n" && prevChar != "/" && i > 0){49 prevChar = contents.charAt(--i);50 }51 if(prevChar == "/" && i < idx - 1){52 markRange(i, idx);53 }54 }55 idx = contents.indexOf("/g", idx + 2)56 }57 58 // Now mark all .match and .replace function calls59 // They generally contain regular expressions, and are just too bloody difficult.60 var fnNames = ["match", "replace"];61 var name;62 63 for (i = 0; i < fnNames.length; i++){64 name = fnNames[i];65 66 idx = contents.indexOf(name + "(");67 68 while(idx > -1){69 // Find the end parenthesis70 if(comments[idx]){71 idx = contents.indexOf(name + "(", idx + name.length);72 } else {73 var fnEnd = contents.indexOf(")", idx);74 markRange(idx, fnEnd + 1);75 }76 }77 }78 79 // Now look for all the lines that declare a regex variable, e.g.80 // var begRegExp = /^,|^NOT |^AND |^OR |^\(|^\)|^!|^&&|^\|\|/i;81 82 idx = contents.indexOf(" = /");83 84 while(idx > -1){85 if(!comments[idx] && contents.charAt(idx + 4) != "*"){86 var eol = contents.indexOf("\n", idx + 1);87 markRange(idx + 3, Math.max(eol, idx + 4));88 }89 90 idx = contents.indexOf(" = /", idx + 3);91 }92 }93 markRegexs();94 95 96 var marker = null;97 var ch;98 99 var DOUBLE_QUOTE = 1;100 var SINGLE_QUOTE = 2;101 var LINE_COMMENT = 3;102 var MULTI_COMMENT = 4;103 var UNMARK = 5;104 105 var pos;106 107 for (i = 0; i < contents.length; i++) {108 var skip = false;109 110 if(comments[i]){111 continue;112 }113 114 ch = contents[i];115 116 switch(ch){117 case "\"":118 if(marker == DOUBLE_QUOTE) {119 marker = UNMARK;120 } else if (marker == null) {121 marker = DOUBLE_QUOTE;122 pos = i;123 }124 125 break;126 case "'":127 if(marker == SINGLE_QUOTE) {128 marker = UNMARK;129 } else if (marker == null) {130 marker = SINGLE_QUOTE;131 pos = i;132 }133 134 break;135 case "/":136 if(marker == null){137 if(contents[i + 1] == "/"){138 marker = LINE_COMMENT;139 pos = i;140 skip = true;141 } else if(contents[i + 1] == "*"){142 marker = MULTI_COMMENT;143 pos = i;144 skip = true;145 }146 }147 148 break;149 case "*":150 if (marker == MULTI_COMMENT){151 if(contents[i + 1] == "/"){152 marker = UNMARK;153 skip = true;154 }155 }156 157 break;158 case "\n":159 if(marker == LINE_COMMENT){160 marker = UNMARK;161 }162 break;163 164 }165 if (marker != null) {166 comments[i] = 1;167 }168 if (marker == UNMARK){169 marker = null;170 }171 if (skip) {172 i++;173 comments[i] = 1;174 }175 }176 177 178 return comments;179}180// Calculate the line number of the character at index 'pos'181checkstyleUtil.getLineNumber = function(contents, pos){182 var counter = 0;183 var sep = "\n";184 185 for(var i = pos; i > -1; i--){186 if(contents.charAt(i) == "\n"){187 counter ++;188 }189 }190 return counter + 1;191};192// Store the information for a single error.193checkstyleUtil.addError = function(msg, fileName, contents, pos){194 while(fileName.indexOf("../") == 0){195 fileName = fileName.substring(3);196 }197 checkstyleUtil.errors.push({198 file: fileName,199 line: checkstyleUtil.getLineNumber(contents, pos),200 message: msg201 });202};203// Find the next character in 'contents' after the index 'start'204// Spaces and tabs are ignored.205checkstyleUtil.getNextChar = function(contents, start, comments, ignoreNewLine){206 for(var i = start; i < contents.length; i++){207 if(comments && comments[i]){208 continue;209 }210 if(contents.charAt(i) != " "211 && contents.charAt(i) != "\t"212 && (!ignoreNewLine || contents.charCodeAt(i) != 13)){213 return {214 value: contents[i],215 pos: i216 };217 }218 }219 return null;220};221// Find the next occurrence of the character in the222// 'contents' array after the index 'start'223checkstyleUtil.findNextCharPos = function(contents, start, character){224 for(var i = start; i < contents.length; i++){225 if(contents.charAt(i) == character){226 return i;227 }228 }229 return -1;230};231// Creates a simple function that searches for the token, and232// adds an error if it is found233checkstyleUtil.createSimpleSearch = function(token, message){234 return function(fileName, contents, comments){235 var idx = contents.indexOf(token);236 237 while(idx > -1){238 239 if(!comments[idx]){240 checkstyleUtil.addError(message, fileName, contents, idx);241 }242 idx = contents.indexOf(token, idx + 1);243 }244 };245};246// Creates a function that fails a test if the given token247// does not have a space to the left and right.248checkstyleUtil.createSpaceWrappedSearch = function(token, message){249 return function(fileName, contents, comments){250 251 var idx = contents.indexOf(token);252 var before, after;253 var tokenLength = token.length;254 while(idx > -1){255 before = contents.charAt(idx - 1);256 after = contents.charAt(idx + tokenLength);257 if(!comments[idx] &&258 ((before != " " && before != "\t"259 && (token != "==" || before != "!")260 && (token != "=" ||261 (before != "<" &&262 before != ">" &&263 before != "=" &&264 before != "!" &&265 before != "+" &&266 before != "-" &&267 before != "*" &&268 before != "/" &&269 before != "&" &&270 before != "|" ))) ||271 (272 (after != " " && contents.charCodeAt(idx + tokenLength) != 13273 && contents.charCodeAt(idx + tokenLength) != 10)274 && (token != "==" || after != "=")275 && (token != "!=" || after != "=")276 && (token != "<" || after != "=")277 && (token != ">" || after != "=")278 && (token != "=" || after != "=")279 && (token != "&" || after != "=")280 && (token != "|" || after != "=")281 && (token != "+" || after != "=")282 && (token != "-" || after != "=")283 && (token != "*" || after != "=")284 && (token != "/" || after != "=")285 ))){286 checkstyleUtil.addError(message, fileName, contents, idx);287 }288 idx = contents.indexOf(token, idx + token.length);289 }290 };291};292checkstyleUtil.isEOL = function(contents, pos){293 var c = contents.charCodeAt(pos);294 return c == 10 || c == 13 || contents.charAt(pos) == "\n";295};296// All the rules that will be applied to each file.297checkstyleUtil.rules = {298 "elseFollowedBySpace": function(fileName, contents, comments){299 var idx = contents.indexOf("else ");300 while(idx > -1){301 if(!comments[idx] && contents.substring(idx + 5, idx + 7) != "if"){302 checkstyleUtil.addError("\" else \" cannot be followed by a space", fileName, contents, idx);303 }304 idx = contents.indexOf("else {", idx + 1);305 }306 },307 308 "trailingComma" : function(fileName, contents, comments){309 310 var s = ",";311 var idx = contents.indexOf(s);312 var nextChar;313 314 while(idx > -1){315 if(!comments[idx]){316 nextChar = checkstyleUtil.getNextChar(contents, idx + 1, comments, true);317 if(nextChar && nextChar.value == "}"){318 checkstyleUtil.addError("Trailing commas are not permitted", fileName, contents, idx);319 }320 }321 idx = contents.indexOf(s, idx + 1);322 }323 },324 325 "switchCaseNewLine" : function(fileName, contents, comments){326 var s = "\tcase ";327 var idx = contents.indexOf(s);328 var nextColonIdx;329 var eolIdx;330 331 while(idx > -1){332 333 if(!comments[idx]){334 eolIdx = contents.indexOf("\n", idx + 4);335 336 if(eolIdx > idx){337 // Count backwards from the end of the line.338 // The first character, that is not a comment,339 // Should be a ':'340 341 for(var i = eolIdx; i > idx + 4; i--){342 var c = contents.charAt(i);343 if(!comments[i]344 && c != ' '345 && c != '\t'346 && c != ':'347 && !checkstyleUtil.isEOL(contents, i)){348 checkstyleUtil.addError(349 "A CASE statement should be followed by a new line",350 fileName, contents, idx);351 break;352 }353 if(c == ':'){354 break;355 }356 }357 }358 }359 idx = contents.indexOf(s, idx + 4);360 }361 },362 363 "curlyBraceAtStartOfLine": function(fileName, contents, comments){364 365 var idx = contents.indexOf("\n");366 367 while(idx > -1){368 var nextChar = checkstyleUtil.getNextChar(contents, idx + 1);369 370 if(nextChar && !comments[nextChar.pos] && nextChar.value == "{"){371 // Go back three lines, and look for "dojo.declare". If it exists in the last three lines,372 // then it is ok to have { at the start of this line.373 374 var nlCount = 0;375 var i;376 for(i = idx - 1; i > -1 && nlCount < 3; i--){377 if(contents[i] == "\n"){378 nlCount++;379 }380 }381 var declarePos = contents.indexOf("dojo.declare", Math.max(0, i));382 if(declarePos < 0 || declarePos > idx){383 checkstyleUtil.addError("An opening curly brace should not be the first on a line", fileName, contents, idx);384 }385 }386 idx = contents.indexOf("\n", idx + 1);387 }388 },389 390 "parenthesisSpaceCurlyBrace": checkstyleUtil.createSimpleSearch(") {", "A space is not permitted between a closing parenthesis and a curly brace"),391 392 "useTabs": function(fileName, contents, comments){393 394 var idx = contents.indexOf(" ");395 396 while(idx > -1){397 var nextChar = checkstyleUtil.getNextChar(contents, idx + 1);398 if(!comments[idx] && nextChar && nextChar.value.charCodeAt(0) != 13){399 checkstyleUtil.addError("Tabs should be used instead of spaces", fileName, contents, idx);400 var nextLine = checkstyleUtil.findNextCharPos(contents, idx + 1, "\n");401 if(nextLine < 0){402 break;403 }404 idx = contents.indexOf(" ", nextLine + 1);405 } else{406 idx = contents.indexOf(" ", idx + 2);407 }408 }409 },410 411 "commentFormatting": function(fileName, contents, comments){412 413 var commentNames = checkstyleUtil.commentNames;414 var invalidPrefixes = ["//", "//\t"];415 var idx;416 417 for(var i = 0; i < commentNames.length; i++){418 var comment = commentNames[i];419 for(var j = 0; j < invalidPrefixes.length; j++){420 idx = contents.indexOf(invalidPrefixes[j] + comment + ":");421 // Make sure that there is a space before the comment.422 while(idx > -1){423 checkstyleUtil.addError("Must be just a space in a comment before \"" + comment + "\"" , fileName, contents, idx);424 var nextLine = checkstyleUtil.findNextCharPos(contents, idx + 1, "\n");425 if(nextLine < 0){426 break;427 }428 idx = contents.indexOf(invalidPrefixes[j] + comment + ":", nextLine);429 }430 }431 432 idx = contents.indexOf(comment + ":");433 434 // Make sure that the comment name is on a line by itself. The body of the comment435 // must be on the next line.436 while(idx > -1){437 if(comments[idx]){438 var search = idx + comment.length + 1;439 440 // Make sure that there is nothing after the comment name on the same line.441 while(!checkstyleUtil.isEOL(contents, search)){442 if(contents[search] != " " && contents[search] != "\t"){443 checkstyleUtil.addError("The comment \"" + comment + "\" must be followed by a new line" ,444 fileName, contents, idx);445 break;446 }447 search++;448 }449 }450 idx = contents.indexOf(comment + ":", idx + comment.length + 2);451 }452 }453 },454 455 "spacesAroundEquals": checkstyleUtil.createSpaceWrappedSearch("==", "The equals sign should be preceded and followed by a space"),456 "spacesAroundNotEquals": checkstyleUtil.createSpaceWrappedSearch("!=", "The != sign should be preceded and followed by a space"),457 "spacesAroundAssignment": checkstyleUtil.createSpaceWrappedSearch("=", "The = sign should be preceded and followed by a space"),458 "spacesAroundOr": checkstyleUtil.createSpaceWrappedSearch("||", "The || sign should be preceded and followed by a space"),459 "spacesAroundLessThan": checkstyleUtil.createSpaceWrappedSearch("<", "The < sign should be preceded and followed by a space"),460 "spacesAroundGreaterThan": checkstyleUtil.createSpaceWrappedSearch(">", "The > sign should be preceded and followed by a space"),461 "spacesAroundAnd": checkstyleUtil.createSpaceWrappedSearch("&&", "The && sign should be preceded and followed by a space")462};463var noSpaceAfter = ["catch","do","finally","for","if","switch","try","while","with"];464// Add checks for all the elements that are not allowed to have a space after them.465checkstyleUtil.createNoSpaceAfterFunction = function(name){466 checkstyleUtil.rules["noSpaceAfter" + noSpaceAfter[i] + "1"] =467 checkstyleUtil.createSimpleSearch(" " + name +" ", "\" " + name + " \" cannot be followed by a space");468 checkstyleUtil.rules["noSpaceAfter" + noSpaceAfter[i] + "2"] =469 checkstyleUtil.createSimpleSearch("\t" + name +" ", "\" " + name + " \" cannot be followed by a space");470}471for(var i = 0; i < noSpaceAfter.length; i++){472 checkstyleUtil.createNoSpaceAfterFunction(noSpaceAfter[i]);473}474checkstyleUtil.clear = function(){475 checkstyleUtil.errors = [];476}477checkstyleUtil.serializeErrors = function(){478 var buf = [];479 var errs = checkstyleUtil.errors;480 for(var i = 0; i < errs.length; i++){481 buf.push(errs[i].file + ":" + errs[i].line + " - " + errs[i].message);482 }483 return buf.join("\n");484}485checkstyleUtil.makeSimpleFixes = function(contents){486 487 var comments = checkstyleUtil.getComments(contents);488 for(var i = 0; i < noSpaceAfter.length; i++){489 contents = checkstyleUtil.fixSpaceAfter(contents, noSpaceAfter[i], comments);490 }491 /*492 contents = contents.split(" ").join("\t")493 .split(" ").join("\t")494 .split(") {").join("){")495 .split("\tif (").join("\tif(")496 .split("} else").join("}else")497 .split("}\telse").join("}else")498 .split("}else {").join("}else{")499 .split("\twhile (").join("\twhile(")500 .split("\tfor (").join("\tfor(")501 .split("\tswitch (").join("\tswitch(");502 */503 504 contents = checkstyleUtil.replaceAllExceptComments(contents, "= ", "= ", comments);505 comments = checkstyleUtil.getComments(contents);506 contents = checkstyleUtil.replaceAllExceptComments(contents, " ", "\t", comments);507 comments = checkstyleUtil.getComments(contents);508 contents = checkstyleUtil.replaceAllExceptComments(contents, " ", "\t", comments);509 comments = checkstyleUtil.getComments(contents);510 contents = checkstyleUtil.replaceAllExceptComments(contents, "\tif (", "\tif(", comments);511 comments = checkstyleUtil.getComments(contents);512 contents = checkstyleUtil.replaceAllExceptComments(contents, "} else", "}else", comments);513 comments = checkstyleUtil.getComments(contents);514 contents = checkstyleUtil.replaceAllExceptComments(contents, "}\telse", "}else", comments);515 comments = checkstyleUtil.getComments(contents);516 contents = checkstyleUtil.replaceAllExceptComments(contents, "}else {", "}else{", comments);517 comments = checkstyleUtil.getComments(contents);518 contents = checkstyleUtil.replaceAllExceptComments(contents, "\twhile (", "\twhile(", comments);519 comments = checkstyleUtil.getComments(contents);520 contents = checkstyleUtil.replaceAllExceptComments(contents, "\tfor (", "\tfor(", comments);521 comments = checkstyleUtil.getComments(contents);522 contents = checkstyleUtil.replaceAllExceptComments(contents, "\tswitch (", "\tswitch(", comments);523 comments = checkstyleUtil.getComments(contents);524 contents = checkstyleUtil.replaceAllExceptComments(contents, ") {", "){", comments);525 comments = checkstyleUtil.getComments(contents);526 contents = checkstyleUtil.replaceAllExceptComments(contents, "//summary:", "// summary:", {});527 contents = checkstyleUtil.replaceAllExceptComments(contents, "//description:", "// description:", {});528 comments = checkstyleUtil.getComments(contents);529 530 contents = checkstyleUtil.fixTrailingWhitespace(contents);531 comments = checkstyleUtil.getComments(contents);532 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "===", comments);533 comments = checkstyleUtil.getComments(contents);534 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "!==", comments);535 comments = checkstyleUtil.getComments(contents);536 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "<=", comments);537 comments = checkstyleUtil.getComments(contents);538 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "<", comments);539 comments = checkstyleUtil.getComments(contents);540 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, ">=", comments);541 comments = checkstyleUtil.getComments(contents);542 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, ">", comments);543 comments = checkstyleUtil.getComments(contents);544 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "!=", comments);545 comments = checkstyleUtil.getComments(contents);546 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "==", comments);547 comments = checkstyleUtil.getComments(contents);548 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "=", comments);549 comments = checkstyleUtil.getComments(contents);550 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "||", comments);551 comments = checkstyleUtil.getComments(contents);552 contents = checkstyleUtil.fixSpaceBeforeAndAfter(contents, "&&", comments);553 comments = checkstyleUtil.getComments(contents);554 555 contents = checkstyleUtil.fixCommentNames(contents);556 557 558 559 return contents;560}561checkstyleUtil.fixCommentNames = function(contents){562 var commentNames = checkstyleUtil.commentNames;563 var i;564 565 for(i = 0; i < commentNames.length; i++){566 contents = checkstyleUtil.replaceAllExceptComments(contents, "//\t" + commentNames[i] + ":", "// " + commentNames[i] + ":", {});567 }568 569 for(i = 0; i < commentNames.length; i++){570 var commentName = commentNames[i];571 var searchToken = "// " + commentName + ":";572 var idx = contents.indexOf(searchToken);573 574 575 while(idx > -1){576 // If the comment name is not followed immediately by a new line, then insert a new line,577 // two forward slashes and two tabs.578 if(!checkstyleUtil.isEOL(contents, idx + commentName.length + 4)){579 // Calculate how many tabs to put before the "//"580 581 var tabs = "";582 var search = idx - 1;583 while(!checkstyleUtil.isEOL(contents, search)){584 tabs += contents.charAt(search);585 search--;586 }587 var insertPos = idx + commentName.length + 4;588 if(contents.charAt(insertPos) == " " || contents.charAt(insertPos) == "\t"){589 contents = checkstyleUtil.deleteChar(contents, insertPos);590 }591 592 contents = checkstyleUtil.insertChar(contents, "\n" + tabs + "//\t\t", idx + commentName.length + 4);593 594 }595 idx = contents.indexOf(searchToken, idx + commentName.length);596 }597 }598 return contents;599}600checkstyleUtil.replaceAllExceptComments = function(contents, old, newStr, comments){601 var idx = contents.indexOf(old);602 var toRemove = [];603 604 while(idx > -1){605 if(!comments[idx]){606 toRemove.push(idx);607 }608 idx = contents.indexOf(old, idx + old.length);609 }610 611 // Process the string backwards so we don't have to recompute the comments each time.612 for(var i = toRemove.length - 1; i > -1; i--){613 idx = toRemove[i];614 if(!comments[idx]){615 contents = contents.substring(0, idx)616 + newStr617 + contents.substring(idx + old.length, contents.length);618 }619 }620 return contents;621}622checkstyleUtil.insertChar = function(contents, ch, pos){623 return contents.substring(0, pos) + ch + contents.substring(pos);624}625checkstyleUtil.deleteChar = function(contents, pos){626 return contents.substring(0, pos) + contents.substring(pos + 1);627}628checkstyleUtil.fixTrailingWhitespace = function(contents) {629 var idx = contents.indexOf("\n");630 631 // Find each new line character, then iterate backwards until a non-whitespace character is found632 // then remove the whitespace.633 while(idx > -1){634 var search = idx - 1;635 636 while(search > -1 && (contents.charAt(search) == " " || contents.charAt(search) == "\t")){637 search--;638 }639 640 if(search < idx -1){641 contents = contents.substring(0, search + 1)642 + contents.substring(idx, contents.length);643 644 idx = contents.indexOf("\n", search + 2);645 }else{646 idx = contents.indexOf("\n", idx + 1);647 }648 }649 return contents;650}651checkstyleUtil.fixSpaceAfter = function(contents, token, comments){652 var idx = contents.indexOf(token + " ");653 654 while(idx > -1){655 if(!comments[idx]){656 contents = checkstyleUtil.deleteChar(contents, idx + token.length);657 }658 659 idx = contents.indexOf(token + " ", idx + token.length);660 }661 return contents;662}663checkstyleUtil.fixSpaceBeforeAndAfter = function(contents, token, comments){664 var idx = contents.indexOf(token);665 var before, after;666 var len = token.length;667 while(idx > -1){668 before = contents.charAt(idx - 1);669 after = contents.charAt(idx + len);670 if(!comments[idx]){671 // Only insert a space before the token if:672 // - char before is not a space or a tab673 // - token is "==" and the char before is neither "!" or "="674 675 if(before != " " && before != "\t"676 && (token != "==" || (before != "!" && before != "="))677 && (token != "=" ||678 (before != "<" &&679 before != ">" &&680 before != "=" &&681 before != "!" &&682 before != "+" &&683 before != "-" &&684 before != "*" &&685 before != "/" &&686 before != "&" &&687 before != "|" ))688 ){689 690 contents = checkstyleUtil.insertChar(contents, " ", idx);691 idx ++;692 }693 694 // Only insert a space after the token if:695 // - char after is not a space696 // - char after is not a new line697 // - char after is not "="698 if((after != " " && contents.charCodeAt(idx + len) != 13699 && contents.charCodeAt(idx + len) != 10)700 && (token != "==" || after != "=")701 && (token != "!=" || after != "=")702 && (token != "=" || after != "=")703 && (token != "<" || after != "=")704 && (token != ">" || after != "=")705 && (token != "&" || after != "=")706 && (token != "|" || after != "=")707 && (token != "+" || after != "=")708 && (token != "-" || after != "=")709 && (token != "*" || after != "=")710 && (token != "/" || after != "=")711 712 ){713 contents = contents = checkstyleUtil.insertChar(contents, " ", idx + token.length);714 idx++;715 }716 }717 idx = contents.indexOf(token, idx + token.length);718 }719 return contents;720}721// Creates the data file suitable to be loaded into a dojo.data.ItemFileReadStore722checkstyleUtil.generateReport = function(skipPrint){723 724 var ids = 1;725 var json = ["{id:'" +(ids++) + "', file: 'All', isFolder:true}"];726 // A map of folders that have already been found.727 var allFolders = {};728 729 var messageIds = {};730 var messageCounter = 1;731 var i, err;732 733 function getFolderName(fileName){734 // Extract the folder name from a file name735 var idx = fileName.lastIndexOf("/");736 return fileName.substring(0, idx);737 }738 739 // Add a folder to the list of folders.740 function pushFolder(folderName){741 if(!allFolders[folderName]){742 allFolders[folderName] = true;743 json.push("{id: '" +(ids++) + "', file: '" + folderName + "', folder: 1}");744 }745 }746 747 for(i = 0; i < checkstyleUtil.errors.length; i++){748 err = checkstyleUtil.errors[i];749 var message = err.message;750 var messageId = messageIds[message];751 if(!messageId){752 messageId = "m" + messageCounter++;753 messageIds[message] = messageId;754 755 json.push("{id:'" + messageId +756 "',msg:'" + message +757 "'}");758 }759 }760 761 pushFolder("All");762 763 // Create the JSON records for each error.764 for(i = 0; i < checkstyleUtil.errors.length; i++){765 err = checkstyleUtil.errors[i];766 var folderName = getFolderName(err.file);767 pushFolder(folderName);768 769 json.push("{id:'" +(ids++) +770 "', file:'" + err.file +771 "',line:" + err.line +772 ",msg:{'_reference':'" + messageIds[err.message] +773 //"'},folder:'" + folderName +774 "'},folder: 0" +775 "}");776 777 }778 // Add the date that the check was run to the store.779 json.push("{id:'" +(ids++) + "', date: " +(new Date()).getTime() + "}");780 781 // Save the file.782 if(!skipPrint){783 print("Found " + checkstyleUtil.errors.length + " checkstyle errors. " +784 "Open the file checkstyleReport.html to view the results.");785 }786 787 return "{ identifier: 'id', label:'file', items: [" + json.join(",\n") + "]}";...
buildUtilXd.js
Source:buildUtilXd.js
1//The functions in this file assume that buildUtil.js have been loaded.2var buildUtilXd = {};3buildUtilXd.setXdDojoConfig = function(/*String*/fileContents, /*String*/url){4 // summary:5 // sets sets up xdomain loading for a particular URL.6 // fileContents:7 // be a built dojo.js (can be uncompressed or compressed).8 // url:9 // value should be the url to the directory that contains the dojo,10 // dijit and dojox directories.11 // Example: "http://some.domain.com/dojo090" (no ending slash)12 //This function will inject some contents after the dojo.registerModulePath() definition.13 //The contents of fileName should have been a dojo.js that includes the contents14 //of loader_xd.js (specify loader=xdomain in the build command).15 //This code is not very robust. It will break if dojo.registerModulePath definition16 //changes to anything more advanced.17 var match = fileContents.match(/(dojo\.registerModulePath\s*=\s*function.*\{)/);18 19 //Find the next two } braces and in inject code after that.20 var endIndex = fileContents.indexOf("}", match.index);21 endIndex = fileContents.indexOf("}", endIndex + 1);22 if(fileContents.charAt(endIndex + 1) == ";"){23 endIndex += 1;24 }25 endIndex +=1;26 var lineSeparator = fileUtil.getLineSeparator();27 return fileContents.substring(0, endIndex)28 + lineSeparator29 + "if(typeof dojo.config[\"useXDomain\"] == \"undefined\"){"30 + "dojo.config.useXDomain = true;};\ndojo.registerModulePath(\"dojo\", \""31 + url + "/dojo"32 + "\");\ndojo.registerModulePath(\"dijit\", \""33 + url + "/dijit"34 + "\");\ndojo.registerModulePath(\"dojox\", \""35 + url + "/dojox"36 + "\");"37 + lineSeparator38 + fileContents.substring(endIndex, fileContents.length);39}40buildUtilXd.xdgen = function(41 /*String*/prefixName,42 /*String*/prefixPath,43 /*Array*/prefixes,44 /*RegExp*/optimizeIgnoreRegExp,45 /*Object*/kwArgs46){47 // summary:48 // generates the .xd.js files for a build.49 var jsFileNames = fileUtil.getFilteredFileList(prefixPath, /\.js$/, true);50 51 //Construct a regexp to avoid xd generating loader_xd.js, since shrinksafe52 //does not like the resulting javascript that is generated, because of53 //bug http://trac.dojotoolkit.org/ticket/276654 var loaderIgnoreRegExp = /dojo\/_base\/_loader\/loader_xd/;55 for(var i = 0; i < jsFileNames.length; i++){56 var jsFileName = jsFileNames[i];57 //Some files, like the layer files, have already been xd58 //processed, so be sure to skip those.59 if(!jsFileName.match(optimizeIgnoreRegExp) && !jsFileName.match(loaderIgnoreRegExp)){60 var xdFileName = jsFileName.replace(/\.js$/, ".xd.js");61 var fileContents = fileUtil.readFile(jsFileName);62 //Files in nls directories, except for the ones that have multiple63 //bundles flattened (therefore have a dojo.provide call),64 //need to have special xd contents.65 if(jsFileName.match(/\/nls\//) && fileContents.indexOf("dojo.provide(") == -1){66 var xdContents = buildUtilXd.makeXdBundleContents(prefixName, prefixPath, jsFileName, fileContents, prefixes, kwArgs);67 }else{68 xdContents = buildUtilXd.makeXdContents(fileContents, prefixes, kwArgs);69 }70 fileUtil.saveUtf8File(xdFileName, xdContents);71 }72 }73}74//Function that generates the XD version of the module file's contents75buildUtilXd.makeXdContents = function(fileContents, prefixes, kwArgs){76 var dependencies = [];77 //Use the regexps to find resource dependencies for this module file.78 var depMatches = buildUtil.removeComments(fileContents).match(buildUtil.globalDependencyRegExp);79 if(depMatches){80 for(var i = 0; i < depMatches.length; i++){81 var partMatches = depMatches[i].match(buildUtil.dependencyPartsRegExp);82 var depCall = partMatches[1];83 var depArgs = partMatches[2];84 if(depCall == "requireLocalization"){85 //Need to find out what locales are available so the dojo loader86 //only has to do one script request for the closest matching locale.87 var reqArgs = i18nUtil.getRequireLocalizationArgsFromString(depArgs);88 if(reqArgs.moduleName){89 //Find the list of locales supported by looking at the path names.90 var locales = i18nUtil.getLocalesForBundle(reqArgs.moduleName, reqArgs.bundleName, prefixes);91 //Add the supported locales to the requireLocalization arguments.92 if(!reqArgs.localeName){93 depArgs += ", null";94 }95 depCall = "requireLocalization";96 depArgs += ', "' + locales.join(",") + '"';97 }else{98 //Malformed requireLocalization call. Skip it. May be a comment.99 continue;100 }101 }102 103 dependencies.push('"' + depCall + '", ' + depArgs);104 }105 }106 //Build the xd file contents.107 var xdContentsBuffer = [];108 var scopeArgs = kwArgs.xdScopeArgs || "dojo, dijit, dojox";109 //Start the module function wrapper.110 xdContentsBuffer.push((kwArgs.xdDojoScopeName || "dojo") + "._xdResourceLoaded(function(" + scopeArgs + "){\n");111 //See if there are any dojo.loadInit calls112 var loadInitCalls = buildUtilXd.extractLoadInits(fileContents);113 if(loadInitCalls){114 //Adjust fileContents since extractLoadInits removed something.115 fileContents = loadInitCalls[0];116 //Add any loadInit calls to an array passed _xdResourceLoaded117 for(i = 1; i < loadInitCalls.length; i++){118 xdContentsBuffer.push(loadInitCalls[i] + ";\n");119 }120 }121 xdContentsBuffer.push("return {");122 //Add in dependencies section.123 if(dependencies.length > 0){124 xdContentsBuffer.push("depends: [");125 for(i = 0; i < dependencies.length; i++){126 if(i > 0){127 xdContentsBuffer.push(",\n");128 }129 xdContentsBuffer.push("[" + dependencies[i] + "]");130 }131 xdContentsBuffer.push("],");132 }133 134 //Add the contents of the file inside a function.135 //Pass in module names to allow for multiple versions of modules in a page.136 xdContentsBuffer.push("\ndefineResource: function(" + scopeArgs + "){");137 //Remove requireLocalization calls, since that will mess things up.138 //String() part is needed since fileContents is a Java object.139 xdContentsBuffer.push(String(fileContents).replace(/dojo\.(requireLocalization|i18n\._preloadLocalizations)\([^\)]*\)/g, ""));140 xdContentsBuffer.push("\n}};});");141 return xdContentsBuffer.join("");142}143buildUtilXd.makeXdBundleContents = function(prefix, prefixPath, srcFileName, fileContents, prefixes, kwArgs){144 //logger.info("Flattening bundle: " + srcFileName);145 var bundleParts = i18nUtil.getBundlePartsFromFileName(prefix, prefixPath, srcFileName);146 if(!bundleParts){147 return null;148 }149 var moduleName = bundleParts.moduleName;150 var bundleName = bundleParts.bundleName;151 var localeName = bundleParts.localeName;152 153 //logger.trace("## moduleName: " + moduleName + ", bundleName: " + bundleName + ", localeName: " + localeName);154 155 //If this is a dojo bundle, it will have already been flattened via the normal build process.156 //If it is an external bundle, then we didn't flatten it during the normal build process since157 //right now, we don't make copies of the external module source files. Need to figure that out at some158 //point, but for now, need to get flattened contents for external modules.159 fileContents = (prefix.indexOf("dojo") == 0) ? fileContents : i18nUtil.makeFlatBundleContents(prefix, prefixPath, srcFileName);160 //Final XD file contents.161 fileContents = 'dojo.provide("' + moduleName + '.nls.' + (localeName ? localeName + '.' : '') + bundleName + '");'162 + 'dojo._xdLoadFlattenedBundle("' + moduleName + '", "' + bundleName163 + '", "' + localeName + '", ' + fileContents + ');';164 //Now make a proper xd.js file out of the content.165 return buildUtilXd.makeXdContents(fileContents, prefixes, kwArgs);166}167buildUtilXd.loadInitRegExp = /dojo\.loadInit\s*\(/g;168buildUtilXd.extractLoadInits = function(/*String*/fileContents){169 return buildUtil.extractMatchedParens(buildUtilXd.loadInitRegExp, fileContents);...
docparser.js
Source:docparser.js
1Trex.install("editor.getDocParser",2 function(editor, toolbar, sidebar, canvas, config){3 var _docparser = new Trex.Docparser(editor, sidebar, config);4 editor.getDocParser = function() {5 return _docparser;6 };7 }8);9Trex.Docparser =Trex.Class.create( {10 initialize : function(editor, sidebar, config){11 this.editor = editor;12 this.sidebar = sidebar;13 this.config = config;14 },15 filters: {},16 /**17 * register contents converting filter 18 * 19 * original = DBì ì ì¥ëë 컨í
ì¸ 20 * html = wysiwyg 모ëìì ë³´ì´ë 컨í
ì¸ 21 * source = source 모ëìì ë³´ì´ë 컨í
ì¸ 22 * text = text 모ëìì ë³´ì´ë 컨í
ì¸ 23 * 24 * @example25 * editor.getDocParser().registerFilter(26 'filter/converting', {27 'text@load': function(contents){ // orginal -> text28 return contents;29 },30 'source@load': function(contents){ // orginal -> source31 return contents;32 },33 'html@load': function(contents){ // orginal -> html34 return contents;35 },36 'text4save': function(contents){ // text -> orginal 37 return contents;38 },39 'source4save': function(contents){ // source -> orginal 40 return contents;41 },42 'html4save': function(contents){ // html -> orginal 43 return contents;44 },45 'text2source': function(contents){ // text -> source46 return contents;47 },48 'text2html': function(contents){ // text -> html49 return contents;50 },51 'source2text': function(contents){ // source -> text52 return contents;53 },54 'source2html': function(contents){ // source -> html55 return contents;56 },57 'html2text': function(contents){ // html -> text58 return contents;59 },60 'html2source': function(contents){ // html -> source61 return contents;62 }63 }64 );65 */66 registerFilter: function(name, filter){67 this.filters[name] = filter;68 },69 getFilter: function(name){70 return this.filters[name];71 },72 executeFilters: function (cmd, contents) {73 var filters = this.filters;74 ["before " + cmd, cmd, "after " + cmd].each(function (cmd) {75 var name, filter;76 for (name in filters) {77 if (filters.hasOwnProperty(name)) {78 filter = filters[name];79 if (filter[cmd]) {80 contents = filter[cmd](contents); 81 }82 }83 }84 });85 return contents;86 },87 getContentsAtChangingMode: function(contents, oldMode, newMode) {88 if (oldMode == newMode) {89 return contents;90 }91 contents = contents.trim() || "";92 return this.executeFilters(oldMode.concat("2").concat(newMode), contents);93 },94 convertAtLoad: function(contents, editorMode, inputMode) { // For Display95 /*96 * DBì ì ì¥ë 컨í
ì¸ 97 * > original, text98 */99 if(inputMode == 'original') { //original 컨í
ì¸ ë³í100 contents = this.executeFilters(editorMode.concat('@load'), contents);101 } else { //ê·¸ì¸ ëª¨ë, ìëì ì¥ì ë³íìì´ ì ì¥ë¨.102 if(editorMode != inputMode) {103 contents = this.executeFilters(inputMode.concat("2").concat(editorMode), contents);104 }105 }106 return contents;107 },108 convertAtSave: function(contents, editorMode, outputMode) { // For Save109 if (outputMode == 'original') { //original 컨í
ì¸ ë³í110 contents = this.executeFilters(editorMode.concat('4save'), contents);111 } else { //ê·¸ì¸ ëª¨ë, ìëì ì¥ì ë³íìì´ ì ì¥ë¨.112 if (editorMode != outputMode) {113 contents = this.executeFilters(editorMode.concat("2").concat(outputMode), contents);114 }115 }116 return contents;117 },118 /* ì¸ë¶ìì 참조í 컨í
ì¸ ë³í íí°ëª
ìì */119 text2source: function(contents) {120 return this.executeFilters("text2source", contents);121 },122 text2html: function(contents) {123 if (contents === "") {124 return $tom.EMPTY_PARAGRAPH_HTML;125 }126 return this.executeFilters("text2html", contents);127 },128 source2text: function(contents) {129 return this.executeFilters("source2text", contents);130 },131 source2html: function(contents) {132 if (contents === "") {133 return $tom.EMPTY_PARAGRAPH_HTML;134 }135 return this.executeFilters("source2html", contents);136 },137 html2text: function(contents) {138 return this.executeFilters("html2text", contents);139 },140 html2source: function(contents) {141 return this.executeFilters("html2source", contents);142 }143 /* ì¸ë¶ìì 참조í 컨í
ì¸ ë³í íí°ëª
ë */144 } ...
redundancy.js
Source:redundancy.js
1Trex.register("filter > clear redundancy",2 function (editor) {3 function clearRedundancy(contents) {4 var clearHandler = function (content, style, loop) {5 var matchCount = 0;6 var matchHandler = function (all, value, text) {7 matchCount++;8 if (text.length == 0 || text.trim().length == 0) {9 return "";10 } else {11 return ['<span style="', style, ':', value, ';">', text, '</span>'].join("");12 }13 };14 var regex = new RegExp("(?:<span[^>;]*style=\"" + style + ":[^\";]*;?\"[^>;]*>){" + loop + "}<span\\s*style=['\"]?" + style + ":\\s*(\\w+)[;'\"]*>([\\S\\s]*?)<\/span>(?:<\/span>){" + loop + "}", "gi"); //#FTDUEDTR-111915 do {16 matchCount = 0;17 content = content.replace(regex, matchHandler);18 } while (matchCount > 0);19 return content;20 };21 contents = contents.replace(/<(span|font)([^>]*)><\/\1>/gi, function (fullMatched, tagName, subMatched) {22 if (/ (?:id|class)=/i.test(subMatched)) { //NOTE: #FTDUEDTR-104123 return fullMatched;24 }25 return "";26 });27 var styles = ['font-size', 'font-family'];28 for (var i = 0; i < styles.length; i++) {29 contents = clearHandler(contents, styles[i], 2);30 contents = clearHandler(contents, styles[i], 1);31 }32 return contents;33 }34 function removeSpacerParagraph(contents) {35 // FTDUEDTR-131936 return $tx.msie ? contents.replace(/<p>\s*<\/p>/gi, '') : contents;37 }38 function makeSpacerParagraph(contents) {39 // FTDUEDTR-131940 return $tx.msie ? contents.replace(/<p>\s*<\/p>/gi, $tom.EMPTY_PARAGRAPH_HTML) : contents;41 }42 var docparser = editor.getDocParser();43 docparser.registerFilter(44 'filter/redundancy', {45 'text@load': function (contents) {46 return contents;47 },48 'source@load': function (contents) {49 return removeSpacerParagraph(clearRedundancy(contents));50 },51 'html@load': function (contents) {52 return removeSpacerParagraph(clearRedundancy(contents));53 },54 'text4save': function (contents) {55 return contents;56 },57 'source4save': function (contents) {58 return makeSpacerParagraph(contents);59 },60 'html4save': function (contents) {61 return makeSpacerParagraph(contents);62 },63 'text2source': function (contents) {64 return contents;65 },66 'text2html': function (contents) {67 return contents;68 },69 'source2text': function (contents) {70 return contents;71 },72 'source2html': function (contents) { //source2wysiwyg73 return contents;74 },75 'html2text': function (contents) {76 return contents;77 },78 'html2source': function (contents) { //wysiwyg2source79 return clearRedundancy(contents);80 }81 }82 );83 }...
icon.js
Source:icon.js
...38 }39 parseContents (complexContentsParams) {40 let contents = this.contents;41 if (typeof contents === 'function') {42 contents = contents(complexContentsParams);43 }44 return `<svg viewBox="${this.viewBox}" xmlns="http://www.w3.org/2000/svg">${contents}</svg>`;45 }46 /**47 * returns the svg markup48 */49 markup () {50 if (typeof this.contents === 'function') {51 return complexContentsParams => this.parseContents(complexContentsParams);52 }53 return this.parseContents();54 }...
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { withInfo } from '@storybook/addon-info';3import { withKnobs, text } from '@storybook/addon-knobs';4import { withNotes } from '@storybook/addon-notes';5import { withReadme } from 'storybook-readme';6import { withA11y } from '@storybook/addon-a11y';7import { withOptions } from '@storybook/addon-options';8import readme from './README.md';9import Button from './index';10storiesOf('Button', module)11 .addDecorator(withKnobs)12 .addDecorator(withInfo)13 .addDecorator(withNotes)14 .addDecorator(withReadme(readme))15 .addDecorator(withA11y)16 .addDecorator(withOptions({
Using AI Code Generation
1const storybookRoot = require('storybook-root');2const contents = storybookRoot.contents();3console.log(contents);4const storybookRoot = require('storybook-root');5const contents = storybookRoot.contents();6console.log(contents);7const storybookRoot = require('storybook-root');8const contents = storybookRoot.contents();9console.log(contents);10const storybookRoot = require('storybook-root');11const contents = storybookRoot.contents();12console.log(contents);13const storybookRoot = require('storybook-root');14const contents = storybookRoot.contents();15console.log(contents);16const storybookRoot = require('storybook-root');17const contents = storybookRoot.contents();18console.log(contents);19const storybookRoot = require('storybook-root');20const contents = storybookRoot.contents();21console.log(contents);22const storybookRoot = require('storybook-root');23const contents = storybookRoot.contents();24console.log(contents);25const storybookRoot = require('storybook-root');26const contents = storybookRoot.contents();27console.log(contents);28const storybookRoot = require('storybook-root');29const contents = storybookRoot.contents();30console.log(contents);31const storybookRoot = require('storybook-root');32const contents = storybookRoot.contents();33console.log(contents);34const storybookRoot = require('storybook-root');35const contents = storybookRoot.contents();36console.log(contents);37const storybookRoot = require('storybook-root');38const contents = storybookRoot.contents();39console.log(contents);
Using AI Code Generation
1import Storybook from 'storybook-root';2const storybook = new Storybook();3storybook.contents();4import Storybook from 'storybook-root';5const storybook = new Storybook();6storybook.contents();7import Storybook from 'storybook-root';8const storybook = new Storybook();9storybook.contents();10import Storybook from 'storybook-root';11const storybook = new Storybook();12storybook.contents();13import Storybook from 'storybook-root';14const storybook = new Storybook();15storybook.contents();16import Storybook from 'storybook-root';17const storybook = new Storybook();18storybook.contents();19import Storybook from 'storybook-root';20const storybook = new Storybook();21storybook.contents();22import Storybook from 'storybook-root';23const storybook = new Storybook();24storybook.contents();25import Storybook from 'storybook-root';26const storybook = new Storybook();27storybook.contents();28import Storybook from 'storybook-root';29const storybook = new Storybook();30storybook.contents();31import Storybook from 'storybook-root';32const storybook = new Storybook();33storybook.contents();34import Storybook from 'storybook-root';35const storybook = new Storybook();36storybook.contents();37import Storybook from 'storybook-root';38const storybook = new Storybook();39storybook.contents();40import Storybook from 'storybook-root';41const storybook = new Storybook();42storybook.contents();
Using AI Code Generation
1const storybookRoot = require('storybook-root');2const contents = storybookRoot.contents();3console.log('contents', contents);4const storybookRoot = require('storybook-root');5const contents = storybookRoot.contents();6console.log('contents', contents);7const storybookRoot = require('storybook-root');8const contents = storybookRoot.contents();9console.log('contents', contents);10const storybookRoot = require('storybook-root');11const contents = storybookRoot.contents();12console.log('contents', contents);13const storybookRoot = require('storybook-root');14const contents = storybookRoot.contents();15console.log('contents', contents);16const storybookRoot = require('storybook-root');17const contents = storybookRoot.contents();18console.log('contents', contents);19const storybookRoot = require('storybook-root');20const contents = storybookRoot.contents();21console.log('contents', contents);22const storybookRoot = require('storybook-root');23const contents = storybookRoot.contents();24console.log('contents', contents);25const storybookRoot = require('storybook-root');26const contents = storybookRoot.contents();27console.log('contents', contents);28const storybookRoot = require('storybook-root');29const contents = storybookRoot.contents();30console.log('contents', contents);31const storybookRoot = require('storybook-root');32const contents = storybookRoot.contents();33console.log('contents', contents);34const storybookRoot = require('storybook-root');35const contents = storybookRoot.contents();36console.log('contents', contents);37const storybookRoot = require('storybook-root');38const contents = storybookRoot.contents();39console.log('contents', contents);
Using AI Code Generation
1import { contents } from 'storybook-root'2console.log(contents)3{4 "dependencies": {5 }6}7import { configure } from '@storybook/react'8import { contents } from 'storybook-root'9configure(contents, module)10const path = require('path')11module.exports = (baseConfig, env, defaultConfig) => {12 defaultConfig.resolve.modules.push(path.resolve(__dirname, '../'))13}14{15 "dependencies": {16 }17}18import { configure } from '@storybook/react'19import { contents } from 'storybook-root'20configure(contents, module)21const path = require('path')22module.exports = (baseConfig, env, defaultConfig) => {23 defaultConfig.resolve.alias['storybook-root'] = path.resolve(__dirname, '../')24}25{26 "dependencies": {27 }28}29import { contents } from 'storybook-root'30console.log(contents)31import { configure } from '@storybook/react'32import { contents } from 'storybook-root'33configure(contents, module)
Using AI Code Generation
1const storybookRoot = require('storybook-root');2storybookRoot.contents('test1', 'test2');3const storybookRoot = require('storybook-root');4storybookRoot.contents('test1', 'test2');5const storybookRoot = require('storybook-root');6storybookRoot.contents('test1', 'test2');7const storybookRoot = require('storybook-root');8storybookRoot.contents('test1', 'test2');9const storybookRoot = require('storybook-root');10storybookRoot.contents('test1', 'test2');11const storybookRoot = require('storybook-root');12storybookRoot.contents('test1', 'test2');13const storybookRoot = require('storybook-root');14storybookRoot.contents('test1', 'test2');15const storybookRoot = require('storybook-root');16storybookRoot.contents('test1', 'test2');17const storybookRoot = require('storybook-root');18storybookRoot.contents('test1', 'test2');
Using AI Code Generation
1import { contents } from 'storybook-root';2contents('my-storybook');3import { contents } from './lib/contents';4export { contents };5export const contents = (storybookRoot) => {6};7import { contents } from './contents';8describe('contents', () => {9 it('should return the contents of a storybook', () => {10 });11});12import { storiesOf } from '@storybook/react';13import { contents } from './contents';14storiesOf('contents', module).add('happy path', () => {15});16import { contents } from './contents';17describe('contents', () => {18 it('should return the contents of a storybook', () => {19 });20});21This project was bootstrapped with [create-react-library](
Using AI Code Generation
1import { contents } from 'storybook-root-provider';2const content = contents[0];3import { content } from 'storybook-root-provider';4import { storybookRootProvider } from 'storybook-root-provider';5import { storybookRootProvider } from 'storybook-root-provider';6import { storybookRootProvider } from 'storybook-root-provider';7import { storybookRootProvider } from 'storybook-root-provider';8import { storybookRootProvider } from 'storybook-root-provider';9import { storybookRootProvider } from 'storybook-root-provider';10import { storybookRootProvider } from 'storybook-root-provider';11import { storybookRootProvider } from 'storybook-root-provider';12import { storybookRootProvider } from 'storybook-root-provider';13import { storybookRootProvider } from 'storybook-root-provider';14import { storybookRootProvider } from 'storybook-root-provider';15import { storybookRootProvider } from 'storybook-root-provider';16import { storybookRootProvider } from 'storybook-root-provider';
Using AI Code Generation
1> const StoryBook = require('./story-book');2> const storyBookRoot = new StoryBook.StoryBookRoot();3> const storyBookLeaf = new StoryBook.StoryBookLeaf();4> const storyBookLeaf2 = new StoryBook.StoryBookLeaf();5> storyBookRoot.addStoryBook(storyBookLeaf);6> storyBookRoot.addStoryBook(storyBookLeaf2);7> storyBookRoot.contents();8> class StoryBookRoot {9> constructor() {10> this.storyBooks = [];11> }12> addStoryBook(storyBook) {13> this.storyBooks.push(storyBook);14> }15> contents() {16> return this.storyBooks;17> }18> }19> class StoryBookLeaf {20> constructor() {21> this.story = '';22> }23> addStory(story) {24> this.story = story;25> }26> contents() {27> return this.story;28> }29> }30> module.exports = {31import { storybookRootProvider } from 'storybook-root-provider';32import { storybookRootProvider } from 'storybook-root-provider';33import { storybookRootProvider } from 'storybook-root-provider';34import { storybookRootProvider } from 'storybook-root-provider';35import { storybookRootProvider } from 'storybook-root-provider';36import { storybookRootProvider } from 'storybook-root-provider';37import { storybookRootProvider } from 'storybook-root-provider';38import { storybookRootProvider } from 'storybook-root-provider';39import { storybookRootProvider } from 'storybook-root-provider';40import { storybookRootProvider } from 'storybook-root-provider';
Using AI Code Generation
1> const StoryBook = require('./story-book');2> const storyBookRoot = new StoryBook.StoryBookRoot();3> const storyBookLeaf = new StoryBook.StoryBookLeaf();4> const storyBookLeaf2 = new StoryBook.StoryBookLeaf();5> storyBookRoot.addStoryBook(storyBookLeaf);6> storyBookRoot.addStoryBook(storyBookLeaf2);7> storyBookRoot.contents();8> class StoryBookRoot {9> constructor() {10> this.storyBooks = [];11> }12> addStoryBook(storyBook) {13> this.storyBooks.push(storyBook);14> }15> contents() {16> return this.storyBooks;17> }18> }19> class StoryBookLeaf {20> constructor() {21> this.story = '';22> }23> addStory(story) {24> this.story = story;25> }26> contents() {27> return this.story;28> }29> }30> module.exports = {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!