Removed isNodeScope option, added more tests

This commit is contained in:
sanex3339
2020-01-27 20:44:16 +03:00
parent c0117912c1
commit f819acbc4b
6 changed files with 322 additions and 151 deletions
+1 -20
View File
@@ -1,15 +1,11 @@
import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { injectable, } from 'inversify';
import * as eslintScope from 'eslint-scope';
import * as estraverse from 'estraverse';
import * as ESTree from 'estree';
import { IOptions } from '../../interfaces/options/IOptions';
import { IScopeAnalyzer } from '../../interfaces/analyzers/scope-analyzer/IScopeAnalyzer';
import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
import { ecmaVersion } from '../../constants/EcmaVersion';
import { NodeGuards } from '../../node/NodeGuards';
@@ -37,25 +33,11 @@ export class ScopeAnalyzer implements IScopeAnalyzer {
*/
private static readonly emptyRangeValue: number = 0;
/**
* @type {IOptions}
*/
private readonly options: IOptions;
/**
* @type {eslintScope.ScopeManager | null}
*/
private scopeManager: eslintScope.ScopeManager | null = null;
/**
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
this.options = options;
}
/**
* `eslint-scope` reads `ranges` property of a nodes
* Should attach that property to the some custom nodes
@@ -97,7 +79,6 @@ export class ScopeAnalyzer implements IScopeAnalyzer {
try {
this.scopeManager = eslintScope.analyze(astTree, {
...ScopeAnalyzer.eslintScopeOptions,
nodejsScope: this.options.target === ObfuscationTarget.Node,
sourceType: ScopeAnalyzer.sourceTypes[i]
});