Updated TSLint rules

This commit is contained in:
sanex3339
2018-03-29 23:42:58 +03:00
parent 80f86dadbd
commit ad16e6403b
14 changed files with 86 additions and 47 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -72,6 +72,7 @@
"tslint": "5.9.1",
"tslint-eslint-rules": "5.1.0",
"tslint-language-service": "0.9.9",
"tslint-microsoft-contrib": "5.0.3",
"tslint-webpack-plugin": "1.2.2",
"typescript": "2.8.1",
"webpack": "4.3.0",
+11 -7
View File
@@ -84,13 +84,15 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
private static filterOptions (options: TInputCLIOptions): TInputOptions {
const filteredOptions: TInputOptions = {};
for (const option in options) {
if (!options.hasOwnProperty(option) || options[option] === undefined) {
continue;
}
Object
.keys(options)
.forEach((option: keyof TInputCLIOptions) => {
if (options[option] === undefined) {
return;
}
filteredOptions[option] = options[option];
}
filteredOptions[option] = options[option];
});
return filteredOptions;
}
@@ -153,7 +155,9 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
const canShowHelp: boolean = !this.arguments.length || this.arguments.includes('--help');
if (canShowHelp) {
return this.commands.outputHelp();
this.commands.outputHelp();
return;
}
const sourceCodeData: TSourceCodeData = new SourceCodeReader(this.inputCLIOptions)
+1 -1
View File
@@ -18,7 +18,7 @@ declare module 'estree' {
interface BaseNode {
metadata?: BaseNodeMetadata;
parentNode?: ESTree.Node;
parentNode?: Node;
}
interface Identifier extends BaseNode {
+2 -3
View File
@@ -1,6 +1,5 @@
/* tslint:disable:interface-name */
import * as escodegen from 'escodegen';
import * as ESTree from 'estree';
import { IGeneratorOutput } from '../interfaces/IGeneratorOutput';
@@ -8,7 +7,7 @@ import { IGeneratorOutput } from '../interfaces/IGeneratorOutput';
declare module 'escodegen' {
export interface XVerbatimProperty {
content?: string;
precedence: escodegen.Precedence;
precedence: Precedence;
}
/**
@@ -16,5 +15,5 @@ declare module 'escodegen' {
* @param options
* @returns IGeneratorOutput
*/
export function generate (ast: ESTree.Node, options?: escodegen.GenerateOptions): IGeneratorOutput;
export function generate (ast: ESTree.Node, options?: GenerateOptions): IGeneratorOutput;
}
+1 -1
View File
@@ -54,7 +54,7 @@ export class Logger implements ILogger {
): void {
const processedMessage: string = loggingLevelColor(`\n${loggingPrefix} ${loggingMessage}`);
!value ? console.log(processedMessage) : console.log(processedMessage, value);
console.log(processedMessage, value || '');
}
/**
+1 -1
View File
@@ -79,7 +79,7 @@ export class NodeAppender {
const firstCall: IStackTraceData = 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) {
+19 -17
View File
@@ -160,27 +160,29 @@ export class NodeUtils {
const copy: TObject = {};
for (const property in node) {
if (!node.hasOwnProperty(property) || property === 'parentNode') {
continue;
}
Object
.keys(node)
.forEach((property: string) => {
if (property === 'parentNode') {
return;
}
const value: T[keyof T] = node[property];
const value: T[keyof T] = node[<keyof T>property];
let clonedValue: T[keyof T] | T[keyof T][] | null;
let clonedValue: T[keyof T] | T[keyof T][] | null;
if (value === null || value instanceof RegExp) {
clonedValue = value;
} else if (Array.isArray(value)) {
clonedValue = value.map(NodeUtils.cloneRecursive);
} else if (typeof value === 'object') {
clonedValue = NodeUtils.cloneRecursive(value);
} else {
clonedValue = value;
}
if (value === null || value instanceof RegExp) {
clonedValue = value;
} else if (Array.isArray(value)) {
clonedValue = value.map(NodeUtils.cloneRecursive);
} else if (typeof value === 'object') {
clonedValue = NodeUtils.cloneRecursive(value);
} else {
clonedValue = value;
}
copy[property] = clonedValue;
}
copy[property] = clonedValue;
});
return <T>copy;
}
+5 -7
View File
@@ -24,13 +24,11 @@ export class ValidationErrorsFormatter {
let errorString: string = `\`${validationError.property}\` errors:\n`;
for (const constraint in constraints) {
if (!constraints.hasOwnProperty(constraint)) {
continue;
}
errorString += ` - ${constraints[constraint]}\n`;
}
Object
.keys(constraints)
.forEach((constraint: string) => {
errorString += ` - ${constraints[constraint]}\n`;
});
return errorString;
}
-2
View File
@@ -81,8 +81,6 @@ export class SourceMapCorrector implements ISourceMapCorrector {
}
sourceMappingUrl += sourceMapUrl;
break;
}
return `${obfuscatedCode}\n${sourceMappingUrl}`;
+5 -2
View File
@@ -53,8 +53,11 @@ export class ArrayUtils implements IArrayUtils {
let temp: T | undefined;
while (times--) {
temp = newArray.pop()!;
newArray.unshift(temp);
temp = newArray.pop();
if (temp) {
newArray.unshift(temp);
}
}
return newArray;
+4 -4
View File
@@ -23,7 +23,7 @@ export class CryptUtils implements ICryptUtils {
this.randomGenerator = randomGenerator;
}
/* tslint:disable */
// tslint:disable
/**
* @param {string} string
* @returns {string}
@@ -53,7 +53,7 @@ export class CryptUtils implements ICryptUtils {
return output;
}
/* tslint:enable */
// tslint:enable
/**
* @param {string} str
@@ -97,7 +97,7 @@ export class CryptUtils implements ICryptUtils {
return [randomMerge(str, randomStringDiff), randomStringDiff];
}
/* tslint:disable */
// tslint:disable
/**
* RC4 symmetric cipher encryption/decryption
* https://gist.github.com/farhadi/2185197
@@ -137,5 +137,5 @@ export class CryptUtils implements ICryptUtils {
return result;
}
/* tslint:enable */
// tslint:enable
}
+29 -1
View File
@@ -1,6 +1,7 @@
{
"extends": [
"tslint-eslint-rules"
"tslint-eslint-rules",
"tslint-microsoft-contrib"
],
"rules": {
"adjacent-overload-signatures": true,
@@ -29,14 +30,24 @@
"check-space",
"check-lowercase"
],
"completed-docs": false,
"curly": true,
"cyclomatic-complexity": [true, 10],
"eofline": true,
"export-name": false,
"forin": true,
"function-name": [true, {
"method-regex": "^[a-z][\\w\\d]+$",
"private-method-regex": "^[a-z][\\w\\d]+$",
"protected-method-regex": "^[a-z][\\w\\d]+$",
"static-method-regex": "^[a-z][\\w\\d]+$",
"function-regex": "^[a-zA-Z][\\w\\d]+$"
}],
"indent": [
true,
"spaces"
],
"insecure-random": false,
"interface-name": [
true,
"always-prefix"
@@ -46,16 +57,21 @@
"jsdoc-format": true,
"label-position": true,
"max-classes-per-file": [true, 1],
"max-func-body-length": [true, 200],
"max-line-length": [true, 150],
"member-access": [true],
"member-ordering": [
true,
{ "order": "fields-first" }
],
"missing-jsdoc": false,
"newline-before-return": true,
"new-parens": true,
"newline-per-chained-call": false,
"no-angle-bracket-type-assertion": false,
"no-any": false,
"no-arg": true,
"no-banned-terms": false,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": true,
@@ -80,6 +96,7 @@
"no-empty": false,
"no-empty-character-class": true,
"no-empty-interface": true,
"no-empty-line-after-opening-brace": true,
"no-eval": false,
"no-ex-assign": true,
"no-extra-boolean-cast": true,
@@ -87,11 +104,13 @@
"no-inferrable-types": false,
"no-inner-declarations": [true, "both"],
"no-implicit-dependencies": false,
"no-increment-decrement": false,
"no-internal-module": true,
"no-invalid-regexp": true,
"no-invalid-this": true,
"no-misused-new": true,
"no-multi-spaces": [true],
"no-multiline-string": false,
"no-namespace": true,
"no-null-keyword": false,
"no-parameter-properties": true,
@@ -100,20 +119,27 @@
"no-reference": true,
"no-reference-import": true,
"no-regex-spaces": true,
"no-relative-imports": false,
"no-require-imports": true,
"no-reserved-keywords": false,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-string-throw": true,
"no-submodule-imports": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": [true, "ignore-blank-lines"],
"no-typeof-undefined": true,
"no-unnecessary-callback-wrapper": true,
"no-unnecessary-class": [true, "allow-static-only"],
"no-unnecessary-initializer": true,
"no-unnecessary-field-initialization": true,
"no-unnecessary-local-variable": true,
"no-unexpected-multiline": true,
"no-unsafe-any": false,
"no-unsafe-finally": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-useless-files": true,
"no-var-keyword": true,
"no-var-requires": true,
"max-file-line-count": [true, 500],
@@ -138,6 +164,7 @@
}
],
"prefer-const": true,
"prefer-object-spread": false,
"prefer-method-signature": true,
"prefer-readonly": true,
"prefer-template": true,
@@ -146,6 +173,7 @@
"semicolon": [true, "always"],
"space-before-function-paren": true,
"space-in-parens": [true, "never"],
"strict-boolean-expressions": false,
"switch-default": false,
"ter-arrow-parens": true,
"ter-func-call-spacing": [true, "never"],
+6
View File
@@ -5664,6 +5664,12 @@ tslint-language-service@0.9.9:
dependencies:
mock-require "^2.0.2"
tslint-microsoft-contrib@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.0.3.tgz#6fc3e238179cd72045c2b422e4d655f4183a8d5c"
dependencies:
tsutils "^2.12.1"
tslint-webpack-plugin@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tslint-webpack-plugin/-/tslint-webpack-plugin-1.2.2.tgz#364369d2842d5fc8115815e9fe92f0d4dc39b9b7"