From dde53c79bf18f814590adb1549bdb4cbe23f5a93 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Sat, 21 May 2016 13:46:47 +0300 Subject: [PATCH] refactoring --- src/NodeUtils.js | 27 ++-- src/NodeUtils.ts | 28 +++-- src/Obfuscator.js | 21 ++-- src/Obfuscator.ts | 21 ++-- src/Utils.js | 3 + src/Utils.ts | 8 ++ src/enums/NodeType.js | 30 +++++ src/enums/NodeType.ts | 30 +++++ .../FunctionDeclarationObfuscator.js | 3 +- .../FunctionDeclarationObfuscator.ts | 4 +- .../MemberExpressionObfuscator.js | 3 +- .../MemberExpressionObfuscator.ts | 4 +- .../ObjectExpressionObfuscator.js | 3 +- .../ObjectExpressionObfuscator.ts | 6 +- .../VariableDeclarationObfuscator.js | 9 +- .../VariableDeclarationObfuscator.ts | 12 +- src/nodes/UnicodeArrayNode.js | 15 +-- src/nodes/UnicodeArrayNode.ts | 17 +-- .../UnicodeArrayRotateFunctionCallNode.js | 15 +-- .../UnicodeArrayRotateFunctionCallNode.ts | 16 +-- src/nodes/UnicodeArrayRotateFunctionNode.js | 115 ++++++++--------- src/nodes/UnicodeArrayRotateFunctionNode.ts | 116 +++++++++--------- tslint.json | 6 +- 23 files changed, 302 insertions(+), 210 deletions(-) create mode 100644 src/enums/NodeType.js create mode 100644 src/enums/NodeType.ts diff --git a/src/NodeUtils.js b/src/NodeUtils.js index 225961a3..2f5700be 100644 --- a/src/NodeUtils.js +++ b/src/NodeUtils.js @@ -1,8 +1,9 @@ "use strict"; +const NodeType_1 = require("./enums/NodeType"); const Utils_1 = require("./Utils"); class NodeUtils { static getScopeOfNode(node, depth = 0) { - if (node.parentNode.type === 'Program') { + if (node.parentNode.type === NodeType_1.NodeType.Program) { return node.parentNode; } if (!Utils_1.Utils.arrayContains(NodeUtils.scopeNodes, node.parentNode.type)) { @@ -11,13 +12,13 @@ class NodeUtils { if (depth > 0) { return NodeUtils.getScopeOfNode(node.parentNode, --depth); } - if (node.type !== 'BlockStatement') { + if (node.type !== NodeType_1.NodeType.BlockStatement) { return NodeUtils.getScopeOfNode(node.parentNode); } return node; } static getParentNodeWithType(node, types, limitNodeTypes = [], depth = 0) { - if (node.parentNode.type === 'Program' || Utils_1.Utils.arrayContains(limitNodeTypes, node.parentNode.type)) { + if (node.parentNode.type === NodeType_1.NodeType.Program || Utils_1.Utils.arrayContains(limitNodeTypes, node.parentNode.type)) { return node.parentNode; } if (!Utils_1.Utils.arrayContains(types, node.parentNode.type)) { @@ -29,28 +30,28 @@ class NodeUtils { return node.parentNode; } static isBlockStatementNode(node) { - return node.type === 'BlockStatement'; + return node.type === NodeType_1.NodeType.BlockStatement; } static isIdentifierNode(node) { - return node.type === 'Identifier'; + return node.type === NodeType_1.NodeType.Identifier; } static isLiteralNode(node) { - return node.type === 'Literal'; + return node.type === NodeType_1.NodeType.Literal; } static isMemberExpressionNode(node) { - return node.type === 'MemberExpression'; + return node.type === NodeType_1.NodeType.MemberExpression; } static isPropertyNode(node) { - return node.type === 'Property'; + return node.type === NodeType_1.NodeType.Property; } static isVariableDeclaratorNode(node) { - return node.type === 'VariableDeclarator'; + return node.type === NodeType_1.NodeType.VariableDeclarator; } } NodeUtils.scopeNodes = [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - 'MethodDefinition' + NodeType_1.NodeType.ArrowFunctionExpression, + NodeType_1.NodeType.FunctionDeclaration, + NodeType_1.NodeType.FunctionExpression, + NodeType_1.NodeType.MethodDefinition ]; exports.NodeUtils = NodeUtils; diff --git a/src/NodeUtils.ts b/src/NodeUtils.ts index fdbd447e..c2c4518d 100644 --- a/src/NodeUtils.ts +++ b/src/NodeUtils.ts @@ -6,6 +6,8 @@ import { IPropertyNode } from "./interfaces/nodes/IPropertyNode"; import { ITreeNode } from './interfaces/nodes/ITreeNode'; import { IVariableDeclaratorNode } from "./interfaces/nodes/IVariableDeclaratorNode"; +import { NodeType } from "./enums/NodeType"; + import { Utils } from "./Utils"; export class NodeUtils { @@ -13,10 +15,10 @@ export class NodeUtils { * @type {string[]} */ private static scopeNodes: string[] = [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - 'MethodDefinition' + NodeType.ArrowFunctionExpression, + NodeType.FunctionDeclaration, + NodeType.FunctionExpression, + NodeType.MethodDefinition ]; /** @@ -25,7 +27,7 @@ export class NodeUtils { * @returns {ITreeNode} */ public static getScopeOfNode (node: ITreeNode, depth: number = 0): ITreeNode { - if (node.parentNode.type === 'Program') { + if (node.parentNode.type === NodeType.Program) { return node.parentNode; } @@ -37,7 +39,7 @@ export class NodeUtils { return NodeUtils.getScopeOfNode(node.parentNode, --depth); } - if (node.type !== 'BlockStatement') { + if (node.type !== NodeType.BlockStatement) { return NodeUtils.getScopeOfNode(node.parentNode); } @@ -57,7 +59,7 @@ export class NodeUtils { limitNodeTypes: string[] = [], depth: number = 0 ): ITreeNode { - if (node.parentNode.type === 'Program' || Utils.arrayContains(limitNodeTypes, node.parentNode.type)) { + if (node.parentNode.type === NodeType.Program || Utils.arrayContains(limitNodeTypes, node.parentNode.type)) { return node.parentNode; } @@ -77,7 +79,7 @@ export class NodeUtils { * @returns {boolean} */ public static isBlockStatementNode (node: ITreeNode): node is IBlockStatementNode { - return node.type === 'BlockStatement'; + return node.type === NodeType.BlockStatement; } /** @@ -85,7 +87,7 @@ export class NodeUtils { * @returns {boolean} */ public static isIdentifierNode (node: ITreeNode): node is IIdentifierNode { - return node.type === 'Identifier'; + return node.type === NodeType.Identifier; } /** @@ -93,7 +95,7 @@ export class NodeUtils { * @returns {boolean} */ public static isLiteralNode (node: ITreeNode): node is ILiteralNode { - return node.type === 'Literal'; + return node.type === NodeType.Literal; } /** @@ -101,7 +103,7 @@ export class NodeUtils { * @returns {boolean} */ public static isMemberExpressionNode (node: ITreeNode): node is IMemberExpressionNode { - return node.type === 'MemberExpression'; + return node.type === NodeType.MemberExpression; } @@ -111,7 +113,7 @@ export class NodeUtils { * @returns {boolean} */ public static isPropertyNode (node: ITreeNode): node is IPropertyNode { - return node.type === 'Property'; + return node.type === NodeType.Property; } /** @@ -120,6 +122,6 @@ export class NodeUtils { * @returns {boolean} */ public static isVariableDeclaratorNode (node: ITreeNode): node is IVariableDeclaratorNode { - return node.type === 'VariableDeclarator'; + return node.type === NodeType.VariableDeclarator; } } diff --git a/src/Obfuscator.js b/src/Obfuscator.js index 7364ecec..46fa2420 100644 --- a/src/Obfuscator.js +++ b/src/Obfuscator.js @@ -1,6 +1,7 @@ "use strict"; const estraverse = require('estraverse'); const AppendState_1 = require('./enums/AppendState'); +const NodeType_1 = require("./enums/NodeType"); const CatchClauseObfuscator_1 = require("./node-obfuscators/CatchClauseObfuscator"); const FunctionDeclarationObfuscator_1 = require('./node-obfuscators/FunctionDeclarationObfuscator'); const FunctionObfuscator_1 = require('./node-obfuscators/FunctionObfuscator'); @@ -16,19 +17,19 @@ class Obfuscator { constructor(options = {}) { this.nodes = new Map(); this.nodeObfuscators = new Map([ - ['ClassDeclaration', [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator]], - ['CatchClause', [CatchClauseObfuscator_1.CatchClauseObfuscator]], - ['FunctionDeclaration', [ + [NodeType_1.NodeType.ArrowFunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], + [NodeType_1.NodeType.ClassDeclaration, [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator]], + [NodeType_1.NodeType.CatchClause, [CatchClauseObfuscator_1.CatchClauseObfuscator]], + [NodeType_1.NodeType.FunctionDeclaration, [ FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator, FunctionObfuscator_1.FunctionObfuscator ]], - ['ArrowFunctionExpression', [FunctionObfuscator_1.FunctionObfuscator]], - ['FunctionExpression', [FunctionObfuscator_1.FunctionObfuscator]], - ['MethodDefinition', [MethodDefinitionObfuscator_1.MethodDefinitionObfuscator]], - ['VariableDeclaration', [VariableDeclarationObfuscator_1.VariableDeclarationObfuscator]], - ['ObjectExpression', [ObjectExpressionObfuscator_1.ObjectExpressionObfuscator]], - ['MemberExpression', [MemberExpressionObfuscator_1.MemberExpressionObfuscator]], - ['Literal', [LiteralObfuscator_1.LiteralObfuscator]] + [NodeType_1.NodeType.FunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], + [NodeType_1.NodeType.MemberExpression, [MemberExpressionObfuscator_1.MemberExpressionObfuscator]], + [NodeType_1.NodeType.MethodDefinition, [MethodDefinitionObfuscator_1.MethodDefinitionObfuscator]], + [NodeType_1.NodeType.ObjectExpression, [ObjectExpressionObfuscator_1.ObjectExpressionObfuscator]], + [NodeType_1.NodeType.VariableDeclaration, [VariableDeclarationObfuscator_1.VariableDeclarationObfuscator]], + [NodeType_1.NodeType.Literal, [LiteralObfuscator_1.LiteralObfuscator]] ]); this.options = options; } diff --git a/src/Obfuscator.ts b/src/Obfuscator.ts index 91fb420e..32107f03 100644 --- a/src/Obfuscator.ts +++ b/src/Obfuscator.ts @@ -6,6 +6,7 @@ import { INodesGroup } from './interfaces/INodesGroup'; import { ITreeNode } from './interfaces/nodes/ITreeNode'; import { AppendState } from './enums/AppendState'; +import { NodeType } from "./enums/NodeType"; import { CatchClauseObfuscator } from "./node-obfuscators/CatchClauseObfuscator"; import { FunctionDeclarationObfuscator } from './node-obfuscators/FunctionDeclarationObfuscator'; @@ -29,19 +30,19 @@ export class Obfuscator { * @type {Map} */ private nodeObfuscators: Map = new Map ([ - ['ClassDeclaration', [FunctionDeclarationObfuscator]], - ['CatchClause', [CatchClauseObfuscator]], - ['FunctionDeclaration', [ + [NodeType.ArrowFunctionExpression, [FunctionObfuscator]], + [NodeType.ClassDeclaration, [FunctionDeclarationObfuscator]], + [NodeType.CatchClause, [CatchClauseObfuscator]], + [NodeType.FunctionDeclaration, [ FunctionDeclarationObfuscator, FunctionObfuscator ]], - ['ArrowFunctionExpression', [FunctionObfuscator]], - ['FunctionExpression', [FunctionObfuscator]], - ['MethodDefinition', [MethodDefinitionObfuscator]], - ['VariableDeclaration', [VariableDeclarationObfuscator]], - ['ObjectExpression', [ObjectExpressionObfuscator]], - ['MemberExpression', [MemberExpressionObfuscator]], - ['Literal', [LiteralObfuscator]] + [NodeType.FunctionExpression, [FunctionObfuscator]], + [NodeType.MemberExpression, [MemberExpressionObfuscator]], + [NodeType.MethodDefinition, [MethodDefinitionObfuscator]], + [NodeType.ObjectExpression, [ObjectExpressionObfuscator]], + [NodeType.VariableDeclaration, [VariableDeclarationObfuscator]], + [NodeType.Literal, [LiteralObfuscator]] ]); /** diff --git a/src/Utils.js b/src/Utils.js index 11f88993..05c53ab3 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -30,6 +30,9 @@ class Utils { const rangeMinInteger = 10000, rangeMaxInteger = 99999999, prefix = '_0x'; return `${prefix}${(Utils.decToHex(Utils.getRandomInteger(rangeMinInteger, rangeMaxInteger))).substr(0, length)}`; } + static strEnumify(obj) { + return obj; + } static stringToUnicode(string) { return `'${string.replace(/[\s\S]/g, (escape) => { return `\\u${('0000' + escape.charCodeAt(0).toString(16)).slice(-4)}`; diff --git a/src/Utils.ts b/src/Utils.ts index 4d61c7af..fee94b48 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -64,6 +64,14 @@ export class Utils { return `${prefix}${(Utils.decToHex(Utils.getRandomInteger(rangeMinInteger, rangeMaxInteger))).substr(0, length)}`; } + /** + * @param obj + * @returns {T} + */ + public static strEnumify (obj: T): T { + return obj; + } + /** * @param string * @returns {string} diff --git a/src/enums/NodeType.js b/src/enums/NodeType.js new file mode 100644 index 00000000..b9aae4bb --- /dev/null +++ b/src/enums/NodeType.js @@ -0,0 +1,30 @@ +"use strict"; +const Utils_1 = require("../Utils"); +exports.NodeType = Utils_1.Utils.strEnumify({ + ArrayExpression: 'ArrayExpression', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AssignmentExpression: 'AssignmentExpression', + BinaryExpression: 'BinaryExpression', + BlockStatement: 'BlockStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassDeclaration: 'ClassDeclaration', + ExpressionStatement: 'ExpressionStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + Literal: 'Literal', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MethodDefinition: 'MethodDefinition', + ObjectExpression: 'ObjectExpression', + Program: 'Program', + Property: 'Property', + ReturnStatement: 'ReturnStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement' +}); diff --git a/src/enums/NodeType.ts b/src/enums/NodeType.ts new file mode 100644 index 00000000..698f7d48 --- /dev/null +++ b/src/enums/NodeType.ts @@ -0,0 +1,30 @@ +import { Utils } from "../Utils"; + +export const NodeType: any = Utils.strEnumify({ + ArrayExpression: 'ArrayExpression', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AssignmentExpression: 'AssignmentExpression', + BinaryExpression: 'BinaryExpression', + BlockStatement: 'BlockStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassDeclaration: 'ClassDeclaration', + ExpressionStatement: 'ExpressionStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + Literal: 'Literal', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MethodDefinition: 'MethodDefinition', + ObjectExpression: 'ObjectExpression', + Program: 'Program', + Property: 'Property', + ReturnStatement: 'ReturnStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement' +}); diff --git a/src/node-obfuscators/FunctionDeclarationObfuscator.js b/src/node-obfuscators/FunctionDeclarationObfuscator.js index f84f8ff2..692b3357 100644 --- a/src/node-obfuscators/FunctionDeclarationObfuscator.js +++ b/src/node-obfuscators/FunctionDeclarationObfuscator.js @@ -1,5 +1,6 @@ "use strict"; const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const NodeObfuscator_1 = require('./NodeObfuscator'); const NodeUtils_1 = require("../NodeUtils"); const Utils_1 = require('../Utils'); @@ -9,7 +10,7 @@ class FunctionDeclarationObfuscator extends NodeObfuscator_1.NodeObfuscator { this.functionName = new Map(); } obfuscateNode(functionDeclarationNode, parentNode) { - if (parentNode.type === 'Program') { + if (parentNode.type === NodeType_1.NodeType.Program) { return; } this.replaceFunctionName(functionDeclarationNode); diff --git a/src/node-obfuscators/FunctionDeclarationObfuscator.ts b/src/node-obfuscators/FunctionDeclarationObfuscator.ts index 31da9dd6..8d3a7870 100644 --- a/src/node-obfuscators/FunctionDeclarationObfuscator.ts +++ b/src/node-obfuscators/FunctionDeclarationObfuscator.ts @@ -3,6 +3,8 @@ import * as estraverse from 'estraverse'; import { IFunctionDeclarationNode } from "../interfaces/nodes/IFunctionDeclarationNode"; import { ITreeNode } from "../interfaces/nodes/ITreeNode"; +import { NodeType } from "../enums/NodeType"; + import { NodeObfuscator } from './NodeObfuscator'; import { NodeUtils } from "../NodeUtils"; import { Utils } from '../Utils'; @@ -27,7 +29,7 @@ export class FunctionDeclarationObfuscator extends NodeObfuscator { * @param parentNode */ public obfuscateNode (functionDeclarationNode: IFunctionDeclarationNode, parentNode: ITreeNode): void { - if (parentNode.type === 'Program') { + if (parentNode.type === NodeType.Program) { return; } diff --git a/src/node-obfuscators/MemberExpressionObfuscator.js b/src/node-obfuscators/MemberExpressionObfuscator.js index cd68cbd2..ccd9e560 100644 --- a/src/node-obfuscators/MemberExpressionObfuscator.js +++ b/src/node-obfuscators/MemberExpressionObfuscator.js @@ -1,6 +1,7 @@ "use strict"; const escodegen = require('escodegen'); const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const NodeObfuscator_1 = require('./NodeObfuscator'); const NodeUtils_1 = require("../NodeUtils"); class MemberExpressionObfuscator extends NodeObfuscator_1.NodeObfuscator { @@ -28,7 +29,7 @@ class MemberExpressionObfuscator extends NodeObfuscator_1.NodeObfuscator { content: this.replaceLiteralStringByArrayElement(nodeValue), precedence: escodegen.Precedence.Primary }, - type: 'Literal', + type: NodeType_1.NodeType.Literal, value: nodeValue }; delete node.name; diff --git a/src/node-obfuscators/MemberExpressionObfuscator.ts b/src/node-obfuscators/MemberExpressionObfuscator.ts index df2ebae9..0e28259f 100644 --- a/src/node-obfuscators/MemberExpressionObfuscator.ts +++ b/src/node-obfuscators/MemberExpressionObfuscator.ts @@ -6,6 +6,8 @@ import { ILiteralNode } from "../interfaces/nodes/ILiteralNode"; import { IMemberExpressionNode } from "../interfaces/nodes/IMemberExpressionNode"; import { ITreeNode } from "../interfaces/nodes/ITreeNode"; +import { NodeType } from "../enums/NodeType"; + import { NodeObfuscator } from './NodeObfuscator'; import { NodeUtils } from "../NodeUtils"; @@ -54,7 +56,7 @@ export class MemberExpressionObfuscator extends NodeObfuscator { content : this.replaceLiteralStringByArrayElement(nodeValue), precedence: escodegen.Precedence.Primary }, - type: 'Literal', + type: NodeType.Literal, value: nodeValue }; diff --git a/src/node-obfuscators/ObjectExpressionObfuscator.js b/src/node-obfuscators/ObjectExpressionObfuscator.js index 5594d6b7..eca5aeec 100644 --- a/src/node-obfuscators/ObjectExpressionObfuscator.js +++ b/src/node-obfuscators/ObjectExpressionObfuscator.js @@ -1,6 +1,7 @@ "use strict"; const escodegen = require('escodegen'); const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const NodeObfuscator_1 = require('./NodeObfuscator'); const NodeUtils_1 = require("../NodeUtils"); const Utils_1 = require('../Utils'); @@ -42,7 +43,7 @@ class ObjectExpressionObfuscator extends NodeObfuscator_1.NodeObfuscator { content: Utils_1.Utils.stringToUnicode(nodeValue), precedence: escodegen.Precedence.Primary }, - type: 'Literal', + type: NodeType_1.NodeType.Literal, value: nodeValue }; delete node.name; diff --git a/src/node-obfuscators/ObjectExpressionObfuscator.ts b/src/node-obfuscators/ObjectExpressionObfuscator.ts index 4fab5d30..b93ea2ca 100644 --- a/src/node-obfuscators/ObjectExpressionObfuscator.ts +++ b/src/node-obfuscators/ObjectExpressionObfuscator.ts @@ -4,12 +4,14 @@ import * as estraverse from 'estraverse'; import { IIdentifierNode } from "../interfaces/nodes/IIdentifierNode"; import { ILiteralNode } from "../interfaces/nodes/ILiteralNode"; import { IObjectExpressionNode } from "../interfaces/nodes/IObjectExpressionNode"; +import { IPropertyNode } from "../interfaces/nodes/IPropertyNode"; import { ITreeNode } from "../interfaces/nodes/ITreeNode"; +import { NodeType } from "../enums/NodeType"; + import { NodeObfuscator } from './NodeObfuscator'; import { NodeUtils } from "../NodeUtils"; import { Utils } from '../Utils'; -import {IPropertyNode} from "../interfaces/nodes/IPropertyNode"; /** * replaces: @@ -76,7 +78,7 @@ export class ObjectExpressionObfuscator extends NodeObfuscator { content : Utils.stringToUnicode(nodeValue), precedence: escodegen.Precedence.Primary }, - type: 'Literal', + type: NodeType.Literal, value: nodeValue }; diff --git a/src/node-obfuscators/VariableDeclarationObfuscator.js b/src/node-obfuscators/VariableDeclarationObfuscator.js index 2b281661..bbce3586 100644 --- a/src/node-obfuscators/VariableDeclarationObfuscator.js +++ b/src/node-obfuscators/VariableDeclarationObfuscator.js @@ -1,5 +1,6 @@ "use strict"; const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const NodeObfuscator_1 = require('./NodeObfuscator'); const NodeUtils_1 = require("../NodeUtils"); const Utils_1 = require('../Utils'); @@ -9,7 +10,7 @@ class VariableDeclarationObfuscator extends NodeObfuscator_1.NodeObfuscator { this.variableNames = new Map(); } obfuscateNode(variableDeclarationNode, parentNode) { - if (parentNode.type === 'Program') { + if (parentNode.type === NodeType_1.NodeType.Program) { return; } this.replaceVariableName(variableDeclarationNode); @@ -36,9 +37,9 @@ class VariableDeclarationObfuscator extends NodeObfuscator_1.NodeObfuscator { estraverse.replace(scopeNode, { enter: (node, parentNode) => { const functionNodes = [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression' + NodeType_1.NodeType.ArrowFunctionExpression, + NodeType_1.NodeType.FunctionDeclaration, + NodeType_1.NodeType.FunctionExpression ]; if (Utils_1.Utils.arrayContains(functionNodes, node.type)) { estraverse.replace(node, { diff --git a/src/node-obfuscators/VariableDeclarationObfuscator.ts b/src/node-obfuscators/VariableDeclarationObfuscator.ts index 3d9eb036..206dfd78 100644 --- a/src/node-obfuscators/VariableDeclarationObfuscator.ts +++ b/src/node-obfuscators/VariableDeclarationObfuscator.ts @@ -2,11 +2,13 @@ import * as estraverse from 'estraverse'; import { ITreeNode } from "../interfaces/nodes/ITreeNode"; import { IVariableDeclarationNode } from "../interfaces/nodes/IVariableDeclarationNode"; +import { IVariableDeclaratorNode } from "../interfaces/nodes/IVariableDeclaratorNode"; + +import { NodeType } from "../enums/NodeType"; import { NodeObfuscator } from './NodeObfuscator'; import { NodeUtils } from "../NodeUtils"; import { Utils } from '../Utils'; -import {IVariableDeclaratorNode} from "../interfaces/nodes/IVariableDeclaratorNode"; /** * replaces: @@ -29,7 +31,7 @@ export class VariableDeclarationObfuscator extends NodeObfuscator { * @param parentNode */ public obfuscateNode (variableDeclarationNode: IVariableDeclarationNode, parentNode: ITreeNode): void { - if (parentNode.type === 'Program') { + if (parentNode.type === NodeType.Program) { return; } @@ -73,9 +75,9 @@ export class VariableDeclarationObfuscator extends NodeObfuscator { estraverse.replace(scopeNode, { enter: (node: ITreeNode, parentNode: ITreeNode): any => { const functionNodes: string[] = [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression' + NodeType.ArrowFunctionExpression, + NodeType.FunctionDeclaration, + NodeType.FunctionExpression ]; if (Utils.arrayContains(functionNodes, node.type)) { diff --git a/src/nodes/UnicodeArrayNode.js b/src/nodes/UnicodeArrayNode.js index 26a54dea..4994abb2 100644 --- a/src/nodes/UnicodeArrayNode.js +++ b/src/nodes/UnicodeArrayNode.js @@ -1,9 +1,10 @@ "use strict"; const escodegen = require('escodegen'); const estraverse = require('estraverse'); +const AppendState_1 = require('../enums/AppendState'); +const NodeType_1 = require("../enums/NodeType"); const Node_1 = require('./Node'); const Utils_1 = require('../Utils'); -const AppendState_1 = require('../enums/AppendState'); class UnicodeArrayNode extends Node_1.Node { constructor(astTree, unicodeArrayName, unicodeArrayRotateValue = 0) { super(); @@ -18,7 +19,7 @@ class UnicodeArrayNode extends Node_1.Node { estraverse.replace(this.astTree, { leave: (node, parent) => { switch (node.type) { - case 'Program': + case NodeType_1.NodeType.Program: node.body.unshift(this.getNode()); break; default: @@ -40,19 +41,19 @@ class UnicodeArrayNode extends Node_1.Node { } getNodeStructure() { return { - 'type': 'VariableDeclaration', + 'type': NodeType_1.NodeType.VariableDeclaration, 'declarations': [ { - 'type': 'VariableDeclarator', + 'type': NodeType_1.NodeType.VariableDeclarator, 'id': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': this.unicodeArrayName }, 'init': { - 'type': 'ArrayExpression', + 'type': NodeType_1.NodeType.ArrayExpression, 'elements': this.unicodeArray.map((value) => { return { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'value': value, 'raw': `'${value}'`, 'x-verbatim-property': { diff --git a/src/nodes/UnicodeArrayNode.ts b/src/nodes/UnicodeArrayNode.ts index b18cfc7b..fc8ebb38 100644 --- a/src/nodes/UnicodeArrayNode.ts +++ b/src/nodes/UnicodeArrayNode.ts @@ -4,11 +4,12 @@ import * as estraverse from 'estraverse'; import { IProgramNode } from '../interfaces/nodes/IProgramNode'; import { ITreeNode } from '../interfaces/nodes/ITreeNode'; +import { AppendState } from '../enums/AppendState'; +import { NodeType } from "../enums/NodeType"; + import { Node } from './Node'; import { Utils } from '../Utils'; -import { AppendState } from '../enums/AppendState'; - export class UnicodeArrayNode extends Node { /** * @type {number} @@ -63,7 +64,7 @@ export class UnicodeArrayNode extends Node { estraverse.replace(this.astTree, { leave: (node: ITreeNode, parent: ITreeNode): any => { switch (node.type) { - case 'Program': + case NodeType.Program: (node).body.unshift(this.getNode()); break; @@ -105,19 +106,19 @@ export class UnicodeArrayNode extends Node { */ protected getNodeStructure (): any { return { - 'type': 'VariableDeclaration', + 'type': NodeType.VariableDeclaration, 'declarations': [ { - 'type': 'VariableDeclarator', + 'type': NodeType.VariableDeclarator, 'id': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': this.unicodeArrayName }, 'init': { - 'type': 'ArrayExpression', + 'type': NodeType.ArrayExpression, 'elements': this.unicodeArray.map((value: string) => { return { - 'type': 'Literal', + 'type': NodeType.Literal, 'value': value, 'raw': `'${value}'`, 'x-verbatim-property': { diff --git a/src/nodes/UnicodeArrayRotateFunctionCallNode.js b/src/nodes/UnicodeArrayRotateFunctionCallNode.js index e279891c..f9a8ca98 100644 --- a/src/nodes/UnicodeArrayRotateFunctionCallNode.js +++ b/src/nodes/UnicodeArrayRotateFunctionCallNode.js @@ -1,5 +1,6 @@ "use strict"; const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const Node_1 = require('./Node'); class UnicodeArrayRotateFunctionCallNode extends Node_1.Node { constructor(astTree, unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue) { @@ -14,7 +15,7 @@ class UnicodeArrayRotateFunctionCallNode extends Node_1.Node { estraverse.replace(this.astTree, { leave: (node, parent) => { switch (node.type) { - case 'Program': + case NodeType_1.NodeType.Program: node.body.unshift(this.getNode()); break; default: @@ -25,25 +26,25 @@ class UnicodeArrayRotateFunctionCallNode extends Node_1.Node { } getNodeStructure() { return { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType_1.NodeType.CallExpression, 'callee': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': this.unicodeArrayRotateFunctionName }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': this.unicodeArrayName }, { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'value': this.unicodeArrayRotateValue, 'raw': `'${this.unicodeArrayRotateValue}'` }, { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'value': true, 'raw': 'true' } diff --git a/src/nodes/UnicodeArrayRotateFunctionCallNode.ts b/src/nodes/UnicodeArrayRotateFunctionCallNode.ts index feb90f99..14c9d476 100644 --- a/src/nodes/UnicodeArrayRotateFunctionCallNode.ts +++ b/src/nodes/UnicodeArrayRotateFunctionCallNode.ts @@ -3,6 +3,8 @@ import * as estraverse from 'estraverse'; import { IProgramNode } from "../interfaces/nodes/IProgramNode"; import { ITreeNode } from "../interfaces/nodes/ITreeNode"; +import { NodeType } from "../enums/NodeType"; + import { Node } from './Node'; export class UnicodeArrayRotateFunctionCallNode extends Node { @@ -56,7 +58,7 @@ export class UnicodeArrayRotateFunctionCallNode extends Node { estraverse.replace(this.astTree, { leave: (node: ITreeNode, parent: ITreeNode): any => { switch (node.type) { - case 'Program': + case NodeType.Program: (node).body.unshift(this.getNode()); break; @@ -73,25 +75,25 @@ export class UnicodeArrayRotateFunctionCallNode extends Node { */ protected getNodeStructure (): any { return { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType.CallExpression, 'callee': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': this.unicodeArrayRotateFunctionName }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': this.unicodeArrayName }, { - 'type': 'Literal', + 'type': NodeType.Literal, 'value': this.unicodeArrayRotateValue, 'raw': `'${this.unicodeArrayRotateValue}'` }, { - 'type': 'Literal', + 'type': NodeType.Literal, 'value': true, 'raw': 'true' } diff --git a/src/nodes/UnicodeArrayRotateFunctionNode.js b/src/nodes/UnicodeArrayRotateFunctionNode.js index 17bc0634..89bfc923 100644 --- a/src/nodes/UnicodeArrayRotateFunctionNode.js +++ b/src/nodes/UnicodeArrayRotateFunctionNode.js @@ -1,5 +1,6 @@ "use strict"; const estraverse = require('estraverse'); +const NodeType_1 = require("../enums/NodeType"); const Node_1 = require('./Node'); const Utils_1 = require('../Utils'); class UnicodeArrayRotateFunctionNode extends Node_1.Node { @@ -14,7 +15,7 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { estraverse.replace(this.astTree, { leave: (node, parent) => { switch (node.type) { - case 'Program': + case NodeType_1.NodeType.Program: node.body.push(this.getNode()); break; default: @@ -28,49 +29,49 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { } getNodeStructure() { return { - 'type': 'FunctionExpression', + 'type': NodeType_1.NodeType.FunctionExpression, 'id': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': this.unicodeArrayRotateFunctionName }, 'params': [ { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'array' }, { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'times' }, { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'reverse' } ], 'defaults': [], 'body': { - 'type': 'BlockStatement', + 'type': NodeType_1.NodeType.BlockStatement, 'body': [ { - 'type': 'IfStatement', + 'type': NodeType_1.NodeType.IfStatement, 'test': { - 'type': 'BinaryExpression', + 'type': NodeType_1.NodeType.BinaryExpression, 'operator': '<', 'left': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'times' }, 'right': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'value': 0, 'raw': '0' } }, 'consequent': { - 'type': 'BlockStatement', + 'type': NodeType_1.NodeType.BlockStatement, 'body': [ { - 'type': 'ReturnStatement', + 'type': NodeType_1.NodeType.ReturnStatement, 'argument': null } ] @@ -78,23 +79,23 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { 'alternate': null }, { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType_1.NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'reverse' }, 'right': { - 'type': 'LogicalExpression', + 'type': NodeType_1.NodeType.LogicalExpression, 'operator': '||', 'left': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'reverse' }, 'right': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'value': false, 'raw': 'false' } @@ -102,12 +103,12 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { } }, { - 'type': 'VariableDeclaration', + 'type': NodeType_1.NodeType.VariableDeclaration, 'declarations': [ { - 'type': 'VariableDeclarator', + 'type': NodeType_1.NodeType.VariableDeclarator, 'id': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'temp' }, 'init': null @@ -116,53 +117,53 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { 'kind': 'var' }, { - 'type': 'WhileStatement', + 'type': NodeType_1.NodeType.WhileStatement, 'test': { - 'type': 'UpdateExpression', + 'type': NodeType_1.NodeType.UpdateExpression, 'operator': '--', 'argument': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'times' }, 'prefix': false }, 'body': { - 'type': 'BlockStatement', + 'type': NodeType_1.NodeType.BlockStatement, 'body': [ { - 'type': 'IfStatement', + 'type': NodeType_1.NodeType.IfStatement, 'test': { - 'type': 'UnaryExpression', + 'type': NodeType_1.NodeType.UnaryExpression, 'operator': '!', 'argument': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'reverse' }, 'prefix': true }, 'consequent': { - 'type': 'BlockStatement', + 'type': NodeType_1.NodeType.BlockStatement, 'body': [ { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType_1.NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'temp' }, 'right': { - 'type': 'CallExpression', + 'type': NodeType_1.NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType_1.NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'name': 'pop', 'x-verbatim-property': Utils_1.Utils.stringToUnicode('pop') } @@ -172,25 +173,25 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { } }, { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType_1.NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType_1.NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'name': 'unshift', 'x-verbatim-property': Utils_1.Utils.stringToUnicode('unshift') } }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'temp' } ] @@ -199,28 +200,28 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { ] }, 'alternate': { - 'type': 'BlockStatement', + 'type': NodeType_1.NodeType.BlockStatement, 'body': [ { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType_1.NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'temp' }, 'right': { - 'type': 'CallExpression', + 'type': NodeType_1.NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType_1.NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'name': 'shift', 'x-verbatim-property': Utils_1.Utils.stringToUnicode('shift') } @@ -230,25 +231,25 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node { } }, { - 'type': 'ExpressionStatement', + 'type': NodeType_1.NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType_1.NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType_1.NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType_1.NodeType.Literal, 'name': 'push', 'x-verbatim-property': Utils_1.Utils.stringToUnicode('push') } }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType_1.NodeType.Identifier, 'name': 'temp' } ] diff --git a/src/nodes/UnicodeArrayRotateFunctionNode.ts b/src/nodes/UnicodeArrayRotateFunctionNode.ts index b4cc111e..5f3d2b29 100644 --- a/src/nodes/UnicodeArrayRotateFunctionNode.ts +++ b/src/nodes/UnicodeArrayRotateFunctionNode.ts @@ -3,6 +3,8 @@ import * as estraverse from 'estraverse'; import { IProgramNode } from '../interfaces/nodes/IProgramNode'; import { ITreeNode } from '../interfaces/nodes/ITreeNode'; +import { NodeType } from "../enums/NodeType"; + import { Node } from './Node'; import { Utils } from '../Utils'; @@ -48,7 +50,7 @@ export class UnicodeArrayRotateFunctionNode extends Node { estraverse.replace(this.astTree, { leave: (node: ITreeNode, parent: ITreeNode): any => { switch (node.type) { - case 'Program': + case NodeType.Program: (node).body.push(this.getNode()); break; @@ -72,49 +74,49 @@ export class UnicodeArrayRotateFunctionNode extends Node { */ protected getNodeStructure (): any { return { - 'type': 'FunctionExpression', + 'type': NodeType.FunctionExpression, 'id': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': this.unicodeArrayRotateFunctionName }, 'params': [ { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'array' }, { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'times' }, { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'reverse' } ], 'defaults': [], 'body': { - 'type': 'BlockStatement', + 'type': NodeType.BlockStatement, 'body': [ { - 'type': 'IfStatement', + 'type': NodeType.IfStatement, 'test': { - 'type': 'BinaryExpression', + 'type': NodeType.BinaryExpression, 'operator': '<', 'left': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'times' }, 'right': { - 'type': 'Literal', + 'type': NodeType.Literal, 'value': 0, 'raw': '0' } }, 'consequent': { - 'type': 'BlockStatement', + 'type': NodeType.BlockStatement, 'body': [ { - 'type': 'ReturnStatement', + 'type': NodeType.ReturnStatement, 'argument': null } ] @@ -122,23 +124,23 @@ export class UnicodeArrayRotateFunctionNode extends Node { 'alternate': null }, { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'reverse' }, 'right': { - 'type': 'LogicalExpression', + 'type': NodeType.LogicalExpression, 'operator': '||', 'left': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'reverse' }, 'right': { - 'type': 'Literal', + 'type': NodeType.Literal, 'value': false, 'raw': 'false' } @@ -146,12 +148,12 @@ export class UnicodeArrayRotateFunctionNode extends Node { } }, { - 'type': 'VariableDeclaration', + 'type': NodeType.VariableDeclaration, 'declarations': [ { - 'type': 'VariableDeclarator', + 'type': NodeType.VariableDeclarator, 'id': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'temp' }, 'init': null @@ -160,53 +162,53 @@ export class UnicodeArrayRotateFunctionNode extends Node { 'kind': 'var' }, { - 'type': 'WhileStatement', + 'type': NodeType.WhileStatement, 'test': { - 'type': 'UpdateExpression', + 'type': NodeType.UpdateExpression, 'operator': '--', 'argument': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'times' }, 'prefix': false }, 'body': { - 'type': 'BlockStatement', + 'type': NodeType.BlockStatement, 'body': [ { - 'type': 'IfStatement', + 'type': NodeType.IfStatement, 'test': { - 'type': 'UnaryExpression', + 'type': NodeType.UnaryExpression, 'operator': '!', 'argument': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'reverse' }, 'prefix': true }, 'consequent': { - 'type': 'BlockStatement', + 'type': NodeType.BlockStatement, 'body': [ { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'temp' }, 'right': { - 'type': 'CallExpression', + 'type': NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType.Literal, 'name': 'pop', 'x-verbatim-property': Utils.stringToUnicode('pop') } @@ -216,25 +218,25 @@ export class UnicodeArrayRotateFunctionNode extends Node { } }, { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType.Literal, 'name': 'unshift', 'x-verbatim-property': Utils.stringToUnicode('unshift') } }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'temp' } ] @@ -243,28 +245,28 @@ export class UnicodeArrayRotateFunctionNode extends Node { ] }, 'alternate': { - 'type': 'BlockStatement', + 'type': NodeType.BlockStatement, 'body': [ { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'AssignmentExpression', + 'type': NodeType.AssignmentExpression, 'operator': '=', 'left': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'temp' }, 'right': { - 'type': 'CallExpression', + 'type': NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType.Literal, 'name': 'shift', 'x-verbatim-property': Utils.stringToUnicode('shift') } @@ -274,25 +276,25 @@ export class UnicodeArrayRotateFunctionNode extends Node { } }, { - 'type': 'ExpressionStatement', + 'type': NodeType.ExpressionStatement, 'expression': { - 'type': 'CallExpression', + 'type': NodeType.CallExpression, 'callee': { - 'type': 'MemberExpression', + 'type': NodeType.MemberExpression, 'computed': true, 'object': { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'array' }, 'property': { - 'type': 'Literal', + 'type': NodeType.Literal, 'name': 'push', 'x-verbatim-property': Utils.stringToUnicode('push') } }, 'arguments': [ { - 'type': 'Identifier', + 'type': NodeType.Identifier, 'name': 'temp' } ] diff --git a/tslint.json b/tslint.json index 76bb6893..4ce075f1 100644 --- a/tslint.json +++ b/tslint.json @@ -136,11 +136,7 @@ "check-module", "check-function" ], - "variable-name": [ - true, - "check-format", - "allow-leading-underscore" - ], + "variable-name": false, "whitespace": [ true, "check-branch",