소스 검색

replace few let on const

sanex3339 8 년 전
부모
커밋
cae81b1538
5개의 변경된 파일20개의 추가작업 그리고 18개의 파일을 삭제
  1. 12 12
      dist/index.js
  2. 1 1
      src/node/NodeAppender.ts
  3. 1 1
      src/node/NodeUtils.ts
  4. 5 4
      src/utils/Utils.ts
  5. 1 0
      tslint.json

+ 12 - 12
dist/index.js

@@ -437,8 +437,8 @@ var Utils = function () {
             if (times <= 0) {
                 return array;
             }
-            var newArray = array,
-                temp = void 0;
+            var newArray = array;
+            var temp = void 0;
             while (times--) {
                 temp = newArray.pop();
                 newArray.unshift(temp);
@@ -518,8 +518,8 @@ var Utils = function () {
         key: "stringToUnicodeEscapeSequence",
         value: function stringToUnicodeEscapeSequence(string) {
             var radix = 16;
+            var regexp = new RegExp('[\x00-\x7F]');
             var prefix = void 0,
-                regexp = new RegExp('[\x00-\x7F]'),
                 template = void 0;
             return "" + string.replace(/[\s\S]/g, function (escape) {
                 if (regexp.test(escape)) {
@@ -999,7 +999,7 @@ var NodeAppender = function () {
     }
 
     _createClass(NodeAppender, null, [{
-        key: 'appendNode',
+        key: "appendNode",
         value: function appendNode(blockScopeNode, nodeBodyStatements) {
             if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) {
                 nodeBodyStatements = [];
@@ -1008,7 +1008,7 @@ var NodeAppender = function () {
             blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body), _toConsumableArray(nodeBodyStatements));
         }
     }, {
-        key: 'appendNodeToOptimalBlockScope',
+        key: "appendNodeToOptimalBlockScope",
         value: function appendNodeToOptimalBlockScope(blockScopeStackTraceData, blockScopeNode, nodeBodyStatements) {
             var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
 
@@ -1021,13 +1021,13 @@ var NodeAppender = function () {
             NodeAppender.prependNode(targetBlockScope, nodeBodyStatements);
         }
     }, {
-        key: 'getOptimalBlockScope',
+        key: "getOptimalBlockScope",
         value: function getOptimalBlockScope(blockScopeTraceData, index) {
             var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
 
             var firstCall = blockScopeTraceData[index];
             if (deep <= 0) {
-                throw new Error('Invalid `deep` argument value. Value should be bigger then 0.');
+                throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");
             }
             if (deep > 1 && firstCall.stackTrace.length) {
                 return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep);
@@ -1036,12 +1036,12 @@ var NodeAppender = function () {
             }
         }
     }, {
-        key: 'getRandomStackTraceIndex',
+        key: "getRandomStackTraceIndex",
         value: function getRandomStackTraceIndex(stackTraceRootLength) {
             return RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomInteger(0, Math.max(0, Math.round(stackTraceRootLength - 1)));
         }
     }, {
-        key: 'insertNodeAtIndex',
+        key: "insertNodeAtIndex",
         value: function insertNodeAtIndex(blockScopeNode, nodeBodyStatements, index) {
             if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) {
                 nodeBodyStatements = [];
@@ -1050,7 +1050,7 @@ var NodeAppender = function () {
             blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body.slice(0, index)), _toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body.slice(index)));
         }
     }, {
-        key: 'prependNode',
+        key: "prependNode",
         value: function prependNode(blockScopeNode, nodeBodyStatements) {
             if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) {
                 nodeBodyStatements = [];
@@ -1059,7 +1059,7 @@ var NodeAppender = function () {
             blockScopeNode.body = [].concat(_toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body));
         }
     }, {
-        key: 'parentizeBodyStatementsBeforeAppend',
+        key: "parentizeBodyStatementsBeforeAppend",
         value: function parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements) {
             var _iteratorNormalCompletion = true;
             var _didIteratorError = false;
@@ -1089,7 +1089,7 @@ var NodeAppender = function () {
             return nodeBodyStatements;
         }
     }, {
-        key: 'validateBodyStatements',
+        key: "validateBodyStatements",
         value: function validateBodyStatements(nodeBodyStatements) {
             return nodeBodyStatements.every(function (statementNode) {
                 return !!statementNode && statementNode.hasOwnProperty('type');

+ 1 - 1
src/node/NodeAppender.ts

@@ -155,7 +155,7 @@ export class NodeAppender {
         blockScopeNode: TNodeWithBlockStatement,
         nodeBodyStatements: TStatement[]
     ): TStatement[] {
-        for (let statement of nodeBodyStatements) {
+        for (const statement of nodeBodyStatements) {
             statement.parentNode = blockScopeNode;
         }
 

+ 1 - 1
src/node/NodeUtils.ts

@@ -56,7 +56,7 @@ export class NodeUtils {
     public static convertStructureToCode (structure: ESTree.Node[]): string {
         let code: string = '';
 
-        for (let node of structure) {
+        for (const node of structure) {
             code += escodegen.generate(node, {
                 sourceMapWithCode: true
             }).code;

+ 5 - 4
src/utils/Utils.ts

@@ -21,8 +21,9 @@ export class Utils {
             return array;
         }
 
-        let newArray: T[] = array,
-            temp: T | undefined;
+        const newArray: T[] = array;
+
+        let temp: T | undefined;
 
         while (times--) {
             temp = newArray.pop()!;
@@ -74,7 +75,7 @@ export class Utils {
      * @returns {T | null}
      */
     public static mapGetFirstKeyOf <T, U> (map: Map <T, U>, value: U): T | null {
-        for (let [key, storageValue] of map) {
+        for (const [key, storageValue] of map) {
             if (_.isEqual(value, storageValue)) {
                 return key;
             }
@@ -110,9 +111,9 @@ export class Utils {
      */
     public static stringToUnicodeEscapeSequence (string: string): string {
         const radix: number = 16;
+        const regexp: RegExp = new RegExp('[\x00-\x7F]');
 
         let prefix: string,
-            regexp: RegExp = new RegExp('[\x00-\x7F]'),
             template: string;
 
         return `${string.replace(/[\s\S]/g, (escape: string): string => {

+ 1 - 0
tslint.json

@@ -83,6 +83,7 @@
       "check-whitespace"
     ],
     "one-variable-per-declaration": false,
+    "prefer-const": true,
     "quotemark": false,
     "radix": true,
     "semicolon": [true, "always"],