Skip to content

Commit 24dd515

Browse files
authored
Merge pull request javascript-obfuscator#237 from javascript-obfuscator/tslint-rules-update
Updated TSLint rules
2 parents 781d1f8 + 5e6169f commit 24dd515

File tree

17 files changed

+99
-57
lines changed

17 files changed

+99
-57
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"tslint": "5.9.1",
7373
"tslint-eslint-rules": "5.1.0",
7474
"tslint-language-service": "0.9.9",
75+
"tslint-microsoft-contrib": "5.0.3",
7576
"tslint-webpack-plugin": "1.2.2",
7677
"typescript": "2.8.1",
7778
"webpack": "4.4.1",

src/cli/JavaScriptObfuscatorCLI.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
8484
private static filterOptions (options: TInputCLIOptions): TInputOptions {
8585
const filteredOptions: TInputOptions = {};
8686

87-
for (const option in options) {
88-
if (!options.hasOwnProperty(option) || options[option] === undefined) {
89-
continue;
90-
}
91-
92-
filteredOptions[option] = options[option];
93-
}
87+
Object
88+
.keys(options)
89+
.forEach((option: keyof TInputCLIOptions) => {
90+
if (options[option] === undefined) {
91+
return;
92+
}
93+
94+
filteredOptions[option] = options[option];
95+
});
9496

9597
return filteredOptions;
9698
}
@@ -153,7 +155,9 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
153155
const canShowHelp: boolean = !this.arguments.length || this.arguments.includes('--help');
154156

155157
if (canShowHelp) {
156-
return this.commands.outputHelp();
158+
this.commands.outputHelp();
159+
160+
return;
157161
}
158162

159163
const sourceCodeData: TSourceCodeData = new SourceCodeReader(this.inputCLIOptions)

src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { inject, injectable, } from 'inversify';
22
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
33

44
import * as ESTree from 'estree';
5+
6+
// tslint:disable
57
import { Expression } from 'estree';
8+
// tslint:enable
69

710
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
811
import { TStatement } from '../../../types/node/TStatement';
@@ -65,7 +68,7 @@ export class CallExpressionControlFlowStorageCallNode extends AbstractCustomNode
6568
public initialize (
6669
controlFlowStorageName: string,
6770
controlFlowStorageKey: string,
68-
callee: Expression,
71+
callee: ESTree.Expression,
6972
expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[]
7073
): void {
7174
this.controlFlowStorageName = controlFlowStorageName;

src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
153153
stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
154154
}
155155
);
156-
157-
break;
158156
}
159157

160158
return decodeStringArrayTemplate;

src/declarations/ESTree.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* tslint:disable:interface-name */
22

33
import * as escodegen from 'escodegen-wallaby';
4-
import * as ESTree from 'estree';
54

65
declare module 'estree' {
76
export interface BaseNodeMetadata {
@@ -18,7 +17,7 @@ declare module 'estree' {
1817

1918
interface BaseNode {
2019
metadata?: BaseNodeMetadata;
21-
parentNode?: ESTree.Node;
20+
parentNode?: Node;
2221
}
2322

2423
interface Identifier extends BaseNode {

src/declarations/escodegen.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
/* tslint:disable:interface-name */
22

3-
import * as escodegen from 'escodegen';
43
import * as ESTree from 'estree';
54

65
import { IGeneratorOutput } from '../interfaces/IGeneratorOutput';
76

87
declare module 'escodegen' {
98
export interface XVerbatimProperty {
109
content?: string;
11-
precedence: escodegen.Precedence;
10+
precedence: Precedence;
1211
}
1312

1413
/**
1514
* @param ast
1615
* @param options
1716
* @returns IGeneratorOutput
1817
*/
19-
export function generate (ast: ESTree.Node, options?: escodegen.GenerateOptions): IGeneratorOutput;
18+
export function generate (ast: ESTree.Node, options?: GenerateOptions): IGeneratorOutput;
2019
}

src/logger/Logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Logger implements ILogger {
5454
): void {
5555
const processedMessage: string = loggingLevelColor(`\n${loggingPrefix} ${loggingMessage}`);
5656

57-
!value ? console.log(processedMessage) : console.log(processedMessage, value);
57+
console.log(processedMessage, value || '');
5858
}
5959

6060
/**

src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class TemplateLiteralTransformer extends AbstractNodeTransformer {
101101
);
102102

103103
nodes.forEach((node: ESTree.Literal | ESTree.Expression) => {
104-
root = NodeFactory.binaryExpressionNode('+', root, <ESTree.Literal | ESTree.Expression>node);
104+
root = NodeFactory.binaryExpressionNode('+', root, node);
105105
});
106106

107107
return root;

src/node/NodeAppender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class NodeAppender {
7979
const firstCall: IStackTraceData = blockScopeTraceData[index];
8080

8181
if (deep <= 0) {
82-
throw new Error(`Invalid \`deep\` argument value. Value should be bigger then 0.`);
82+
throw new Error('Invalid `deep` argument value. Value should be bigger then 0.');
8383
}
8484

8585
if (deep > 1 && firstCall.stackTrace.length) {

0 commit comments

Comments
 (0)