Ver código fonte

Renamed ScopeIdentifiersTraverser methods, interfaces and types to more concrete `variable` traverse

sanex 4 anos atrás
pai
commit
dce365079c

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
dist/index.browser.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
dist/index.cli.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
dist/index.js


+ 2 - 2
package.json

@@ -66,9 +66,9 @@
     "@typescript-eslint/parser": "3.9.0",
     "chai": "4.2.0",
     "coveralls": "3.1.0",
-    "eslint": "7.6.0",
+    "eslint": "7.7.0",
     "eslint-plugin-import": "2.22.0",
-    "eslint-plugin-jsdoc": "30.2.2",
+    "eslint-plugin-jsdoc": "30.2.3",
     "eslint-plugin-no-null": "1.0.2",
     "eslint-plugin-prefer-arrow": "1.2.2",
     "eslint-plugin-unicorn": "21.0.0",

+ 4 - 4
src/interfaces/node/IScopeIdentifiersTraverser.ts

@@ -1,17 +1,17 @@
 import * as ESTree from 'estree';
 
-import { TScopeIdentifiersTraverserCallback } from '../../types/node/TScopeIdentifiersTraverserCallback';
+import { TScopeIdentifiersTraverserVariableCallback } from '../../types/node/TScopeIdentifiersTraverserVariableCallback';
 
 export interface IScopeIdentifiersTraverser {
     /**
      * @param {Program} programNode
      * @param {Node | null} parentNode
-     * @param {TScopeIdentifiersTraverserCallback} callback
+     * @param {TScopeIdentifiersTraverserVariableCallback} callback
      */
-    traverse (
+    traverseScopeVariables (
         programNode: ESTree.Program,
         parentNode: ESTree.Node | null,
-        callback: TScopeIdentifiersTraverserCallback
+        callback: TScopeIdentifiersTraverserVariableCallback
     ): void;
 
 }

+ 1 - 1
src/interfaces/node/IScopeIdentifiersTraverserCallbackData.ts → src/interfaces/node/IScopeIdentifiersTraverserVariableCallbackData.ts

@@ -2,7 +2,7 @@ import * as eslintScope from 'eslint-scope';
 
 import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
 
-export interface IScopeIdentifiersTraverserCallbackData {
+export interface IScopeIdentifiersTraverserVariableCallbackData {
     isGlobalDeclaration: boolean;
     isBubblingDeclaration: boolean;
     rootScope: eslintScope.Scope;

+ 3 - 3
src/node-transformers/obfuscating-transformers/ScopeIdentifiersTransformer.ts

@@ -12,7 +12,7 @@ import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transforme
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 import { IScopeIdentifiersTraverser } from '../../interfaces/node/IScopeIdentifiersTraverser';
-import { IScopeIdentifiersTraverserCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserCallbackData';
+import { IScopeIdentifiersTraverserVariableCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserVariableCallbackData';
 import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 
 import { IdentifierObfuscatingReplacer } from '../../enums/node-transformers/obfuscating-transformers/obfuscating-replacers/IdentifierObfuscatingReplacer';
@@ -89,10 +89,10 @@ export class ScopeIdentifiersTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      */
     public transformNode (programNode: ESTree.Program, parentNode: ESTree.Node): ESTree.Node {
-        this.scopeIdentifiersTraverser.traverse(
+        this.scopeIdentifiersTraverser.traverseScopeVariables(
             programNode,
             parentNode,
-            (data: IScopeIdentifiersTraverserCallbackData) => {
+            (data: IScopeIdentifiersTraverserVariableCallbackData) => {
                 const {
                     isGlobalDeclaration,
                     variable,

+ 4 - 4
src/node-transformers/preparing-transformers/VariablePreserveTransformer.ts

@@ -9,7 +9,7 @@ import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transforme
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 import { IScopeIdentifiersTraverser } from '../../interfaces/node/IScopeIdentifiersTraverser';
-import { IScopeIdentifiersTraverserCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserCallbackData';
+import { IScopeIdentifiersTraverserVariableCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserVariableCallbackData';
 import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 
 import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer';
@@ -93,7 +93,7 @@ export class VariablePreserveTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      */
     public transformNode (programNode: ESTree.Program, parentNode: ESTree.Node): ESTree.Node {
-        this.scopeIdentifiersTraverser.traverse(
+        this.scopeIdentifiersTraverser.traverseScopeVariables(
             programNode,
             parentNode,
             this.preserveScopeVariableIdentifiers
@@ -103,9 +103,9 @@ export class VariablePreserveTransformer extends AbstractNodeTransformer {
     }
 
     /**
-     * @param {IScopeIdentifiersTraverserCallbackData} data
+     * @param {IScopeIdentifiersTraverserVariableCallbackData} data
      */
-    private preserveScopeVariableIdentifiers (data: IScopeIdentifiersTraverserCallbackData): void {
+    private preserveScopeVariableIdentifiers (data: IScopeIdentifiersTraverserVariableCallbackData): void {
         const {
             isGlobalDeclaration,
             isBubblingDeclaration,

+ 9 - 9
src/node/ScopeIdentifiersTraverser.ts

@@ -5,7 +5,7 @@ import * as eslintScope from 'eslint-scope';
 import * as ESTree from 'estree';
 
 import { TNodeWithLexicalScope } from '../types/node/TNodeWithLexicalScope';
-import { TScopeIdentifiersTraverserCallback } from '../types/node/TScopeIdentifiersTraverserCallback';
+import { TScopeIdentifiersTraverserVariableCallback } from '../types/node/TScopeIdentifiersTraverserVariableCallback';
 
 import { IScopeAnalyzer } from '../interfaces/analyzers/scope-analyzer/IScopeAnalyzer';
 import { IScopeIdentifiersTraverser } from '../interfaces/node/IScopeIdentifiersTraverser';
@@ -47,29 +47,29 @@ export class ScopeIdentifiersTraverser implements IScopeIdentifiersTraverser {
     /**
      * @param {Program} programNode
      * @param {Node | null} parentNode
-     * @param {TScopeIdentifiersTraverserCallback} callback
+     * @param {TScopeIdentifiersTraverserVariableCallback} callback
      */
-    public traverse (
+    public traverseScopeVariables (
         programNode: ESTree.Program,
         parentNode: ESTree.Node | null,
-        callback: TScopeIdentifiersTraverserCallback
+        callback: TScopeIdentifiersTraverserVariableCallback
     ): void {
         this.scopeAnalyzer.analyze(programNode);
 
         const globalScope: eslintScope.Scope = this.scopeAnalyzer.acquireScope(programNode);
 
-        this.traverseScopeVariables(globalScope, globalScope, callback);
+        this.traverseScopeVariablesRecursive(globalScope, globalScope, callback);
     }
 
     /**
      * @param {Scope} rootScope
      * @param {Scope} currentScope
-     * @param {TScopeIdentifiersTraverserCallback} callback
+     * @param {TScopeIdentifiersTraverserVariableCallback} callback
      */
-    private traverseScopeVariables (
+    private traverseScopeVariablesRecursive (
         rootScope: eslintScope.Scope,
         currentScope: eslintScope.Scope,
-        callback: TScopeIdentifiersTraverserCallback
+        callback: TScopeIdentifiersTraverserVariableCallback
     ): void {
         const variableScope: eslintScope.Scope = currentScope.variableScope;
         const variableLexicalScopeNode: TNodeWithLexicalScope | null = NodeGuards.isNodeWithBlockLexicalScope(variableScope.block)
@@ -105,7 +105,7 @@ export class ScopeIdentifiersTraverser implements IScopeIdentifiersTraverser {
         }
 
         for (const childScope of currentScope.childScopes) {
-            this.traverseScopeVariables(rootScope, childScope, callback);
+            this.traverseScopeVariablesRecursive(rootScope, childScope, callback);
         }
     }
 }

+ 0 - 3
src/types/node/TScopeIdentifiersTraverserCallback.ts

@@ -1,3 +0,0 @@
-import { IScopeIdentifiersTraverserCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserCallbackData';
-
-export type TScopeIdentifiersTraverserCallback = (data: IScopeIdentifiersTraverserCallbackData) => void;

+ 3 - 0
src/types/node/TScopeIdentifiersTraverserVariableCallback.ts

@@ -0,0 +1,3 @@
+import { IScopeIdentifiersTraverserVariableCallbackData } from '../../interfaces/node/IScopeIdentifiersTraverserVariableCallbackData';
+
+export type TScopeIdentifiersTraverserVariableCallback = (data: IScopeIdentifiersTraverserVariableCallbackData) => void;

+ 1 - 1
test/fixtures/compile-performance.js

@@ -17747,7 +17747,7 @@
                 this.injector = injector;
                 this.checks = [];
             }
-            PreActivation.prototype.traverse = function (parentOutletMap) {
+            PreActivation.prototype.traverseScopeVariables = function (parentOutletMap) {
                 var futureRoot = this.future._root;
                 var currRoot = this.curr ? this.curr._root : null;
                 this.traverseChildRoutes(futureRoot, currRoot, parentOutletMap, [futureRoot.value]);

+ 19 - 14
yarn.lock

@@ -1404,10 +1404,10 @@ commander@^2.20.0:
   resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
   integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
 
-comment-parser@^0.7.5:
-  version "0.7.5"
-  resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.7.5.tgz#06db157a3b34addf8502393743e41897e2c73059"
-  integrity sha512-iH9YA35ccw94nx5244GVkpyC9eVTsL71jZz6iz5w6RIf79JLF2AsXHXq9p6Oaohyl3sx5qSMnGsWUDFIAfWL4w==
+comment-parser@^0.7.6:
+  version "0.7.6"
+  resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.7.6.tgz#0e743a53c8e646c899a1323db31f6cd337b10f12"
+  integrity sha512-GKNxVA7/iuTnAqGADlTWX4tkhzxZKXp5fLJqKTlQLHkE65XDUKutZ3BHaJC5IGcper2tT3QRD1xr4o3jNpgXXg==
 
 commondir@^1.0.1:
   version "1.0.1"
@@ -1971,15 +1971,15 @@ [email protected]:
     resolve "^1.17.0"
     tsconfig-paths "^3.9.0"
 
[email protected].2:
-  version "30.2.2"
-  resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.2.2.tgz#f554a172c54b0e5514af03f1300af495670bea16"
-  integrity sha512-588zVyRy+g7s8VU3D0AL75r7xBYN0UX6tZEwP5EQ4JvpVavwu2iPJRaBxwuG3QAj99WZkUBlrLU16p4qST6vSw==
[email protected].3:
+  version "30.2.3"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.2.3.tgz#5cdfac270144eec9a5fac60061923204082266fe"
+  integrity sha512-yj3EEjukab/PuspQRHKJuxFK6WP4RiZDklikQz5t4PJdwUo0I7hUA9GtcS8aY+IP5jvXs6HMlnjBwvVit8aG/A==
   dependencies:
-    comment-parser "^0.7.5"
+    comment-parser "^0.7.6"
     debug "^4.1.1"
     jsdoctypeparser "^9.0.0"
-    lodash "^4.17.19"
+    lodash "^4.17.20"
     regextras "^0.7.1"
     semver "^7.3.2"
     spdx-expression-parse "^3.0.1"
@@ -2070,10 +2070,10 @@ eslint-visitor-keys@^1.3.0:
   resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
   integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
 
-eslint@7.6.0:
-  version "7.6.0"
-  resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.6.0.tgz#522d67cfaea09724d96949c70e7a0550614d64d6"
-  integrity sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==
+eslint@7.7.0:
+  version "7.7.0"
+  resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.7.0.tgz#18beba51411927c4b64da0a8ceadefe4030d6073"
+  integrity sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==
   dependencies:
     "@babel/code-frame" "^7.0.0"
     ajv "^6.10.0"
@@ -3412,6 +3412,11 @@ lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
   integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
 
+lodash@^4.17.20:
+  version "4.17.20"
+  resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
+  integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
+
 log-driver@^1.2.7:
   version "1.2.7"
   resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8"

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff