Leon4gr45 commited on
Commit
2515b86
·
verified ·
1 Parent(s): 0e0e18b

Upload folder using huggingface_hub (part 4)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. server/node_modules/eslint-scope/LICENSE +22 -0
  2. server/node_modules/eslint-scope/README.md +198 -0
  3. server/node_modules/eslint-scope/dist/eslint-scope.cjs +2339 -0
  4. server/node_modules/eslint-scope/lib/assert.js +17 -0
  5. server/node_modules/eslint-scope/lib/definition.js +85 -0
  6. server/node_modules/eslint-scope/lib/index.js +170 -0
  7. server/node_modules/eslint-scope/lib/pattern-visitor.js +154 -0
  8. server/node_modules/eslint-scope/lib/reference.js +166 -0
  9. server/node_modules/eslint-scope/lib/referencer.js +708 -0
  10. server/node_modules/eslint-scope/lib/scope-manager.js +253 -0
  11. server/node_modules/eslint-scope/lib/scope.js +793 -0
  12. server/node_modules/eslint-scope/lib/variable.js +87 -0
  13. server/node_modules/eslint-scope/lib/version.js +3 -0
  14. server/node_modules/eslint-scope/package.json +64 -0
  15. server/node_modules/eslint-visitor-keys/LICENSE +201 -0
  16. server/node_modules/eslint-visitor-keys/README.md +121 -0
  17. server/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +396 -0
  18. server/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +28 -0
  19. server/node_modules/eslint-visitor-keys/dist/index.d.ts +16 -0
  20. server/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +12 -0
  21. server/node_modules/eslint-visitor-keys/lib/index.js +67 -0
  22. server/node_modules/eslint-visitor-keys/lib/visitor-keys.js +327 -0
  23. server/node_modules/eslint-visitor-keys/package.json +70 -0
  24. server/node_modules/eslint/lib/rules/no-new-symbol.js +74 -0
  25. server/node_modules/eslint/lib/rules/no-new-wrappers.js +62 -0
  26. server/node_modules/eslint/lib/rules/no-new.js +42 -0
  27. server/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js +176 -0
  28. server/node_modules/eslint/lib/rules/no-obj-calls.js +99 -0
  29. server/node_modules/eslint/lib/rules/no-object-constructor.js +124 -0
  30. server/node_modules/eslint/lib/rules/no-octal-escape.js +53 -0
  31. server/node_modules/eslint/lib/rules/no-octal.js +42 -0
  32. server/node_modules/eslint/lib/rules/no-param-reassign.js +248 -0
  33. server/node_modules/eslint/lib/rules/no-path-concat.js +79 -0
  34. server/node_modules/eslint/lib/rules/no-plusplus.js +102 -0
  35. server/node_modules/eslint/lib/rules/no-process-env.js +68 -0
  36. server/node_modules/eslint/lib/rules/no-process-exit.js +67 -0
  37. server/node_modules/eslint/lib/rules/no-promise-executor-return.js +264 -0
  38. server/node_modules/eslint/lib/rules/no-proto.js +45 -0
  39. server/node_modules/eslint/lib/rules/no-prototype-builtins.js +181 -0
  40. server/node_modules/eslint/lib/rules/no-redeclare.js +173 -0
  41. server/node_modules/eslint/lib/rules/no-regex-spaces.js +219 -0
  42. server/node_modules/eslint/lib/rules/no-restricted-exports.js +227 -0
  43. server/node_modules/eslint/lib/rules/no-restricted-globals.js +266 -0
  44. server/node_modules/eslint/lib/rules/no-restricted-imports.js +850 -0
  45. server/node_modules/eslint/lib/rules/no-restricted-modules.js +249 -0
  46. server/node_modules/eslint/lib/rules/no-restricted-properties.js +233 -0
  47. server/node_modules/eslint/lib/rules/no-restricted-syntax.js +74 -0
  48. server/node_modules/eslint/lib/rules/no-return-assign.js +87 -0
  49. server/node_modules/eslint/lib/rules/no-return-await.js +162 -0
  50. server/node_modules/eslint/lib/rules/no-script-url.js +68 -0
server/node_modules/eslint-scope/LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright JS Foundation and other contributors, https://js.foundation
2
+ Copyright (C) 2012-2013 Yusuke Suzuki (twitter: @Constellation) and other contributors.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
server/node_modules/eslint-scope/README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![npm version](https://img.shields.io/npm/v/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
2
+ [![Downloads](https://img.shields.io/npm/dm/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
3
+ [![Build Status](https://github.com/eslint/js/workflows/CI/badge.svg)](https://github.com/eslint/js/actions)
4
+
5
+ # ESLint Scope
6
+
7
+ ESLint Scope is the [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) scope analyzer used in ESLint. It is a fork of [escope](http://github.com/estools/escope).
8
+
9
+ ## Install
10
+
11
+ ```
12
+ npm i eslint-scope --save
13
+ ```
14
+
15
+ ## 📖 Usage
16
+
17
+ To use in an ESM file:
18
+
19
+ ```js
20
+ import * as eslintScope from 'eslint-scope';
21
+ ```
22
+
23
+ To use in a CommonJS file:
24
+
25
+ ```js
26
+ const eslintScope = require('eslint-scope');
27
+ ```
28
+
29
+ In order to analyze scope, you'll need to have an [ESTree](https://github.com/estree/estree) compliant AST structure to run it on. The primary method is `eslintScope.analyze()`, which takes two arguments:
30
+
31
+ 1. `ast` - the ESTree-compliant AST structure to analyze.
32
+ 2. `options` (optional) - Options to adjust how the scope is analyzed, including:
33
+ * `ignoreEval` (default: `false`) - Set to `true` to ignore all `eval()` calls (which would normally create scopes).
34
+ * `nodejsScope` (default: `false`) - Set to `true` to create a top-level function scope needed for CommonJS evaluation.
35
+ * `impliedStrict` (default: `false`) - Set to `true` to evaluate the code in strict mode even outside of modules and without `"use strict"`.
36
+ * `ecmaVersion` (default: `5`) - The version of ECMAScript to use to evaluate the code.
37
+ * `sourceType` (default: `"script"`) - The type of JavaScript file to evaluate. Change to `"module"` for ECMAScript module code.
38
+ * `childVisitorKeys` (default: `null`) - An object with visitor key information (like [`eslint-visitor-keys`](https://github.com/eslint/js/tree/main/packages/eslint-visitor-keys)). Without this, `eslint-scope` finds child nodes to visit algorithmically. Providing this option is a performance enhancement.
39
+ * `fallback` (default: `"iteration"`) - The strategy to use when `childVisitorKeys` is not specified. May be a function.
40
+ * `jsx` (default: `false`) - Enables the tracking of JSX components as variable references.
41
+
42
+ Example:
43
+
44
+ ```js
45
+ import * as eslintScope from 'eslint-scope';
46
+ import * as espree from 'espree';
47
+ import estraverse from 'estraverse';
48
+
49
+ const options = {
50
+ ecmaVersion: 2022,
51
+ sourceType: "module"
52
+ };
53
+
54
+ const ast = espree.parse(code, { range: true, ...options });
55
+ const scopeManager = eslintScope.analyze(ast, options);
56
+
57
+ const currentScope = scopeManager.acquire(ast); // global scope
58
+
59
+ estraverse.traverse(ast, {
60
+ enter (node, parent) {
61
+ // do stuff
62
+
63
+ if (/Function/.test(node.type)) {
64
+ currentScope = scopeManager.acquire(node); // get current function scope
65
+ }
66
+ },
67
+ leave(node, parent) {
68
+ if (/Function/.test(node.type)) {
69
+ currentScope = currentScope.upper; // set to parent scope
70
+ }
71
+
72
+ // do stuff
73
+ }
74
+ });
75
+ ```
76
+
77
+ ## API
78
+
79
+ The following section describes the API for this package. You can also read [the docs](https://eslint.org/docs/latest/extend/scope-manager-interface).
80
+
81
+ ### ScopeManager
82
+
83
+ The `ScopeManager` class is at the core of eslint-scope and is returned when you call `eslintScope.analyze()`. It manages all scopes in a given AST.
84
+
85
+ #### Properties
86
+
87
+ - `scopes` - An array of all scopes.
88
+ - `globalScope` - Reference to the global scope.
89
+
90
+ #### Methods
91
+
92
+ - **`acquire(node, inner)`**
93
+ Acquires the appropriate scope for a given node.
94
+ - `node` - The AST node to acquire the scope from.
95
+ - `inner` - Optional boolean. When `true`, returns the innermost scope, otherwise returns the outermost scope. Default is `false`.
96
+ - Returns: The acquired scope or `null` if no scope is found.
97
+
98
+ - **`acquireAll(node)`**
99
+ Acquires all scopes for a given node.
100
+ - `node` - The AST node to acquire scopes from.
101
+ - Returns: An array of scopes or `undefined` if none are found.
102
+
103
+ - **`release(node, inner)`**
104
+ Returns the upper scope for a given node.
105
+ - `node` - The AST node to release.
106
+ - `inner` - Optional boolean. When `true`, returns the innermost upper scope, otherwise returns the outermost upper scope. Default is `false`.
107
+ - Returns: The upper scope or `null` if no upper scope exists.
108
+
109
+ - **`getDeclaredVariables(node)`**
110
+ Get variables that are declared by the node.
111
+ - `node` - The AST node to get declarations from.
112
+ - Returns: An array of variable objects declared by the node. If the node doesn't declare any variables, it returns an empty array.
113
+
114
+ - **`isGlobalReturn()`**
115
+ Determines if the global return statement should be allowed.
116
+ - Returns: `true` if the global return is enabled.
117
+
118
+ - **`isModule()`**
119
+ Checks if the code should be handled as an ECMAScript module.
120
+ - Returns: `true` if the sourceType is "module".
121
+
122
+ - **`isImpliedStrict()`**
123
+ Checks if implied strict mode is enabled.
124
+ - Returns: `true` if implied strict mode is enabled.
125
+
126
+ - **`isStrictModeSupported()`**
127
+ Checks if strict mode is supported based on ECMAScript version.
128
+ - Returns: `true` if the ECMAScript version supports strict mode.
129
+
130
+ ### Scope Objects
131
+
132
+ Scopes returned by the ScopeManager methods have the following properties:
133
+
134
+ - `type` - The type of scope (e.g., "function", "block", "global").
135
+ - `variables` - Array of variables declared in this scope.
136
+ - `set` - A Map of variable names to Variable objects for variables declared in this scope.
137
+ - `references` - Array of references in this scope.
138
+ - `through` - Array of references in this scope and its child scopes that aren't resolved in this scope or its child scopes.
139
+ - `variableScope` - Reference to the closest variable scope.
140
+ - `upper` - Reference to the parent scope.
141
+ - `childScopes` - Array of child scopes.
142
+ - `block` - The AST node that created this scope.
143
+
144
+ ### GlobalScope
145
+
146
+ The `GlobalScope` class is a specialized scope representing the global execution context. It extends the base `Scope` class with additional functionality for handling implicitly defined global variables.
147
+
148
+ #### Properties
149
+
150
+ - **`implicit`** - Tracks implicitly defined global variables (those used without declaration).
151
+ - `set` - A Map of variable names to Variable objects for implicitly defined globals.
152
+ - `variables` - Array of implicit global Variable objects.
153
+ - `left` - Array of References that need to be linked to the variable they refer to.
154
+
155
+ ### Variable Objects
156
+
157
+ Each variable object has the following properties:
158
+
159
+ - `name` - The variable name.
160
+ - `identifiers` - Array of identifier nodes declaring this variable.
161
+ - `references` - Array of references to this variable.
162
+ - `defs` - Array of definition objects for this variable.
163
+ - `scope` - The scope object where this variable is defined.
164
+
165
+ ## Contributing
166
+
167
+ Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/js/issues).
168
+
169
+ ## Security Policy
170
+
171
+ We work hard to ensure that ESLint Scope is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
172
+
173
+ ## Build Commands
174
+
175
+ * `npm test` - run all linting and tests
176
+ * `npm run lint` - run all linting
177
+
178
+ ## License
179
+
180
+ ESLint Scope is licensed under a permissive BSD 2-clause license.
181
+
182
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
183
+ <!--sponsorsstart-->
184
+ ## Sponsors
185
+
186
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
187
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
188
+
189
+ <h3>Diamond Sponsors</h3>
190
+ <p><a href="https://www.ag-grid.com/"><img src="https://images.opencollective.com/ag-grid/bec0580/logo.png" alt="AG Grid" height="128"></a></p><h3>Platinum Sponsors</h3>
191
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
192
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
193
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
194
+ <p><a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
195
+ <h3>Technology Sponsors</h3>
196
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
197
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
198
+ <!--sponsorsend-->
server/node_modules/eslint-scope/dist/eslint-scope.cjs ADDED
@@ -0,0 +1,2339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var estraverse = require('estraverse');
6
+ var esrecurse = require('esrecurse');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var estraverse__default = /*#__PURE__*/_interopDefaultLegacy(estraverse);
11
+ var esrecurse__default = /*#__PURE__*/_interopDefaultLegacy(esrecurse);
12
+
13
+ /**
14
+ * @fileoverview Assertion utilities.
15
+ * @author Nicholas C. Zakas
16
+ */
17
+
18
+ /**
19
+ * Throws an error if the given condition is not truthy.
20
+ * @param {boolean} condition The condition to check.
21
+ * @param {string} message The message to include with the error.
22
+ * @returns {void}
23
+ * @throws {Error} When the condition is not truthy.
24
+ */
25
+ function assert(condition, message = "Assertion failed.") {
26
+ if (!condition) {
27
+ throw new Error(message);
28
+ }
29
+ }
30
+
31
+ /*
32
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
33
+
34
+ Redistribution and use in source and binary forms, with or without
35
+ modification, are permitted provided that the following conditions are met:
36
+
37
+ * Redistributions of source code must retain the above copyright
38
+ notice, this list of conditions and the following disclaimer.
39
+ * Redistributions in binary form must reproduce the above copyright
40
+ notice, this list of conditions and the following disclaimer in the
41
+ documentation and/or other materials provided with the distribution.
42
+
43
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
47
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53
+ */
54
+
55
+ const READ = 0x1;
56
+ const WRITE = 0x2;
57
+ const RW = READ | WRITE;
58
+
59
+ /**
60
+ * A Reference represents a single occurrence of an identifier in code.
61
+ * @constructor Reference
62
+ */
63
+ class Reference {
64
+ constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
65
+
66
+ /**
67
+ * Identifier syntax node.
68
+ * @member {espreeIdentifier} Reference#identifier
69
+ */
70
+ this.identifier = ident;
71
+
72
+ /**
73
+ * Reference to the enclosing Scope.
74
+ * @member {Scope} Reference#from
75
+ */
76
+ this.from = scope;
77
+
78
+ /**
79
+ * Whether the reference comes from a dynamic scope (such as 'eval',
80
+ * 'with', etc.), and may be trapped by dynamic scopes.
81
+ * @member {boolean} Reference#tainted
82
+ */
83
+ this.tainted = false;
84
+
85
+ /**
86
+ * The variable this reference is resolved with.
87
+ * @member {Variable} Reference#resolved
88
+ */
89
+ this.resolved = null;
90
+
91
+ /**
92
+ * The read-write mode of the reference. (Value is one of {@link
93
+ * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
94
+ * @member {number} Reference#flag
95
+ * @private
96
+ */
97
+ this.flag = flag;
98
+ if (this.isWrite()) {
99
+
100
+ /**
101
+ * If reference is writeable, this is the tree being written to it.
102
+ * @member {espreeNode} Reference#writeExpr
103
+ */
104
+ this.writeExpr = writeExpr;
105
+
106
+ /**
107
+ * Whether the Reference might refer to a partial value of writeExpr.
108
+ * @member {boolean} Reference#partial
109
+ */
110
+ this.partial = partial;
111
+
112
+ /**
113
+ * Whether the Reference is to write of initialization.
114
+ * @member {boolean} Reference#init
115
+ */
116
+ this.init = init;
117
+ }
118
+ this.__maybeImplicitGlobal = maybeImplicitGlobal;
119
+ }
120
+
121
+ /**
122
+ * Whether the reference is static.
123
+ * @function Reference#isStatic
124
+ * @returns {boolean} static
125
+ */
126
+ isStatic() {
127
+ return !this.tainted && this.resolved && this.resolved.scope.isStatic();
128
+ }
129
+
130
+ /**
131
+ * Whether the reference is writeable.
132
+ * @function Reference#isWrite
133
+ * @returns {boolean} write
134
+ */
135
+ isWrite() {
136
+ return !!(this.flag & Reference.WRITE);
137
+ }
138
+
139
+ /**
140
+ * Whether the reference is readable.
141
+ * @function Reference#isRead
142
+ * @returns {boolean} read
143
+ */
144
+ isRead() {
145
+ return !!(this.flag & Reference.READ);
146
+ }
147
+
148
+ /**
149
+ * Whether the reference is read-only.
150
+ * @function Reference#isReadOnly
151
+ * @returns {boolean} read only
152
+ */
153
+ isReadOnly() {
154
+ return this.flag === Reference.READ;
155
+ }
156
+
157
+ /**
158
+ * Whether the reference is write-only.
159
+ * @function Reference#isWriteOnly
160
+ * @returns {boolean} write only
161
+ */
162
+ isWriteOnly() {
163
+ return this.flag === Reference.WRITE;
164
+ }
165
+
166
+ /**
167
+ * Whether the reference is read-write.
168
+ * @function Reference#isReadWrite
169
+ * @returns {boolean} read write
170
+ */
171
+ isReadWrite() {
172
+ return this.flag === Reference.RW;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * @constant Reference.READ
178
+ * @private
179
+ */
180
+ Reference.READ = READ;
181
+
182
+ /**
183
+ * @constant Reference.WRITE
184
+ * @private
185
+ */
186
+ Reference.WRITE = WRITE;
187
+
188
+ /**
189
+ * @constant Reference.RW
190
+ * @private
191
+ */
192
+ Reference.RW = RW;
193
+
194
+ /* vim: set sw=4 ts=4 et tw=80 : */
195
+
196
+ /*
197
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
198
+
199
+ Redistribution and use in source and binary forms, with or without
200
+ modification, are permitted provided that the following conditions are met:
201
+
202
+ * Redistributions of source code must retain the above copyright
203
+ notice, this list of conditions and the following disclaimer.
204
+ * Redistributions in binary form must reproduce the above copyright
205
+ notice, this list of conditions and the following disclaimer in the
206
+ documentation and/or other materials provided with the distribution.
207
+
208
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
209
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
210
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
212
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
213
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
214
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
215
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
216
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
217
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
218
+ */
219
+
220
+ /**
221
+ * A Variable represents a locally scoped identifier. These include arguments to
222
+ * functions.
223
+ * @constructor Variable
224
+ */
225
+ class Variable {
226
+ constructor(name, scope) {
227
+
228
+ /**
229
+ * The variable name, as given in the source code.
230
+ * @member {string} Variable#name
231
+ */
232
+ this.name = name;
233
+
234
+ /**
235
+ * List of defining occurrences of this variable (like in 'var ...'
236
+ * statements or as parameter), as AST nodes.
237
+ * @member {espree.Identifier[]} Variable#identifiers
238
+ */
239
+ this.identifiers = [];
240
+
241
+ /**
242
+ * List of {@link Reference|references} of this variable (excluding parameter entries)
243
+ * in its defining scope and all nested scopes. For defining
244
+ * occurrences only see {@link Variable#defs}.
245
+ * @member {Reference[]} Variable#references
246
+ */
247
+ this.references = [];
248
+
249
+ /**
250
+ * List of defining occurrences of this variable (like in 'var ...'
251
+ * statements or as parameter), as custom objects.
252
+ * @member {Definition[]} Variable#defs
253
+ */
254
+ this.defs = [];
255
+
256
+ this.tainted = false;
257
+
258
+ /**
259
+ * Whether this is a stack variable.
260
+ * @member {boolean} Variable#stack
261
+ */
262
+ this.stack = true;
263
+
264
+ /**
265
+ * Reference to the enclosing Scope.
266
+ * @member {Scope} Variable#scope
267
+ */
268
+ this.scope = scope;
269
+ }
270
+ }
271
+
272
+ Variable.CatchClause = "CatchClause";
273
+ Variable.Parameter = "Parameter";
274
+ Variable.FunctionName = "FunctionName";
275
+ Variable.ClassName = "ClassName";
276
+ Variable.Variable = "Variable";
277
+ Variable.ImportBinding = "ImportBinding";
278
+ Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
279
+
280
+ /* vim: set sw=4 ts=4 et tw=80 : */
281
+
282
+ /*
283
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
284
+
285
+ Redistribution and use in source and binary forms, with or without
286
+ modification, are permitted provided that the following conditions are met:
287
+
288
+ * Redistributions of source code must retain the above copyright
289
+ notice, this list of conditions and the following disclaimer.
290
+ * Redistributions in binary form must reproduce the above copyright
291
+ notice, this list of conditions and the following disclaimer in the
292
+ documentation and/or other materials provided with the distribution.
293
+
294
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
295
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
296
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
297
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
298
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
299
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
300
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
301
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
302
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
303
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
304
+ */
305
+
306
+ /**
307
+ * @constructor Definition
308
+ */
309
+ class Definition {
310
+ constructor(type, name, node, parent, index, kind) {
311
+
312
+ /**
313
+ * @member {string} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
314
+ */
315
+ this.type = type;
316
+
317
+ /**
318
+ * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
319
+ */
320
+ this.name = name;
321
+
322
+ /**
323
+ * @member {espree.Node} Definition#node - the enclosing node of the identifier.
324
+ */
325
+ this.node = node;
326
+
327
+ /**
328
+ * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
329
+ */
330
+ this.parent = parent;
331
+
332
+ /**
333
+ * @member {number?} Definition#index - the index in the declaration statement.
334
+ */
335
+ this.index = index;
336
+
337
+ /**
338
+ * @member {string?} Definition#kind - the kind of the declaration statement.
339
+ */
340
+ this.kind = kind;
341
+ }
342
+ }
343
+
344
+ /**
345
+ * @constructor ParameterDefinition
346
+ */
347
+ class ParameterDefinition extends Definition {
348
+ constructor(name, node, index, rest) {
349
+ super(Variable.Parameter, name, node, null, index, null);
350
+
351
+ /**
352
+ * Whether the parameter definition is a part of a rest parameter.
353
+ * @member {boolean} ParameterDefinition#rest
354
+ */
355
+ this.rest = rest;
356
+ }
357
+ }
358
+
359
+ /* vim: set sw=4 ts=4 et tw=80 : */
360
+
361
+ /*
362
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
363
+
364
+ Redistribution and use in source and binary forms, with or without
365
+ modification, are permitted provided that the following conditions are met:
366
+
367
+ * Redistributions of source code must retain the above copyright
368
+ notice, this list of conditions and the following disclaimer.
369
+ * Redistributions in binary form must reproduce the above copyright
370
+ notice, this list of conditions and the following disclaimer in the
371
+ documentation and/or other materials provided with the distribution.
372
+
373
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
374
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
375
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
376
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
377
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
378
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
379
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
380
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
381
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
382
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
383
+ */
384
+
385
+ const { Syntax: Syntax$2 } = estraverse__default["default"];
386
+
387
+ /**
388
+ * Test if scope is struct
389
+ * @param {Scope} scope scope
390
+ * @param {Block} block block
391
+ * @param {boolean} isMethodDefinition is method definition
392
+ * @returns {boolean} is strict scope
393
+ */
394
+ function isStrictScope(scope, block, isMethodDefinition) {
395
+ let body;
396
+
397
+ // When upper scope is exists and strict, inner scope is also strict.
398
+ if (scope.upper && scope.upper.isStrict) {
399
+ return true;
400
+ }
401
+
402
+ if (isMethodDefinition) {
403
+ return true;
404
+ }
405
+
406
+ if (scope.type === "class" || scope.type === "module") {
407
+ return true;
408
+ }
409
+
410
+ if (scope.type === "block" || scope.type === "switch") {
411
+ return false;
412
+ }
413
+
414
+ if (scope.type === "function") {
415
+ if (block.type === Syntax$2.ArrowFunctionExpression && block.body.type !== Syntax$2.BlockStatement) {
416
+ return false;
417
+ }
418
+
419
+ if (block.type === Syntax$2.Program) {
420
+ body = block;
421
+ } else {
422
+ body = block.body;
423
+ }
424
+
425
+ if (!body) {
426
+ return false;
427
+ }
428
+ } else if (scope.type === "global") {
429
+ body = block;
430
+ } else {
431
+ return false;
432
+ }
433
+
434
+ // Search for a 'use strict' directive.
435
+ for (let i = 0, iz = body.body.length; i < iz; ++i) {
436
+ const stmt = body.body[i];
437
+
438
+ /*
439
+ * Check if the current statement is a directive.
440
+ * If it isn't, then we're past the directive prologue
441
+ * so stop the search because directives cannot
442
+ * appear after this point.
443
+ *
444
+ * Some parsers set `directive:null` on non-directive
445
+ * statements, so the `typeof` check is safer than
446
+ * checking for property existence.
447
+ */
448
+ if (typeof stmt.directive !== "string") {
449
+ break;
450
+ }
451
+
452
+ if (stmt.directive === "use strict") {
453
+ return true;
454
+ }
455
+ }
456
+
457
+ return false;
458
+ }
459
+
460
+ /**
461
+ * Register scope
462
+ * @param {ScopeManager} scopeManager scope manager
463
+ * @param {Scope} scope scope
464
+ * @returns {void}
465
+ */
466
+ function registerScope(scopeManager, scope) {
467
+ scopeManager.scopes.push(scope);
468
+
469
+ const scopes = scopeManager.__nodeToScope.get(scope.block);
470
+
471
+ if (scopes) {
472
+ scopes.push(scope);
473
+ } else {
474
+ scopeManager.__nodeToScope.set(scope.block, [scope]);
475
+ }
476
+ }
477
+
478
+ /**
479
+ * Should be statically
480
+ * @param {Object} def def
481
+ * @returns {boolean} should be statically
482
+ */
483
+ function shouldBeStatically(def) {
484
+ return (
485
+ (def.type === Variable.ClassName) ||
486
+ (def.type === Variable.Variable && def.parent.kind !== "var")
487
+ );
488
+ }
489
+
490
+ /**
491
+ * @constructor Scope
492
+ */
493
+ class Scope {
494
+ constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
495
+
496
+ /**
497
+ * One of "global", "module", "function", "function-expression-name", "block", "switch", "catch", "with", "for",
498
+ * "class", "class-field-initializer", "class-static-block".
499
+ * @member {string} Scope#type
500
+ */
501
+ this.type = type;
502
+
503
+ /**
504
+ * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
505
+ * : Variable }</code>.
506
+ * @member {Map} Scope#set
507
+ */
508
+ this.set = new Map();
509
+
510
+ /**
511
+ * The tainted variables of this scope, as <code>{ Variable.name :
512
+ * boolean }</code>.
513
+ * @member {Map} Scope#taints
514
+ */
515
+ this.taints = new Map();
516
+
517
+ /**
518
+ * Generally, through the lexical scoping of JS you can always know
519
+ * which variable an identifier in the source code refers to. There are
520
+ * a few exceptions to this rule. With 'global' and 'with' scopes you
521
+ * can only decide at runtime which variable a reference refers to.
522
+ * Moreover, if 'eval()' is used in a scope, it might introduce new
523
+ * bindings in this or its parent scopes.
524
+ * All those scopes are considered 'dynamic'.
525
+ * @member {boolean} Scope#dynamic
526
+ */
527
+ this.dynamic = this.type === "global" || this.type === "with";
528
+
529
+ /**
530
+ * A reference to the scope-defining syntax node.
531
+ * @member {espree.Node} Scope#block
532
+ */
533
+ this.block = block;
534
+
535
+ /**
536
+ * The {@link Reference|references} that are not resolved with this scope.
537
+ * @member {Reference[]} Scope#through
538
+ */
539
+ this.through = [];
540
+
541
+ /**
542
+ * The scoped {@link Variable}s of this scope. In the case of a
543
+ * 'function' scope this includes the automatic argument <em>arguments</em> as
544
+ * its first element, as well as all further formal arguments.
545
+ * @member {Variable[]} Scope#variables
546
+ */
547
+ this.variables = [];
548
+
549
+ /**
550
+ * Any variable {@link Reference|reference} found in this scope. This
551
+ * includes occurrences of local variables as well as variables from
552
+ * parent scopes (including the global scope). For local variables
553
+ * this also includes defining occurrences (like in a 'var' statement).
554
+ * In a 'function' scope this does not include the occurrences of the
555
+ * formal parameter in the parameter list.
556
+ * @member {Reference[]} Scope#references
557
+ */
558
+ this.references = [];
559
+
560
+ /**
561
+ * For 'global' and 'function' scopes, this is a self-reference. For
562
+ * other scope types this is the <em>variableScope</em> value of the
563
+ * parent scope.
564
+ * @member {Scope} Scope#variableScope
565
+ */
566
+ this.variableScope =
567
+ this.type === "global" ||
568
+ this.type === "module" ||
569
+ this.type === "function" ||
570
+ this.type === "class-field-initializer" ||
571
+ this.type === "class-static-block"
572
+ ? this
573
+ : upperScope.variableScope;
574
+
575
+ /**
576
+ * Whether this scope is created by a FunctionExpression.
577
+ * @member {boolean} Scope#functionExpressionScope
578
+ */
579
+ this.functionExpressionScope = false;
580
+
581
+ /**
582
+ * Whether this is a scope that contains an 'eval()' invocation.
583
+ * @member {boolean} Scope#directCallToEvalScope
584
+ */
585
+ this.directCallToEvalScope = false;
586
+
587
+ /**
588
+ * @member {boolean} Scope#thisFound
589
+ */
590
+ this.thisFound = false;
591
+
592
+ this.__left = [];
593
+
594
+ /**
595
+ * Reference to the parent {@link Scope|scope}.
596
+ * @member {Scope} Scope#upper
597
+ */
598
+ this.upper = upperScope;
599
+
600
+ /**
601
+ * Whether 'use strict' is in effect in this scope.
602
+ * @member {boolean} Scope#isStrict
603
+ */
604
+ this.isStrict = scopeManager.isStrictModeSupported()
605
+ ? isStrictScope(this, block, isMethodDefinition)
606
+ : false;
607
+
608
+ /**
609
+ * List of nested {@link Scope}s.
610
+ * @member {Scope[]} Scope#childScopes
611
+ */
612
+ this.childScopes = [];
613
+ if (this.upper) {
614
+ this.upper.childScopes.push(this);
615
+ }
616
+
617
+ this.__declaredVariables = scopeManager.__declaredVariables;
618
+
619
+ registerScope(scopeManager, this);
620
+ }
621
+
622
+ __shouldStaticallyClose(scopeManager) {
623
+ return (!this.dynamic || scopeManager.__isOptimistic());
624
+ }
625
+
626
+ __shouldStaticallyCloseForGlobal(ref) {
627
+
628
+ // On global scope, let/const/class declarations should be resolved statically.
629
+ const name = ref.identifier.name;
630
+
631
+ if (!this.set.has(name)) {
632
+ return false;
633
+ }
634
+
635
+ const variable = this.set.get(name);
636
+ const defs = variable.defs;
637
+
638
+ return defs.length > 0 && defs.every(shouldBeStatically);
639
+ }
640
+
641
+ __staticCloseRef(ref) {
642
+ if (!this.__resolve(ref)) {
643
+ this.__delegateToUpperScope(ref);
644
+ }
645
+ }
646
+
647
+ __dynamicCloseRef(ref) {
648
+
649
+ // notify all names are through to global
650
+ let current = this;
651
+
652
+ do {
653
+ current.through.push(ref);
654
+ current = current.upper;
655
+ } while (current);
656
+ }
657
+
658
+ __globalCloseRef(ref) {
659
+
660
+ // let/const/class declarations should be resolved statically.
661
+ // others should be resolved dynamically.
662
+ if (this.__shouldStaticallyCloseForGlobal(ref)) {
663
+ this.__staticCloseRef(ref);
664
+ } else {
665
+ this.__dynamicCloseRef(ref);
666
+ }
667
+ }
668
+
669
+ __close(scopeManager) {
670
+ let closeRef;
671
+
672
+ if (this.__shouldStaticallyClose(scopeManager)) {
673
+ closeRef = this.__staticCloseRef;
674
+ } else if (this.type !== "global") {
675
+ closeRef = this.__dynamicCloseRef;
676
+ } else {
677
+ closeRef = this.__globalCloseRef;
678
+ }
679
+
680
+ // Try Resolving all references in this scope.
681
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
682
+ const ref = this.__left[i];
683
+
684
+ closeRef.call(this, ref);
685
+ }
686
+ this.__left = null;
687
+
688
+ return this.upper;
689
+ }
690
+
691
+ // To override by function scopes.
692
+ // References in default parameters isn't resolved to variables which are in their function body.
693
+ __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
694
+ return true;
695
+ }
696
+
697
+ __resolve(ref) {
698
+ const name = ref.identifier.name;
699
+
700
+ if (!this.set.has(name)) {
701
+ return false;
702
+ }
703
+ const variable = this.set.get(name);
704
+
705
+ if (!this.__isValidResolution(ref, variable)) {
706
+ return false;
707
+ }
708
+ variable.references.push(ref);
709
+ variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
710
+ if (ref.tainted) {
711
+ variable.tainted = true;
712
+ this.taints.set(variable.name, true);
713
+ }
714
+ ref.resolved = variable;
715
+
716
+ return true;
717
+ }
718
+
719
+ __delegateToUpperScope(ref) {
720
+ if (this.upper) {
721
+ this.upper.__left.push(ref);
722
+ }
723
+ this.through.push(ref);
724
+ }
725
+
726
+ __addDeclaredVariablesOfNode(variable, node) {
727
+ if (node === null || node === void 0) {
728
+ return;
729
+ }
730
+
731
+ let variables = this.__declaredVariables.get(node);
732
+
733
+ if (variables === null || variables === void 0) {
734
+ variables = [];
735
+ this.__declaredVariables.set(node, variables);
736
+ }
737
+ if (!variables.includes(variable)) {
738
+ variables.push(variable);
739
+ }
740
+ }
741
+
742
+ __defineGeneric(name, set, variables, node, def) {
743
+ let variable;
744
+
745
+ variable = set.get(name);
746
+ if (!variable) {
747
+ variable = new Variable(name, this);
748
+ set.set(name, variable);
749
+ variables.push(variable);
750
+ }
751
+
752
+ if (def) {
753
+ variable.defs.push(def);
754
+ this.__addDeclaredVariablesOfNode(variable, def.node);
755
+ this.__addDeclaredVariablesOfNode(variable, def.parent);
756
+ }
757
+ if (node) {
758
+ variable.identifiers.push(node);
759
+ }
760
+ }
761
+
762
+ __define(node, def) {
763
+ if (node && node.type === Syntax$2.Identifier) {
764
+ this.__defineGeneric(
765
+ node.name,
766
+ this.set,
767
+ this.variables,
768
+ node,
769
+ def
770
+ );
771
+ }
772
+ }
773
+
774
+ __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
775
+
776
+ // because Array element may be null
777
+ if (!node || (node.type !== Syntax$2.Identifier && node.type !== "JSXIdentifier")) {
778
+ return;
779
+ }
780
+
781
+ // Specially handle like `this`.
782
+ if (node.name === "super") {
783
+ return;
784
+ }
785
+
786
+ const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
787
+
788
+ this.references.push(ref);
789
+ this.__left.push(ref);
790
+ }
791
+
792
+ __detectEval() {
793
+ let current = this;
794
+
795
+ this.directCallToEvalScope = true;
796
+ do {
797
+ current.dynamic = true;
798
+ current = current.upper;
799
+ } while (current);
800
+ }
801
+
802
+ __detectThis() {
803
+ this.thisFound = true;
804
+ }
805
+
806
+ __isClosed() {
807
+ return this.__left === null;
808
+ }
809
+
810
+ /**
811
+ * returns resolved {Reference}
812
+ * @function Scope#resolve
813
+ * @param {Espree.Identifier} ident identifier to be resolved.
814
+ * @returns {Reference} reference
815
+ */
816
+ resolve(ident) {
817
+ let ref, i, iz;
818
+
819
+ assert(this.__isClosed(), "Scope should be closed.");
820
+ assert(ident.type === Syntax$2.Identifier, "Target should be identifier.");
821
+ for (i = 0, iz = this.references.length; i < iz; ++i) {
822
+ ref = this.references[i];
823
+ if (ref.identifier === ident) {
824
+ return ref;
825
+ }
826
+ }
827
+ return null;
828
+ }
829
+
830
+ /**
831
+ * returns this scope is static
832
+ * @function Scope#isStatic
833
+ * @returns {boolean} static
834
+ */
835
+ isStatic() {
836
+ return !this.dynamic;
837
+ }
838
+
839
+ /**
840
+ * returns this scope has materialized arguments
841
+ * @function Scope#isArgumentsMaterialized
842
+ * @returns {boolean} arguemnts materialized
843
+ */
844
+ isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
845
+ return true;
846
+ }
847
+
848
+ /**
849
+ * returns this scope has materialized `this` reference
850
+ * @function Scope#isThisMaterialized
851
+ * @returns {boolean} this materialized
852
+ */
853
+ isThisMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
854
+ return true;
855
+ }
856
+
857
+ isUsedName(name) {
858
+ if (this.set.has(name)) {
859
+ return true;
860
+ }
861
+ for (let i = 0, iz = this.through.length; i < iz; ++i) {
862
+ if (this.through[i].identifier.name === name) {
863
+ return true;
864
+ }
865
+ }
866
+ return false;
867
+ }
868
+ }
869
+
870
+ /**
871
+ * Global scope.
872
+ */
873
+ class GlobalScope extends Scope {
874
+ constructor(scopeManager, block) {
875
+ super(scopeManager, "global", null, block, false);
876
+ this.implicit = {
877
+ set: new Map(),
878
+ variables: [],
879
+
880
+ /**
881
+ * List of {@link Reference}s that are left to be resolved (i.e. which
882
+ * need to be linked to the variable they refer to).
883
+ * @member {Reference[]} Scope#implicit#left
884
+ */
885
+ left: []
886
+ };
887
+ }
888
+
889
+ __close(scopeManager) {
890
+ const implicit = [];
891
+
892
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
893
+ const ref = this.__left[i];
894
+
895
+ if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
896
+ implicit.push(ref.__maybeImplicitGlobal);
897
+ }
898
+ }
899
+
900
+ // create an implicit global variable from assignment expression
901
+ for (let i = 0, iz = implicit.length; i < iz; ++i) {
902
+ const info = implicit[i];
903
+
904
+ this.__defineImplicit(info.pattern,
905
+ new Definition(
906
+ Variable.ImplicitGlobalVariable,
907
+ info.pattern,
908
+ info.node,
909
+ null,
910
+ null,
911
+ null
912
+ ));
913
+
914
+ }
915
+
916
+ this.implicit.left = this.__left;
917
+
918
+ return super.__close(scopeManager);
919
+ }
920
+
921
+ __defineImplicit(node, def) {
922
+ if (node && node.type === Syntax$2.Identifier) {
923
+ this.__defineGeneric(
924
+ node.name,
925
+ this.implicit.set,
926
+ this.implicit.variables,
927
+ node,
928
+ def
929
+ );
930
+ }
931
+ }
932
+ }
933
+
934
+ /**
935
+ * Module scope.
936
+ */
937
+ class ModuleScope extends Scope {
938
+ constructor(scopeManager, upperScope, block) {
939
+ super(scopeManager, "module", upperScope, block, false);
940
+ }
941
+ }
942
+
943
+ /**
944
+ * Function expression name scope.
945
+ */
946
+ class FunctionExpressionNameScope extends Scope {
947
+ constructor(scopeManager, upperScope, block) {
948
+ super(scopeManager, "function-expression-name", upperScope, block, false);
949
+ this.__define(block.id,
950
+ new Definition(
951
+ Variable.FunctionName,
952
+ block.id,
953
+ block,
954
+ null,
955
+ null,
956
+ null
957
+ ));
958
+ this.functionExpressionScope = true;
959
+ }
960
+ }
961
+
962
+ /**
963
+ * Catch scope.
964
+ */
965
+ class CatchScope extends Scope {
966
+ constructor(scopeManager, upperScope, block) {
967
+ super(scopeManager, "catch", upperScope, block, false);
968
+ }
969
+ }
970
+
971
+ /**
972
+ * With statement scope.
973
+ */
974
+ class WithScope extends Scope {
975
+ constructor(scopeManager, upperScope, block) {
976
+ super(scopeManager, "with", upperScope, block, false);
977
+ }
978
+
979
+ __close(scopeManager) {
980
+ if (this.__shouldStaticallyClose(scopeManager)) {
981
+ return super.__close(scopeManager);
982
+ }
983
+
984
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
985
+ const ref = this.__left[i];
986
+
987
+ ref.tainted = true;
988
+ this.__delegateToUpperScope(ref);
989
+ }
990
+ this.__left = null;
991
+
992
+ return this.upper;
993
+ }
994
+ }
995
+
996
+ /**
997
+ * Block scope.
998
+ */
999
+ class BlockScope extends Scope {
1000
+ constructor(scopeManager, upperScope, block) {
1001
+ super(scopeManager, "block", upperScope, block, false);
1002
+ }
1003
+ }
1004
+
1005
+ /**
1006
+ * Switch scope.
1007
+ */
1008
+ class SwitchScope extends Scope {
1009
+ constructor(scopeManager, upperScope, block) {
1010
+ super(scopeManager, "switch", upperScope, block, false);
1011
+ }
1012
+ }
1013
+
1014
+ /**
1015
+ * Function scope.
1016
+ */
1017
+ class FunctionScope extends Scope {
1018
+ constructor(scopeManager, upperScope, block, isMethodDefinition) {
1019
+ super(scopeManager, "function", upperScope, block, isMethodDefinition);
1020
+
1021
+ // section 9.2.13, FunctionDeclarationInstantiation.
1022
+ // NOTE Arrow functions never have an arguments objects.
1023
+ if (this.block.type !== Syntax$2.ArrowFunctionExpression) {
1024
+ this.__defineArguments();
1025
+ }
1026
+ }
1027
+
1028
+ isArgumentsMaterialized() {
1029
+
1030
+ // TODO(Constellation)
1031
+ // We can more aggressive on this condition like this.
1032
+ //
1033
+ // function t() {
1034
+ // // arguments of t is always hidden.
1035
+ // function arguments() {
1036
+ // }
1037
+ // }
1038
+ if (this.block.type === Syntax$2.ArrowFunctionExpression) {
1039
+ return false;
1040
+ }
1041
+
1042
+ if (!this.isStatic()) {
1043
+ return true;
1044
+ }
1045
+
1046
+ const variable = this.set.get("arguments");
1047
+
1048
+ assert(variable, "Always have arguments variable.");
1049
+ return variable.tainted || variable.references.length !== 0;
1050
+ }
1051
+
1052
+ isThisMaterialized() {
1053
+ if (!this.isStatic()) {
1054
+ return true;
1055
+ }
1056
+ return this.thisFound;
1057
+ }
1058
+
1059
+ __defineArguments() {
1060
+ this.__defineGeneric(
1061
+ "arguments",
1062
+ this.set,
1063
+ this.variables,
1064
+ null,
1065
+ null
1066
+ );
1067
+ this.taints.set("arguments", true);
1068
+ }
1069
+
1070
+ // References in default parameters isn't resolved to variables which are in their function body.
1071
+ // const x = 1
1072
+ // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
1073
+ // const x = 2
1074
+ // console.log(a)
1075
+ // }
1076
+ __isValidResolution(ref, variable) {
1077
+
1078
+ // If `options.nodejsScope` is true, `this.block` becomes a Program node.
1079
+ if (this.block.type === "Program") {
1080
+ return true;
1081
+ }
1082
+
1083
+ const bodyStart = this.block.body.range[0];
1084
+
1085
+ // It's invalid resolution in the following case:
1086
+ return !(
1087
+ variable.scope === this &&
1088
+ ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
1089
+ variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
1090
+ );
1091
+ }
1092
+ }
1093
+
1094
+ /**
1095
+ * Scope of for, for-in, and for-of statements.
1096
+ */
1097
+ class ForScope extends Scope {
1098
+ constructor(scopeManager, upperScope, block) {
1099
+ super(scopeManager, "for", upperScope, block, false);
1100
+ }
1101
+ }
1102
+
1103
+ /**
1104
+ * Class scope.
1105
+ */
1106
+ class ClassScope extends Scope {
1107
+ constructor(scopeManager, upperScope, block) {
1108
+ super(scopeManager, "class", upperScope, block, false);
1109
+ }
1110
+ }
1111
+
1112
+ /**
1113
+ * Class field initializer scope.
1114
+ */
1115
+ class ClassFieldInitializerScope extends Scope {
1116
+ constructor(scopeManager, upperScope, block) {
1117
+ super(scopeManager, "class-field-initializer", upperScope, block, true);
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Class static block scope.
1123
+ */
1124
+ class ClassStaticBlockScope extends Scope {
1125
+ constructor(scopeManager, upperScope, block) {
1126
+ super(scopeManager, "class-static-block", upperScope, block, true);
1127
+ }
1128
+ }
1129
+
1130
+ /* vim: set sw=4 ts=4 et tw=80 : */
1131
+
1132
+ /*
1133
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
1134
+
1135
+ Redistribution and use in source and binary forms, with or without
1136
+ modification, are permitted provided that the following conditions are met:
1137
+
1138
+ * Redistributions of source code must retain the above copyright
1139
+ notice, this list of conditions and the following disclaimer.
1140
+ * Redistributions in binary form must reproduce the above copyright
1141
+ notice, this list of conditions and the following disclaimer in the
1142
+ documentation and/or other materials provided with the distribution.
1143
+
1144
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1145
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1146
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1147
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1148
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1149
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1150
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1151
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1152
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1153
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1154
+ */
1155
+
1156
+ /**
1157
+ * @constructor ScopeManager
1158
+ */
1159
+ class ScopeManager {
1160
+ constructor(options) {
1161
+ this.scopes = [];
1162
+ this.globalScope = null;
1163
+ this.__nodeToScope = new WeakMap();
1164
+ this.__currentScope = null;
1165
+ this.__options = options;
1166
+ this.__declaredVariables = new WeakMap();
1167
+ }
1168
+
1169
+ __isOptimistic() {
1170
+ return this.__options.optimistic;
1171
+ }
1172
+
1173
+ __ignoreEval() {
1174
+ return this.__options.ignoreEval;
1175
+ }
1176
+
1177
+ __isJSXEnabled() {
1178
+ return this.__options.jsx === true;
1179
+ }
1180
+
1181
+ isGlobalReturn() {
1182
+ return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
1183
+ }
1184
+
1185
+ isModule() {
1186
+ return this.__options.sourceType === "module";
1187
+ }
1188
+
1189
+ isImpliedStrict() {
1190
+ return this.__options.impliedStrict;
1191
+ }
1192
+
1193
+ isStrictModeSupported() {
1194
+ return this.__options.ecmaVersion >= 5;
1195
+ }
1196
+
1197
+ // Returns appropriate scope for this node.
1198
+ __get(node) {
1199
+ return this.__nodeToScope.get(node);
1200
+ }
1201
+
1202
+ /**
1203
+ * Get variables that are declared by the node.
1204
+ *
1205
+ * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
1206
+ * If the node declares nothing, this method returns an empty array.
1207
+ * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
1208
+ * @param {Espree.Node} node a node to get.
1209
+ * @returns {Variable[]} variables that declared by the node.
1210
+ */
1211
+ getDeclaredVariables(node) {
1212
+ return this.__declaredVariables.get(node) || [];
1213
+ }
1214
+
1215
+ /**
1216
+ * acquire scope from node.
1217
+ * @function ScopeManager#acquire
1218
+ * @param {Espree.Node} node node for the acquired scope.
1219
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
1220
+ * @returns {Scope?} Scope from node
1221
+ */
1222
+ acquire(node, inner) {
1223
+
1224
+ /**
1225
+ * predicate
1226
+ * @param {Scope} testScope scope to test
1227
+ * @returns {boolean} predicate
1228
+ */
1229
+ function predicate(testScope) {
1230
+ if (testScope.type === "function" && testScope.functionExpressionScope) {
1231
+ return false;
1232
+ }
1233
+ return true;
1234
+ }
1235
+
1236
+ const scopes = this.__get(node);
1237
+
1238
+ if (!scopes || scopes.length === 0) {
1239
+ return null;
1240
+ }
1241
+
1242
+ // Heuristic selection from all scopes.
1243
+ // If you would like to get all scopes, please use ScopeManager#acquireAll.
1244
+ if (scopes.length === 1) {
1245
+ return scopes[0];
1246
+ }
1247
+
1248
+ if (inner) {
1249
+ for (let i = scopes.length - 1; i >= 0; --i) {
1250
+ const scope = scopes[i];
1251
+
1252
+ if (predicate(scope)) {
1253
+ return scope;
1254
+ }
1255
+ }
1256
+ } else {
1257
+ for (let i = 0, iz = scopes.length; i < iz; ++i) {
1258
+ const scope = scopes[i];
1259
+
1260
+ if (predicate(scope)) {
1261
+ return scope;
1262
+ }
1263
+ }
1264
+ }
1265
+
1266
+ return null;
1267
+ }
1268
+
1269
+ /**
1270
+ * acquire all scopes from node.
1271
+ * @function ScopeManager#acquireAll
1272
+ * @param {Espree.Node} node node for the acquired scope.
1273
+ * @returns {Scopes?} Scope array
1274
+ */
1275
+ acquireAll(node) {
1276
+ return this.__get(node);
1277
+ }
1278
+
1279
+ /**
1280
+ * release the node.
1281
+ * @function ScopeManager#release
1282
+ * @param {Espree.Node} node releasing node.
1283
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
1284
+ * @returns {Scope?} upper scope for the node.
1285
+ */
1286
+ release(node, inner) {
1287
+ const scopes = this.__get(node);
1288
+
1289
+ if (scopes && scopes.length) {
1290
+ const scope = scopes[0].upper;
1291
+
1292
+ if (!scope) {
1293
+ return null;
1294
+ }
1295
+ return this.acquire(scope.block, inner);
1296
+ }
1297
+ return null;
1298
+ }
1299
+
1300
+ attach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
1301
+
1302
+ detach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
1303
+
1304
+ __nestScope(scope) {
1305
+ if (scope instanceof GlobalScope) {
1306
+ assert(this.__currentScope === null);
1307
+ this.globalScope = scope;
1308
+ }
1309
+ this.__currentScope = scope;
1310
+ return scope;
1311
+ }
1312
+
1313
+ __nestGlobalScope(node) {
1314
+ return this.__nestScope(new GlobalScope(this, node));
1315
+ }
1316
+
1317
+ __nestBlockScope(node) {
1318
+ return this.__nestScope(new BlockScope(this, this.__currentScope, node));
1319
+ }
1320
+
1321
+ __nestFunctionScope(node, isMethodDefinition) {
1322
+ return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
1323
+ }
1324
+
1325
+ __nestForScope(node) {
1326
+ return this.__nestScope(new ForScope(this, this.__currentScope, node));
1327
+ }
1328
+
1329
+ __nestCatchScope(node) {
1330
+ return this.__nestScope(new CatchScope(this, this.__currentScope, node));
1331
+ }
1332
+
1333
+ __nestWithScope(node) {
1334
+ return this.__nestScope(new WithScope(this, this.__currentScope, node));
1335
+ }
1336
+
1337
+ __nestClassScope(node) {
1338
+ return this.__nestScope(new ClassScope(this, this.__currentScope, node));
1339
+ }
1340
+
1341
+ __nestClassFieldInitializerScope(node) {
1342
+ return this.__nestScope(new ClassFieldInitializerScope(this, this.__currentScope, node));
1343
+ }
1344
+
1345
+ __nestClassStaticBlockScope(node) {
1346
+ return this.__nestScope(new ClassStaticBlockScope(this, this.__currentScope, node));
1347
+ }
1348
+
1349
+ __nestSwitchScope(node) {
1350
+ return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
1351
+ }
1352
+
1353
+ __nestModuleScope(node) {
1354
+ return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
1355
+ }
1356
+
1357
+ __nestFunctionExpressionNameScope(node) {
1358
+ return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
1359
+ }
1360
+
1361
+ __isES6() {
1362
+ return this.__options.ecmaVersion >= 6;
1363
+ }
1364
+ }
1365
+
1366
+ /* vim: set sw=4 ts=4 et tw=80 : */
1367
+
1368
+ /*
1369
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
1370
+
1371
+ Redistribution and use in source and binary forms, with or without
1372
+ modification, are permitted provided that the following conditions are met:
1373
+
1374
+ * Redistributions of source code must retain the above copyright
1375
+ notice, this list of conditions and the following disclaimer.
1376
+ * Redistributions in binary form must reproduce the above copyright
1377
+ notice, this list of conditions and the following disclaimer in the
1378
+ documentation and/or other materials provided with the distribution.
1379
+
1380
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1381
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1382
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1383
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1384
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1385
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1386
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1387
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1388
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1389
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1390
+ */
1391
+
1392
+ const { Syntax: Syntax$1 } = estraverse__default["default"];
1393
+
1394
+ /**
1395
+ * Get last array element
1396
+ * @param {Array} xs array
1397
+ * @returns {any} Last elment
1398
+ */
1399
+ function getLast(xs) {
1400
+ return xs.at(-1) || null;
1401
+ }
1402
+
1403
+ /**
1404
+ * Visitor for destructuring patterns.
1405
+ */
1406
+ class PatternVisitor extends esrecurse__default["default"].Visitor {
1407
+ static isPattern(node) {
1408
+ const nodeType = node.type;
1409
+
1410
+ return (
1411
+ nodeType === Syntax$1.Identifier ||
1412
+ nodeType === Syntax$1.ObjectPattern ||
1413
+ nodeType === Syntax$1.ArrayPattern ||
1414
+ nodeType === Syntax$1.SpreadElement ||
1415
+ nodeType === Syntax$1.RestElement ||
1416
+ nodeType === Syntax$1.AssignmentPattern
1417
+ );
1418
+ }
1419
+
1420
+ constructor(options, rootPattern, callback) {
1421
+ super(null, options);
1422
+ this.rootPattern = rootPattern;
1423
+ this.callback = callback;
1424
+ this.assignments = [];
1425
+ this.rightHandNodes = [];
1426
+ this.restElements = [];
1427
+ }
1428
+
1429
+ Identifier(pattern) {
1430
+ const lastRestElement = getLast(this.restElements);
1431
+
1432
+ this.callback(pattern, {
1433
+ topLevel: pattern === this.rootPattern,
1434
+ rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern,
1435
+ assignments: this.assignments
1436
+ });
1437
+ }
1438
+
1439
+ Property(property) {
1440
+
1441
+ // Computed property's key is a right hand node.
1442
+ if (property.computed) {
1443
+ this.rightHandNodes.push(property.key);
1444
+ }
1445
+
1446
+ // If it's shorthand, its key is same as its value.
1447
+ // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
1448
+ // If it's not shorthand, the name of new variable is its value's.
1449
+ this.visit(property.value);
1450
+ }
1451
+
1452
+ ArrayPattern(pattern) {
1453
+ for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
1454
+ const element = pattern.elements[i];
1455
+
1456
+ this.visit(element);
1457
+ }
1458
+ }
1459
+
1460
+ AssignmentPattern(pattern) {
1461
+ this.assignments.push(pattern);
1462
+ this.visit(pattern.left);
1463
+ this.rightHandNodes.push(pattern.right);
1464
+ this.assignments.pop();
1465
+ }
1466
+
1467
+ RestElement(pattern) {
1468
+ this.restElements.push(pattern);
1469
+ this.visit(pattern.argument);
1470
+ this.restElements.pop();
1471
+ }
1472
+
1473
+ MemberExpression(node) {
1474
+
1475
+ // Computed property's key is a right hand node.
1476
+ if (node.computed) {
1477
+ this.rightHandNodes.push(node.property);
1478
+ }
1479
+
1480
+ // the object is only read, write to its property.
1481
+ this.rightHandNodes.push(node.object);
1482
+ }
1483
+
1484
+ //
1485
+ // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
1486
+ // By spec, LeftHandSideExpression is Pattern or MemberExpression.
1487
+ // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
1488
+ // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
1489
+ //
1490
+
1491
+ SpreadElement(node) {
1492
+ this.visit(node.argument);
1493
+ }
1494
+
1495
+ ArrayExpression(node) {
1496
+ node.elements.forEach(this.visit, this);
1497
+ }
1498
+
1499
+ AssignmentExpression(node) {
1500
+ this.assignments.push(node);
1501
+ this.visit(node.left);
1502
+ this.rightHandNodes.push(node.right);
1503
+ this.assignments.pop();
1504
+ }
1505
+
1506
+ CallExpression(node) {
1507
+
1508
+ // arguments are right hand nodes.
1509
+ node.arguments.forEach(a => {
1510
+ this.rightHandNodes.push(a);
1511
+ });
1512
+ this.visit(node.callee);
1513
+ }
1514
+ }
1515
+
1516
+ /* vim: set sw=4 ts=4 et tw=80 : */
1517
+
1518
+ /*
1519
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
1520
+
1521
+ Redistribution and use in source and binary forms, with or without
1522
+ modification, are permitted provided that the following conditions are met:
1523
+
1524
+ * Redistributions of source code must retain the above copyright
1525
+ notice, this list of conditions and the following disclaimer.
1526
+ * Redistributions in binary form must reproduce the above copyright
1527
+ notice, this list of conditions and the following disclaimer in the
1528
+ documentation and/or other materials provided with the distribution.
1529
+
1530
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1531
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1532
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1533
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1534
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1535
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1536
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1537
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1538
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1539
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1540
+ */
1541
+
1542
+ const { Syntax } = estraverse__default["default"];
1543
+
1544
+ /**
1545
+ * Traverse identifier in pattern
1546
+ * @param {Object} options options
1547
+ * @param {pattern} rootPattern root pattern
1548
+ * @param {Refencer} referencer referencer
1549
+ * @param {callback} callback callback
1550
+ * @returns {void}
1551
+ */
1552
+ function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
1553
+
1554
+ // Call the callback at left hand identifier nodes, and Collect right hand nodes.
1555
+ const visitor = new PatternVisitor(options, rootPattern, callback);
1556
+
1557
+ visitor.visit(rootPattern);
1558
+
1559
+ // Process the right hand nodes recursively.
1560
+ if (referencer !== null && referencer !== void 0) {
1561
+ visitor.rightHandNodes.forEach(referencer.visit, referencer);
1562
+ }
1563
+ }
1564
+
1565
+ // Importing ImportDeclaration.
1566
+ // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
1567
+ // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
1568
+ // FIXME: Now, we don't create module environment, because the context is
1569
+ // implementation dependent.
1570
+
1571
+ /**
1572
+ * Visitor for import specifiers.
1573
+ */
1574
+ class Importer extends esrecurse__default["default"].Visitor {
1575
+ constructor(declaration, referencer) {
1576
+ super(null, referencer.options);
1577
+ this.declaration = declaration;
1578
+ this.referencer = referencer;
1579
+ }
1580
+
1581
+ visitImport(id, specifier) {
1582
+ this.referencer.visitPattern(id, pattern => {
1583
+ this.referencer.currentScope().__define(pattern,
1584
+ new Definition(
1585
+ Variable.ImportBinding,
1586
+ pattern,
1587
+ specifier,
1588
+ this.declaration,
1589
+ null,
1590
+ null
1591
+ ));
1592
+ });
1593
+ }
1594
+
1595
+ ImportNamespaceSpecifier(node) {
1596
+ const local = (node.local || node.id);
1597
+
1598
+ if (local) {
1599
+ this.visitImport(local, node);
1600
+ }
1601
+ }
1602
+
1603
+ ImportDefaultSpecifier(node) {
1604
+ const local = (node.local || node.id);
1605
+
1606
+ this.visitImport(local, node);
1607
+ }
1608
+
1609
+ ImportSpecifier(node) {
1610
+ const local = (node.local || node.id);
1611
+
1612
+ if (node.name) {
1613
+ this.visitImport(node.name, node);
1614
+ } else {
1615
+ this.visitImport(local, node);
1616
+ }
1617
+ }
1618
+ }
1619
+
1620
+ /**
1621
+ * Referencing variables and creating bindings.
1622
+ */
1623
+ class Referencer extends esrecurse__default["default"].Visitor {
1624
+ constructor(options, scopeManager) {
1625
+ super(null, options);
1626
+ this.options = options;
1627
+ this.scopeManager = scopeManager;
1628
+ this.parent = null;
1629
+ this.isInnerMethodDefinition = false;
1630
+ }
1631
+
1632
+ currentScope() {
1633
+ return this.scopeManager.__currentScope;
1634
+ }
1635
+
1636
+ close(node) {
1637
+ while (this.currentScope() && node === this.currentScope().block) {
1638
+ this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
1639
+ }
1640
+ }
1641
+
1642
+ pushInnerMethodDefinition(isInnerMethodDefinition) {
1643
+ const previous = this.isInnerMethodDefinition;
1644
+
1645
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
1646
+ return previous;
1647
+ }
1648
+
1649
+ popInnerMethodDefinition(isInnerMethodDefinition) {
1650
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
1651
+ }
1652
+
1653
+ referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
1654
+ const scope = this.currentScope();
1655
+
1656
+ assignments.forEach(assignment => {
1657
+ scope.__referencing(
1658
+ pattern,
1659
+ Reference.WRITE,
1660
+ assignment.right,
1661
+ maybeImplicitGlobal,
1662
+ pattern !== assignment.left,
1663
+ init
1664
+ );
1665
+ });
1666
+ }
1667
+
1668
+ visitPattern(node, options, callback) {
1669
+ let visitPatternOptions = options;
1670
+ let visitPatternCallback = callback;
1671
+
1672
+ if (typeof options === "function") {
1673
+ visitPatternCallback = options;
1674
+ visitPatternOptions = { processRightHandNodes: false };
1675
+ }
1676
+
1677
+ traverseIdentifierInPattern(
1678
+ this.options,
1679
+ node,
1680
+ visitPatternOptions.processRightHandNodes ? this : null,
1681
+ visitPatternCallback
1682
+ );
1683
+ }
1684
+
1685
+ visitFunction(node) {
1686
+ let i, iz;
1687
+
1688
+ // FunctionDeclaration name is defined in upper scope
1689
+ // NOTE: Not referring variableScope. It is intended.
1690
+ // Since
1691
+ // in ES5, FunctionDeclaration should be in FunctionBody.
1692
+ // in ES6, FunctionDeclaration should be block scoped.
1693
+
1694
+ if (node.type === Syntax.FunctionDeclaration) {
1695
+
1696
+ // id is defined in upper scope
1697
+ this.currentScope().__define(node.id,
1698
+ new Definition(
1699
+ Variable.FunctionName,
1700
+ node.id,
1701
+ node,
1702
+ null,
1703
+ null,
1704
+ null
1705
+ ));
1706
+ }
1707
+
1708
+ // FunctionExpression with name creates its special scope;
1709
+ // FunctionExpressionNameScope.
1710
+ if (node.type === Syntax.FunctionExpression && node.id) {
1711
+ this.scopeManager.__nestFunctionExpressionNameScope(node);
1712
+ }
1713
+
1714
+ // Consider this function is in the MethodDefinition.
1715
+ this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
1716
+
1717
+ const that = this;
1718
+
1719
+ /**
1720
+ * Visit pattern callback
1721
+ * @param {pattern} pattern pattern
1722
+ * @param {Object} info info
1723
+ * @returns {void}
1724
+ */
1725
+ function visitPatternCallback(pattern, info) {
1726
+ that.currentScope().__define(pattern,
1727
+ new ParameterDefinition(
1728
+ pattern,
1729
+ node,
1730
+ i,
1731
+ info.rest
1732
+ ));
1733
+
1734
+ that.referencingDefaultValue(pattern, info.assignments, null, true);
1735
+ }
1736
+
1737
+ // Process parameter declarations.
1738
+ for (i = 0, iz = node.params.length; i < iz; ++i) {
1739
+ this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback);
1740
+ }
1741
+
1742
+ // if there's a rest argument, add that
1743
+ if (node.rest) {
1744
+ this.visitPattern({
1745
+ type: "RestElement",
1746
+ argument: node.rest
1747
+ }, pattern => {
1748
+ this.currentScope().__define(pattern,
1749
+ new ParameterDefinition(
1750
+ pattern,
1751
+ node,
1752
+ node.params.length,
1753
+ true
1754
+ ));
1755
+ });
1756
+ }
1757
+
1758
+ // In TypeScript there are a number of function-like constructs which have no body,
1759
+ // so check it exists before traversing
1760
+ if (node.body) {
1761
+
1762
+ // Skip BlockStatement to prevent creating BlockStatement scope.
1763
+ if (node.body.type === Syntax.BlockStatement) {
1764
+ this.visitChildren(node.body);
1765
+ } else {
1766
+ this.visit(node.body);
1767
+ }
1768
+ }
1769
+
1770
+ this.close(node);
1771
+ }
1772
+
1773
+ visitClass(node) {
1774
+ if (node.type === Syntax.ClassDeclaration) {
1775
+ this.currentScope().__define(node.id,
1776
+ new Definition(
1777
+ Variable.ClassName,
1778
+ node.id,
1779
+ node,
1780
+ null,
1781
+ null,
1782
+ null
1783
+ ));
1784
+ }
1785
+
1786
+ this.scopeManager.__nestClassScope(node);
1787
+
1788
+ if (node.id) {
1789
+ this.currentScope().__define(node.id,
1790
+ new Definition(
1791
+ Variable.ClassName,
1792
+ node.id,
1793
+ node
1794
+ ));
1795
+ }
1796
+
1797
+ this.visit(node.superClass);
1798
+ this.visit(node.body);
1799
+
1800
+ this.close(node);
1801
+ }
1802
+
1803
+ visitProperty(node) {
1804
+ let previous;
1805
+
1806
+ if (node.computed) {
1807
+ this.visit(node.key);
1808
+ }
1809
+
1810
+ const isMethodDefinition = node.type === Syntax.MethodDefinition;
1811
+
1812
+ if (isMethodDefinition) {
1813
+ previous = this.pushInnerMethodDefinition(true);
1814
+ }
1815
+ this.visit(node.value);
1816
+ if (isMethodDefinition) {
1817
+ this.popInnerMethodDefinition(previous);
1818
+ }
1819
+ }
1820
+
1821
+ visitForIn(node) {
1822
+ if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
1823
+ this.scopeManager.__nestForScope(node);
1824
+ }
1825
+
1826
+ if (node.left.type === Syntax.VariableDeclaration) {
1827
+ this.visit(node.left);
1828
+ this.visitPattern(node.left.declarations[0].id, pattern => {
1829
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
1830
+ });
1831
+ } else {
1832
+ this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
1833
+ let maybeImplicitGlobal = null;
1834
+
1835
+ if (!this.currentScope().isStrict) {
1836
+ maybeImplicitGlobal = {
1837
+ pattern,
1838
+ node
1839
+ };
1840
+ }
1841
+ this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
1842
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
1843
+ });
1844
+ }
1845
+ this.visit(node.right);
1846
+ this.visit(node.body);
1847
+
1848
+ this.close(node);
1849
+ }
1850
+
1851
+ visitVariableDeclaration(variableTargetScope, type, node, index) {
1852
+
1853
+ const decl = node.declarations[index];
1854
+ const init = decl.init;
1855
+
1856
+ this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => {
1857
+ variableTargetScope.__define(
1858
+ pattern,
1859
+ new Definition(
1860
+ type,
1861
+ pattern,
1862
+ decl,
1863
+ node,
1864
+ index,
1865
+ node.kind
1866
+ )
1867
+ );
1868
+
1869
+ this.referencingDefaultValue(pattern, info.assignments, null, true);
1870
+ if (init) {
1871
+ this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
1872
+ }
1873
+ });
1874
+ }
1875
+
1876
+ AssignmentExpression(node) {
1877
+ if (PatternVisitor.isPattern(node.left)) {
1878
+ if (node.operator === "=") {
1879
+ this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
1880
+ let maybeImplicitGlobal = null;
1881
+
1882
+ if (!this.currentScope().isStrict) {
1883
+ maybeImplicitGlobal = {
1884
+ pattern,
1885
+ node
1886
+ };
1887
+ }
1888
+ this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
1889
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
1890
+ });
1891
+ } else {
1892
+ this.currentScope().__referencing(node.left, Reference.RW, node.right);
1893
+ }
1894
+ } else {
1895
+ this.visit(node.left);
1896
+ }
1897
+ this.visit(node.right);
1898
+ }
1899
+
1900
+ CatchClause(node) {
1901
+ this.scopeManager.__nestCatchScope(node);
1902
+
1903
+ this.visitPattern(node.param, { processRightHandNodes: true }, (pattern, info) => {
1904
+ this.currentScope().__define(pattern,
1905
+ new Definition(
1906
+ Variable.CatchClause,
1907
+ pattern,
1908
+ node,
1909
+ null,
1910
+ null,
1911
+ null
1912
+ ));
1913
+ this.referencingDefaultValue(pattern, info.assignments, null, true);
1914
+ });
1915
+ this.visit(node.body);
1916
+
1917
+ this.close(node);
1918
+ }
1919
+
1920
+ Program(node) {
1921
+ this.scopeManager.__nestGlobalScope(node);
1922
+
1923
+ if (this.scopeManager.isGlobalReturn()) {
1924
+
1925
+ // Force strictness of GlobalScope to false when using node.js scope.
1926
+ this.currentScope().isStrict = false;
1927
+ this.scopeManager.__nestFunctionScope(node, false);
1928
+ }
1929
+
1930
+ if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
1931
+ this.scopeManager.__nestModuleScope(node);
1932
+ }
1933
+
1934
+ if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
1935
+ this.currentScope().isStrict = true;
1936
+ }
1937
+
1938
+ this.visitChildren(node);
1939
+ this.close(node);
1940
+ }
1941
+
1942
+ Identifier(node) {
1943
+ this.currentScope().__referencing(node);
1944
+ }
1945
+
1946
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
1947
+ PrivateIdentifier() {
1948
+
1949
+ // Do nothing.
1950
+ }
1951
+
1952
+ UpdateExpression(node) {
1953
+ if (PatternVisitor.isPattern(node.argument)) {
1954
+ this.currentScope().__referencing(node.argument, Reference.RW, null);
1955
+ } else {
1956
+ this.visitChildren(node);
1957
+ }
1958
+ }
1959
+
1960
+ MemberExpression(node) {
1961
+ this.visit(node.object);
1962
+ if (node.computed) {
1963
+ this.visit(node.property);
1964
+ }
1965
+ }
1966
+
1967
+ Property(node) {
1968
+ this.visitProperty(node);
1969
+ }
1970
+
1971
+ PropertyDefinition(node) {
1972
+ const { computed, key, value } = node;
1973
+
1974
+ if (computed) {
1975
+ this.visit(key);
1976
+ }
1977
+ if (value) {
1978
+ this.scopeManager.__nestClassFieldInitializerScope(value);
1979
+ this.visit(value);
1980
+ this.close(value);
1981
+ }
1982
+ }
1983
+
1984
+ StaticBlock(node) {
1985
+ this.scopeManager.__nestClassStaticBlockScope(node);
1986
+
1987
+ this.visitChildren(node);
1988
+
1989
+ this.close(node);
1990
+ }
1991
+
1992
+ MethodDefinition(node) {
1993
+ this.visitProperty(node);
1994
+ }
1995
+
1996
+ BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
1997
+
1998
+ ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
1999
+
2000
+ LabeledStatement(node) {
2001
+ this.visit(node.body);
2002
+ }
2003
+
2004
+ ForStatement(node) {
2005
+
2006
+ // Create ForStatement declaration.
2007
+ // NOTE: In ES6, ForStatement dynamically generates
2008
+ // per iteration environment. However, escope is
2009
+ // a static analyzer, we only generate one scope for ForStatement.
2010
+ if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
2011
+ this.scopeManager.__nestForScope(node);
2012
+ }
2013
+
2014
+ this.visitChildren(node);
2015
+
2016
+ this.close(node);
2017
+ }
2018
+
2019
+ ClassExpression(node) {
2020
+ this.visitClass(node);
2021
+ }
2022
+
2023
+ ClassDeclaration(node) {
2024
+ this.visitClass(node);
2025
+ }
2026
+
2027
+ CallExpression(node) {
2028
+
2029
+ // Check this is direct call to eval
2030
+ if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
2031
+
2032
+ // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
2033
+ // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
2034
+ this.currentScope().variableScope.__detectEval();
2035
+ }
2036
+ this.visitChildren(node);
2037
+ }
2038
+
2039
+ BlockStatement(node) {
2040
+ if (this.scopeManager.__isES6()) {
2041
+ this.scopeManager.__nestBlockScope(node);
2042
+ }
2043
+
2044
+ this.visitChildren(node);
2045
+
2046
+ this.close(node);
2047
+ }
2048
+
2049
+ ThisExpression() {
2050
+ this.currentScope().variableScope.__detectThis();
2051
+ }
2052
+
2053
+ WithStatement(node) {
2054
+ this.visit(node.object);
2055
+
2056
+ // Then nest scope for WithStatement.
2057
+ this.scopeManager.__nestWithScope(node);
2058
+
2059
+ this.visit(node.body);
2060
+
2061
+ this.close(node);
2062
+ }
2063
+
2064
+ VariableDeclaration(node) {
2065
+ const variableTargetScope = (node.kind === "var") ? this.currentScope().variableScope : this.currentScope();
2066
+
2067
+ for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
2068
+ const decl = node.declarations[i];
2069
+
2070
+ this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
2071
+ if (decl.init) {
2072
+ this.visit(decl.init);
2073
+ }
2074
+ }
2075
+ }
2076
+
2077
+ // sec 13.11.8
2078
+ SwitchStatement(node) {
2079
+ this.visit(node.discriminant);
2080
+
2081
+ if (this.scopeManager.__isES6()) {
2082
+ this.scopeManager.__nestSwitchScope(node);
2083
+ }
2084
+
2085
+ for (let i = 0, iz = node.cases.length; i < iz; ++i) {
2086
+ this.visit(node.cases[i]);
2087
+ }
2088
+
2089
+ this.close(node);
2090
+ }
2091
+
2092
+ FunctionDeclaration(node) {
2093
+ this.visitFunction(node);
2094
+ }
2095
+
2096
+ FunctionExpression(node) {
2097
+ this.visitFunction(node);
2098
+ }
2099
+
2100
+ ForOfStatement(node) {
2101
+ this.visitForIn(node);
2102
+ }
2103
+
2104
+ ForInStatement(node) {
2105
+ this.visitForIn(node);
2106
+ }
2107
+
2108
+ ArrowFunctionExpression(node) {
2109
+ this.visitFunction(node);
2110
+ }
2111
+
2112
+ ImportDeclaration(node) {
2113
+ assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
2114
+
2115
+ const importer = new Importer(node, this);
2116
+
2117
+ importer.visit(node);
2118
+ }
2119
+
2120
+ visitExportDeclaration(node) {
2121
+ if (node.source) {
2122
+ return;
2123
+ }
2124
+ if (node.declaration) {
2125
+ this.visit(node.declaration);
2126
+ return;
2127
+ }
2128
+
2129
+ this.visitChildren(node);
2130
+ }
2131
+
2132
+ // TODO: ExportDeclaration doesn't exist. for bc?
2133
+ ExportDeclaration(node) {
2134
+ this.visitExportDeclaration(node);
2135
+ }
2136
+
2137
+ ExportAllDeclaration(node) {
2138
+ this.visitExportDeclaration(node);
2139
+ }
2140
+
2141
+ ExportDefaultDeclaration(node) {
2142
+ this.visitExportDeclaration(node);
2143
+ }
2144
+
2145
+ ExportNamedDeclaration(node) {
2146
+ this.visitExportDeclaration(node);
2147
+ }
2148
+
2149
+ ExportSpecifier(node) {
2150
+
2151
+ // TODO: `node.id` doesn't exist. for bc?
2152
+ const local = (node.id || node.local);
2153
+
2154
+ this.visit(local);
2155
+ }
2156
+
2157
+ MetaProperty() { // eslint-disable-line class-methods-use-this -- Desired as instance method
2158
+
2159
+ // do nothing.
2160
+ }
2161
+
2162
+ JSXIdentifier(node) {
2163
+
2164
+ // Special case: "this" should not count as a reference
2165
+ if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
2166
+ this.currentScope().__referencing(node);
2167
+ }
2168
+ }
2169
+
2170
+ JSXMemberExpression(node) {
2171
+ this.visit(node.object);
2172
+ }
2173
+
2174
+ JSXElement(node) {
2175
+ if (this.scopeManager.__isJSXEnabled()) {
2176
+ this.visit(node.openingElement);
2177
+ node.children.forEach(this.visit, this);
2178
+ } else {
2179
+ this.visitChildren(node);
2180
+ }
2181
+ }
2182
+
2183
+ JSXOpeningElement(node) {
2184
+ if (this.scopeManager.__isJSXEnabled()) {
2185
+
2186
+ const nameNode = node.name;
2187
+ const isComponentName = nameNode.type === "JSXIdentifier" && nameNode.name[0].toUpperCase() === nameNode.name[0];
2188
+ const isComponent = isComponentName || nameNode.type === "JSXMemberExpression";
2189
+
2190
+ // we only want to visit JSXIdentifier nodes if they are capitalized
2191
+ if (isComponent) {
2192
+ this.visit(nameNode);
2193
+ }
2194
+ }
2195
+
2196
+ node.attributes.forEach(this.visit, this);
2197
+ }
2198
+
2199
+ JSXAttribute(node) {
2200
+ if (node.value) {
2201
+ this.visit(node.value);
2202
+ }
2203
+ }
2204
+
2205
+ JSXExpressionContainer(node) {
2206
+ this.visit(node.expression);
2207
+ }
2208
+
2209
+ JSXNamespacedName(node) {
2210
+ this.visit(node.namespace);
2211
+ this.visit(node.name);
2212
+ }
2213
+ }
2214
+
2215
+ /* vim: set sw=4 ts=4 et tw=80 : */
2216
+
2217
+ const version = "8.4.0";
2218
+
2219
+ /*
2220
+ Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
2221
+ Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
2222
+ Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
2223
+
2224
+ Redistribution and use in source and binary forms, with or without
2225
+ modification, are permitted provided that the following conditions are met:
2226
+
2227
+ * Redistributions of source code must retain the above copyright
2228
+ notice, this list of conditions and the following disclaimer.
2229
+ * Redistributions in binary form must reproduce the above copyright
2230
+ notice, this list of conditions and the following disclaimer in the
2231
+ documentation and/or other materials provided with the distribution.
2232
+
2233
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2234
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2235
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2236
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
2237
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2238
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2239
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2240
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2241
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2242
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2243
+ */
2244
+
2245
+ /**
2246
+ * Set the default options
2247
+ * @returns {Object} options
2248
+ */
2249
+ function defaultOptions() {
2250
+ return {
2251
+ optimistic: false,
2252
+ nodejsScope: false,
2253
+ impliedStrict: false,
2254
+ sourceType: "script", // one of ['script', 'module', 'commonjs']
2255
+ ecmaVersion: 5,
2256
+ childVisitorKeys: null,
2257
+ fallback: "iteration"
2258
+ };
2259
+ }
2260
+
2261
+ /**
2262
+ * Preform deep update on option object
2263
+ * @param {Object} target Options
2264
+ * @param {Object} override Updates
2265
+ * @returns {Object} Updated options
2266
+ */
2267
+ function updateDeeply(target, override) {
2268
+
2269
+ /**
2270
+ * Is hash object
2271
+ * @param {Object} value Test value
2272
+ * @returns {boolean} Result
2273
+ */
2274
+ function isHashObject(value) {
2275
+ return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
2276
+ }
2277
+
2278
+ for (const key in override) {
2279
+ if (Object.hasOwn(override, key)) {
2280
+ const val = override[key];
2281
+
2282
+ if (isHashObject(val)) {
2283
+ if (isHashObject(target[key])) {
2284
+ updateDeeply(target[key], val);
2285
+ } else {
2286
+ target[key] = updateDeeply({}, val);
2287
+ }
2288
+ } else {
2289
+ target[key] = val;
2290
+ }
2291
+ }
2292
+ }
2293
+ return target;
2294
+ }
2295
+
2296
+ /**
2297
+ * Main interface function. Takes an Espree syntax tree and returns the
2298
+ * analyzed scopes.
2299
+ * @function analyze
2300
+ * @param {espree.Tree} tree Abstract Syntax Tree
2301
+ * @param {Object} providedOptions Options that tailor the scope analysis
2302
+ * @param {boolean} [providedOptions.optimistic=false] the optimistic flag
2303
+ * @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
2304
+ * @param {boolean} [providedOptions.nodejsScope=false] whether the whole
2305
+ * script is executed under node.js environment. When enabled, escope adds
2306
+ * a function scope immediately following the global scope.
2307
+ * @param {boolean} [providedOptions.impliedStrict=false] implied strict mode
2308
+ * (if ecmaVersion >= 5).
2309
+ * @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
2310
+ * @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
2311
+ * @param {boolean} [providedOptions.jsx=false] support JSX references
2312
+ * @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
2313
+ * @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
2314
+ * @returns {ScopeManager} ScopeManager
2315
+ */
2316
+ function analyze(tree, providedOptions) {
2317
+ const options = updateDeeply(defaultOptions(), providedOptions);
2318
+ const scopeManager = new ScopeManager(options);
2319
+ const referencer = new Referencer(options, scopeManager);
2320
+
2321
+ referencer.visit(tree);
2322
+
2323
+ assert(scopeManager.__currentScope === null, "currentScope should be null.");
2324
+
2325
+ return scopeManager;
2326
+ }
2327
+
2328
+ /* vim: set sw=4 ts=4 et tw=80 : */
2329
+
2330
+ exports.Definition = Definition;
2331
+ exports.PatternVisitor = PatternVisitor;
2332
+ exports.Reference = Reference;
2333
+ exports.Referencer = Referencer;
2334
+ exports.Scope = Scope;
2335
+ exports.ScopeManager = ScopeManager;
2336
+ exports.Variable = Variable;
2337
+ exports.analyze = analyze;
2338
+ exports.version = version;
2339
+ //# sourceMappingURL=eslint-scope.cjs.map
server/node_modules/eslint-scope/lib/assert.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Assertion utilities.
3
+ * @author Nicholas C. Zakas
4
+ */
5
+
6
+ /**
7
+ * Throws an error if the given condition is not truthy.
8
+ * @param {boolean} condition The condition to check.
9
+ * @param {string} message The message to include with the error.
10
+ * @returns {void}
11
+ * @throws {Error} When the condition is not truthy.
12
+ */
13
+ export function assert(condition, message = "Assertion failed.") {
14
+ if (!condition) {
15
+ throw new Error(message);
16
+ }
17
+ }
server/node_modules/eslint-scope/lib/definition.js ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import Variable from "./variable.js";
26
+
27
+ /**
28
+ * @constructor Definition
29
+ */
30
+ class Definition {
31
+ constructor(type, name, node, parent, index, kind) {
32
+
33
+ /**
34
+ * @member {string} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
35
+ */
36
+ this.type = type;
37
+
38
+ /**
39
+ * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
40
+ */
41
+ this.name = name;
42
+
43
+ /**
44
+ * @member {espree.Node} Definition#node - the enclosing node of the identifier.
45
+ */
46
+ this.node = node;
47
+
48
+ /**
49
+ * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
50
+ */
51
+ this.parent = parent;
52
+
53
+ /**
54
+ * @member {number?} Definition#index - the index in the declaration statement.
55
+ */
56
+ this.index = index;
57
+
58
+ /**
59
+ * @member {string?} Definition#kind - the kind of the declaration statement.
60
+ */
61
+ this.kind = kind;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @constructor ParameterDefinition
67
+ */
68
+ class ParameterDefinition extends Definition {
69
+ constructor(name, node, index, rest) {
70
+ super(Variable.Parameter, name, node, null, index, null);
71
+
72
+ /**
73
+ * Whether the parameter definition is a part of a rest parameter.
74
+ * @member {boolean} ParameterDefinition#rest
75
+ */
76
+ this.rest = rest;
77
+ }
78
+ }
79
+
80
+ export {
81
+ ParameterDefinition,
82
+ Definition
83
+ };
84
+
85
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/index.js ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
3
+ Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
4
+ Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+ * Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ /**
28
+ * Escope (<a href="http://github.com/estools/escope">escope</a>) is an <a
29
+ * href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a>
30
+ * scope analyzer extracted from the <a
31
+ * href="http://github.com/estools/esmangle">esmangle project</a/>.
32
+ * <p>
33
+ * <em>escope</em> finds lexical scopes in a source program, i.e. areas of that
34
+ * program where different occurrences of the same identifier refer to the same
35
+ * variable. With each scope the contained variables are collected, and each
36
+ * identifier reference in code is linked to its corresponding variable (if
37
+ * possible).
38
+ * <p>
39
+ * <em>escope</em> works on a syntax tree of the parsed source code which has
40
+ * to adhere to the <a
41
+ * href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
42
+ * Mozilla Parser API</a>. E.g. <a href="https://github.com/eslint/espree">espree</a> is a parser
43
+ * that produces such syntax trees.
44
+ * <p>
45
+ * The main interface is the {@link analyze} function.
46
+ * @module escope
47
+ */
48
+
49
+ import { assert } from "./assert.js";
50
+
51
+ import ScopeManager from "./scope-manager.js";
52
+ import Referencer from "./referencer.js";
53
+ import Reference from "./reference.js";
54
+ import Variable from "./variable.js";
55
+
56
+ import eslintScopeVersion from "./version.js";
57
+
58
+ /**
59
+ * Set the default options
60
+ * @returns {Object} options
61
+ */
62
+ function defaultOptions() {
63
+ return {
64
+ optimistic: false,
65
+ nodejsScope: false,
66
+ impliedStrict: false,
67
+ sourceType: "script", // one of ['script', 'module', 'commonjs']
68
+ ecmaVersion: 5,
69
+ childVisitorKeys: null,
70
+ fallback: "iteration"
71
+ };
72
+ }
73
+
74
+ /**
75
+ * Preform deep update on option object
76
+ * @param {Object} target Options
77
+ * @param {Object} override Updates
78
+ * @returns {Object} Updated options
79
+ */
80
+ function updateDeeply(target, override) {
81
+
82
+ /**
83
+ * Is hash object
84
+ * @param {Object} value Test value
85
+ * @returns {boolean} Result
86
+ */
87
+ function isHashObject(value) {
88
+ return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
89
+ }
90
+
91
+ for (const key in override) {
92
+ if (Object.hasOwn(override, key)) {
93
+ const val = override[key];
94
+
95
+ if (isHashObject(val)) {
96
+ if (isHashObject(target[key])) {
97
+ updateDeeply(target[key], val);
98
+ } else {
99
+ target[key] = updateDeeply({}, val);
100
+ }
101
+ } else {
102
+ target[key] = val;
103
+ }
104
+ }
105
+ }
106
+ return target;
107
+ }
108
+
109
+ /**
110
+ * Main interface function. Takes an Espree syntax tree and returns the
111
+ * analyzed scopes.
112
+ * @function analyze
113
+ * @param {espree.Tree} tree Abstract Syntax Tree
114
+ * @param {Object} providedOptions Options that tailor the scope analysis
115
+ * @param {boolean} [providedOptions.optimistic=false] the optimistic flag
116
+ * @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
117
+ * @param {boolean} [providedOptions.nodejsScope=false] whether the whole
118
+ * script is executed under node.js environment. When enabled, escope adds
119
+ * a function scope immediately following the global scope.
120
+ * @param {boolean} [providedOptions.impliedStrict=false] implied strict mode
121
+ * (if ecmaVersion >= 5).
122
+ * @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
123
+ * @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
124
+ * @param {boolean} [providedOptions.jsx=false] support JSX references
125
+ * @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
126
+ * @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
127
+ * @returns {ScopeManager} ScopeManager
128
+ */
129
+ function analyze(tree, providedOptions) {
130
+ const options = updateDeeply(defaultOptions(), providedOptions);
131
+ const scopeManager = new ScopeManager(options);
132
+ const referencer = new Referencer(options, scopeManager);
133
+
134
+ referencer.visit(tree);
135
+
136
+ assert(scopeManager.__currentScope === null, "currentScope should be null.");
137
+
138
+ return scopeManager;
139
+ }
140
+
141
+ export {
142
+
143
+ /** @name module:escope.version */
144
+ eslintScopeVersion as version,
145
+
146
+ /** @name module:escope.Reference */
147
+ Reference,
148
+
149
+ /** @name module:escope.Variable */
150
+ Variable,
151
+
152
+ /** @name module:escope.ScopeManager */
153
+ ScopeManager,
154
+
155
+ /** @name module:escope.Referencer */
156
+ Referencer,
157
+
158
+ analyze
159
+ };
160
+
161
+ /** @name module:escope.Definition */
162
+ export { Definition } from "./definition.js";
163
+
164
+ /** @name module:escope.PatternVisitor */
165
+ export { default as PatternVisitor } from "./pattern-visitor.js";
166
+
167
+ /** @name module:escope.Scope */
168
+ export { Scope } from "./scope.js";
169
+
170
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/pattern-visitor.js ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+ import esrecurse from "esrecurse";
27
+
28
+ const { Syntax } = estraverse;
29
+
30
+ /**
31
+ * Get last array element
32
+ * @param {Array} xs array
33
+ * @returns {any} Last elment
34
+ */
35
+ function getLast(xs) {
36
+ return xs.at(-1) || null;
37
+ }
38
+
39
+ /**
40
+ * Visitor for destructuring patterns.
41
+ */
42
+ class PatternVisitor extends esrecurse.Visitor {
43
+ static isPattern(node) {
44
+ const nodeType = node.type;
45
+
46
+ return (
47
+ nodeType === Syntax.Identifier ||
48
+ nodeType === Syntax.ObjectPattern ||
49
+ nodeType === Syntax.ArrayPattern ||
50
+ nodeType === Syntax.SpreadElement ||
51
+ nodeType === Syntax.RestElement ||
52
+ nodeType === Syntax.AssignmentPattern
53
+ );
54
+ }
55
+
56
+ constructor(options, rootPattern, callback) {
57
+ super(null, options);
58
+ this.rootPattern = rootPattern;
59
+ this.callback = callback;
60
+ this.assignments = [];
61
+ this.rightHandNodes = [];
62
+ this.restElements = [];
63
+ }
64
+
65
+ Identifier(pattern) {
66
+ const lastRestElement = getLast(this.restElements);
67
+
68
+ this.callback(pattern, {
69
+ topLevel: pattern === this.rootPattern,
70
+ rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern,
71
+ assignments: this.assignments
72
+ });
73
+ }
74
+
75
+ Property(property) {
76
+
77
+ // Computed property's key is a right hand node.
78
+ if (property.computed) {
79
+ this.rightHandNodes.push(property.key);
80
+ }
81
+
82
+ // If it's shorthand, its key is same as its value.
83
+ // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
84
+ // If it's not shorthand, the name of new variable is its value's.
85
+ this.visit(property.value);
86
+ }
87
+
88
+ ArrayPattern(pattern) {
89
+ for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
90
+ const element = pattern.elements[i];
91
+
92
+ this.visit(element);
93
+ }
94
+ }
95
+
96
+ AssignmentPattern(pattern) {
97
+ this.assignments.push(pattern);
98
+ this.visit(pattern.left);
99
+ this.rightHandNodes.push(pattern.right);
100
+ this.assignments.pop();
101
+ }
102
+
103
+ RestElement(pattern) {
104
+ this.restElements.push(pattern);
105
+ this.visit(pattern.argument);
106
+ this.restElements.pop();
107
+ }
108
+
109
+ MemberExpression(node) {
110
+
111
+ // Computed property's key is a right hand node.
112
+ if (node.computed) {
113
+ this.rightHandNodes.push(node.property);
114
+ }
115
+
116
+ // the object is only read, write to its property.
117
+ this.rightHandNodes.push(node.object);
118
+ }
119
+
120
+ //
121
+ // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
122
+ // By spec, LeftHandSideExpression is Pattern or MemberExpression.
123
+ // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
124
+ // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
125
+ //
126
+
127
+ SpreadElement(node) {
128
+ this.visit(node.argument);
129
+ }
130
+
131
+ ArrayExpression(node) {
132
+ node.elements.forEach(this.visit, this);
133
+ }
134
+
135
+ AssignmentExpression(node) {
136
+ this.assignments.push(node);
137
+ this.visit(node.left);
138
+ this.rightHandNodes.push(node.right);
139
+ this.assignments.pop();
140
+ }
141
+
142
+ CallExpression(node) {
143
+
144
+ // arguments are right hand nodes.
145
+ node.arguments.forEach(a => {
146
+ this.rightHandNodes.push(a);
147
+ });
148
+ this.visit(node.callee);
149
+ }
150
+ }
151
+
152
+ export default PatternVisitor;
153
+
154
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/reference.js ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ const READ = 0x1;
26
+ const WRITE = 0x2;
27
+ const RW = READ | WRITE;
28
+
29
+ /**
30
+ * A Reference represents a single occurrence of an identifier in code.
31
+ * @constructor Reference
32
+ */
33
+ class Reference {
34
+ constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
35
+
36
+ /**
37
+ * Identifier syntax node.
38
+ * @member {espreeIdentifier} Reference#identifier
39
+ */
40
+ this.identifier = ident;
41
+
42
+ /**
43
+ * Reference to the enclosing Scope.
44
+ * @member {Scope} Reference#from
45
+ */
46
+ this.from = scope;
47
+
48
+ /**
49
+ * Whether the reference comes from a dynamic scope (such as 'eval',
50
+ * 'with', etc.), and may be trapped by dynamic scopes.
51
+ * @member {boolean} Reference#tainted
52
+ */
53
+ this.tainted = false;
54
+
55
+ /**
56
+ * The variable this reference is resolved with.
57
+ * @member {Variable} Reference#resolved
58
+ */
59
+ this.resolved = null;
60
+
61
+ /**
62
+ * The read-write mode of the reference. (Value is one of {@link
63
+ * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
64
+ * @member {number} Reference#flag
65
+ * @private
66
+ */
67
+ this.flag = flag;
68
+ if (this.isWrite()) {
69
+
70
+ /**
71
+ * If reference is writeable, this is the tree being written to it.
72
+ * @member {espreeNode} Reference#writeExpr
73
+ */
74
+ this.writeExpr = writeExpr;
75
+
76
+ /**
77
+ * Whether the Reference might refer to a partial value of writeExpr.
78
+ * @member {boolean} Reference#partial
79
+ */
80
+ this.partial = partial;
81
+
82
+ /**
83
+ * Whether the Reference is to write of initialization.
84
+ * @member {boolean} Reference#init
85
+ */
86
+ this.init = init;
87
+ }
88
+ this.__maybeImplicitGlobal = maybeImplicitGlobal;
89
+ }
90
+
91
+ /**
92
+ * Whether the reference is static.
93
+ * @function Reference#isStatic
94
+ * @returns {boolean} static
95
+ */
96
+ isStatic() {
97
+ return !this.tainted && this.resolved && this.resolved.scope.isStatic();
98
+ }
99
+
100
+ /**
101
+ * Whether the reference is writeable.
102
+ * @function Reference#isWrite
103
+ * @returns {boolean} write
104
+ */
105
+ isWrite() {
106
+ return !!(this.flag & Reference.WRITE);
107
+ }
108
+
109
+ /**
110
+ * Whether the reference is readable.
111
+ * @function Reference#isRead
112
+ * @returns {boolean} read
113
+ */
114
+ isRead() {
115
+ return !!(this.flag & Reference.READ);
116
+ }
117
+
118
+ /**
119
+ * Whether the reference is read-only.
120
+ * @function Reference#isReadOnly
121
+ * @returns {boolean} read only
122
+ */
123
+ isReadOnly() {
124
+ return this.flag === Reference.READ;
125
+ }
126
+
127
+ /**
128
+ * Whether the reference is write-only.
129
+ * @function Reference#isWriteOnly
130
+ * @returns {boolean} write only
131
+ */
132
+ isWriteOnly() {
133
+ return this.flag === Reference.WRITE;
134
+ }
135
+
136
+ /**
137
+ * Whether the reference is read-write.
138
+ * @function Reference#isReadWrite
139
+ * @returns {boolean} read write
140
+ */
141
+ isReadWrite() {
142
+ return this.flag === Reference.RW;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * @constant Reference.READ
148
+ * @private
149
+ */
150
+ Reference.READ = READ;
151
+
152
+ /**
153
+ * @constant Reference.WRITE
154
+ * @private
155
+ */
156
+ Reference.WRITE = WRITE;
157
+
158
+ /**
159
+ * @constant Reference.RW
160
+ * @private
161
+ */
162
+ Reference.RW = RW;
163
+
164
+ export default Reference;
165
+
166
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/referencer.js ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+ import esrecurse from "esrecurse";
27
+ import Reference from "./reference.js";
28
+ import Variable from "./variable.js";
29
+ import PatternVisitor from "./pattern-visitor.js";
30
+ import { Definition, ParameterDefinition } from "./definition.js";
31
+ import { assert } from "./assert.js";
32
+
33
+ const { Syntax } = estraverse;
34
+
35
+ /**
36
+ * Traverse identifier in pattern
37
+ * @param {Object} options options
38
+ * @param {pattern} rootPattern root pattern
39
+ * @param {Refencer} referencer referencer
40
+ * @param {callback} callback callback
41
+ * @returns {void}
42
+ */
43
+ function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
44
+
45
+ // Call the callback at left hand identifier nodes, and Collect right hand nodes.
46
+ const visitor = new PatternVisitor(options, rootPattern, callback);
47
+
48
+ visitor.visit(rootPattern);
49
+
50
+ // Process the right hand nodes recursively.
51
+ if (referencer !== null && referencer !== void 0) {
52
+ visitor.rightHandNodes.forEach(referencer.visit, referencer);
53
+ }
54
+ }
55
+
56
+ // Importing ImportDeclaration.
57
+ // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
58
+ // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
59
+ // FIXME: Now, we don't create module environment, because the context is
60
+ // implementation dependent.
61
+
62
+ /**
63
+ * Visitor for import specifiers.
64
+ */
65
+ class Importer extends esrecurse.Visitor {
66
+ constructor(declaration, referencer) {
67
+ super(null, referencer.options);
68
+ this.declaration = declaration;
69
+ this.referencer = referencer;
70
+ }
71
+
72
+ visitImport(id, specifier) {
73
+ this.referencer.visitPattern(id, pattern => {
74
+ this.referencer.currentScope().__define(pattern,
75
+ new Definition(
76
+ Variable.ImportBinding,
77
+ pattern,
78
+ specifier,
79
+ this.declaration,
80
+ null,
81
+ null
82
+ ));
83
+ });
84
+ }
85
+
86
+ ImportNamespaceSpecifier(node) {
87
+ const local = (node.local || node.id);
88
+
89
+ if (local) {
90
+ this.visitImport(local, node);
91
+ }
92
+ }
93
+
94
+ ImportDefaultSpecifier(node) {
95
+ const local = (node.local || node.id);
96
+
97
+ this.visitImport(local, node);
98
+ }
99
+
100
+ ImportSpecifier(node) {
101
+ const local = (node.local || node.id);
102
+
103
+ if (node.name) {
104
+ this.visitImport(node.name, node);
105
+ } else {
106
+ this.visitImport(local, node);
107
+ }
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Referencing variables and creating bindings.
113
+ */
114
+ class Referencer extends esrecurse.Visitor {
115
+ constructor(options, scopeManager) {
116
+ super(null, options);
117
+ this.options = options;
118
+ this.scopeManager = scopeManager;
119
+ this.parent = null;
120
+ this.isInnerMethodDefinition = false;
121
+ }
122
+
123
+ currentScope() {
124
+ return this.scopeManager.__currentScope;
125
+ }
126
+
127
+ close(node) {
128
+ while (this.currentScope() && node === this.currentScope().block) {
129
+ this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
130
+ }
131
+ }
132
+
133
+ pushInnerMethodDefinition(isInnerMethodDefinition) {
134
+ const previous = this.isInnerMethodDefinition;
135
+
136
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
137
+ return previous;
138
+ }
139
+
140
+ popInnerMethodDefinition(isInnerMethodDefinition) {
141
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
142
+ }
143
+
144
+ referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
145
+ const scope = this.currentScope();
146
+
147
+ assignments.forEach(assignment => {
148
+ scope.__referencing(
149
+ pattern,
150
+ Reference.WRITE,
151
+ assignment.right,
152
+ maybeImplicitGlobal,
153
+ pattern !== assignment.left,
154
+ init
155
+ );
156
+ });
157
+ }
158
+
159
+ visitPattern(node, options, callback) {
160
+ let visitPatternOptions = options;
161
+ let visitPatternCallback = callback;
162
+
163
+ if (typeof options === "function") {
164
+ visitPatternCallback = options;
165
+ visitPatternOptions = { processRightHandNodes: false };
166
+ }
167
+
168
+ traverseIdentifierInPattern(
169
+ this.options,
170
+ node,
171
+ visitPatternOptions.processRightHandNodes ? this : null,
172
+ visitPatternCallback
173
+ );
174
+ }
175
+
176
+ visitFunction(node) {
177
+ let i, iz;
178
+
179
+ // FunctionDeclaration name is defined in upper scope
180
+ // NOTE: Not referring variableScope. It is intended.
181
+ // Since
182
+ // in ES5, FunctionDeclaration should be in FunctionBody.
183
+ // in ES6, FunctionDeclaration should be block scoped.
184
+
185
+ if (node.type === Syntax.FunctionDeclaration) {
186
+
187
+ // id is defined in upper scope
188
+ this.currentScope().__define(node.id,
189
+ new Definition(
190
+ Variable.FunctionName,
191
+ node.id,
192
+ node,
193
+ null,
194
+ null,
195
+ null
196
+ ));
197
+ }
198
+
199
+ // FunctionExpression with name creates its special scope;
200
+ // FunctionExpressionNameScope.
201
+ if (node.type === Syntax.FunctionExpression && node.id) {
202
+ this.scopeManager.__nestFunctionExpressionNameScope(node);
203
+ }
204
+
205
+ // Consider this function is in the MethodDefinition.
206
+ this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
207
+
208
+ const that = this;
209
+
210
+ /**
211
+ * Visit pattern callback
212
+ * @param {pattern} pattern pattern
213
+ * @param {Object} info info
214
+ * @returns {void}
215
+ */
216
+ function visitPatternCallback(pattern, info) {
217
+ that.currentScope().__define(pattern,
218
+ new ParameterDefinition(
219
+ pattern,
220
+ node,
221
+ i,
222
+ info.rest
223
+ ));
224
+
225
+ that.referencingDefaultValue(pattern, info.assignments, null, true);
226
+ }
227
+
228
+ // Process parameter declarations.
229
+ for (i = 0, iz = node.params.length; i < iz; ++i) {
230
+ this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback);
231
+ }
232
+
233
+ // if there's a rest argument, add that
234
+ if (node.rest) {
235
+ this.visitPattern({
236
+ type: "RestElement",
237
+ argument: node.rest
238
+ }, pattern => {
239
+ this.currentScope().__define(pattern,
240
+ new ParameterDefinition(
241
+ pattern,
242
+ node,
243
+ node.params.length,
244
+ true
245
+ ));
246
+ });
247
+ }
248
+
249
+ // In TypeScript there are a number of function-like constructs which have no body,
250
+ // so check it exists before traversing
251
+ if (node.body) {
252
+
253
+ // Skip BlockStatement to prevent creating BlockStatement scope.
254
+ if (node.body.type === Syntax.BlockStatement) {
255
+ this.visitChildren(node.body);
256
+ } else {
257
+ this.visit(node.body);
258
+ }
259
+ }
260
+
261
+ this.close(node);
262
+ }
263
+
264
+ visitClass(node) {
265
+ if (node.type === Syntax.ClassDeclaration) {
266
+ this.currentScope().__define(node.id,
267
+ new Definition(
268
+ Variable.ClassName,
269
+ node.id,
270
+ node,
271
+ null,
272
+ null,
273
+ null
274
+ ));
275
+ }
276
+
277
+ this.scopeManager.__nestClassScope(node);
278
+
279
+ if (node.id) {
280
+ this.currentScope().__define(node.id,
281
+ new Definition(
282
+ Variable.ClassName,
283
+ node.id,
284
+ node
285
+ ));
286
+ }
287
+
288
+ this.visit(node.superClass);
289
+ this.visit(node.body);
290
+
291
+ this.close(node);
292
+ }
293
+
294
+ visitProperty(node) {
295
+ let previous;
296
+
297
+ if (node.computed) {
298
+ this.visit(node.key);
299
+ }
300
+
301
+ const isMethodDefinition = node.type === Syntax.MethodDefinition;
302
+
303
+ if (isMethodDefinition) {
304
+ previous = this.pushInnerMethodDefinition(true);
305
+ }
306
+ this.visit(node.value);
307
+ if (isMethodDefinition) {
308
+ this.popInnerMethodDefinition(previous);
309
+ }
310
+ }
311
+
312
+ visitForIn(node) {
313
+ if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
314
+ this.scopeManager.__nestForScope(node);
315
+ }
316
+
317
+ if (node.left.type === Syntax.VariableDeclaration) {
318
+ this.visit(node.left);
319
+ this.visitPattern(node.left.declarations[0].id, pattern => {
320
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
321
+ });
322
+ } else {
323
+ this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
324
+ let maybeImplicitGlobal = null;
325
+
326
+ if (!this.currentScope().isStrict) {
327
+ maybeImplicitGlobal = {
328
+ pattern,
329
+ node
330
+ };
331
+ }
332
+ this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
333
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
334
+ });
335
+ }
336
+ this.visit(node.right);
337
+ this.visit(node.body);
338
+
339
+ this.close(node);
340
+ }
341
+
342
+ visitVariableDeclaration(variableTargetScope, type, node, index) {
343
+
344
+ const decl = node.declarations[index];
345
+ const init = decl.init;
346
+
347
+ this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => {
348
+ variableTargetScope.__define(
349
+ pattern,
350
+ new Definition(
351
+ type,
352
+ pattern,
353
+ decl,
354
+ node,
355
+ index,
356
+ node.kind
357
+ )
358
+ );
359
+
360
+ this.referencingDefaultValue(pattern, info.assignments, null, true);
361
+ if (init) {
362
+ this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
363
+ }
364
+ });
365
+ }
366
+
367
+ AssignmentExpression(node) {
368
+ if (PatternVisitor.isPattern(node.left)) {
369
+ if (node.operator === "=") {
370
+ this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
371
+ let maybeImplicitGlobal = null;
372
+
373
+ if (!this.currentScope().isStrict) {
374
+ maybeImplicitGlobal = {
375
+ pattern,
376
+ node
377
+ };
378
+ }
379
+ this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
380
+ this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
381
+ });
382
+ } else {
383
+ this.currentScope().__referencing(node.left, Reference.RW, node.right);
384
+ }
385
+ } else {
386
+ this.visit(node.left);
387
+ }
388
+ this.visit(node.right);
389
+ }
390
+
391
+ CatchClause(node) {
392
+ this.scopeManager.__nestCatchScope(node);
393
+
394
+ this.visitPattern(node.param, { processRightHandNodes: true }, (pattern, info) => {
395
+ this.currentScope().__define(pattern,
396
+ new Definition(
397
+ Variable.CatchClause,
398
+ pattern,
399
+ node,
400
+ null,
401
+ null,
402
+ null
403
+ ));
404
+ this.referencingDefaultValue(pattern, info.assignments, null, true);
405
+ });
406
+ this.visit(node.body);
407
+
408
+ this.close(node);
409
+ }
410
+
411
+ Program(node) {
412
+ this.scopeManager.__nestGlobalScope(node);
413
+
414
+ if (this.scopeManager.isGlobalReturn()) {
415
+
416
+ // Force strictness of GlobalScope to false when using node.js scope.
417
+ this.currentScope().isStrict = false;
418
+ this.scopeManager.__nestFunctionScope(node, false);
419
+ }
420
+
421
+ if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
422
+ this.scopeManager.__nestModuleScope(node);
423
+ }
424
+
425
+ if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
426
+ this.currentScope().isStrict = true;
427
+ }
428
+
429
+ this.visitChildren(node);
430
+ this.close(node);
431
+ }
432
+
433
+ Identifier(node) {
434
+ this.currentScope().__referencing(node);
435
+ }
436
+
437
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
438
+ PrivateIdentifier() {
439
+
440
+ // Do nothing.
441
+ }
442
+
443
+ UpdateExpression(node) {
444
+ if (PatternVisitor.isPattern(node.argument)) {
445
+ this.currentScope().__referencing(node.argument, Reference.RW, null);
446
+ } else {
447
+ this.visitChildren(node);
448
+ }
449
+ }
450
+
451
+ MemberExpression(node) {
452
+ this.visit(node.object);
453
+ if (node.computed) {
454
+ this.visit(node.property);
455
+ }
456
+ }
457
+
458
+ Property(node) {
459
+ this.visitProperty(node);
460
+ }
461
+
462
+ PropertyDefinition(node) {
463
+ const { computed, key, value } = node;
464
+
465
+ if (computed) {
466
+ this.visit(key);
467
+ }
468
+ if (value) {
469
+ this.scopeManager.__nestClassFieldInitializerScope(value);
470
+ this.visit(value);
471
+ this.close(value);
472
+ }
473
+ }
474
+
475
+ StaticBlock(node) {
476
+ this.scopeManager.__nestClassStaticBlockScope(node);
477
+
478
+ this.visitChildren(node);
479
+
480
+ this.close(node);
481
+ }
482
+
483
+ MethodDefinition(node) {
484
+ this.visitProperty(node);
485
+ }
486
+
487
+ BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
488
+
489
+ ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
490
+
491
+ LabeledStatement(node) {
492
+ this.visit(node.body);
493
+ }
494
+
495
+ ForStatement(node) {
496
+
497
+ // Create ForStatement declaration.
498
+ // NOTE: In ES6, ForStatement dynamically generates
499
+ // per iteration environment. However, escope is
500
+ // a static analyzer, we only generate one scope for ForStatement.
501
+ if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
502
+ this.scopeManager.__nestForScope(node);
503
+ }
504
+
505
+ this.visitChildren(node);
506
+
507
+ this.close(node);
508
+ }
509
+
510
+ ClassExpression(node) {
511
+ this.visitClass(node);
512
+ }
513
+
514
+ ClassDeclaration(node) {
515
+ this.visitClass(node);
516
+ }
517
+
518
+ CallExpression(node) {
519
+
520
+ // Check this is direct call to eval
521
+ if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
522
+
523
+ // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
524
+ // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
525
+ this.currentScope().variableScope.__detectEval();
526
+ }
527
+ this.visitChildren(node);
528
+ }
529
+
530
+ BlockStatement(node) {
531
+ if (this.scopeManager.__isES6()) {
532
+ this.scopeManager.__nestBlockScope(node);
533
+ }
534
+
535
+ this.visitChildren(node);
536
+
537
+ this.close(node);
538
+ }
539
+
540
+ ThisExpression() {
541
+ this.currentScope().variableScope.__detectThis();
542
+ }
543
+
544
+ WithStatement(node) {
545
+ this.visit(node.object);
546
+
547
+ // Then nest scope for WithStatement.
548
+ this.scopeManager.__nestWithScope(node);
549
+
550
+ this.visit(node.body);
551
+
552
+ this.close(node);
553
+ }
554
+
555
+ VariableDeclaration(node) {
556
+ const variableTargetScope = (node.kind === "var") ? this.currentScope().variableScope : this.currentScope();
557
+
558
+ for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
559
+ const decl = node.declarations[i];
560
+
561
+ this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
562
+ if (decl.init) {
563
+ this.visit(decl.init);
564
+ }
565
+ }
566
+ }
567
+
568
+ // sec 13.11.8
569
+ SwitchStatement(node) {
570
+ this.visit(node.discriminant);
571
+
572
+ if (this.scopeManager.__isES6()) {
573
+ this.scopeManager.__nestSwitchScope(node);
574
+ }
575
+
576
+ for (let i = 0, iz = node.cases.length; i < iz; ++i) {
577
+ this.visit(node.cases[i]);
578
+ }
579
+
580
+ this.close(node);
581
+ }
582
+
583
+ FunctionDeclaration(node) {
584
+ this.visitFunction(node);
585
+ }
586
+
587
+ FunctionExpression(node) {
588
+ this.visitFunction(node);
589
+ }
590
+
591
+ ForOfStatement(node) {
592
+ this.visitForIn(node);
593
+ }
594
+
595
+ ForInStatement(node) {
596
+ this.visitForIn(node);
597
+ }
598
+
599
+ ArrowFunctionExpression(node) {
600
+ this.visitFunction(node);
601
+ }
602
+
603
+ ImportDeclaration(node) {
604
+ assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
605
+
606
+ const importer = new Importer(node, this);
607
+
608
+ importer.visit(node);
609
+ }
610
+
611
+ visitExportDeclaration(node) {
612
+ if (node.source) {
613
+ return;
614
+ }
615
+ if (node.declaration) {
616
+ this.visit(node.declaration);
617
+ return;
618
+ }
619
+
620
+ this.visitChildren(node);
621
+ }
622
+
623
+ // TODO: ExportDeclaration doesn't exist. for bc?
624
+ ExportDeclaration(node) {
625
+ this.visitExportDeclaration(node);
626
+ }
627
+
628
+ ExportAllDeclaration(node) {
629
+ this.visitExportDeclaration(node);
630
+ }
631
+
632
+ ExportDefaultDeclaration(node) {
633
+ this.visitExportDeclaration(node);
634
+ }
635
+
636
+ ExportNamedDeclaration(node) {
637
+ this.visitExportDeclaration(node);
638
+ }
639
+
640
+ ExportSpecifier(node) {
641
+
642
+ // TODO: `node.id` doesn't exist. for bc?
643
+ const local = (node.id || node.local);
644
+
645
+ this.visit(local);
646
+ }
647
+
648
+ MetaProperty() { // eslint-disable-line class-methods-use-this -- Desired as instance method
649
+
650
+ // do nothing.
651
+ }
652
+
653
+ JSXIdentifier(node) {
654
+
655
+ // Special case: "this" should not count as a reference
656
+ if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
657
+ this.currentScope().__referencing(node);
658
+ }
659
+ }
660
+
661
+ JSXMemberExpression(node) {
662
+ this.visit(node.object);
663
+ }
664
+
665
+ JSXElement(node) {
666
+ if (this.scopeManager.__isJSXEnabled()) {
667
+ this.visit(node.openingElement);
668
+ node.children.forEach(this.visit, this);
669
+ } else {
670
+ this.visitChildren(node);
671
+ }
672
+ }
673
+
674
+ JSXOpeningElement(node) {
675
+ if (this.scopeManager.__isJSXEnabled()) {
676
+
677
+ const nameNode = node.name;
678
+ const isComponentName = nameNode.type === "JSXIdentifier" && nameNode.name[0].toUpperCase() === nameNode.name[0];
679
+ const isComponent = isComponentName || nameNode.type === "JSXMemberExpression";
680
+
681
+ // we only want to visit JSXIdentifier nodes if they are capitalized
682
+ if (isComponent) {
683
+ this.visit(nameNode);
684
+ }
685
+ }
686
+
687
+ node.attributes.forEach(this.visit, this);
688
+ }
689
+
690
+ JSXAttribute(node) {
691
+ if (node.value) {
692
+ this.visit(node.value);
693
+ }
694
+ }
695
+
696
+ JSXExpressionContainer(node) {
697
+ this.visit(node.expression);
698
+ }
699
+
700
+ JSXNamespacedName(node) {
701
+ this.visit(node.namespace);
702
+ this.visit(node.name);
703
+ }
704
+ }
705
+
706
+ export default Referencer;
707
+
708
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/scope-manager.js ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import {
26
+ BlockScope,
27
+ CatchScope,
28
+ ClassFieldInitializerScope,
29
+ ClassStaticBlockScope,
30
+ ClassScope,
31
+ ForScope,
32
+ FunctionExpressionNameScope,
33
+ FunctionScope,
34
+ GlobalScope,
35
+ ModuleScope,
36
+ SwitchScope,
37
+ WithScope
38
+ } from "./scope.js";
39
+ import { assert } from "./assert.js";
40
+
41
+ /**
42
+ * @constructor ScopeManager
43
+ */
44
+ class ScopeManager {
45
+ constructor(options) {
46
+ this.scopes = [];
47
+ this.globalScope = null;
48
+ this.__nodeToScope = new WeakMap();
49
+ this.__currentScope = null;
50
+ this.__options = options;
51
+ this.__declaredVariables = new WeakMap();
52
+ }
53
+
54
+ __isOptimistic() {
55
+ return this.__options.optimistic;
56
+ }
57
+
58
+ __ignoreEval() {
59
+ return this.__options.ignoreEval;
60
+ }
61
+
62
+ __isJSXEnabled() {
63
+ return this.__options.jsx === true;
64
+ }
65
+
66
+ isGlobalReturn() {
67
+ return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
68
+ }
69
+
70
+ isModule() {
71
+ return this.__options.sourceType === "module";
72
+ }
73
+
74
+ isImpliedStrict() {
75
+ return this.__options.impliedStrict;
76
+ }
77
+
78
+ isStrictModeSupported() {
79
+ return this.__options.ecmaVersion >= 5;
80
+ }
81
+
82
+ // Returns appropriate scope for this node.
83
+ __get(node) {
84
+ return this.__nodeToScope.get(node);
85
+ }
86
+
87
+ /**
88
+ * Get variables that are declared by the node.
89
+ *
90
+ * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
91
+ * If the node declares nothing, this method returns an empty array.
92
+ * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
93
+ * @param {Espree.Node} node a node to get.
94
+ * @returns {Variable[]} variables that declared by the node.
95
+ */
96
+ getDeclaredVariables(node) {
97
+ return this.__declaredVariables.get(node) || [];
98
+ }
99
+
100
+ /**
101
+ * acquire scope from node.
102
+ * @function ScopeManager#acquire
103
+ * @param {Espree.Node} node node for the acquired scope.
104
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
105
+ * @returns {Scope?} Scope from node
106
+ */
107
+ acquire(node, inner) {
108
+
109
+ /**
110
+ * predicate
111
+ * @param {Scope} testScope scope to test
112
+ * @returns {boolean} predicate
113
+ */
114
+ function predicate(testScope) {
115
+ if (testScope.type === "function" && testScope.functionExpressionScope) {
116
+ return false;
117
+ }
118
+ return true;
119
+ }
120
+
121
+ const scopes = this.__get(node);
122
+
123
+ if (!scopes || scopes.length === 0) {
124
+ return null;
125
+ }
126
+
127
+ // Heuristic selection from all scopes.
128
+ // If you would like to get all scopes, please use ScopeManager#acquireAll.
129
+ if (scopes.length === 1) {
130
+ return scopes[0];
131
+ }
132
+
133
+ if (inner) {
134
+ for (let i = scopes.length - 1; i >= 0; --i) {
135
+ const scope = scopes[i];
136
+
137
+ if (predicate(scope)) {
138
+ return scope;
139
+ }
140
+ }
141
+ } else {
142
+ for (let i = 0, iz = scopes.length; i < iz; ++i) {
143
+ const scope = scopes[i];
144
+
145
+ if (predicate(scope)) {
146
+ return scope;
147
+ }
148
+ }
149
+ }
150
+
151
+ return null;
152
+ }
153
+
154
+ /**
155
+ * acquire all scopes from node.
156
+ * @function ScopeManager#acquireAll
157
+ * @param {Espree.Node} node node for the acquired scope.
158
+ * @returns {Scopes?} Scope array
159
+ */
160
+ acquireAll(node) {
161
+ return this.__get(node);
162
+ }
163
+
164
+ /**
165
+ * release the node.
166
+ * @function ScopeManager#release
167
+ * @param {Espree.Node} node releasing node.
168
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
169
+ * @returns {Scope?} upper scope for the node.
170
+ */
171
+ release(node, inner) {
172
+ const scopes = this.__get(node);
173
+
174
+ if (scopes && scopes.length) {
175
+ const scope = scopes[0].upper;
176
+
177
+ if (!scope) {
178
+ return null;
179
+ }
180
+ return this.acquire(scope.block, inner);
181
+ }
182
+ return null;
183
+ }
184
+
185
+ attach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
186
+
187
+ detach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
188
+
189
+ __nestScope(scope) {
190
+ if (scope instanceof GlobalScope) {
191
+ assert(this.__currentScope === null);
192
+ this.globalScope = scope;
193
+ }
194
+ this.__currentScope = scope;
195
+ return scope;
196
+ }
197
+
198
+ __nestGlobalScope(node) {
199
+ return this.__nestScope(new GlobalScope(this, node));
200
+ }
201
+
202
+ __nestBlockScope(node) {
203
+ return this.__nestScope(new BlockScope(this, this.__currentScope, node));
204
+ }
205
+
206
+ __nestFunctionScope(node, isMethodDefinition) {
207
+ return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
208
+ }
209
+
210
+ __nestForScope(node) {
211
+ return this.__nestScope(new ForScope(this, this.__currentScope, node));
212
+ }
213
+
214
+ __nestCatchScope(node) {
215
+ return this.__nestScope(new CatchScope(this, this.__currentScope, node));
216
+ }
217
+
218
+ __nestWithScope(node) {
219
+ return this.__nestScope(new WithScope(this, this.__currentScope, node));
220
+ }
221
+
222
+ __nestClassScope(node) {
223
+ return this.__nestScope(new ClassScope(this, this.__currentScope, node));
224
+ }
225
+
226
+ __nestClassFieldInitializerScope(node) {
227
+ return this.__nestScope(new ClassFieldInitializerScope(this, this.__currentScope, node));
228
+ }
229
+
230
+ __nestClassStaticBlockScope(node) {
231
+ return this.__nestScope(new ClassStaticBlockScope(this, this.__currentScope, node));
232
+ }
233
+
234
+ __nestSwitchScope(node) {
235
+ return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
236
+ }
237
+
238
+ __nestModuleScope(node) {
239
+ return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
240
+ }
241
+
242
+ __nestFunctionExpressionNameScope(node) {
243
+ return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
244
+ }
245
+
246
+ __isES6() {
247
+ return this.__options.ecmaVersion >= 6;
248
+ }
249
+ }
250
+
251
+ export default ScopeManager;
252
+
253
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/scope.js ADDED
@@ -0,0 +1,793 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+
27
+ import Reference from "./reference.js";
28
+ import Variable from "./variable.js";
29
+ import { Definition } from "./definition.js";
30
+ import { assert } from "./assert.js";
31
+
32
+ const { Syntax } = estraverse;
33
+
34
+ /**
35
+ * Test if scope is struct
36
+ * @param {Scope} scope scope
37
+ * @param {Block} block block
38
+ * @param {boolean} isMethodDefinition is method definition
39
+ * @returns {boolean} is strict scope
40
+ */
41
+ function isStrictScope(scope, block, isMethodDefinition) {
42
+ let body;
43
+
44
+ // When upper scope is exists and strict, inner scope is also strict.
45
+ if (scope.upper && scope.upper.isStrict) {
46
+ return true;
47
+ }
48
+
49
+ if (isMethodDefinition) {
50
+ return true;
51
+ }
52
+
53
+ if (scope.type === "class" || scope.type === "module") {
54
+ return true;
55
+ }
56
+
57
+ if (scope.type === "block" || scope.type === "switch") {
58
+ return false;
59
+ }
60
+
61
+ if (scope.type === "function") {
62
+ if (block.type === Syntax.ArrowFunctionExpression && block.body.type !== Syntax.BlockStatement) {
63
+ return false;
64
+ }
65
+
66
+ if (block.type === Syntax.Program) {
67
+ body = block;
68
+ } else {
69
+ body = block.body;
70
+ }
71
+
72
+ if (!body) {
73
+ return false;
74
+ }
75
+ } else if (scope.type === "global") {
76
+ body = block;
77
+ } else {
78
+ return false;
79
+ }
80
+
81
+ // Search for a 'use strict' directive.
82
+ for (let i = 0, iz = body.body.length; i < iz; ++i) {
83
+ const stmt = body.body[i];
84
+
85
+ /*
86
+ * Check if the current statement is a directive.
87
+ * If it isn't, then we're past the directive prologue
88
+ * so stop the search because directives cannot
89
+ * appear after this point.
90
+ *
91
+ * Some parsers set `directive:null` on non-directive
92
+ * statements, so the `typeof` check is safer than
93
+ * checking for property existence.
94
+ */
95
+ if (typeof stmt.directive !== "string") {
96
+ break;
97
+ }
98
+
99
+ if (stmt.directive === "use strict") {
100
+ return true;
101
+ }
102
+ }
103
+
104
+ return false;
105
+ }
106
+
107
+ /**
108
+ * Register scope
109
+ * @param {ScopeManager} scopeManager scope manager
110
+ * @param {Scope} scope scope
111
+ * @returns {void}
112
+ */
113
+ function registerScope(scopeManager, scope) {
114
+ scopeManager.scopes.push(scope);
115
+
116
+ const scopes = scopeManager.__nodeToScope.get(scope.block);
117
+
118
+ if (scopes) {
119
+ scopes.push(scope);
120
+ } else {
121
+ scopeManager.__nodeToScope.set(scope.block, [scope]);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Should be statically
127
+ * @param {Object} def def
128
+ * @returns {boolean} should be statically
129
+ */
130
+ function shouldBeStatically(def) {
131
+ return (
132
+ (def.type === Variable.ClassName) ||
133
+ (def.type === Variable.Variable && def.parent.kind !== "var")
134
+ );
135
+ }
136
+
137
+ /**
138
+ * @constructor Scope
139
+ */
140
+ class Scope {
141
+ constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
142
+
143
+ /**
144
+ * One of "global", "module", "function", "function-expression-name", "block", "switch", "catch", "with", "for",
145
+ * "class", "class-field-initializer", "class-static-block".
146
+ * @member {string} Scope#type
147
+ */
148
+ this.type = type;
149
+
150
+ /**
151
+ * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
152
+ * : Variable }</code>.
153
+ * @member {Map} Scope#set
154
+ */
155
+ this.set = new Map();
156
+
157
+ /**
158
+ * The tainted variables of this scope, as <code>{ Variable.name :
159
+ * boolean }</code>.
160
+ * @member {Map} Scope#taints
161
+ */
162
+ this.taints = new Map();
163
+
164
+ /**
165
+ * Generally, through the lexical scoping of JS you can always know
166
+ * which variable an identifier in the source code refers to. There are
167
+ * a few exceptions to this rule. With 'global' and 'with' scopes you
168
+ * can only decide at runtime which variable a reference refers to.
169
+ * Moreover, if 'eval()' is used in a scope, it might introduce new
170
+ * bindings in this or its parent scopes.
171
+ * All those scopes are considered 'dynamic'.
172
+ * @member {boolean} Scope#dynamic
173
+ */
174
+ this.dynamic = this.type === "global" || this.type === "with";
175
+
176
+ /**
177
+ * A reference to the scope-defining syntax node.
178
+ * @member {espree.Node} Scope#block
179
+ */
180
+ this.block = block;
181
+
182
+ /**
183
+ * The {@link Reference|references} that are not resolved with this scope.
184
+ * @member {Reference[]} Scope#through
185
+ */
186
+ this.through = [];
187
+
188
+ /**
189
+ * The scoped {@link Variable}s of this scope. In the case of a
190
+ * 'function' scope this includes the automatic argument <em>arguments</em> as
191
+ * its first element, as well as all further formal arguments.
192
+ * @member {Variable[]} Scope#variables
193
+ */
194
+ this.variables = [];
195
+
196
+ /**
197
+ * Any variable {@link Reference|reference} found in this scope. This
198
+ * includes occurrences of local variables as well as variables from
199
+ * parent scopes (including the global scope). For local variables
200
+ * this also includes defining occurrences (like in a 'var' statement).
201
+ * In a 'function' scope this does not include the occurrences of the
202
+ * formal parameter in the parameter list.
203
+ * @member {Reference[]} Scope#references
204
+ */
205
+ this.references = [];
206
+
207
+ /**
208
+ * For 'global' and 'function' scopes, this is a self-reference. For
209
+ * other scope types this is the <em>variableScope</em> value of the
210
+ * parent scope.
211
+ * @member {Scope} Scope#variableScope
212
+ */
213
+ this.variableScope =
214
+ this.type === "global" ||
215
+ this.type === "module" ||
216
+ this.type === "function" ||
217
+ this.type === "class-field-initializer" ||
218
+ this.type === "class-static-block"
219
+ ? this
220
+ : upperScope.variableScope;
221
+
222
+ /**
223
+ * Whether this scope is created by a FunctionExpression.
224
+ * @member {boolean} Scope#functionExpressionScope
225
+ */
226
+ this.functionExpressionScope = false;
227
+
228
+ /**
229
+ * Whether this is a scope that contains an 'eval()' invocation.
230
+ * @member {boolean} Scope#directCallToEvalScope
231
+ */
232
+ this.directCallToEvalScope = false;
233
+
234
+ /**
235
+ * @member {boolean} Scope#thisFound
236
+ */
237
+ this.thisFound = false;
238
+
239
+ this.__left = [];
240
+
241
+ /**
242
+ * Reference to the parent {@link Scope|scope}.
243
+ * @member {Scope} Scope#upper
244
+ */
245
+ this.upper = upperScope;
246
+
247
+ /**
248
+ * Whether 'use strict' is in effect in this scope.
249
+ * @member {boolean} Scope#isStrict
250
+ */
251
+ this.isStrict = scopeManager.isStrictModeSupported()
252
+ ? isStrictScope(this, block, isMethodDefinition)
253
+ : false;
254
+
255
+ /**
256
+ * List of nested {@link Scope}s.
257
+ * @member {Scope[]} Scope#childScopes
258
+ */
259
+ this.childScopes = [];
260
+ if (this.upper) {
261
+ this.upper.childScopes.push(this);
262
+ }
263
+
264
+ this.__declaredVariables = scopeManager.__declaredVariables;
265
+
266
+ registerScope(scopeManager, this);
267
+ }
268
+
269
+ __shouldStaticallyClose(scopeManager) {
270
+ return (!this.dynamic || scopeManager.__isOptimistic());
271
+ }
272
+
273
+ __shouldStaticallyCloseForGlobal(ref) {
274
+
275
+ // On global scope, let/const/class declarations should be resolved statically.
276
+ const name = ref.identifier.name;
277
+
278
+ if (!this.set.has(name)) {
279
+ return false;
280
+ }
281
+
282
+ const variable = this.set.get(name);
283
+ const defs = variable.defs;
284
+
285
+ return defs.length > 0 && defs.every(shouldBeStatically);
286
+ }
287
+
288
+ __staticCloseRef(ref) {
289
+ if (!this.__resolve(ref)) {
290
+ this.__delegateToUpperScope(ref);
291
+ }
292
+ }
293
+
294
+ __dynamicCloseRef(ref) {
295
+
296
+ // notify all names are through to global
297
+ let current = this;
298
+
299
+ do {
300
+ current.through.push(ref);
301
+ current = current.upper;
302
+ } while (current);
303
+ }
304
+
305
+ __globalCloseRef(ref) {
306
+
307
+ // let/const/class declarations should be resolved statically.
308
+ // others should be resolved dynamically.
309
+ if (this.__shouldStaticallyCloseForGlobal(ref)) {
310
+ this.__staticCloseRef(ref);
311
+ } else {
312
+ this.__dynamicCloseRef(ref);
313
+ }
314
+ }
315
+
316
+ __close(scopeManager) {
317
+ let closeRef;
318
+
319
+ if (this.__shouldStaticallyClose(scopeManager)) {
320
+ closeRef = this.__staticCloseRef;
321
+ } else if (this.type !== "global") {
322
+ closeRef = this.__dynamicCloseRef;
323
+ } else {
324
+ closeRef = this.__globalCloseRef;
325
+ }
326
+
327
+ // Try Resolving all references in this scope.
328
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
329
+ const ref = this.__left[i];
330
+
331
+ closeRef.call(this, ref);
332
+ }
333
+ this.__left = null;
334
+
335
+ return this.upper;
336
+ }
337
+
338
+ // To override by function scopes.
339
+ // References in default parameters isn't resolved to variables which are in their function body.
340
+ __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
341
+ return true;
342
+ }
343
+
344
+ __resolve(ref) {
345
+ const name = ref.identifier.name;
346
+
347
+ if (!this.set.has(name)) {
348
+ return false;
349
+ }
350
+ const variable = this.set.get(name);
351
+
352
+ if (!this.__isValidResolution(ref, variable)) {
353
+ return false;
354
+ }
355
+ variable.references.push(ref);
356
+ variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
357
+ if (ref.tainted) {
358
+ variable.tainted = true;
359
+ this.taints.set(variable.name, true);
360
+ }
361
+ ref.resolved = variable;
362
+
363
+ return true;
364
+ }
365
+
366
+ __delegateToUpperScope(ref) {
367
+ if (this.upper) {
368
+ this.upper.__left.push(ref);
369
+ }
370
+ this.through.push(ref);
371
+ }
372
+
373
+ __addDeclaredVariablesOfNode(variable, node) {
374
+ if (node === null || node === void 0) {
375
+ return;
376
+ }
377
+
378
+ let variables = this.__declaredVariables.get(node);
379
+
380
+ if (variables === null || variables === void 0) {
381
+ variables = [];
382
+ this.__declaredVariables.set(node, variables);
383
+ }
384
+ if (!variables.includes(variable)) {
385
+ variables.push(variable);
386
+ }
387
+ }
388
+
389
+ __defineGeneric(name, set, variables, node, def) {
390
+ let variable;
391
+
392
+ variable = set.get(name);
393
+ if (!variable) {
394
+ variable = new Variable(name, this);
395
+ set.set(name, variable);
396
+ variables.push(variable);
397
+ }
398
+
399
+ if (def) {
400
+ variable.defs.push(def);
401
+ this.__addDeclaredVariablesOfNode(variable, def.node);
402
+ this.__addDeclaredVariablesOfNode(variable, def.parent);
403
+ }
404
+ if (node) {
405
+ variable.identifiers.push(node);
406
+ }
407
+ }
408
+
409
+ __define(node, def) {
410
+ if (node && node.type === Syntax.Identifier) {
411
+ this.__defineGeneric(
412
+ node.name,
413
+ this.set,
414
+ this.variables,
415
+ node,
416
+ def
417
+ );
418
+ }
419
+ }
420
+
421
+ __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
422
+
423
+ // because Array element may be null
424
+ if (!node || (node.type !== Syntax.Identifier && node.type !== "JSXIdentifier")) {
425
+ return;
426
+ }
427
+
428
+ // Specially handle like `this`.
429
+ if (node.name === "super") {
430
+ return;
431
+ }
432
+
433
+ const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
434
+
435
+ this.references.push(ref);
436
+ this.__left.push(ref);
437
+ }
438
+
439
+ __detectEval() {
440
+ let current = this;
441
+
442
+ this.directCallToEvalScope = true;
443
+ do {
444
+ current.dynamic = true;
445
+ current = current.upper;
446
+ } while (current);
447
+ }
448
+
449
+ __detectThis() {
450
+ this.thisFound = true;
451
+ }
452
+
453
+ __isClosed() {
454
+ return this.__left === null;
455
+ }
456
+
457
+ /**
458
+ * returns resolved {Reference}
459
+ * @function Scope#resolve
460
+ * @param {Espree.Identifier} ident identifier to be resolved.
461
+ * @returns {Reference} reference
462
+ */
463
+ resolve(ident) {
464
+ let ref, i, iz;
465
+
466
+ assert(this.__isClosed(), "Scope should be closed.");
467
+ assert(ident.type === Syntax.Identifier, "Target should be identifier.");
468
+ for (i = 0, iz = this.references.length; i < iz; ++i) {
469
+ ref = this.references[i];
470
+ if (ref.identifier === ident) {
471
+ return ref;
472
+ }
473
+ }
474
+ return null;
475
+ }
476
+
477
+ /**
478
+ * returns this scope is static
479
+ * @function Scope#isStatic
480
+ * @returns {boolean} static
481
+ */
482
+ isStatic() {
483
+ return !this.dynamic;
484
+ }
485
+
486
+ /**
487
+ * returns this scope has materialized arguments
488
+ * @function Scope#isArgumentsMaterialized
489
+ * @returns {boolean} arguemnts materialized
490
+ */
491
+ isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
492
+ return true;
493
+ }
494
+
495
+ /**
496
+ * returns this scope has materialized `this` reference
497
+ * @function Scope#isThisMaterialized
498
+ * @returns {boolean} this materialized
499
+ */
500
+ isThisMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
501
+ return true;
502
+ }
503
+
504
+ isUsedName(name) {
505
+ if (this.set.has(name)) {
506
+ return true;
507
+ }
508
+ for (let i = 0, iz = this.through.length; i < iz; ++i) {
509
+ if (this.through[i].identifier.name === name) {
510
+ return true;
511
+ }
512
+ }
513
+ return false;
514
+ }
515
+ }
516
+
517
+ /**
518
+ * Global scope.
519
+ */
520
+ class GlobalScope extends Scope {
521
+ constructor(scopeManager, block) {
522
+ super(scopeManager, "global", null, block, false);
523
+ this.implicit = {
524
+ set: new Map(),
525
+ variables: [],
526
+
527
+ /**
528
+ * List of {@link Reference}s that are left to be resolved (i.e. which
529
+ * need to be linked to the variable they refer to).
530
+ * @member {Reference[]} Scope#implicit#left
531
+ */
532
+ left: []
533
+ };
534
+ }
535
+
536
+ __close(scopeManager) {
537
+ const implicit = [];
538
+
539
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
540
+ const ref = this.__left[i];
541
+
542
+ if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
543
+ implicit.push(ref.__maybeImplicitGlobal);
544
+ }
545
+ }
546
+
547
+ // create an implicit global variable from assignment expression
548
+ for (let i = 0, iz = implicit.length; i < iz; ++i) {
549
+ const info = implicit[i];
550
+
551
+ this.__defineImplicit(info.pattern,
552
+ new Definition(
553
+ Variable.ImplicitGlobalVariable,
554
+ info.pattern,
555
+ info.node,
556
+ null,
557
+ null,
558
+ null
559
+ ));
560
+
561
+ }
562
+
563
+ this.implicit.left = this.__left;
564
+
565
+ return super.__close(scopeManager);
566
+ }
567
+
568
+ __defineImplicit(node, def) {
569
+ if (node && node.type === Syntax.Identifier) {
570
+ this.__defineGeneric(
571
+ node.name,
572
+ this.implicit.set,
573
+ this.implicit.variables,
574
+ node,
575
+ def
576
+ );
577
+ }
578
+ }
579
+ }
580
+
581
+ /**
582
+ * Module scope.
583
+ */
584
+ class ModuleScope extends Scope {
585
+ constructor(scopeManager, upperScope, block) {
586
+ super(scopeManager, "module", upperScope, block, false);
587
+ }
588
+ }
589
+
590
+ /**
591
+ * Function expression name scope.
592
+ */
593
+ class FunctionExpressionNameScope extends Scope {
594
+ constructor(scopeManager, upperScope, block) {
595
+ super(scopeManager, "function-expression-name", upperScope, block, false);
596
+ this.__define(block.id,
597
+ new Definition(
598
+ Variable.FunctionName,
599
+ block.id,
600
+ block,
601
+ null,
602
+ null,
603
+ null
604
+ ));
605
+ this.functionExpressionScope = true;
606
+ }
607
+ }
608
+
609
+ /**
610
+ * Catch scope.
611
+ */
612
+ class CatchScope extends Scope {
613
+ constructor(scopeManager, upperScope, block) {
614
+ super(scopeManager, "catch", upperScope, block, false);
615
+ }
616
+ }
617
+
618
+ /**
619
+ * With statement scope.
620
+ */
621
+ class WithScope extends Scope {
622
+ constructor(scopeManager, upperScope, block) {
623
+ super(scopeManager, "with", upperScope, block, false);
624
+ }
625
+
626
+ __close(scopeManager) {
627
+ if (this.__shouldStaticallyClose(scopeManager)) {
628
+ return super.__close(scopeManager);
629
+ }
630
+
631
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
632
+ const ref = this.__left[i];
633
+
634
+ ref.tainted = true;
635
+ this.__delegateToUpperScope(ref);
636
+ }
637
+ this.__left = null;
638
+
639
+ return this.upper;
640
+ }
641
+ }
642
+
643
+ /**
644
+ * Block scope.
645
+ */
646
+ class BlockScope extends Scope {
647
+ constructor(scopeManager, upperScope, block) {
648
+ super(scopeManager, "block", upperScope, block, false);
649
+ }
650
+ }
651
+
652
+ /**
653
+ * Switch scope.
654
+ */
655
+ class SwitchScope extends Scope {
656
+ constructor(scopeManager, upperScope, block) {
657
+ super(scopeManager, "switch", upperScope, block, false);
658
+ }
659
+ }
660
+
661
+ /**
662
+ * Function scope.
663
+ */
664
+ class FunctionScope extends Scope {
665
+ constructor(scopeManager, upperScope, block, isMethodDefinition) {
666
+ super(scopeManager, "function", upperScope, block, isMethodDefinition);
667
+
668
+ // section 9.2.13, FunctionDeclarationInstantiation.
669
+ // NOTE Arrow functions never have an arguments objects.
670
+ if (this.block.type !== Syntax.ArrowFunctionExpression) {
671
+ this.__defineArguments();
672
+ }
673
+ }
674
+
675
+ isArgumentsMaterialized() {
676
+
677
+ // TODO(Constellation)
678
+ // We can more aggressive on this condition like this.
679
+ //
680
+ // function t() {
681
+ // // arguments of t is always hidden.
682
+ // function arguments() {
683
+ // }
684
+ // }
685
+ if (this.block.type === Syntax.ArrowFunctionExpression) {
686
+ return false;
687
+ }
688
+
689
+ if (!this.isStatic()) {
690
+ return true;
691
+ }
692
+
693
+ const variable = this.set.get("arguments");
694
+
695
+ assert(variable, "Always have arguments variable.");
696
+ return variable.tainted || variable.references.length !== 0;
697
+ }
698
+
699
+ isThisMaterialized() {
700
+ if (!this.isStatic()) {
701
+ return true;
702
+ }
703
+ return this.thisFound;
704
+ }
705
+
706
+ __defineArguments() {
707
+ this.__defineGeneric(
708
+ "arguments",
709
+ this.set,
710
+ this.variables,
711
+ null,
712
+ null
713
+ );
714
+ this.taints.set("arguments", true);
715
+ }
716
+
717
+ // References in default parameters isn't resolved to variables which are in their function body.
718
+ // const x = 1
719
+ // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
720
+ // const x = 2
721
+ // console.log(a)
722
+ // }
723
+ __isValidResolution(ref, variable) {
724
+
725
+ // If `options.nodejsScope` is true, `this.block` becomes a Program node.
726
+ if (this.block.type === "Program") {
727
+ return true;
728
+ }
729
+
730
+ const bodyStart = this.block.body.range[0];
731
+
732
+ // It's invalid resolution in the following case:
733
+ return !(
734
+ variable.scope === this &&
735
+ ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
736
+ variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
737
+ );
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Scope of for, for-in, and for-of statements.
743
+ */
744
+ class ForScope extends Scope {
745
+ constructor(scopeManager, upperScope, block) {
746
+ super(scopeManager, "for", upperScope, block, false);
747
+ }
748
+ }
749
+
750
+ /**
751
+ * Class scope.
752
+ */
753
+ class ClassScope extends Scope {
754
+ constructor(scopeManager, upperScope, block) {
755
+ super(scopeManager, "class", upperScope, block, false);
756
+ }
757
+ }
758
+
759
+ /**
760
+ * Class field initializer scope.
761
+ */
762
+ class ClassFieldInitializerScope extends Scope {
763
+ constructor(scopeManager, upperScope, block) {
764
+ super(scopeManager, "class-field-initializer", upperScope, block, true);
765
+ }
766
+ }
767
+
768
+ /**
769
+ * Class static block scope.
770
+ */
771
+ class ClassStaticBlockScope extends Scope {
772
+ constructor(scopeManager, upperScope, block) {
773
+ super(scopeManager, "class-static-block", upperScope, block, true);
774
+ }
775
+ }
776
+
777
+ export {
778
+ Scope,
779
+ GlobalScope,
780
+ ModuleScope,
781
+ FunctionExpressionNameScope,
782
+ CatchScope,
783
+ WithScope,
784
+ BlockScope,
785
+ SwitchScope,
786
+ FunctionScope,
787
+ ForScope,
788
+ ClassScope,
789
+ ClassFieldInitializerScope,
790
+ ClassStaticBlockScope
791
+ };
792
+
793
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/variable.js ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ /**
26
+ * A Variable represents a locally scoped identifier. These include arguments to
27
+ * functions.
28
+ * @constructor Variable
29
+ */
30
+ class Variable {
31
+ constructor(name, scope) {
32
+
33
+ /**
34
+ * The variable name, as given in the source code.
35
+ * @member {string} Variable#name
36
+ */
37
+ this.name = name;
38
+
39
+ /**
40
+ * List of defining occurrences of this variable (like in 'var ...'
41
+ * statements or as parameter), as AST nodes.
42
+ * @member {espree.Identifier[]} Variable#identifiers
43
+ */
44
+ this.identifiers = [];
45
+
46
+ /**
47
+ * List of {@link Reference|references} of this variable (excluding parameter entries)
48
+ * in its defining scope and all nested scopes. For defining
49
+ * occurrences only see {@link Variable#defs}.
50
+ * @member {Reference[]} Variable#references
51
+ */
52
+ this.references = [];
53
+
54
+ /**
55
+ * List of defining occurrences of this variable (like in 'var ...'
56
+ * statements or as parameter), as custom objects.
57
+ * @member {Definition[]} Variable#defs
58
+ */
59
+ this.defs = [];
60
+
61
+ this.tainted = false;
62
+
63
+ /**
64
+ * Whether this is a stack variable.
65
+ * @member {boolean} Variable#stack
66
+ */
67
+ this.stack = true;
68
+
69
+ /**
70
+ * Reference to the enclosing Scope.
71
+ * @member {Scope} Variable#scope
72
+ */
73
+ this.scope = scope;
74
+ }
75
+ }
76
+
77
+ Variable.CatchClause = "CatchClause";
78
+ Variable.Parameter = "Parameter";
79
+ Variable.FunctionName = "FunctionName";
80
+ Variable.ClassName = "ClassName";
81
+ Variable.Variable = "Variable";
82
+ Variable.ImportBinding = "ImportBinding";
83
+ Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
84
+
85
+ export default Variable;
86
+
87
+ /* vim: set sw=4 ts=4 et tw=80 : */
server/node_modules/eslint-scope/lib/version.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ const version = "8.4.0";
2
+
3
+ export default version;
server/node_modules/eslint-scope/package.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-scope",
3
+ "description": "ECMAScript scope analyzer for ESLint",
4
+ "homepage": "https://github.com/eslint/js/blob/main/packages/eslint-scope/README.md",
5
+ "main": "./dist/eslint-scope.cjs",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./lib/index.js",
10
+ "require": "./dist/eslint-scope.cjs"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "version": "8.4.0",
15
+ "engines": {
16
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/eslint/js.git",
21
+ "directory": "packages/eslint-scope"
22
+ },
23
+ "funding": "https://opencollective.com/eslint",
24
+ "keywords": [
25
+ "eslint"
26
+ ],
27
+ "bugs": {
28
+ "url": "https://github.com/eslint/js/issues"
29
+ },
30
+ "license": "BSD-2-Clause",
31
+ "scripts": {
32
+ "build": "rollup -c",
33
+ "build:update-version": "node tools/update-version.js",
34
+ "prepublishOnly": "npm run build:update-version && npm run build",
35
+ "pretest": "npm run build",
36
+ "release:generate:latest": "eslint-generate-release",
37
+ "release:generate:alpha": "eslint-generate-prerelease alpha",
38
+ "release:generate:beta": "eslint-generate-prerelease beta",
39
+ "release:generate:rc": "eslint-generate-prerelease rc",
40
+ "release:publish": "eslint-publish-release",
41
+ "test": "node Makefile.js test"
42
+ },
43
+ "files": [
44
+ "LICENSE",
45
+ "README.md",
46
+ "lib",
47
+ "dist/eslint-scope.cjs"
48
+ ],
49
+ "dependencies": {
50
+ "esrecurse": "^4.3.0",
51
+ "estraverse": "^5.2.0"
52
+ },
53
+ "devDependencies": {
54
+ "@typescript-eslint/parser": "^8.7.0",
55
+ "chai": "^4.3.4",
56
+ "eslint-release": "^3.2.0",
57
+ "eslint-visitor-keys": "^4.2.1",
58
+ "espree": "^10.4.0",
59
+ "npm-license": "^0.3.3",
60
+ "rollup": "^2.52.7",
61
+ "shelljs": "^0.8.5",
62
+ "typescript": "^5.4.2"
63
+ }
64
+ }
server/node_modules/eslint-visitor-keys/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
server/node_modules/eslint-visitor-keys/README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # eslint-visitor-keys
2
+
3
+ [![npm version](https://img.shields.io/npm/v/eslint-visitor-keys.svg)](https://www.npmjs.com/package/eslint-visitor-keys)
4
+ [![Downloads/month](https://img.shields.io/npm/dm/eslint-visitor-keys.svg)](http://www.npmtrends.com/eslint-visitor-keys)
5
+ [![Build Status](https://github.com/eslint/js/workflows/CI/badge.svg)](https://github.com/eslint/js/actions)
6
+
7
+ Constants and utilities about visitor keys to traverse AST.
8
+
9
+ ## 💿 Installation
10
+
11
+ Use [npm] to install.
12
+
13
+ ```bash
14
+ $ npm install eslint-visitor-keys
15
+ ```
16
+
17
+ ### Requirements
18
+
19
+ - [Node.js] `^18.18.0`, `^20.9.0`, or `>=21.1.0`
20
+
21
+ ## 📖 Usage
22
+
23
+ To use in an ESM file:
24
+
25
+ ```js
26
+ import * as evk from "eslint-visitor-keys"
27
+ ```
28
+
29
+ To use in a CommonJS file:
30
+
31
+ ```js
32
+ const evk = require("eslint-visitor-keys")
33
+ ```
34
+
35
+ ### evk.KEYS
36
+
37
+ > type: `{ [type: string]: string[] | undefined }`
38
+
39
+ Visitor keys. This keys are frozen.
40
+
41
+ This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
42
+
43
+ For example:
44
+
45
+ ```
46
+ console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
47
+ ```
48
+
49
+ ### evk.getKeys(node)
50
+
51
+ > type: `(node: object) => string[]`
52
+
53
+ Get the visitor keys of a given AST node.
54
+
55
+ This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
56
+
57
+ This will be used to traverse unknown nodes.
58
+
59
+ For example:
60
+
61
+ ```js
62
+ const node = {
63
+ type: "AssignmentExpression",
64
+ left: { type: "Identifier", name: "foo" },
65
+ right: { type: "Literal", value: 0 }
66
+ }
67
+ console.log(evk.getKeys(node)) // → ["type", "left", "right"]
68
+ ```
69
+
70
+ ### evk.unionWith(additionalKeys)
71
+
72
+ > type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
73
+
74
+ Make the union set with `evk.KEYS` and the given keys.
75
+
76
+ - The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
77
+ - It removes duplicated keys as keeping the first one.
78
+
79
+ For example:
80
+
81
+ ```js
82
+ console.log(evk.unionWith({
83
+ MethodDefinition: ["decorators"]
84
+ })) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
85
+ ```
86
+
87
+ ## 📰 Change log
88
+
89
+ See [GitHub releases](https://github.com/eslint/js/releases).
90
+
91
+ ## 🍻 Contributing
92
+
93
+ Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
94
+
95
+ ### Development commands
96
+
97
+ - `npm test` runs tests and measures code coverage.
98
+ - `npm run lint` checks source codes with ESLint.
99
+ - `npm run test:open-coverage` opens the code coverage report of the previous test with your default browser.
100
+
101
+ [npm]: https://www.npmjs.com/
102
+ [Node.js]: https://nodejs.org/
103
+ [ESTree]: https://github.com/estree/estree
104
+
105
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
106
+ <!--sponsorsstart-->
107
+ ## Sponsors
108
+
109
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
110
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
111
+
112
+ <h3>Diamond Sponsors</h3>
113
+ <p><a href="https://www.ag-grid.com/"><img src="https://images.opencollective.com/ag-grid/bec0580/logo.png" alt="AG Grid" height="128"></a></p><h3>Platinum Sponsors</h3>
114
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
115
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
116
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
117
+ <p><a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
118
+ <h3>Technology Sponsors</h3>
119
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
120
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
121
+ <!--sponsorsend-->
server/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ /* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
4
+ TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
5
+ */
6
+ /**
7
+ * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
8
+ */
9
+ /* eslint-enable jsdoc/valid-types -- doesn't allow `readonly string[]`. TODO: check why */
10
+
11
+ /**
12
+ * @type {VisitorKeys}
13
+ */
14
+ const KEYS = {
15
+ ArrayExpression: [
16
+ "elements"
17
+ ],
18
+ ArrayPattern: [
19
+ "elements"
20
+ ],
21
+ ArrowFunctionExpression: [
22
+ "params",
23
+ "body"
24
+ ],
25
+ AssignmentExpression: [
26
+ "left",
27
+ "right"
28
+ ],
29
+ AssignmentPattern: [
30
+ "left",
31
+ "right"
32
+ ],
33
+ AwaitExpression: [
34
+ "argument"
35
+ ],
36
+ BinaryExpression: [
37
+ "left",
38
+ "right"
39
+ ],
40
+ BlockStatement: [
41
+ "body"
42
+ ],
43
+ BreakStatement: [
44
+ "label"
45
+ ],
46
+ CallExpression: [
47
+ "callee",
48
+ "arguments"
49
+ ],
50
+ CatchClause: [
51
+ "param",
52
+ "body"
53
+ ],
54
+ ChainExpression: [
55
+ "expression"
56
+ ],
57
+ ClassBody: [
58
+ "body"
59
+ ],
60
+ ClassDeclaration: [
61
+ "id",
62
+ "superClass",
63
+ "body"
64
+ ],
65
+ ClassExpression: [
66
+ "id",
67
+ "superClass",
68
+ "body"
69
+ ],
70
+ ConditionalExpression: [
71
+ "test",
72
+ "consequent",
73
+ "alternate"
74
+ ],
75
+ ContinueStatement: [
76
+ "label"
77
+ ],
78
+ DebuggerStatement: [],
79
+ DoWhileStatement: [
80
+ "body",
81
+ "test"
82
+ ],
83
+ EmptyStatement: [],
84
+ ExperimentalRestProperty: [
85
+ "argument"
86
+ ],
87
+ ExperimentalSpreadProperty: [
88
+ "argument"
89
+ ],
90
+ ExportAllDeclaration: [
91
+ "exported",
92
+ "source",
93
+ "attributes"
94
+ ],
95
+ ExportDefaultDeclaration: [
96
+ "declaration"
97
+ ],
98
+ ExportNamedDeclaration: [
99
+ "declaration",
100
+ "specifiers",
101
+ "source",
102
+ "attributes"
103
+ ],
104
+ ExportSpecifier: [
105
+ "local",
106
+ "exported"
107
+ ],
108
+ ExpressionStatement: [
109
+ "expression"
110
+ ],
111
+ ForInStatement: [
112
+ "left",
113
+ "right",
114
+ "body"
115
+ ],
116
+ ForOfStatement: [
117
+ "left",
118
+ "right",
119
+ "body"
120
+ ],
121
+ ForStatement: [
122
+ "init",
123
+ "test",
124
+ "update",
125
+ "body"
126
+ ],
127
+ FunctionDeclaration: [
128
+ "id",
129
+ "params",
130
+ "body"
131
+ ],
132
+ FunctionExpression: [
133
+ "id",
134
+ "params",
135
+ "body"
136
+ ],
137
+ Identifier: [],
138
+ IfStatement: [
139
+ "test",
140
+ "consequent",
141
+ "alternate"
142
+ ],
143
+ ImportAttribute: [
144
+ "key",
145
+ "value"
146
+ ],
147
+ ImportDeclaration: [
148
+ "specifiers",
149
+ "source",
150
+ "attributes"
151
+ ],
152
+ ImportDefaultSpecifier: [
153
+ "local"
154
+ ],
155
+ ImportExpression: [
156
+ "source",
157
+ "options"
158
+ ],
159
+ ImportNamespaceSpecifier: [
160
+ "local"
161
+ ],
162
+ ImportSpecifier: [
163
+ "imported",
164
+ "local"
165
+ ],
166
+ JSXAttribute: [
167
+ "name",
168
+ "value"
169
+ ],
170
+ JSXClosingElement: [
171
+ "name"
172
+ ],
173
+ JSXClosingFragment: [],
174
+ JSXElement: [
175
+ "openingElement",
176
+ "children",
177
+ "closingElement"
178
+ ],
179
+ JSXEmptyExpression: [],
180
+ JSXExpressionContainer: [
181
+ "expression"
182
+ ],
183
+ JSXFragment: [
184
+ "openingFragment",
185
+ "children",
186
+ "closingFragment"
187
+ ],
188
+ JSXIdentifier: [],
189
+ JSXMemberExpression: [
190
+ "object",
191
+ "property"
192
+ ],
193
+ JSXNamespacedName: [
194
+ "namespace",
195
+ "name"
196
+ ],
197
+ JSXOpeningElement: [
198
+ "name",
199
+ "attributes"
200
+ ],
201
+ JSXOpeningFragment: [],
202
+ JSXSpreadAttribute: [
203
+ "argument"
204
+ ],
205
+ JSXSpreadChild: [
206
+ "expression"
207
+ ],
208
+ JSXText: [],
209
+ LabeledStatement: [
210
+ "label",
211
+ "body"
212
+ ],
213
+ Literal: [],
214
+ LogicalExpression: [
215
+ "left",
216
+ "right"
217
+ ],
218
+ MemberExpression: [
219
+ "object",
220
+ "property"
221
+ ],
222
+ MetaProperty: [
223
+ "meta",
224
+ "property"
225
+ ],
226
+ MethodDefinition: [
227
+ "key",
228
+ "value"
229
+ ],
230
+ NewExpression: [
231
+ "callee",
232
+ "arguments"
233
+ ],
234
+ ObjectExpression: [
235
+ "properties"
236
+ ],
237
+ ObjectPattern: [
238
+ "properties"
239
+ ],
240
+ PrivateIdentifier: [],
241
+ Program: [
242
+ "body"
243
+ ],
244
+ Property: [
245
+ "key",
246
+ "value"
247
+ ],
248
+ PropertyDefinition: [
249
+ "key",
250
+ "value"
251
+ ],
252
+ RestElement: [
253
+ "argument"
254
+ ],
255
+ ReturnStatement: [
256
+ "argument"
257
+ ],
258
+ SequenceExpression: [
259
+ "expressions"
260
+ ],
261
+ SpreadElement: [
262
+ "argument"
263
+ ],
264
+ StaticBlock: [
265
+ "body"
266
+ ],
267
+ Super: [],
268
+ SwitchCase: [
269
+ "test",
270
+ "consequent"
271
+ ],
272
+ SwitchStatement: [
273
+ "discriminant",
274
+ "cases"
275
+ ],
276
+ TaggedTemplateExpression: [
277
+ "tag",
278
+ "quasi"
279
+ ],
280
+ TemplateElement: [],
281
+ TemplateLiteral: [
282
+ "quasis",
283
+ "expressions"
284
+ ],
285
+ ThisExpression: [],
286
+ ThrowStatement: [
287
+ "argument"
288
+ ],
289
+ TryStatement: [
290
+ "block",
291
+ "handler",
292
+ "finalizer"
293
+ ],
294
+ UnaryExpression: [
295
+ "argument"
296
+ ],
297
+ UpdateExpression: [
298
+ "argument"
299
+ ],
300
+ VariableDeclaration: [
301
+ "declarations"
302
+ ],
303
+ VariableDeclarator: [
304
+ "id",
305
+ "init"
306
+ ],
307
+ WhileStatement: [
308
+ "test",
309
+ "body"
310
+ ],
311
+ WithStatement: [
312
+ "object",
313
+ "body"
314
+ ],
315
+ YieldExpression: [
316
+ "argument"
317
+ ]
318
+ };
319
+
320
+ // Types.
321
+ const NODE_TYPES = Object.keys(KEYS);
322
+
323
+ // Freeze the keys.
324
+ for (const type of NODE_TYPES) {
325
+ Object.freeze(KEYS[type]);
326
+ }
327
+ Object.freeze(KEYS);
328
+
329
+ /**
330
+ * @author Toru Nagashima <https://github.com/mysticatea>
331
+ * See LICENSE file in root directory for full license.
332
+ */
333
+
334
+ /**
335
+ * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
336
+ */
337
+
338
+ // List to ignore keys.
339
+ const KEY_BLACKLIST = new Set([
340
+ "parent",
341
+ "leadingComments",
342
+ "trailingComments"
343
+ ]);
344
+
345
+ /**
346
+ * Check whether a given key should be used or not.
347
+ * @param {string} key The key to check.
348
+ * @returns {boolean} `true` if the key should be used.
349
+ */
350
+ function filterKey(key) {
351
+ return !KEY_BLACKLIST.has(key) && key[0] !== "_";
352
+ }
353
+
354
+
355
+ /* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
356
+ TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
357
+ */
358
+ /**
359
+ * Get visitor keys of a given node.
360
+ * @param {Object} node The AST node to get keys.
361
+ * @returns {readonly string[]} Visitor keys of the node.
362
+ */
363
+ function getKeys(node) {
364
+ return Object.keys(node).filter(filterKey);
365
+ }
366
+ /* eslint-enable jsdoc/valid-types -- doesn't allow `readonly` */
367
+
368
+ /**
369
+ * Make the union set with `KEYS` and given keys.
370
+ * @param {VisitorKeys} additionalKeys The additional keys.
371
+ * @returns {VisitorKeys} The union set.
372
+ */
373
+ function unionWith(additionalKeys) {
374
+ const retv = /** @type {{ [type: string]: ReadonlyArray<string> }} */
375
+ (Object.assign({}, KEYS));
376
+
377
+ for (const type of Object.keys(additionalKeys)) {
378
+ if (Object.hasOwn(retv, type)) {
379
+ const keys = new Set(additionalKeys[type]);
380
+
381
+ for (const key of retv[type]) {
382
+ keys.add(key);
383
+ }
384
+
385
+ retv[type] = Object.freeze(Array.from(keys));
386
+ } else {
387
+ retv[type] = Object.freeze(Array.from(additionalKeys[type]));
388
+ }
389
+ }
390
+
391
+ return Object.freeze(retv);
392
+ }
393
+
394
+ exports.KEYS = KEYS;
395
+ exports.getKeys = getKeys;
396
+ exports.unionWith = unionWith;
server/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ type VisitorKeys$1 = {
2
+ readonly [type: string]: ReadonlyArray<string>;
3
+ };
4
+ /**
5
+ * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
6
+ */
7
+ /**
8
+ * @type {VisitorKeys}
9
+ */
10
+ declare const KEYS: VisitorKeys$1;
11
+
12
+ /**
13
+ * Get visitor keys of a given node.
14
+ * @param {Object} node The AST node to get keys.
15
+ * @returns {readonly string[]} Visitor keys of the node.
16
+ */
17
+ declare function getKeys(node: Object): readonly string[];
18
+ /**
19
+ * Make the union set with `KEYS` and given keys.
20
+ * @param {VisitorKeys} additionalKeys The additional keys.
21
+ * @returns {VisitorKeys} The union set.
22
+ */
23
+ declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
24
+
25
+ type VisitorKeys = VisitorKeys$1;
26
+
27
+ export { KEYS, getKeys, unionWith };
28
+ export type { VisitorKeys };
server/node_modules/eslint-visitor-keys/dist/index.d.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Get visitor keys of a given node.
3
+ * @param {Object} node The AST node to get keys.
4
+ * @returns {readonly string[]} Visitor keys of the node.
5
+ */
6
+ export function getKeys(node: Object): readonly string[];
7
+ /**
8
+ * Make the union set with `KEYS` and given keys.
9
+ * @param {VisitorKeys} additionalKeys The additional keys.
10
+ * @returns {VisitorKeys} The union set.
11
+ */
12
+ export function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
13
+ export { KEYS };
14
+ export type VisitorKeys = import("./visitor-keys.js").VisitorKeys;
15
+ import KEYS from "./visitor-keys.js";
16
+ //# sourceMappingURL=index.d.ts.map
server/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default KEYS;
2
+ export type VisitorKeys = {
3
+ readonly [type: string]: ReadonlyArray<string>;
4
+ };
5
+ /**
6
+ * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
7
+ */
8
+ /**
9
+ * @type {VisitorKeys}
10
+ */
11
+ declare const KEYS: VisitorKeys;
12
+ //# sourceMappingURL=visitor-keys.d.ts.map
server/node_modules/eslint-visitor-keys/lib/index.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Toru Nagashima <https://github.com/mysticatea>
3
+ * See LICENSE file in root directory for full license.
4
+ */
5
+ import KEYS from "./visitor-keys.js";
6
+
7
+ /**
8
+ * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
9
+ */
10
+
11
+ // List to ignore keys.
12
+ const KEY_BLACKLIST = new Set([
13
+ "parent",
14
+ "leadingComments",
15
+ "trailingComments"
16
+ ]);
17
+
18
+ /**
19
+ * Check whether a given key should be used or not.
20
+ * @param {string} key The key to check.
21
+ * @returns {boolean} `true` if the key should be used.
22
+ */
23
+ function filterKey(key) {
24
+ return !KEY_BLACKLIST.has(key) && key[0] !== "_";
25
+ }
26
+
27
+
28
+ /* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
29
+ TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
30
+ */
31
+ /**
32
+ * Get visitor keys of a given node.
33
+ * @param {Object} node The AST node to get keys.
34
+ * @returns {readonly string[]} Visitor keys of the node.
35
+ */
36
+ export function getKeys(node) {
37
+ return Object.keys(node).filter(filterKey);
38
+ }
39
+ /* eslint-enable jsdoc/valid-types -- doesn't allow `readonly` */
40
+
41
+ /**
42
+ * Make the union set with `KEYS` and given keys.
43
+ * @param {VisitorKeys} additionalKeys The additional keys.
44
+ * @returns {VisitorKeys} The union set.
45
+ */
46
+ export function unionWith(additionalKeys) {
47
+ const retv = /** @type {{ [type: string]: ReadonlyArray<string> }} */
48
+ (Object.assign({}, KEYS));
49
+
50
+ for (const type of Object.keys(additionalKeys)) {
51
+ if (Object.hasOwn(retv, type)) {
52
+ const keys = new Set(additionalKeys[type]);
53
+
54
+ for (const key of retv[type]) {
55
+ keys.add(key);
56
+ }
57
+
58
+ retv[type] = Object.freeze(Array.from(keys));
59
+ } else {
60
+ retv[type] = Object.freeze(Array.from(additionalKeys[type]));
61
+ }
62
+ }
63
+
64
+ return Object.freeze(retv);
65
+ }
66
+
67
+ export { KEYS };
server/node_modules/eslint-visitor-keys/lib/visitor-keys.js ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
2
+ TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
3
+ */
4
+ /**
5
+ * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
6
+ */
7
+ /* eslint-enable jsdoc/valid-types -- doesn't allow `readonly string[]`. TODO: check why */
8
+
9
+ /**
10
+ * @type {VisitorKeys}
11
+ */
12
+ const KEYS = {
13
+ ArrayExpression: [
14
+ "elements"
15
+ ],
16
+ ArrayPattern: [
17
+ "elements"
18
+ ],
19
+ ArrowFunctionExpression: [
20
+ "params",
21
+ "body"
22
+ ],
23
+ AssignmentExpression: [
24
+ "left",
25
+ "right"
26
+ ],
27
+ AssignmentPattern: [
28
+ "left",
29
+ "right"
30
+ ],
31
+ AwaitExpression: [
32
+ "argument"
33
+ ],
34
+ BinaryExpression: [
35
+ "left",
36
+ "right"
37
+ ],
38
+ BlockStatement: [
39
+ "body"
40
+ ],
41
+ BreakStatement: [
42
+ "label"
43
+ ],
44
+ CallExpression: [
45
+ "callee",
46
+ "arguments"
47
+ ],
48
+ CatchClause: [
49
+ "param",
50
+ "body"
51
+ ],
52
+ ChainExpression: [
53
+ "expression"
54
+ ],
55
+ ClassBody: [
56
+ "body"
57
+ ],
58
+ ClassDeclaration: [
59
+ "id",
60
+ "superClass",
61
+ "body"
62
+ ],
63
+ ClassExpression: [
64
+ "id",
65
+ "superClass",
66
+ "body"
67
+ ],
68
+ ConditionalExpression: [
69
+ "test",
70
+ "consequent",
71
+ "alternate"
72
+ ],
73
+ ContinueStatement: [
74
+ "label"
75
+ ],
76
+ DebuggerStatement: [],
77
+ DoWhileStatement: [
78
+ "body",
79
+ "test"
80
+ ],
81
+ EmptyStatement: [],
82
+ ExperimentalRestProperty: [
83
+ "argument"
84
+ ],
85
+ ExperimentalSpreadProperty: [
86
+ "argument"
87
+ ],
88
+ ExportAllDeclaration: [
89
+ "exported",
90
+ "source",
91
+ "attributes"
92
+ ],
93
+ ExportDefaultDeclaration: [
94
+ "declaration"
95
+ ],
96
+ ExportNamedDeclaration: [
97
+ "declaration",
98
+ "specifiers",
99
+ "source",
100
+ "attributes"
101
+ ],
102
+ ExportSpecifier: [
103
+ "local",
104
+ "exported"
105
+ ],
106
+ ExpressionStatement: [
107
+ "expression"
108
+ ],
109
+ ForInStatement: [
110
+ "left",
111
+ "right",
112
+ "body"
113
+ ],
114
+ ForOfStatement: [
115
+ "left",
116
+ "right",
117
+ "body"
118
+ ],
119
+ ForStatement: [
120
+ "init",
121
+ "test",
122
+ "update",
123
+ "body"
124
+ ],
125
+ FunctionDeclaration: [
126
+ "id",
127
+ "params",
128
+ "body"
129
+ ],
130
+ FunctionExpression: [
131
+ "id",
132
+ "params",
133
+ "body"
134
+ ],
135
+ Identifier: [],
136
+ IfStatement: [
137
+ "test",
138
+ "consequent",
139
+ "alternate"
140
+ ],
141
+ ImportAttribute: [
142
+ "key",
143
+ "value"
144
+ ],
145
+ ImportDeclaration: [
146
+ "specifiers",
147
+ "source",
148
+ "attributes"
149
+ ],
150
+ ImportDefaultSpecifier: [
151
+ "local"
152
+ ],
153
+ ImportExpression: [
154
+ "source",
155
+ "options"
156
+ ],
157
+ ImportNamespaceSpecifier: [
158
+ "local"
159
+ ],
160
+ ImportSpecifier: [
161
+ "imported",
162
+ "local"
163
+ ],
164
+ JSXAttribute: [
165
+ "name",
166
+ "value"
167
+ ],
168
+ JSXClosingElement: [
169
+ "name"
170
+ ],
171
+ JSXClosingFragment: [],
172
+ JSXElement: [
173
+ "openingElement",
174
+ "children",
175
+ "closingElement"
176
+ ],
177
+ JSXEmptyExpression: [],
178
+ JSXExpressionContainer: [
179
+ "expression"
180
+ ],
181
+ JSXFragment: [
182
+ "openingFragment",
183
+ "children",
184
+ "closingFragment"
185
+ ],
186
+ JSXIdentifier: [],
187
+ JSXMemberExpression: [
188
+ "object",
189
+ "property"
190
+ ],
191
+ JSXNamespacedName: [
192
+ "namespace",
193
+ "name"
194
+ ],
195
+ JSXOpeningElement: [
196
+ "name",
197
+ "attributes"
198
+ ],
199
+ JSXOpeningFragment: [],
200
+ JSXSpreadAttribute: [
201
+ "argument"
202
+ ],
203
+ JSXSpreadChild: [
204
+ "expression"
205
+ ],
206
+ JSXText: [],
207
+ LabeledStatement: [
208
+ "label",
209
+ "body"
210
+ ],
211
+ Literal: [],
212
+ LogicalExpression: [
213
+ "left",
214
+ "right"
215
+ ],
216
+ MemberExpression: [
217
+ "object",
218
+ "property"
219
+ ],
220
+ MetaProperty: [
221
+ "meta",
222
+ "property"
223
+ ],
224
+ MethodDefinition: [
225
+ "key",
226
+ "value"
227
+ ],
228
+ NewExpression: [
229
+ "callee",
230
+ "arguments"
231
+ ],
232
+ ObjectExpression: [
233
+ "properties"
234
+ ],
235
+ ObjectPattern: [
236
+ "properties"
237
+ ],
238
+ PrivateIdentifier: [],
239
+ Program: [
240
+ "body"
241
+ ],
242
+ Property: [
243
+ "key",
244
+ "value"
245
+ ],
246
+ PropertyDefinition: [
247
+ "key",
248
+ "value"
249
+ ],
250
+ RestElement: [
251
+ "argument"
252
+ ],
253
+ ReturnStatement: [
254
+ "argument"
255
+ ],
256
+ SequenceExpression: [
257
+ "expressions"
258
+ ],
259
+ SpreadElement: [
260
+ "argument"
261
+ ],
262
+ StaticBlock: [
263
+ "body"
264
+ ],
265
+ Super: [],
266
+ SwitchCase: [
267
+ "test",
268
+ "consequent"
269
+ ],
270
+ SwitchStatement: [
271
+ "discriminant",
272
+ "cases"
273
+ ],
274
+ TaggedTemplateExpression: [
275
+ "tag",
276
+ "quasi"
277
+ ],
278
+ TemplateElement: [],
279
+ TemplateLiteral: [
280
+ "quasis",
281
+ "expressions"
282
+ ],
283
+ ThisExpression: [],
284
+ ThrowStatement: [
285
+ "argument"
286
+ ],
287
+ TryStatement: [
288
+ "block",
289
+ "handler",
290
+ "finalizer"
291
+ ],
292
+ UnaryExpression: [
293
+ "argument"
294
+ ],
295
+ UpdateExpression: [
296
+ "argument"
297
+ ],
298
+ VariableDeclaration: [
299
+ "declarations"
300
+ ],
301
+ VariableDeclarator: [
302
+ "id",
303
+ "init"
304
+ ],
305
+ WhileStatement: [
306
+ "test",
307
+ "body"
308
+ ],
309
+ WithStatement: [
310
+ "object",
311
+ "body"
312
+ ],
313
+ YieldExpression: [
314
+ "argument"
315
+ ]
316
+ };
317
+
318
+ // Types.
319
+ const NODE_TYPES = Object.keys(KEYS);
320
+
321
+ // Freeze the keys.
322
+ for (const type of NODE_TYPES) {
323
+ Object.freeze(KEYS[type]);
324
+ }
325
+ Object.freeze(KEYS);
326
+
327
+ export default KEYS;
server/node_modules/eslint-visitor-keys/package.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-visitor-keys",
3
+ "version": "4.2.1",
4
+ "description": "Constants and utilities about visitor keys to traverse AST.",
5
+ "type": "module",
6
+ "main": "dist/eslint-visitor-keys.cjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": [
10
+ {
11
+ "import": "./lib/index.js",
12
+ "require": "./dist/eslint-visitor-keys.cjs"
13
+ },
14
+ "./dist/eslint-visitor-keys.cjs"
15
+ ],
16
+ "./package.json": "./package.json"
17
+ },
18
+ "files": [
19
+ "dist/index.d.ts",
20
+ "dist/visitor-keys.d.ts",
21
+ "dist/eslint-visitor-keys.cjs",
22
+ "dist/eslint-visitor-keys.d.cts",
23
+ "lib"
24
+ ],
25
+ "engines": {
26
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/estree": "^0.0.51",
30
+ "@types/estree-jsx": "^0.0.1",
31
+ "@typescript-eslint/parser": "^8.7.0",
32
+ "eslint-release": "^3.2.0",
33
+ "esquery": "^1.4.0",
34
+ "json-diff": "^0.7.3",
35
+ "opener": "^1.5.2",
36
+ "rollup": "^4.22.4",
37
+ "rollup-plugin-dts": "^6.1.1",
38
+ "tsd": "^0.31.2",
39
+ "typescript": "^5.6.2"
40
+ },
41
+ "scripts": {
42
+ "build": "npm run build:cjs && npm run build:types",
43
+ "build:cjs": "rollup -c",
44
+ "build:debug": "npm run build:cjs -- -m && npm run build:types",
45
+ "build:types": "tsc -v && tsc",
46
+ "release:generate:latest": "eslint-generate-release",
47
+ "release:generate:alpha": "eslint-generate-prerelease alpha",
48
+ "release:generate:beta": "eslint-generate-prerelease beta",
49
+ "release:generate:rc": "eslint-generate-prerelease rc",
50
+ "release:publish": "eslint-publish-release",
51
+ "test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types",
52
+ "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
53
+ "test:types": "tsd"
54
+ },
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/eslint/js.git",
58
+ "directory": "packages/eslint-visitor-keys"
59
+ },
60
+ "funding": "https://opencollective.com/eslint",
61
+ "keywords": [
62
+ "eslint"
63
+ ],
64
+ "author": "Toru Nagashima (https://github.com/mysticatea)",
65
+ "license": "Apache-2.0",
66
+ "bugs": {
67
+ "url": "https://github.com/eslint/js/issues"
68
+ },
69
+ "homepage": "https://github.com/eslint/js/blob/main/packages/eslint-visitor-keys/README.md"
70
+ }
server/node_modules/eslint/lib/rules/no-new-symbol.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
3
+ * @author Alberto Rodríguez
4
+ * @deprecated in ESLint v9.0.0
5
+ */
6
+
7
+ "use strict";
8
+
9
+ //------------------------------------------------------------------------------
10
+ // Rule Definition
11
+ //------------------------------------------------------------------------------
12
+
13
+ /** @type {import('../types').Rule.RuleModule} */
14
+ module.exports = {
15
+ meta: {
16
+ type: "problem",
17
+
18
+ docs: {
19
+ description: "Disallow `new` operators with the `Symbol` object",
20
+ recommended: false,
21
+ url: "https://eslint.org/docs/latest/rules/no-new-symbol",
22
+ },
23
+
24
+ deprecated: {
25
+ message: "The rule was replaced with a more general rule.",
26
+ url: "https://eslint.org/docs/latest/use/migrate-to-9.0.0#eslint-recommended",
27
+ deprecatedSince: "9.0.0",
28
+ availableUntil: "11.0.0",
29
+ replacedBy: [
30
+ {
31
+ rule: {
32
+ name: "no-new-native-nonconstructor",
33
+ url: "https://eslint.org/docs/latest/rules/no-new-native-nonconstructor",
34
+ },
35
+ },
36
+ ],
37
+ },
38
+
39
+ schema: [],
40
+
41
+ messages: {
42
+ noNewSymbol: "`Symbol` cannot be called as a constructor.",
43
+ },
44
+ },
45
+
46
+ create(context) {
47
+ const sourceCode = context.sourceCode;
48
+
49
+ return {
50
+ "Program:exit"(node) {
51
+ const globalScope = sourceCode.getScope(node);
52
+ const variable = globalScope.set.get("Symbol");
53
+
54
+ if (variable && variable.defs.length === 0) {
55
+ variable.references.forEach(ref => {
56
+ const idNode = ref.identifier;
57
+ const parent = idNode.parent;
58
+
59
+ if (
60
+ parent &&
61
+ parent.type === "NewExpression" &&
62
+ parent.callee === idNode
63
+ ) {
64
+ context.report({
65
+ node: idNode,
66
+ messageId: "noNewSymbol",
67
+ });
68
+ }
69
+ });
70
+ }
71
+ },
72
+ };
73
+ },
74
+ };
server/node_modules/eslint/lib/rules/no-new-wrappers.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag when using constructor for wrapper objects
3
+ * @author Ilya Volodin
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const { getVariableByName } = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Rule Definition
16
+ //------------------------------------------------------------------------------
17
+
18
+ /** @type {import('../types').Rule.RuleModule} */
19
+ module.exports = {
20
+ meta: {
21
+ type: "suggestion",
22
+
23
+ docs: {
24
+ description:
25
+ "Disallow `new` operators with the `String`, `Number`, and `Boolean` objects",
26
+ recommended: false,
27
+ url: "https://eslint.org/docs/latest/rules/no-new-wrappers",
28
+ },
29
+
30
+ schema: [],
31
+
32
+ messages: {
33
+ noConstructor: "Do not use {{fn}} as a constructor.",
34
+ },
35
+ },
36
+
37
+ create(context) {
38
+ const { sourceCode } = context;
39
+
40
+ return {
41
+ NewExpression(node) {
42
+ const wrapperObjects = ["String", "Number", "Boolean"];
43
+ const { name } = node.callee;
44
+
45
+ if (wrapperObjects.includes(name)) {
46
+ const variable = getVariableByName(
47
+ sourceCode.getScope(node),
48
+ name,
49
+ );
50
+
51
+ if (variable && variable.identifiers.length === 0) {
52
+ context.report({
53
+ node,
54
+ messageId: "noConstructor",
55
+ data: { fn: name },
56
+ });
57
+ }
58
+ }
59
+ },
60
+ };
61
+ },
62
+ };
server/node_modules/eslint/lib/rules/no-new.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag statements with function invocation preceded by
3
+ * "new" and not part of assignment
4
+ * @author Ilya Volodin
5
+ */
6
+
7
+ "use strict";
8
+
9
+ //------------------------------------------------------------------------------
10
+ // Rule Definition
11
+ //------------------------------------------------------------------------------
12
+
13
+ /** @type {import('../types').Rule.RuleModule} */
14
+ module.exports = {
15
+ meta: {
16
+ type: "suggestion",
17
+
18
+ docs: {
19
+ description:
20
+ "Disallow `new` operators outside of assignments or comparisons",
21
+ recommended: false,
22
+ url: "https://eslint.org/docs/latest/rules/no-new",
23
+ },
24
+
25
+ schema: [],
26
+
27
+ messages: {
28
+ noNewStatement: "Do not use 'new' for side effects.",
29
+ },
30
+ },
31
+
32
+ create(context) {
33
+ return {
34
+ "ExpressionStatement > NewExpression"(node) {
35
+ context.report({
36
+ node: node.parent,
37
+ messageId: "noNewStatement",
38
+ });
39
+ },
40
+ };
41
+ },
42
+ };
server/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow `\8` and `\9` escape sequences in string literals.
3
+ * @author Milos Djermanovic
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Typedefs
10
+ //------------------------------------------------------------------------------
11
+
12
+ /**
13
+ * @import { SourceRange } from "@eslint/core";
14
+ */
15
+
16
+ //------------------------------------------------------------------------------
17
+ // Helpers
18
+ //------------------------------------------------------------------------------
19
+
20
+ const QUICK_TEST_REGEX = /\\[89]/u;
21
+
22
+ /**
23
+ * Returns unicode escape sequence that represents the given character.
24
+ * @param {string} character A single code unit.
25
+ * @returns {string} "\uXXXX" sequence.
26
+ */
27
+ function getUnicodeEscape(character) {
28
+ return `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`;
29
+ }
30
+
31
+ //------------------------------------------------------------------------------
32
+ // Rule Definition
33
+ //------------------------------------------------------------------------------
34
+
35
+ /** @type {import('../types').Rule.RuleModule} */
36
+ module.exports = {
37
+ meta: {
38
+ type: "suggestion",
39
+
40
+ docs: {
41
+ description:
42
+ "Disallow `\\8` and `\\9` escape sequences in string literals",
43
+ recommended: true,
44
+ url: "https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape",
45
+ },
46
+
47
+ hasSuggestions: true,
48
+
49
+ schema: [],
50
+
51
+ messages: {
52
+ decimalEscape: "Don't use '{{decimalEscape}}' escape sequence.",
53
+
54
+ // suggestions
55
+ refactor:
56
+ "Replace '{{original}}' with '{{replacement}}'. This maintains the current functionality.",
57
+ escapeBackslash:
58
+ "Replace '{{original}}' with '{{replacement}}' to include the actual backslash character.",
59
+ },
60
+ },
61
+
62
+ create(context) {
63
+ const sourceCode = context.sourceCode;
64
+
65
+ /**
66
+ * Creates a new Suggestion object.
67
+ * @param {string} messageId "refactor" or "escapeBackslash".
68
+ * @param {SourceRange} range The range to replace.
69
+ * @param {string} replacement New text for the range.
70
+ * @returns {Object} Suggestion
71
+ */
72
+ function createSuggestion(messageId, range, replacement) {
73
+ return {
74
+ messageId,
75
+ data: {
76
+ original: sourceCode.getText().slice(...range),
77
+ replacement,
78
+ },
79
+ fix(fixer) {
80
+ return fixer.replaceTextRange(range, replacement);
81
+ },
82
+ };
83
+ }
84
+
85
+ return {
86
+ Literal(node) {
87
+ if (typeof node.value !== "string") {
88
+ return;
89
+ }
90
+
91
+ if (!QUICK_TEST_REGEX.test(node.raw)) {
92
+ return;
93
+ }
94
+
95
+ const regex =
96
+ /(?:[^\\]|(?<previousEscape>\\.))*?(?<decimalEscape>\\[89])/suy;
97
+ let match;
98
+
99
+ while ((match = regex.exec(node.raw))) {
100
+ const { previousEscape, decimalEscape } = match.groups;
101
+ const decimalEscapeRangeEnd =
102
+ node.range[0] + match.index + match[0].length;
103
+ const decimalEscapeRangeStart =
104
+ decimalEscapeRangeEnd - decimalEscape.length;
105
+ const decimalEscapeRange = [
106
+ decimalEscapeRangeStart,
107
+ decimalEscapeRangeEnd,
108
+ ];
109
+ const suggest = [];
110
+
111
+ // When `regex` is matched, `previousEscape` can only capture characters adjacent to `decimalEscape`
112
+ if (previousEscape === "\\0") {
113
+ /*
114
+ * Now we have a NULL escape "\0" immediately followed by a decimal escape, e.g.: "\0\8".
115
+ * Fixing this to "\08" would turn "\0" into a legacy octal escape. To avoid producing
116
+ * an octal escape while fixing a decimal escape, we provide different suggestions.
117
+ */
118
+ suggest.push(
119
+ createSuggestion(
120
+ // "\0\8" -> "\u00008"
121
+ "refactor",
122
+ [
123
+ decimalEscapeRangeStart -
124
+ previousEscape.length,
125
+ decimalEscapeRangeEnd,
126
+ ],
127
+ `${getUnicodeEscape("\0")}${decimalEscape[1]}`,
128
+ ),
129
+ createSuggestion(
130
+ // "\8" -> "\u0038"
131
+ "refactor",
132
+ decimalEscapeRange,
133
+ getUnicodeEscape(decimalEscape[1]),
134
+ ),
135
+ );
136
+ } else {
137
+ suggest.push(
138
+ createSuggestion(
139
+ // "\8" -> "8"
140
+ "refactor",
141
+ decimalEscapeRange,
142
+ decimalEscape[1],
143
+ ),
144
+ );
145
+ }
146
+
147
+ suggest.push(
148
+ createSuggestion(
149
+ // "\8" -> "\\8"
150
+ "escapeBackslash",
151
+ decimalEscapeRange,
152
+ `\\${decimalEscape}`,
153
+ ),
154
+ );
155
+
156
+ context.report({
157
+ node,
158
+ loc: {
159
+ start: sourceCode.getLocFromIndex(
160
+ decimalEscapeRangeStart,
161
+ ),
162
+ end: sourceCode.getLocFromIndex(
163
+ decimalEscapeRangeEnd,
164
+ ),
165
+ },
166
+ messageId: "decimalEscape",
167
+ data: {
168
+ decimalEscape,
169
+ },
170
+ suggest,
171
+ });
172
+ }
173
+ },
174
+ };
175
+ },
176
+ };
server/node_modules/eslint/lib/rules/no-obj-calls.js ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
3
+ * @author James Allardice
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const {
13
+ CALL,
14
+ CONSTRUCT,
15
+ ReferenceTracker,
16
+ } = require("@eslint-community/eslint-utils");
17
+ const getPropertyName = require("./utils/ast-utils").getStaticPropertyName;
18
+
19
+ //------------------------------------------------------------------------------
20
+ // Helpers
21
+ //------------------------------------------------------------------------------
22
+
23
+ const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect", "Intl"];
24
+
25
+ /**
26
+ * Returns the name of the node to report
27
+ * @param {ASTNode} node A node to report
28
+ * @returns {string} name to report
29
+ */
30
+ function getReportNodeName(node) {
31
+ if (node.type === "ChainExpression") {
32
+ return getReportNodeName(node.expression);
33
+ }
34
+ if (node.type === "MemberExpression") {
35
+ return getPropertyName(node);
36
+ }
37
+ return node.name;
38
+ }
39
+
40
+ //------------------------------------------------------------------------------
41
+ // Rule Definition
42
+ //------------------------------------------------------------------------------
43
+
44
+ /** @type {import('../types').Rule.RuleModule} */
45
+ module.exports = {
46
+ meta: {
47
+ type: "problem",
48
+
49
+ docs: {
50
+ description:
51
+ "Disallow calling global object properties as functions",
52
+ recommended: true,
53
+ url: "https://eslint.org/docs/latest/rules/no-obj-calls",
54
+ },
55
+
56
+ schema: [],
57
+
58
+ messages: {
59
+ unexpectedCall: "'{{name}}' is not a function.",
60
+ unexpectedRefCall:
61
+ "'{{name}}' is reference to '{{ref}}', which is not a function.",
62
+ },
63
+ },
64
+
65
+ create(context) {
66
+ const sourceCode = context.sourceCode;
67
+
68
+ return {
69
+ Program(node) {
70
+ const scope = sourceCode.getScope(node);
71
+ const tracker = new ReferenceTracker(scope);
72
+ const traceMap = {};
73
+
74
+ for (const g of nonCallableGlobals) {
75
+ traceMap[g] = {
76
+ [CALL]: true,
77
+ [CONSTRUCT]: true,
78
+ };
79
+ }
80
+
81
+ for (const {
82
+ node: refNode,
83
+ path,
84
+ } of tracker.iterateGlobalReferences(traceMap)) {
85
+ const name = getReportNodeName(refNode.callee);
86
+ const ref = path[0];
87
+ const messageId =
88
+ name === ref ? "unexpectedCall" : "unexpectedRefCall";
89
+
90
+ context.report({
91
+ node: refNode,
92
+ messageId,
93
+ data: { name, ref },
94
+ });
95
+ }
96
+ },
97
+ };
98
+ },
99
+ };
server/node_modules/eslint/lib/rules/no-object-constructor.js ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow calls to the `Object` constructor without an argument
3
+ * @author Francesco Trotta
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const {
13
+ getVariableByName,
14
+ isArrowToken,
15
+ isStartOfExpressionStatement,
16
+ needsPrecedingSemicolon,
17
+ } = require("./utils/ast-utils");
18
+
19
+ //------------------------------------------------------------------------------
20
+ // Rule Definition
21
+ //------------------------------------------------------------------------------
22
+
23
+ /** @type {import('../types').Rule.RuleModule} */
24
+ module.exports = {
25
+ meta: {
26
+ type: "suggestion",
27
+
28
+ docs: {
29
+ description:
30
+ "Disallow calls to the `Object` constructor without an argument",
31
+ recommended: false,
32
+ url: "https://eslint.org/docs/latest/rules/no-object-constructor",
33
+ },
34
+
35
+ hasSuggestions: true,
36
+
37
+ schema: [],
38
+
39
+ messages: {
40
+ preferLiteral: "The object literal notation {} is preferable.",
41
+ useLiteral: "Replace with '{{replacement}}'.",
42
+ useLiteralAfterSemicolon:
43
+ "Replace with '{{replacement}}', add preceding semicolon.",
44
+ },
45
+ },
46
+
47
+ create(context) {
48
+ const sourceCode = context.sourceCode;
49
+
50
+ /**
51
+ * Determines whether or not an object literal that replaces a specified node needs to be enclosed in parentheses.
52
+ * @param {ASTNode} node The node to be replaced.
53
+ * @returns {boolean} Whether or not parentheses around the object literal are required.
54
+ */
55
+ function needsParentheses(node) {
56
+ if (isStartOfExpressionStatement(node)) {
57
+ return true;
58
+ }
59
+
60
+ const prevToken = sourceCode.getTokenBefore(node);
61
+
62
+ if (prevToken && isArrowToken(prevToken)) {
63
+ return true;
64
+ }
65
+
66
+ return false;
67
+ }
68
+
69
+ /**
70
+ * Reports on nodes where the `Object` constructor is called without arguments.
71
+ * @param {ASTNode} node The node to evaluate.
72
+ * @returns {void}
73
+ */
74
+ function check(node) {
75
+ if (
76
+ node.callee.type !== "Identifier" ||
77
+ node.callee.name !== "Object" ||
78
+ node.arguments.length
79
+ ) {
80
+ return;
81
+ }
82
+
83
+ const variable = getVariableByName(
84
+ sourceCode.getScope(node),
85
+ "Object",
86
+ );
87
+
88
+ if (variable && variable.identifiers.length === 0) {
89
+ let replacement;
90
+ let fixText;
91
+ let messageId = "useLiteral";
92
+
93
+ if (needsParentheses(node)) {
94
+ replacement = "({})";
95
+ if (needsPrecedingSemicolon(sourceCode, node)) {
96
+ fixText = ";({})";
97
+ messageId = "useLiteralAfterSemicolon";
98
+ } else {
99
+ fixText = "({})";
100
+ }
101
+ } else {
102
+ replacement = fixText = "{}";
103
+ }
104
+
105
+ context.report({
106
+ node,
107
+ messageId: "preferLiteral",
108
+ suggest: [
109
+ {
110
+ messageId,
111
+ data: { replacement },
112
+ fix: fixer => fixer.replaceText(node, fixText),
113
+ },
114
+ ],
115
+ });
116
+ }
117
+ }
118
+
119
+ return {
120
+ CallExpression: check,
121
+ NewExpression: check,
122
+ };
123
+ },
124
+ };
server/node_modules/eslint/lib/rules/no-octal-escape.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag octal escape sequences in string literals.
3
+ * @author Ian Christian Myers
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ /** @type {import('../types').Rule.RuleModule} */
13
+ module.exports = {
14
+ meta: {
15
+ type: "suggestion",
16
+
17
+ docs: {
18
+ description: "Disallow octal escape sequences in string literals",
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/latest/rules/no-octal-escape",
21
+ },
22
+
23
+ schema: [],
24
+
25
+ messages: {
26
+ octalEscapeSequence:
27
+ "Don't use octal: '\\{{sequence}}'. Use '\\u....' instead.",
28
+ },
29
+ },
30
+
31
+ create(context) {
32
+ return {
33
+ Literal(node) {
34
+ if (typeof node.value !== "string") {
35
+ return;
36
+ }
37
+
38
+ // \0 represents a valid NULL character if it isn't followed by a digit.
39
+ const match = node.raw.match(
40
+ /^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/su,
41
+ );
42
+
43
+ if (match) {
44
+ context.report({
45
+ node,
46
+ messageId: "octalEscapeSequence",
47
+ data: { sequence: match[1] },
48
+ });
49
+ }
50
+ },
51
+ };
52
+ },
53
+ };
server/node_modules/eslint/lib/rules/no-octal.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag when initializing octal literal
3
+ * @author Ilya Volodin
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ /** @type {import('../types').Rule.RuleModule} */
13
+ module.exports = {
14
+ meta: {
15
+ type: "suggestion",
16
+
17
+ docs: {
18
+ description: "Disallow octal literals",
19
+ recommended: true,
20
+ url: "https://eslint.org/docs/latest/rules/no-octal",
21
+ },
22
+
23
+ schema: [],
24
+
25
+ messages: {
26
+ noOctal: "Octal literals should not be used.",
27
+ },
28
+ },
29
+
30
+ create(context) {
31
+ return {
32
+ Literal(node) {
33
+ if (typeof node.value === "number" && /^0\d/u.test(node.raw)) {
34
+ context.report({
35
+ node,
36
+ messageId: "noOctal",
37
+ });
38
+ }
39
+ },
40
+ };
41
+ },
42
+ };
server/node_modules/eslint/lib/rules/no-param-reassign.js ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Disallow reassigning function parameters.
3
+ * @author Nat Burns
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Rule Definition
9
+ //------------------------------------------------------------------------------
10
+
11
+ const stopNodePattern =
12
+ /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
13
+
14
+ /** @type {import('../types').Rule.RuleModule} */
15
+ module.exports = {
16
+ meta: {
17
+ type: "suggestion",
18
+
19
+ docs: {
20
+ description: "Disallow reassigning function parameters",
21
+ recommended: false,
22
+ url: "https://eslint.org/docs/latest/rules/no-param-reassign",
23
+ },
24
+
25
+ schema: [
26
+ {
27
+ oneOf: [
28
+ {
29
+ type: "object",
30
+ properties: {
31
+ props: {
32
+ enum: [false],
33
+ },
34
+ },
35
+ additionalProperties: false,
36
+ },
37
+ {
38
+ type: "object",
39
+ properties: {
40
+ props: {
41
+ enum: [true],
42
+ },
43
+ ignorePropertyModificationsFor: {
44
+ type: "array",
45
+ items: {
46
+ type: "string",
47
+ },
48
+ uniqueItems: true,
49
+ },
50
+ ignorePropertyModificationsForRegex: {
51
+ type: "array",
52
+ items: {
53
+ type: "string",
54
+ },
55
+ uniqueItems: true,
56
+ },
57
+ },
58
+ additionalProperties: false,
59
+ },
60
+ ],
61
+ },
62
+ ],
63
+
64
+ messages: {
65
+ assignmentToFunctionParam:
66
+ "Assignment to function parameter '{{name}}'.",
67
+ assignmentToFunctionParamProp:
68
+ "Assignment to property of function parameter '{{name}}'.",
69
+ },
70
+ },
71
+
72
+ create(context) {
73
+ const props = context.options[0] && context.options[0].props;
74
+ const ignoredPropertyAssignmentsFor =
75
+ (context.options[0] &&
76
+ context.options[0].ignorePropertyModificationsFor) ||
77
+ [];
78
+ const ignoredPropertyAssignmentsForRegex =
79
+ (context.options[0] &&
80
+ context.options[0].ignorePropertyModificationsForRegex) ||
81
+ [];
82
+ const sourceCode = context.sourceCode;
83
+
84
+ /**
85
+ * Checks whether or not the reference modifies properties of its variable.
86
+ * @param {Reference} reference A reference to check.
87
+ * @returns {boolean} Whether or not the reference modifies properties of its variable.
88
+ */
89
+ function isModifyingProp(reference) {
90
+ let node = reference.identifier;
91
+ let parent = node.parent;
92
+
93
+ while (
94
+ parent &&
95
+ (!stopNodePattern.test(parent.type) ||
96
+ parent.type === "ForInStatement" ||
97
+ parent.type === "ForOfStatement")
98
+ ) {
99
+ switch (parent.type) {
100
+ // e.g. foo.a = 0;
101
+ case "AssignmentExpression":
102
+ return parent.left === node;
103
+
104
+ // e.g. ++foo.a;
105
+ case "UpdateExpression":
106
+ return true;
107
+
108
+ // e.g. delete foo.a;
109
+ case "UnaryExpression":
110
+ if (parent.operator === "delete") {
111
+ return true;
112
+ }
113
+ break;
114
+
115
+ // e.g. for (foo.a in b) {}
116
+ case "ForInStatement":
117
+ case "ForOfStatement":
118
+ if (parent.left === node) {
119
+ return true;
120
+ }
121
+
122
+ // this is a stop node for parent.right and parent.body
123
+ return false;
124
+
125
+ // EXCLUDES: e.g. cache.get(foo.a).b = 0;
126
+ case "CallExpression":
127
+ if (parent.callee !== node) {
128
+ return false;
129
+ }
130
+ break;
131
+
132
+ // EXCLUDES: e.g. cache[foo.a] = 0;
133
+ case "MemberExpression":
134
+ if (parent.property === node) {
135
+ return false;
136
+ }
137
+ break;
138
+
139
+ // EXCLUDES: e.g. ({ [foo]: a }) = bar;
140
+ case "Property":
141
+ if (parent.key === node) {
142
+ return false;
143
+ }
144
+
145
+ break;
146
+
147
+ // EXCLUDES: e.g. (foo ? a : b).c = bar;
148
+ case "ConditionalExpression":
149
+ if (parent.test === node) {
150
+ return false;
151
+ }
152
+
153
+ break;
154
+
155
+ // no default
156
+ }
157
+
158
+ node = parent;
159
+ parent = node.parent;
160
+ }
161
+
162
+ return false;
163
+ }
164
+
165
+ /**
166
+ * Tests that an identifier name matches any of the ignored property assignments.
167
+ * First we test strings in ignoredPropertyAssignmentsFor.
168
+ * Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings.
169
+ * @param {string} identifierName A string that describes the name of an identifier to
170
+ * ignore property assignments for.
171
+ * @returns {boolean} Whether the string matches an ignored property assignment regular expression or not.
172
+ */
173
+ function isIgnoredPropertyAssignment(identifierName) {
174
+ return (
175
+ ignoredPropertyAssignmentsFor.includes(identifierName) ||
176
+ ignoredPropertyAssignmentsForRegex.some(ignored =>
177
+ new RegExp(ignored, "u").test(identifierName),
178
+ )
179
+ );
180
+ }
181
+
182
+ /**
183
+ * Reports a reference if is non initializer and writable.
184
+ * @param {Reference} reference A reference to check.
185
+ * @param {number} index The index of the reference in the references.
186
+ * @param {Reference[]} references The array that the reference belongs to.
187
+ * @returns {void}
188
+ */
189
+ function checkReference(reference, index, references) {
190
+ const identifier = reference.identifier;
191
+
192
+ if (
193
+ identifier &&
194
+ !reference.init &&
195
+ /*
196
+ * Destructuring assignments can have multiple default value,
197
+ * so possibly there are multiple writeable references for the same identifier.
198
+ */
199
+ (index === 0 || references[index - 1].identifier !== identifier)
200
+ ) {
201
+ if (reference.isWrite()) {
202
+ context.report({
203
+ node: identifier,
204
+ messageId: "assignmentToFunctionParam",
205
+ data: { name: identifier.name },
206
+ });
207
+ } else if (
208
+ props &&
209
+ isModifyingProp(reference) &&
210
+ !isIgnoredPropertyAssignment(identifier.name)
211
+ ) {
212
+ context.report({
213
+ node: identifier,
214
+ messageId: "assignmentToFunctionParamProp",
215
+ data: { name: identifier.name },
216
+ });
217
+ }
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Finds and reports references that are non initializer and writable.
223
+ * @param {Variable} variable A variable to check.
224
+ * @returns {void}
225
+ */
226
+ function checkVariable(variable) {
227
+ if (variable.defs[0].type === "Parameter") {
228
+ variable.references.forEach(checkReference);
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Checks parameters of a given function node.
234
+ * @param {ASTNode} node A function node to check.
235
+ * @returns {void}
236
+ */
237
+ function checkForFunction(node) {
238
+ sourceCode.getDeclaredVariables(node).forEach(checkVariable);
239
+ }
240
+
241
+ return {
242
+ // `:exit` is needed for the `node.parent` property of identifier nodes.
243
+ "FunctionDeclaration:exit": checkForFunction,
244
+ "FunctionExpression:exit": checkForFunction,
245
+ "ArrowFunctionExpression:exit": checkForFunction,
246
+ };
247
+ },
248
+ };
server/node_modules/eslint/lib/rules/no-path-concat.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Disallow string concatenation when using __dirname and __filename
3
+ * @author Nicholas C. Zakas
4
+ * @deprecated in ESLint v7.0.0
5
+ */
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ /** @type {import('../types').Rule.RuleModule} */
13
+ module.exports = {
14
+ meta: {
15
+ deprecated: {
16
+ message: "Node.js rules were moved out of ESLint core.",
17
+ url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
18
+ deprecatedSince: "7.0.0",
19
+ availableUntil: "11.0.0",
20
+ replacedBy: [
21
+ {
22
+ message:
23
+ "eslint-plugin-n now maintains deprecated Node.js-related rules.",
24
+ plugin: {
25
+ name: "eslint-plugin-n",
26
+ url: "https://github.com/eslint-community/eslint-plugin-n",
27
+ },
28
+ rule: {
29
+ name: "no-path-concat",
30
+ url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-path-concat.md",
31
+ },
32
+ },
33
+ ],
34
+ },
35
+
36
+ type: "suggestion",
37
+
38
+ docs: {
39
+ description:
40
+ "Disallow string concatenation with `__dirname` and `__filename`",
41
+ recommended: false,
42
+ url: "https://eslint.org/docs/latest/rules/no-path-concat",
43
+ },
44
+
45
+ schema: [],
46
+
47
+ messages: {
48
+ usePathFunctions:
49
+ "Use path.join() or path.resolve() instead of + to create paths.",
50
+ },
51
+ },
52
+
53
+ create(context) {
54
+ const MATCHER = /^__(?:dir|file)name$/u;
55
+
56
+ //--------------------------------------------------------------------------
57
+ // Public
58
+ //--------------------------------------------------------------------------
59
+
60
+ return {
61
+ BinaryExpression(node) {
62
+ const left = node.left,
63
+ right = node.right;
64
+
65
+ if (
66
+ node.operator === "+" &&
67
+ ((left.type === "Identifier" && MATCHER.test(left.name)) ||
68
+ (right.type === "Identifier" &&
69
+ MATCHER.test(right.name)))
70
+ ) {
71
+ context.report({
72
+ node,
73
+ messageId: "usePathFunctions",
74
+ });
75
+ }
76
+ },
77
+ };
78
+ },
79
+ };
server/node_modules/eslint/lib/rules/no-plusplus.js ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag use of unary increment and decrement operators.
3
+ * @author Ian Christian Myers
4
+ * @author Brody McKee (github.com/mrmckeb)
5
+ */
6
+
7
+ "use strict";
8
+
9
+ //------------------------------------------------------------------------------
10
+ // Helpers
11
+ //------------------------------------------------------------------------------
12
+
13
+ /**
14
+ * Determines whether the given node is the update node of a `ForStatement`.
15
+ * @param {ASTNode} node The node to check.
16
+ * @returns {boolean} `true` if the node is `ForStatement` update.
17
+ */
18
+ function isForStatementUpdate(node) {
19
+ const parent = node.parent;
20
+
21
+ return parent.type === "ForStatement" && parent.update === node;
22
+ }
23
+
24
+ /**
25
+ * Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule.
26
+ * In particular, it returns `true` if the given node is either:
27
+ * - The update node of a `ForStatement`: for (;; i++) {}
28
+ * - An operand of a sequence expression that is the update node: for (;; foo(), i++) {}
29
+ * - An operand of a sequence expression that is child of another sequence expression, etc.,
30
+ * up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {}
31
+ * @param {ASTNode} node The node to check.
32
+ * @returns {boolean} `true` if the node is a for loop afterthought.
33
+ */
34
+ function isForLoopAfterthought(node) {
35
+ const parent = node.parent;
36
+
37
+ if (parent.type === "SequenceExpression") {
38
+ return isForLoopAfterthought(parent);
39
+ }
40
+
41
+ return isForStatementUpdate(node);
42
+ }
43
+
44
+ //------------------------------------------------------------------------------
45
+ // Rule Definition
46
+ //------------------------------------------------------------------------------
47
+
48
+ /** @type {import('../types').Rule.RuleModule} */
49
+ module.exports = {
50
+ meta: {
51
+ type: "suggestion",
52
+
53
+ defaultOptions: [
54
+ {
55
+ allowForLoopAfterthoughts: false,
56
+ },
57
+ ],
58
+
59
+ docs: {
60
+ description: "Disallow the unary operators `++` and `--`",
61
+ recommended: false,
62
+ frozen: true,
63
+ url: "https://eslint.org/docs/latest/rules/no-plusplus",
64
+ },
65
+
66
+ schema: [
67
+ {
68
+ type: "object",
69
+ properties: {
70
+ allowForLoopAfterthoughts: {
71
+ type: "boolean",
72
+ },
73
+ },
74
+ additionalProperties: false,
75
+ },
76
+ ],
77
+
78
+ messages: {
79
+ unexpectedUnaryOp: "Unary operator '{{operator}}' used.",
80
+ },
81
+ },
82
+
83
+ create(context) {
84
+ const [{ allowForLoopAfterthoughts }] = context.options;
85
+
86
+ return {
87
+ UpdateExpression(node) {
88
+ if (allowForLoopAfterthoughts && isForLoopAfterthought(node)) {
89
+ return;
90
+ }
91
+
92
+ context.report({
93
+ node,
94
+ messageId: "unexpectedUnaryOp",
95
+ data: {
96
+ operator: node.operator,
97
+ },
98
+ });
99
+ },
100
+ };
101
+ },
102
+ };
server/node_modules/eslint/lib/rules/no-process-env.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Disallow the use of process.env()
3
+ * @author Vignesh Anand
4
+ * @deprecated in ESLint v7.0.0
5
+ */
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ /** @type {import('../types').Rule.RuleModule} */
13
+ module.exports = {
14
+ meta: {
15
+ deprecated: {
16
+ message: "Node.js rules were moved out of ESLint core.",
17
+ url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
18
+ deprecatedSince: "7.0.0",
19
+ availableUntil: "11.0.0",
20
+ replacedBy: [
21
+ {
22
+ message:
23
+ "eslint-plugin-n now maintains deprecated Node.js-related rules.",
24
+ plugin: {
25
+ name: "eslint-plugin-n",
26
+ url: "https://github.com/eslint-community/eslint-plugin-n",
27
+ },
28
+ rule: {
29
+ name: "no-process-env",
30
+ url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-process-env.md",
31
+ },
32
+ },
33
+ ],
34
+ },
35
+
36
+ type: "suggestion",
37
+
38
+ docs: {
39
+ description: "Disallow the use of `process.env`",
40
+ recommended: false,
41
+ url: "https://eslint.org/docs/latest/rules/no-process-env",
42
+ },
43
+
44
+ schema: [],
45
+
46
+ messages: {
47
+ unexpectedProcessEnv: "Unexpected use of process.env.",
48
+ },
49
+ },
50
+
51
+ create(context) {
52
+ return {
53
+ MemberExpression(node) {
54
+ const objectName = node.object.name,
55
+ propertyName = node.property.name;
56
+
57
+ if (
58
+ objectName === "process" &&
59
+ !node.computed &&
60
+ propertyName &&
61
+ propertyName === "env"
62
+ ) {
63
+ context.report({ node, messageId: "unexpectedProcessEnv" });
64
+ }
65
+ },
66
+ };
67
+ },
68
+ };
server/node_modules/eslint/lib/rules/no-process-exit.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Disallow the use of process.exit()
3
+ * @author Nicholas C. Zakas
4
+ * @deprecated in ESLint v7.0.0
5
+ */
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ /** @type {import('../types').Rule.RuleModule} */
13
+ module.exports = {
14
+ meta: {
15
+ deprecated: {
16
+ message: "Node.js rules were moved out of ESLint core.",
17
+ url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
18
+ deprecatedSince: "7.0.0",
19
+ availableUntil: "11.0.0",
20
+ replacedBy: [
21
+ {
22
+ message:
23
+ "eslint-plugin-n now maintains deprecated Node.js-related rules.",
24
+ plugin: {
25
+ name: "eslint-plugin-n",
26
+ url: "https://github.com/eslint-community/eslint-plugin-n",
27
+ },
28
+ rule: {
29
+ name: "no-process-exit",
30
+ url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-process-exit.md",
31
+ },
32
+ },
33
+ ],
34
+ },
35
+
36
+ type: "suggestion",
37
+
38
+ docs: {
39
+ description: "Disallow the use of `process.exit()`",
40
+ recommended: false,
41
+ url: "https://eslint.org/docs/latest/rules/no-process-exit",
42
+ },
43
+
44
+ schema: [],
45
+
46
+ messages: {
47
+ noProcessExit: "Don't use process.exit(); throw an error instead.",
48
+ },
49
+ },
50
+
51
+ create(context) {
52
+ //--------------------------------------------------------------------------
53
+ // Public
54
+ //--------------------------------------------------------------------------
55
+
56
+ return {
57
+ "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(
58
+ node,
59
+ ) {
60
+ context.report({
61
+ node: node.parent,
62
+ messageId: "noProcessExit",
63
+ });
64
+ },
65
+ };
66
+ },
67
+ };
server/node_modules/eslint/lib/rules/no-promise-executor-return.js ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow returning values from Promise executor functions
3
+ * @author Milos Djermanovic
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Helpers
16
+ //------------------------------------------------------------------------------
17
+
18
+ const functionTypesToCheck = new Set([
19
+ "ArrowFunctionExpression",
20
+ "FunctionExpression",
21
+ ]);
22
+
23
+ /**
24
+ * Determines whether the given function node is used as a Promise executor.
25
+ * @param {ASTNode} node The node to check.
26
+ * @param {SourceCode} sourceCode Source code to which the node belongs.
27
+ * @returns {boolean} `true` if the node is a Promise executor.
28
+ */
29
+ function isPromiseExecutor(node, sourceCode) {
30
+ const parent = node.parent;
31
+
32
+ return (
33
+ parent.type === "NewExpression" &&
34
+ parent.arguments[0] === node &&
35
+ parent.callee.type === "Identifier" &&
36
+ parent.callee.name === "Promise" &&
37
+ sourceCode.isGlobalReference(parent.callee)
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Checks if the given node is a void expression.
43
+ * @param {ASTNode} node The node to check.
44
+ * @returns {boolean} - `true` if the node is a void expression
45
+ */
46
+ function expressionIsVoid(node) {
47
+ return node.type === "UnaryExpression" && node.operator === "void";
48
+ }
49
+
50
+ /**
51
+ * Fixes the linting error by prepending "void " to the given node
52
+ * @param {Object} sourceCode context given by context.sourceCode
53
+ * @param {ASTNode} node The node to fix.
54
+ * @param {Object} fixer The fixer object provided by ESLint.
55
+ * @returns {Array<Object>} - An array of fix objects to apply to the node.
56
+ */
57
+ function voidPrependFixer(sourceCode, node, fixer) {
58
+ const requiresParens =
59
+ // prepending `void ` will fail if the node has a lower precedence than void
60
+ astUtils.getPrecedence(node) <
61
+ astUtils.getPrecedence({
62
+ type: "UnaryExpression",
63
+ operator: "void",
64
+ }) &&
65
+ // check if there are parentheses around the node to avoid redundant parentheses
66
+ !astUtils.isParenthesised(sourceCode, node);
67
+
68
+ // avoid parentheses issues
69
+ const returnOrArrowToken = sourceCode.getTokenBefore(
70
+ node,
71
+ node.parent.type === "ArrowFunctionExpression"
72
+ ? astUtils.isArrowToken
73
+ : // isReturnToken
74
+ token => token.type === "Keyword" && token.value === "return",
75
+ );
76
+
77
+ const firstToken = sourceCode.getTokenAfter(returnOrArrowToken);
78
+
79
+ const prependSpace =
80
+ // is return token, as => allows void to be adjacent
81
+ returnOrArrowToken.value === "return" &&
82
+ // If two tokens (return and "(") are adjacent
83
+ returnOrArrowToken.range[1] === firstToken.range[0];
84
+
85
+ return [
86
+ fixer.insertTextBefore(
87
+ firstToken,
88
+ `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`,
89
+ ),
90
+ fixer.insertTextAfter(node, requiresParens ? ")" : ""),
91
+ ];
92
+ }
93
+
94
+ /**
95
+ * Fixes the linting error by `wrapping {}` around the given node's body.
96
+ * @param {Object} sourceCode context given by context.sourceCode
97
+ * @param {ASTNode} node The node to fix.
98
+ * @param {Object} fixer The fixer object provided by ESLint.
99
+ * @returns {Array<Object>} - An array of fix objects to apply to the node.
100
+ */
101
+ function curlyWrapFixer(sourceCode, node, fixer) {
102
+ // https://github.com/eslint/eslint/pull/17282#issuecomment-1592795923
103
+ const arrowToken = sourceCode.getTokenBefore(
104
+ node.body,
105
+ astUtils.isArrowToken,
106
+ );
107
+ const firstToken = sourceCode.getTokenAfter(arrowToken);
108
+ const lastToken = sourceCode.getLastToken(node);
109
+
110
+ return [
111
+ fixer.insertTextBefore(firstToken, "{"),
112
+ fixer.insertTextAfter(lastToken, "}"),
113
+ ];
114
+ }
115
+
116
+ //------------------------------------------------------------------------------
117
+ // Rule Definition
118
+ //------------------------------------------------------------------------------
119
+
120
+ /** @type {import('../types').Rule.RuleModule} */
121
+ module.exports = {
122
+ meta: {
123
+ type: "problem",
124
+
125
+ defaultOptions: [
126
+ {
127
+ allowVoid: false,
128
+ },
129
+ ],
130
+
131
+ docs: {
132
+ description:
133
+ "Disallow returning values from Promise executor functions",
134
+ recommended: false,
135
+ url: "https://eslint.org/docs/latest/rules/no-promise-executor-return",
136
+ },
137
+
138
+ hasSuggestions: true,
139
+
140
+ schema: [
141
+ {
142
+ type: "object",
143
+ properties: {
144
+ allowVoid: {
145
+ type: "boolean",
146
+ },
147
+ },
148
+ additionalProperties: false,
149
+ },
150
+ ],
151
+
152
+ messages: {
153
+ returnsValue:
154
+ "Return values from promise executor functions cannot be read.",
155
+
156
+ // arrow and function suggestions
157
+ prependVoid: "Prepend `void` to the expression.",
158
+
159
+ // only arrow suggestions
160
+ wrapBraces: "Wrap the expression in `{}`.",
161
+ },
162
+ },
163
+
164
+ create(context) {
165
+ let funcInfo = null;
166
+ const sourceCode = context.sourceCode;
167
+ const [{ allowVoid }] = context.options;
168
+
169
+ return {
170
+ onCodePathStart(_, node) {
171
+ funcInfo = {
172
+ upper: funcInfo,
173
+ shouldCheck:
174
+ functionTypesToCheck.has(node.type) &&
175
+ isPromiseExecutor(node, sourceCode),
176
+ };
177
+
178
+ if (
179
+ // Is a Promise executor
180
+ funcInfo.shouldCheck &&
181
+ node.type === "ArrowFunctionExpression" &&
182
+ node.expression &&
183
+ // Except void
184
+ !(allowVoid && expressionIsVoid(node.body))
185
+ ) {
186
+ const suggest = [];
187
+
188
+ // prevent useless refactors
189
+ if (allowVoid) {
190
+ suggest.push({
191
+ messageId: "prependVoid",
192
+ fix(fixer) {
193
+ return voidPrependFixer(
194
+ sourceCode,
195
+ node.body,
196
+ fixer,
197
+ );
198
+ },
199
+ });
200
+ }
201
+
202
+ // Do not suggest wrapping an unnamed FunctionExpression in braces as that would be invalid syntax.
203
+ if (
204
+ !(
205
+ node.body.type === "FunctionExpression" &&
206
+ !node.body.id
207
+ )
208
+ ) {
209
+ suggest.push({
210
+ messageId: "wrapBraces",
211
+ fix(fixer) {
212
+ return curlyWrapFixer(sourceCode, node, fixer);
213
+ },
214
+ });
215
+ }
216
+
217
+ context.report({
218
+ node: node.body,
219
+ messageId: "returnsValue",
220
+ suggest,
221
+ });
222
+ }
223
+ },
224
+
225
+ onCodePathEnd() {
226
+ funcInfo = funcInfo.upper;
227
+ },
228
+
229
+ ReturnStatement(node) {
230
+ if (!(funcInfo.shouldCheck && node.argument)) {
231
+ return;
232
+ }
233
+
234
+ // node is `return <expression>`
235
+ if (!allowVoid) {
236
+ context.report({ node, messageId: "returnsValue" });
237
+ return;
238
+ }
239
+
240
+ if (expressionIsVoid(node.argument)) {
241
+ return;
242
+ }
243
+
244
+ // allowVoid && !expressionIsVoid
245
+ context.report({
246
+ node,
247
+ messageId: "returnsValue",
248
+ suggest: [
249
+ {
250
+ messageId: "prependVoid",
251
+ fix(fixer) {
252
+ return voidPrependFixer(
253
+ sourceCode,
254
+ node.argument,
255
+ fixer,
256
+ );
257
+ },
258
+ },
259
+ ],
260
+ });
261
+ },
262
+ };
263
+ },
264
+ };
server/node_modules/eslint/lib/rules/no-proto.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag usage of __proto__ property
3
+ * @author Ilya Volodin
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const { getStaticPropertyName } = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Rule Definition
16
+ //------------------------------------------------------------------------------
17
+
18
+ /** @type {import('../types').Rule.RuleModule} */
19
+ module.exports = {
20
+ meta: {
21
+ type: "suggestion",
22
+
23
+ docs: {
24
+ description: "Disallow the use of the `__proto__` property",
25
+ recommended: false,
26
+ url: "https://eslint.org/docs/latest/rules/no-proto",
27
+ },
28
+
29
+ schema: [],
30
+
31
+ messages: {
32
+ unexpectedProto: "The '__proto__' property is deprecated.",
33
+ },
34
+ },
35
+
36
+ create(context) {
37
+ return {
38
+ MemberExpression(node) {
39
+ if (getStaticPropertyName(node) === "__proto__") {
40
+ context.report({ node, messageId: "unexpectedProto" });
41
+ }
42
+ },
43
+ };
44
+ },
45
+ };
server/node_modules/eslint/lib/rules/no-prototype-builtins.js ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow use of Object.prototype builtins on objects
3
+ * @author Andrew Levine
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Helpers
15
+ //------------------------------------------------------------------------------
16
+
17
+ /**
18
+ * Returns true if the node or any of the objects
19
+ * to the left of it in the member/call chain is optional.
20
+ *
21
+ * e.g. `a?.b`, `a?.b.c`, `a?.()`, `a()?.()`
22
+ * @param {ASTNode} node The expression to check
23
+ * @returns {boolean} `true` if there is a short-circuiting optional `?.`
24
+ * in the same option chain to the left of this call or member expression,
25
+ * or the node itself is an optional call or member `?.`.
26
+ */
27
+ function isAfterOptional(node) {
28
+ let leftNode;
29
+
30
+ if (node.type === "MemberExpression") {
31
+ leftNode = node.object;
32
+ } else if (node.type === "CallExpression") {
33
+ leftNode = node.callee;
34
+ } else {
35
+ return false;
36
+ }
37
+ if (node.optional) {
38
+ return true;
39
+ }
40
+ return isAfterOptional(leftNode);
41
+ }
42
+
43
+ //------------------------------------------------------------------------------
44
+ // Rule Definition
45
+ //------------------------------------------------------------------------------
46
+
47
+ /** @type {import('../types').Rule.RuleModule} */
48
+ module.exports = {
49
+ meta: {
50
+ type: "problem",
51
+
52
+ docs: {
53
+ description:
54
+ "Disallow calling some `Object.prototype` methods directly on objects",
55
+ recommended: true,
56
+ url: "https://eslint.org/docs/latest/rules/no-prototype-builtins",
57
+ },
58
+
59
+ hasSuggestions: true,
60
+
61
+ schema: [],
62
+
63
+ messages: {
64
+ prototypeBuildIn:
65
+ "Do not access Object.prototype method '{{prop}}' from target object.",
66
+ callObjectPrototype: "Call Object.prototype.{{prop}} explicitly.",
67
+ },
68
+ },
69
+
70
+ create(context) {
71
+ const DISALLOWED_PROPS = new Set([
72
+ "hasOwnProperty",
73
+ "isPrototypeOf",
74
+ "propertyIsEnumerable",
75
+ ]);
76
+
77
+ /**
78
+ * Reports if a disallowed property is used in a CallExpression
79
+ * @param {ASTNode} node The CallExpression node.
80
+ * @returns {void}
81
+ */
82
+ function disallowBuiltIns(node) {
83
+ const callee = astUtils.skipChainExpression(node.callee);
84
+
85
+ if (callee.type !== "MemberExpression") {
86
+ return;
87
+ }
88
+
89
+ const propName = astUtils.getStaticPropertyName(callee);
90
+
91
+ if (propName !== null && DISALLOWED_PROPS.has(propName)) {
92
+ context.report({
93
+ messageId: "prototypeBuildIn",
94
+ loc: callee.property.loc,
95
+ data: { prop: propName },
96
+ node,
97
+ suggest: [
98
+ {
99
+ messageId: "callObjectPrototype",
100
+ data: { prop: propName },
101
+ fix(fixer) {
102
+ const sourceCode = context.sourceCode;
103
+
104
+ /*
105
+ * A call after an optional chain (e.g. a?.b.hasOwnProperty(c))
106
+ * must be fixed manually because the call can be short-circuited
107
+ */
108
+ if (isAfterOptional(node)) {
109
+ return null;
110
+ }
111
+
112
+ /*
113
+ * A call on a ChainExpression (e.g. (a?.hasOwnProperty)(c)) will trigger
114
+ * no-unsafe-optional-chaining which should be fixed before this suggestion
115
+ */
116
+ if (node.callee.type === "ChainExpression") {
117
+ return null;
118
+ }
119
+
120
+ const objectVariable =
121
+ astUtils.getVariableByName(
122
+ sourceCode.getScope(node),
123
+ "Object",
124
+ );
125
+
126
+ /*
127
+ * We can't use Object if the global Object was shadowed,
128
+ * or Object does not exist in the global scope for some reason
129
+ */
130
+ if (
131
+ !objectVariable ||
132
+ objectVariable.scope.type !== "global" ||
133
+ objectVariable.defs.length > 0
134
+ ) {
135
+ return null;
136
+ }
137
+
138
+ let objectText = sourceCode.getText(
139
+ callee.object,
140
+ );
141
+
142
+ if (
143
+ astUtils.getPrecedence(callee.object) <=
144
+ astUtils.getPrecedence({
145
+ type: "SequenceExpression",
146
+ })
147
+ ) {
148
+ objectText = `(${objectText})`;
149
+ }
150
+
151
+ const openParenToken = sourceCode.getTokenAfter(
152
+ node.callee,
153
+ astUtils.isOpeningParenToken,
154
+ );
155
+ const isEmptyParameters =
156
+ node.arguments.length === 0;
157
+ const delim = isEmptyParameters ? "" : ", ";
158
+ const fixes = [
159
+ fixer.replaceText(
160
+ callee,
161
+ `Object.prototype.${propName}.call`,
162
+ ),
163
+ fixer.insertTextAfter(
164
+ openParenToken,
165
+ objectText + delim,
166
+ ),
167
+ ];
168
+
169
+ return fixes;
170
+ },
171
+ },
172
+ ],
173
+ });
174
+ }
175
+ }
176
+
177
+ return {
178
+ CallExpression: disallowBuiltIns,
179
+ };
180
+ },
181
+ };
server/node_modules/eslint/lib/rules/no-redeclare.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag when the same variable is declared more then once.
3
+ * @author Ilya Volodin
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Rule Definition
16
+ //------------------------------------------------------------------------------
17
+
18
+ /** @type {import('../types').Rule.RuleModule} */
19
+ module.exports = {
20
+ meta: {
21
+ type: "suggestion",
22
+
23
+ defaultOptions: [{ builtinGlobals: true }],
24
+
25
+ docs: {
26
+ description: "Disallow variable redeclaration",
27
+ recommended: true,
28
+ url: "https://eslint.org/docs/latest/rules/no-redeclare",
29
+ },
30
+
31
+ messages: {
32
+ redeclared: "'{{id}}' is already defined.",
33
+ redeclaredAsBuiltin:
34
+ "'{{id}}' is already defined as a built-in global variable.",
35
+ redeclaredBySyntax:
36
+ "'{{id}}' is already defined by a variable declaration.",
37
+ },
38
+
39
+ schema: [
40
+ {
41
+ type: "object",
42
+ properties: {
43
+ builtinGlobals: { type: "boolean" },
44
+ },
45
+ additionalProperties: false,
46
+ },
47
+ ],
48
+ },
49
+
50
+ create(context) {
51
+ const [{ builtinGlobals }] = context.options;
52
+ const sourceCode = context.sourceCode;
53
+
54
+ /**
55
+ * Iterate declarations of a given variable.
56
+ * @param {escope.variable} variable The variable object to iterate declarations.
57
+ * @returns {IterableIterator<{type:string,node:ASTNode,loc:SourceLocation}>} The declarations.
58
+ */
59
+ function* iterateDeclarations(variable) {
60
+ if (
61
+ builtinGlobals &&
62
+ (variable.eslintImplicitGlobalSetting === "readonly" ||
63
+ variable.eslintImplicitGlobalSetting === "writable")
64
+ ) {
65
+ yield { type: "builtin" };
66
+ }
67
+
68
+ for (const id of variable.identifiers) {
69
+ yield { type: "syntax", node: id, loc: id.loc };
70
+ }
71
+
72
+ if (variable.eslintExplicitGlobalComments) {
73
+ for (const comment of variable.eslintExplicitGlobalComments) {
74
+ yield {
75
+ type: "comment",
76
+ node: comment,
77
+ loc: astUtils.getNameLocationInGlobalDirectiveComment(
78
+ sourceCode,
79
+ comment,
80
+ variable.name,
81
+ ),
82
+ };
83
+ }
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Find variables in a given scope and flag redeclared ones.
89
+ * @param {Scope} scope An eslint-scope scope object.
90
+ * @returns {void}
91
+ * @private
92
+ */
93
+ function findVariablesInScope(scope) {
94
+ for (const variable of scope.variables) {
95
+ const [declaration, ...extraDeclarations] =
96
+ iterateDeclarations(variable);
97
+
98
+ if (extraDeclarations.length === 0) {
99
+ continue;
100
+ }
101
+
102
+ /*
103
+ * If the type of a declaration is different from the type of
104
+ * the first declaration, it shows the location of the first
105
+ * declaration.
106
+ */
107
+ const detailMessageId =
108
+ declaration.type === "builtin"
109
+ ? "redeclaredAsBuiltin"
110
+ : "redeclaredBySyntax";
111
+ const data = { id: variable.name };
112
+
113
+ // Report extra declarations.
114
+ for (const { type, node, loc } of extraDeclarations) {
115
+ const messageId =
116
+ type === declaration.type
117
+ ? "redeclared"
118
+ : detailMessageId;
119
+
120
+ context.report({ node, loc, messageId, data });
121
+ }
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Find variables in the current scope.
127
+ * @param {ASTNode} node The node of the current scope.
128
+ * @returns {void}
129
+ * @private
130
+ */
131
+ function checkForBlock(node) {
132
+ const scope = sourceCode.getScope(node);
133
+
134
+ /*
135
+ * In ES5, some node type such as `BlockStatement` doesn't have that scope.
136
+ * `scope.block` is a different node in such a case.
137
+ */
138
+ if (scope.block === node) {
139
+ findVariablesInScope(scope);
140
+ }
141
+ }
142
+
143
+ return {
144
+ Program(node) {
145
+ const scope = sourceCode.getScope(node);
146
+
147
+ findVariablesInScope(scope);
148
+
149
+ // Node.js or ES modules has a special scope.
150
+ if (
151
+ scope.type === "global" &&
152
+ scope.childScopes[0] &&
153
+ // The special scope's block is the Program node.
154
+ scope.block === scope.childScopes[0].block
155
+ ) {
156
+ findVariablesInScope(scope.childScopes[0]);
157
+ }
158
+ },
159
+
160
+ FunctionDeclaration: checkForBlock,
161
+ FunctionExpression: checkForBlock,
162
+ ArrowFunctionExpression: checkForBlock,
163
+
164
+ StaticBlock: checkForBlock,
165
+
166
+ BlockStatement: checkForBlock,
167
+ ForStatement: checkForBlock,
168
+ ForInStatement: checkForBlock,
169
+ ForOfStatement: checkForBlock,
170
+ SwitchStatement: checkForBlock,
171
+ };
172
+ },
173
+ };
server/node_modules/eslint/lib/rules/no-regex-spaces.js ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to count multiple spaces in regular expressions
3
+ * @author Matt DuVall <http://www.mattduvall.com/>
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+ const regexpp = require("@eslint-community/regexpp");
14
+
15
+ //------------------------------------------------------------------------------
16
+ // Helpers
17
+ //------------------------------------------------------------------------------
18
+
19
+ const regExpParser = new regexpp.RegExpParser();
20
+ const DOUBLE_SPACE = / {2}/u;
21
+
22
+ /**
23
+ * Check if node is a string
24
+ * @param {ASTNode} node node to evaluate
25
+ * @returns {boolean} True if its a string
26
+ * @private
27
+ */
28
+ function isString(node) {
29
+ return node && node.type === "Literal" && typeof node.value === "string";
30
+ }
31
+
32
+ //------------------------------------------------------------------------------
33
+ // Rule Definition
34
+ //------------------------------------------------------------------------------
35
+
36
+ /** @type {import('../types').Rule.RuleModule} */
37
+ module.exports = {
38
+ meta: {
39
+ type: "suggestion",
40
+
41
+ docs: {
42
+ description: "Disallow multiple spaces in regular expressions",
43
+ recommended: true,
44
+ url: "https://eslint.org/docs/latest/rules/no-regex-spaces",
45
+ },
46
+
47
+ schema: [],
48
+ fixable: "code",
49
+
50
+ messages: {
51
+ multipleSpaces: "Spaces are hard to count. Use {{{length}}}.",
52
+ },
53
+ },
54
+
55
+ create(context) {
56
+ const sourceCode = context.sourceCode;
57
+
58
+ /**
59
+ * Validate regular expression
60
+ * @param {ASTNode} nodeToReport Node to report.
61
+ * @param {string} pattern Regular expression pattern to validate.
62
+ * @param {string} rawPattern Raw representation of the pattern in the source code.
63
+ * @param {number} rawPatternStartRange Start range of the pattern in the source code.
64
+ * @param {string} flags Regular expression flags.
65
+ * @returns {void}
66
+ * @private
67
+ */
68
+ function checkRegex(
69
+ nodeToReport,
70
+ pattern,
71
+ rawPattern,
72
+ rawPatternStartRange,
73
+ flags,
74
+ ) {
75
+ // Skip if there are no consecutive spaces in the source code, to avoid reporting e.g., RegExp(' \ ').
76
+ if (!DOUBLE_SPACE.test(rawPattern)) {
77
+ return;
78
+ }
79
+
80
+ const characterClassNodes = [];
81
+ let regExpAST;
82
+
83
+ try {
84
+ regExpAST = regExpParser.parsePattern(
85
+ pattern,
86
+ 0,
87
+ pattern.length,
88
+ {
89
+ unicode: flags.includes("u"),
90
+ unicodeSets: flags.includes("v"),
91
+ },
92
+ );
93
+ } catch {
94
+ // Ignore regular expressions with syntax errors
95
+ return;
96
+ }
97
+
98
+ regexpp.visitRegExpAST(regExpAST, {
99
+ onCharacterClassEnter(ccNode) {
100
+ characterClassNodes.push(ccNode);
101
+ },
102
+ });
103
+
104
+ const spacesPattern = /( {2,})(?: [+*{?]|[^+*{?]|$)/gu;
105
+ let match;
106
+
107
+ while ((match = spacesPattern.exec(pattern))) {
108
+ const {
109
+ 1: { length },
110
+ index,
111
+ } = match;
112
+
113
+ // Report only consecutive spaces that are not in character classes.
114
+ if (
115
+ characterClassNodes.every(
116
+ ({ start, end }) => index < start || end <= index,
117
+ )
118
+ ) {
119
+ context.report({
120
+ node: nodeToReport,
121
+ messageId: "multipleSpaces",
122
+ data: { length },
123
+ fix(fixer) {
124
+ if (pattern !== rawPattern) {
125
+ return null;
126
+ }
127
+ return fixer.replaceTextRange(
128
+ [
129
+ rawPatternStartRange + index,
130
+ rawPatternStartRange + index + length,
131
+ ],
132
+ ` {${length}}`,
133
+ );
134
+ },
135
+ });
136
+
137
+ // Report only the first occurrence of consecutive spaces
138
+ return;
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Validate regular expression literals
145
+ * @param {ASTNode} node node to validate
146
+ * @returns {void}
147
+ * @private
148
+ */
149
+ function checkLiteral(node) {
150
+ if (node.regex) {
151
+ const pattern = node.regex.pattern;
152
+ const rawPattern = node.raw.slice(1, node.raw.lastIndexOf("/"));
153
+ const rawPatternStartRange = node.range[0] + 1;
154
+ const flags = node.regex.flags;
155
+
156
+ checkRegex(
157
+ node,
158
+ pattern,
159
+ rawPattern,
160
+ rawPatternStartRange,
161
+ flags,
162
+ );
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Validate strings passed to the RegExp constructor
168
+ * @param {ASTNode} node node to validate
169
+ * @returns {void}
170
+ * @private
171
+ */
172
+ function checkFunction(node) {
173
+ const scope = sourceCode.getScope(node);
174
+ const regExpVar = astUtils.getVariableByName(scope, "RegExp");
175
+ const shadowed = regExpVar && regExpVar.defs.length > 0;
176
+ const patternNode = node.arguments[0];
177
+
178
+ if (
179
+ node.callee.type === "Identifier" &&
180
+ node.callee.name === "RegExp" &&
181
+ isString(patternNode) &&
182
+ !shadowed
183
+ ) {
184
+ const pattern = patternNode.value;
185
+ const rawPattern = patternNode.raw.slice(1, -1);
186
+ const rawPatternStartRange = patternNode.range[0] + 1;
187
+ let flags;
188
+
189
+ if (node.arguments.length < 2) {
190
+ // It has no flags.
191
+ flags = "";
192
+ } else {
193
+ const flagsNode = node.arguments[1];
194
+
195
+ if (isString(flagsNode)) {
196
+ flags = flagsNode.value;
197
+ } else {
198
+ // The flags cannot be determined.
199
+ return;
200
+ }
201
+ }
202
+
203
+ checkRegex(
204
+ node,
205
+ pattern,
206
+ rawPattern,
207
+ rawPatternStartRange,
208
+ flags,
209
+ );
210
+ }
211
+ }
212
+
213
+ return {
214
+ Literal: checkLiteral,
215
+ CallExpression: checkFunction,
216
+ NewExpression: checkFunction,
217
+ };
218
+ },
219
+ };
server/node_modules/eslint/lib/rules/no-restricted-exports.js ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow specified names in exports
3
+ * @author Milos Djermanovic
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Rule Definition
16
+ //------------------------------------------------------------------------------
17
+
18
+ /** @type {import('../types').Rule.RuleModule} */
19
+ module.exports = {
20
+ meta: {
21
+ type: "suggestion",
22
+
23
+ docs: {
24
+ description: "Disallow specified names in exports",
25
+ recommended: false,
26
+ url: "https://eslint.org/docs/latest/rules/no-restricted-exports",
27
+ },
28
+
29
+ schema: [
30
+ {
31
+ anyOf: [
32
+ {
33
+ type: "object",
34
+ properties: {
35
+ restrictedNamedExports: {
36
+ type: "array",
37
+ items: {
38
+ type: "string",
39
+ },
40
+ uniqueItems: true,
41
+ },
42
+ restrictedNamedExportsPattern: { type: "string" },
43
+ },
44
+ additionalProperties: false,
45
+ },
46
+ {
47
+ type: "object",
48
+ properties: {
49
+ restrictedNamedExports: {
50
+ type: "array",
51
+ items: {
52
+ type: "string",
53
+ pattern: "^(?!default$)",
54
+ },
55
+ uniqueItems: true,
56
+ },
57
+ restrictedNamedExportsPattern: { type: "string" },
58
+ restrictDefaultExports: {
59
+ type: "object",
60
+ properties: {
61
+ // Allow/Disallow `export default foo; export default 42; export default function foo() {}` format
62
+ direct: {
63
+ type: "boolean",
64
+ },
65
+
66
+ // Allow/Disallow `export { foo as default };` declarations
67
+ named: {
68
+ type: "boolean",
69
+ },
70
+
71
+ // Allow/Disallow `export { default } from "mod"; export { default as default } from "mod";` declarations
72
+ defaultFrom: {
73
+ type: "boolean",
74
+ },
75
+
76
+ // Allow/Disallow `export { foo as default } from "mod";` declarations
77
+ namedFrom: {
78
+ type: "boolean",
79
+ },
80
+
81
+ // Allow/Disallow `export * as default from "mod"`; declarations
82
+ namespaceFrom: {
83
+ type: "boolean",
84
+ },
85
+ },
86
+ additionalProperties: false,
87
+ },
88
+ },
89
+ additionalProperties: false,
90
+ },
91
+ ],
92
+ },
93
+ ],
94
+
95
+ messages: {
96
+ restrictedNamed:
97
+ "'{{name}}' is restricted from being used as an exported name.",
98
+ restrictedDefault: "Exporting 'default' is restricted.",
99
+ },
100
+ },
101
+
102
+ create(context) {
103
+ const restrictedNames = new Set(
104
+ context.options[0] && context.options[0].restrictedNamedExports,
105
+ );
106
+ const restrictedNamePattern =
107
+ context.options[0] &&
108
+ context.options[0].restrictedNamedExportsPattern;
109
+ const restrictDefaultExports =
110
+ context.options[0] && context.options[0].restrictDefaultExports;
111
+ const sourceCode = context.sourceCode;
112
+
113
+ /**
114
+ * Checks and reports given exported name.
115
+ * @param {ASTNode} node exported `Identifier` or string `Literal` node to check.
116
+ * @returns {void}
117
+ */
118
+ function checkExportedName(node) {
119
+ const name = astUtils.getModuleExportName(node);
120
+
121
+ let matchesRestrictedNamePattern = false;
122
+
123
+ if (restrictedNamePattern && name !== "default") {
124
+ const patternRegex = new RegExp(restrictedNamePattern, "u");
125
+
126
+ matchesRestrictedNamePattern = patternRegex.test(name);
127
+ }
128
+
129
+ if (matchesRestrictedNamePattern || restrictedNames.has(name)) {
130
+ context.report({
131
+ node,
132
+ messageId: "restrictedNamed",
133
+ data: { name },
134
+ });
135
+ return;
136
+ }
137
+
138
+ if (name === "default") {
139
+ if (node.parent.type === "ExportAllDeclaration") {
140
+ if (
141
+ restrictDefaultExports &&
142
+ restrictDefaultExports.namespaceFrom
143
+ ) {
144
+ context.report({
145
+ node,
146
+ messageId: "restrictedDefault",
147
+ });
148
+ }
149
+ } else {
150
+ // ExportSpecifier
151
+ const isSourceSpecified = !!node.parent.parent.source;
152
+ const specifierLocalName = astUtils.getModuleExportName(
153
+ node.parent.local,
154
+ );
155
+
156
+ if (
157
+ !isSourceSpecified &&
158
+ restrictDefaultExports &&
159
+ restrictDefaultExports.named
160
+ ) {
161
+ context.report({
162
+ node,
163
+ messageId: "restrictedDefault",
164
+ });
165
+ return;
166
+ }
167
+
168
+ if (isSourceSpecified && restrictDefaultExports) {
169
+ if (
170
+ (specifierLocalName === "default" &&
171
+ restrictDefaultExports.defaultFrom) ||
172
+ (specifierLocalName !== "default" &&
173
+ restrictDefaultExports.namedFrom)
174
+ ) {
175
+ context.report({
176
+ node,
177
+ messageId: "restrictedDefault",
178
+ });
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ return {
186
+ ExportAllDeclaration(node) {
187
+ if (node.exported) {
188
+ checkExportedName(node.exported);
189
+ }
190
+ },
191
+
192
+ ExportDefaultDeclaration(node) {
193
+ if (restrictDefaultExports && restrictDefaultExports.direct) {
194
+ context.report({
195
+ node,
196
+ messageId: "restrictedDefault",
197
+ });
198
+ }
199
+ },
200
+
201
+ ExportNamedDeclaration(node) {
202
+ const declaration = node.declaration;
203
+
204
+ if (declaration) {
205
+ if (
206
+ declaration.type === "FunctionDeclaration" ||
207
+ declaration.type === "ClassDeclaration"
208
+ ) {
209
+ checkExportedName(declaration.id);
210
+ } else if (declaration.type === "VariableDeclaration") {
211
+ sourceCode
212
+ .getDeclaredVariables(declaration)
213
+ .map(v =>
214
+ v.defs.find(d => d.parent === declaration),
215
+ )
216
+ .map(d => d.name) // Identifier nodes
217
+ .forEach(checkExportedName);
218
+ }
219
+ } else {
220
+ node.specifiers
221
+ .map(s => s.exported)
222
+ .forEach(checkExportedName);
223
+ }
224
+ },
225
+ };
226
+ },
227
+ };
server/node_modules/eslint/lib/rules/no-restricted-globals.js ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Restrict usage of specified globals.
3
+ * @author Benoît Zugmeyer
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Helpers
15
+ //------------------------------------------------------------------------------
16
+
17
+ const TYPE_NODES = new Set([
18
+ "TSTypeReference",
19
+ "TSInterfaceHeritage",
20
+ "TSClassImplements",
21
+ "TSTypeQuery",
22
+ "TSQualifiedName",
23
+ ]);
24
+
25
+ const GLOBAL_OBJECTS = new Set(["globalThis", "self", "window"]);
26
+
27
+ //------------------------------------------------------------------------------
28
+ // Rule Definition
29
+ //------------------------------------------------------------------------------
30
+
31
+ const arrayOfGlobals = {
32
+ type: "array",
33
+ items: {
34
+ oneOf: [
35
+ {
36
+ type: "string",
37
+ },
38
+ {
39
+ type: "object",
40
+ properties: {
41
+ name: { type: "string" },
42
+ message: { type: "string" },
43
+ },
44
+ required: ["name"],
45
+ additionalProperties: false,
46
+ },
47
+ ],
48
+ },
49
+ uniqueItems: true,
50
+ minItems: 0,
51
+ };
52
+
53
+ /** @type {import('../types').Rule.RuleModule} */
54
+ module.exports = {
55
+ meta: {
56
+ dialects: ["javascript", "typescript"],
57
+ language: "javascript",
58
+ type: "suggestion",
59
+
60
+ docs: {
61
+ description: "Disallow specified global variables",
62
+ recommended: false,
63
+ url: "https://eslint.org/docs/latest/rules/no-restricted-globals",
64
+ },
65
+
66
+ schema: {
67
+ anyOf: [
68
+ arrayOfGlobals,
69
+ {
70
+ type: "array",
71
+ items: [
72
+ {
73
+ type: "object",
74
+ properties: {
75
+ globals: arrayOfGlobals,
76
+ checkGlobalObject: {
77
+ type: "boolean",
78
+ },
79
+ globalObjects: {
80
+ type: "array",
81
+ items: {
82
+ type: "string",
83
+ },
84
+ uniqueItems: true,
85
+ },
86
+ },
87
+ required: ["globals"],
88
+ additionalProperties: false,
89
+ },
90
+ ],
91
+ additionalItems: false,
92
+ },
93
+ ],
94
+ },
95
+
96
+ messages: {
97
+ defaultMessage: "Unexpected use of '{{name}}'.",
98
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
99
+ customMessage: "Unexpected use of '{{name}}'. {{customMessage}}",
100
+ },
101
+ },
102
+
103
+ create(context) {
104
+ const { sourceCode, options } = context;
105
+
106
+ const isGlobalsObject =
107
+ typeof options[0] === "object" &&
108
+ Object.hasOwn(options[0], "globals");
109
+
110
+ const restrictedGlobals = isGlobalsObject
111
+ ? options[0].globals
112
+ : options;
113
+ const checkGlobalObject = isGlobalsObject
114
+ ? options[0].checkGlobalObject
115
+ : false;
116
+ const userGlobalObjects = isGlobalsObject
117
+ ? options[0].globalObjects || []
118
+ : [];
119
+
120
+ const globalObjects = new Set([
121
+ ...GLOBAL_OBJECTS,
122
+ ...userGlobalObjects,
123
+ ]);
124
+
125
+ // If no globals are restricted, we don't need to do anything
126
+ if (restrictedGlobals.length === 0) {
127
+ return {};
128
+ }
129
+
130
+ const restrictedGlobalMessages = restrictedGlobals.reduce(
131
+ (memo, option) => {
132
+ if (typeof option === "string") {
133
+ memo[option] = null;
134
+ } else {
135
+ memo[option.name] = option.message;
136
+ }
137
+
138
+ return memo;
139
+ },
140
+ {},
141
+ );
142
+
143
+ /**
144
+ * Report a variable to be used as a restricted global.
145
+ * @param {Reference} reference the variable reference
146
+ * @returns {void}
147
+ * @private
148
+ */
149
+ function reportReference(reference) {
150
+ const name = reference.identifier.name,
151
+ customMessage = restrictedGlobalMessages[name],
152
+ messageId = customMessage ? "customMessage" : "defaultMessage";
153
+
154
+ context.report({
155
+ node: reference.identifier,
156
+ messageId,
157
+ data: {
158
+ name,
159
+ customMessage,
160
+ },
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Check if the given name is a restricted global name.
166
+ * @param {string} name name of a variable
167
+ * @returns {boolean} whether the variable is a restricted global or not
168
+ * @private
169
+ */
170
+ function isRestricted(name) {
171
+ return Object.hasOwn(restrictedGlobalMessages, name);
172
+ }
173
+
174
+ /**
175
+ * Check if the given reference occurs within a TypeScript type context.
176
+ * @param {Reference} reference The variable reference to check.
177
+ * @returns {boolean} Whether the reference is in a type context.
178
+ * @private
179
+ */
180
+ function isInTypeContext(reference) {
181
+ const parent = reference.identifier.parent;
182
+
183
+ return TYPE_NODES.has(parent.type);
184
+ }
185
+
186
+ return {
187
+ Program(node) {
188
+ const scope = sourceCode.getScope(node);
189
+
190
+ // Report variables declared elsewhere (ex: variables defined as "global" by eslint)
191
+ scope.variables.forEach(variable => {
192
+ if (!variable.defs.length && isRestricted(variable.name)) {
193
+ variable.references.forEach(reference => {
194
+ if (!isInTypeContext(reference)) {
195
+ reportReference(reference);
196
+ }
197
+ });
198
+ }
199
+ });
200
+
201
+ // Report variables not declared at all
202
+ scope.through.forEach(reference => {
203
+ if (
204
+ isRestricted(reference.identifier.name) &&
205
+ !isInTypeContext(reference)
206
+ ) {
207
+ reportReference(reference);
208
+ }
209
+ });
210
+ },
211
+
212
+ "Program:exit"(node) {
213
+ if (!checkGlobalObject) {
214
+ return;
215
+ }
216
+
217
+ const globalScope = sourceCode.getScope(node);
218
+ globalObjects.forEach(globalObjectName => {
219
+ const variable = astUtils.getVariableByName(
220
+ globalScope,
221
+ globalObjectName,
222
+ );
223
+
224
+ if (!variable) {
225
+ return;
226
+ }
227
+
228
+ variable.references.forEach(reference => {
229
+ const identifier = reference.identifier;
230
+ let parent = identifier.parent;
231
+
232
+ // To detect code like `window.window.Promise`.
233
+ while (
234
+ astUtils.isSpecificMemberAccess(
235
+ parent,
236
+ null,
237
+ globalObjectName,
238
+ )
239
+ ) {
240
+ parent = parent.parent;
241
+ }
242
+
243
+ const propertyName =
244
+ astUtils.getStaticPropertyName(parent);
245
+ if (propertyName && isRestricted(propertyName)) {
246
+ const customMessage =
247
+ restrictedGlobalMessages[propertyName];
248
+ const messageId = customMessage
249
+ ? "customMessage"
250
+ : "defaultMessage";
251
+
252
+ context.report({
253
+ node: parent.property,
254
+ messageId,
255
+ data: {
256
+ name: propertyName,
257
+ customMessage,
258
+ },
259
+ });
260
+ }
261
+ });
262
+ });
263
+ },
264
+ };
265
+ },
266
+ };
server/node_modules/eslint/lib/rules/no-restricted-imports.js ADDED
@@ -0,0 +1,850 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Restrict usage of specified node imports.
3
+ * @author Guy Ellis
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Rule Definition
15
+ //------------------------------------------------------------------------------
16
+
17
+ const ignore = require("ignore");
18
+
19
+ const arrayOfStringsOrObjects = {
20
+ type: "array",
21
+ items: {
22
+ anyOf: [
23
+ { type: "string" },
24
+ {
25
+ type: "object",
26
+ properties: {
27
+ name: { type: "string" },
28
+ message: {
29
+ type: "string",
30
+ minLength: 1,
31
+ },
32
+ importNames: {
33
+ type: "array",
34
+ items: {
35
+ type: "string",
36
+ },
37
+ },
38
+ allowImportNames: {
39
+ type: "array",
40
+ items: {
41
+ type: "string",
42
+ },
43
+ },
44
+ allowTypeImports: {
45
+ type: "boolean",
46
+ description:
47
+ "Whether to allow type-only imports for a path.",
48
+ },
49
+ },
50
+ additionalProperties: false,
51
+ required: ["name"],
52
+ not: { required: ["importNames", "allowImportNames"] },
53
+ },
54
+ ],
55
+ },
56
+ uniqueItems: true,
57
+ };
58
+
59
+ const arrayOfStringsOrObjectPatterns = {
60
+ anyOf: [
61
+ {
62
+ type: "array",
63
+ items: {
64
+ type: "string",
65
+ },
66
+ uniqueItems: true,
67
+ },
68
+ {
69
+ type: "array",
70
+ items: {
71
+ type: "object",
72
+ properties: {
73
+ importNames: {
74
+ type: "array",
75
+ items: {
76
+ type: "string",
77
+ },
78
+ minItems: 1,
79
+ uniqueItems: true,
80
+ },
81
+ allowImportNames: {
82
+ type: "array",
83
+ items: {
84
+ type: "string",
85
+ },
86
+ minItems: 1,
87
+ uniqueItems: true,
88
+ },
89
+ group: {
90
+ type: "array",
91
+ items: {
92
+ type: "string",
93
+ },
94
+ minItems: 1,
95
+ uniqueItems: true,
96
+ },
97
+ regex: {
98
+ type: "string",
99
+ },
100
+ importNamePattern: {
101
+ type: "string",
102
+ },
103
+ allowImportNamePattern: {
104
+ type: "string",
105
+ },
106
+ message: {
107
+ type: "string",
108
+ minLength: 1,
109
+ },
110
+ caseSensitive: {
111
+ type: "boolean",
112
+ },
113
+ allowTypeImports: {
114
+ type: "boolean",
115
+ description:
116
+ "Whether to allow type-only imports for a pattern.",
117
+ },
118
+ },
119
+ additionalProperties: false,
120
+ not: {
121
+ anyOf: [
122
+ { required: ["importNames", "allowImportNames"] },
123
+ {
124
+ required: [
125
+ "importNamePattern",
126
+ "allowImportNamePattern",
127
+ ],
128
+ },
129
+ { required: ["importNames", "allowImportNamePattern"] },
130
+ { required: ["importNamePattern", "allowImportNames"] },
131
+ {
132
+ required: [
133
+ "allowImportNames",
134
+ "allowImportNamePattern",
135
+ ],
136
+ },
137
+ ],
138
+ },
139
+ oneOf: [{ required: ["group"] }, { required: ["regex"] }],
140
+ },
141
+ uniqueItems: true,
142
+ },
143
+ ],
144
+ };
145
+
146
+ /** @type {import('../types').Rule.RuleModule} */
147
+ module.exports = {
148
+ meta: {
149
+ type: "suggestion",
150
+ dialects: ["typescript", "javascript"],
151
+ language: "javascript",
152
+
153
+ docs: {
154
+ description: "Disallow specified modules when loaded by `import`",
155
+ recommended: false,
156
+ url: "https://eslint.org/docs/latest/rules/no-restricted-imports",
157
+ },
158
+
159
+ messages: {
160
+ path: "'{{importSource}}' import is restricted from being used.",
161
+ pathWithCustomMessage:
162
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
163
+ "'{{importSource}}' import is restricted from being used. {{customMessage}}",
164
+
165
+ patterns:
166
+ "'{{importSource}}' import is restricted from being used by a pattern.",
167
+ patternWithCustomMessage:
168
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
169
+ "'{{importSource}}' import is restricted from being used by a pattern. {{customMessage}}",
170
+
171
+ patternAndImportName:
172
+ "'{{importName}}' import from '{{importSource}}' is restricted from being used by a pattern.",
173
+ patternAndImportNameWithCustomMessage:
174
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
175
+ "'{{importName}}' import from '{{importSource}}' is restricted from being used by a pattern. {{customMessage}}",
176
+
177
+ patternAndEverything:
178
+ "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern.",
179
+
180
+ patternAndEverythingWithRegexImportName:
181
+ "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used.",
182
+ patternAndEverythingWithCustomMessage:
183
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
184
+ "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern. {{customMessage}}",
185
+ patternAndEverythingWithRegexImportNameAndCustomMessage:
186
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
187
+ "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used. {{customMessage}}",
188
+
189
+ everything:
190
+ "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",
191
+ everythingWithCustomMessage:
192
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
193
+ "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}",
194
+
195
+ importName:
196
+ "'{{importName}}' import from '{{importSource}}' is restricted.",
197
+ importNameWithCustomMessage:
198
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
199
+ "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}",
200
+
201
+ allowedImportName:
202
+ "'{{importName}}' import from '{{importSource}}' is restricted because only '{{allowedImportNames}}' import(s) is/are allowed.",
203
+ allowedImportNameWithCustomMessage:
204
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
205
+ "'{{importName}}' import from '{{importSource}}' is restricted because only '{{allowedImportNames}}' import(s) is/are allowed. {{customMessage}}",
206
+
207
+ everythingWithAllowImportNames:
208
+ "* import is invalid because only '{{allowedImportNames}}' from '{{importSource}}' is/are allowed.",
209
+ everythingWithAllowImportNamesAndCustomMessage:
210
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
211
+ "* import is invalid because only '{{allowedImportNames}}' from '{{importSource}}' is/are allowed. {{customMessage}}",
212
+
213
+ allowedImportNamePattern:
214
+ "'{{importName}}' import from '{{importSource}}' is restricted because only imports that match the pattern '{{allowedImportNamePattern}}' are allowed from '{{importSource}}'.",
215
+ allowedImportNamePatternWithCustomMessage:
216
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
217
+ "'{{importName}}' import from '{{importSource}}' is restricted because only imports that match the pattern '{{allowedImportNamePattern}}' are allowed from '{{importSource}}'. {{customMessage}}",
218
+
219
+ everythingWithAllowedImportNamePattern:
220
+ "* import is invalid because only imports that match the pattern '{{allowedImportNamePattern}}' from '{{importSource}}' are allowed.",
221
+ everythingWithAllowedImportNamePatternWithCustomMessage:
222
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
223
+ "* import is invalid because only imports that match the pattern '{{allowedImportNamePattern}}' from '{{importSource}}' are allowed. {{customMessage}}",
224
+ },
225
+
226
+ schema: {
227
+ anyOf: [
228
+ arrayOfStringsOrObjects,
229
+ {
230
+ type: "array",
231
+ items: [
232
+ {
233
+ type: "object",
234
+ properties: {
235
+ paths: arrayOfStringsOrObjects,
236
+ patterns: arrayOfStringsOrObjectPatterns,
237
+ },
238
+ additionalProperties: false,
239
+ },
240
+ ],
241
+ additionalItems: false,
242
+ },
243
+ ],
244
+ },
245
+ },
246
+
247
+ create(context) {
248
+ const sourceCode = context.sourceCode;
249
+ const options = Array.isArray(context.options) ? context.options : [];
250
+ const isPathAndPatternsObject =
251
+ typeof options[0] === "object" &&
252
+ (Object.hasOwn(options[0], "paths") ||
253
+ Object.hasOwn(options[0], "patterns"));
254
+
255
+ const restrictedPaths =
256
+ (isPathAndPatternsObject ? options[0].paths : context.options) ||
257
+ [];
258
+ const groupedRestrictedPaths = restrictedPaths.reduce(
259
+ (memo, importSource) => {
260
+ const path =
261
+ typeof importSource === "string"
262
+ ? importSource
263
+ : importSource.name;
264
+
265
+ if (!memo[path]) {
266
+ memo[path] = [];
267
+ }
268
+
269
+ if (typeof importSource === "string") {
270
+ memo[path].push({});
271
+ } else {
272
+ memo[path].push({
273
+ message: importSource.message,
274
+ importNames: importSource.importNames,
275
+ allowImportNames: importSource.allowImportNames,
276
+ allowTypeImports: importSource.allowTypeImports,
277
+ });
278
+ }
279
+ return memo;
280
+ },
281
+ Object.create(null),
282
+ );
283
+
284
+ // Handle patterns too, either as strings or groups
285
+ let restrictedPatterns =
286
+ (isPathAndPatternsObject ? options[0].patterns : []) || [];
287
+
288
+ // standardize to array of objects if we have an array of strings
289
+ if (
290
+ restrictedPatterns.length > 0 &&
291
+ typeof restrictedPatterns[0] === "string"
292
+ ) {
293
+ restrictedPatterns = [{ group: restrictedPatterns }];
294
+ }
295
+
296
+ // relative paths are supported for this rule
297
+ const restrictedPatternGroups = restrictedPatterns.map(
298
+ ({
299
+ group,
300
+ regex,
301
+ message,
302
+ caseSensitive,
303
+ importNames,
304
+ importNamePattern,
305
+ allowImportNames,
306
+ allowImportNamePattern,
307
+ allowTypeImports,
308
+ }) => ({
309
+ ...(group
310
+ ? {
311
+ matcher: ignore({
312
+ allowRelativePaths: true,
313
+ ignorecase: !caseSensitive,
314
+ }).add(group),
315
+ }
316
+ : {}),
317
+ ...(typeof regex === "string"
318
+ ? {
319
+ regexMatcher: new RegExp(
320
+ regex,
321
+ caseSensitive ? "u" : "iu",
322
+ ),
323
+ }
324
+ : {}),
325
+ customMessage: message,
326
+ importNames,
327
+ importNamePattern,
328
+ allowImportNames,
329
+ allowImportNamePattern,
330
+ allowTypeImports,
331
+ }),
332
+ );
333
+
334
+ // if no imports are restricted we don't need to check
335
+ if (
336
+ Object.keys(restrictedPaths).length === 0 &&
337
+ restrictedPatternGroups.length === 0
338
+ ) {
339
+ return {};
340
+ }
341
+
342
+ /**
343
+ * Check if the node is a type-only import
344
+ * @param {ASTNode} node The node to check
345
+ * @returns {boolean} Whether the node is a type-only import
346
+ */
347
+ function isTypeOnlyImport(node) {
348
+ return (
349
+ node.importKind === "type" ||
350
+ (node.specifiers?.length > 0 &&
351
+ node.specifiers.every(
352
+ specifier => specifier.importKind === "type",
353
+ ))
354
+ );
355
+ }
356
+
357
+ /**
358
+ * Check if a specifier is type-only
359
+ * @param {ASTNode} specifier The specifier to check
360
+ * @returns {boolean} Whether the specifier is type-only
361
+ */
362
+ function isTypeOnlySpecifier(specifier) {
363
+ return (
364
+ specifier.importKind === "type" ||
365
+ specifier.exportKind === "type"
366
+ );
367
+ }
368
+
369
+ /**
370
+ * Check if the node is a type-only export
371
+ * @param {ASTNode} node The node to check
372
+ * @returns {boolean} Whether the node is a type-only export
373
+ */
374
+ function isTypeOnlyExport(node) {
375
+ return (
376
+ node.exportKind === "type" ||
377
+ (node.specifiers?.length > 0 &&
378
+ node.specifiers.every(
379
+ specifier => specifier.exportKind === "type",
380
+ ))
381
+ );
382
+ }
383
+
384
+ /**
385
+ * Report a restricted path.
386
+ * @param {string} importSource path of the import
387
+ * @param {Map<string,Object[]>} importNames Map of import names that are being imported
388
+ * @param {node} node representing the restricted path reference
389
+ * @returns {void}
390
+ * @private
391
+ */
392
+ function checkRestrictedPathAndReport(importSource, importNames, node) {
393
+ if (!Object.hasOwn(groupedRestrictedPaths, importSource)) {
394
+ return;
395
+ }
396
+
397
+ groupedRestrictedPaths[importSource].forEach(
398
+ restrictedPathEntry => {
399
+ const customMessage = restrictedPathEntry.message;
400
+ const restrictedImportNames =
401
+ restrictedPathEntry.importNames;
402
+ const allowedImportNames =
403
+ restrictedPathEntry.allowImportNames;
404
+ const allowTypeImports =
405
+ restrictedPathEntry.allowTypeImports;
406
+
407
+ // Skip if this is a type-only import and it's allowed for this specific entry
408
+ if (
409
+ allowTypeImports &&
410
+ (node.type === "ImportDeclaration" ||
411
+ node.type === "TSImportEqualsDeclaration") &&
412
+ isTypeOnlyImport(node)
413
+ ) {
414
+ return;
415
+ }
416
+
417
+ // Skip if this is a type-only export and it's allowed for this specific entry
418
+ if (
419
+ allowTypeImports &&
420
+ (node.type === "ExportNamedDeclaration" ||
421
+ node.type === "ExportAllDeclaration") &&
422
+ isTypeOnlyExport(node)
423
+ ) {
424
+ return;
425
+ }
426
+
427
+ if (!restrictedImportNames && !allowedImportNames) {
428
+ context.report({
429
+ node,
430
+ messageId: customMessage
431
+ ? "pathWithCustomMessage"
432
+ : "path",
433
+ data: {
434
+ importSource,
435
+ customMessage,
436
+ },
437
+ });
438
+
439
+ return;
440
+ }
441
+
442
+ importNames.forEach((specifiers, importName) => {
443
+ if (importName === "*") {
444
+ const [specifier] = specifiers;
445
+
446
+ if (restrictedImportNames) {
447
+ context.report({
448
+ node,
449
+ messageId: customMessage
450
+ ? "everythingWithCustomMessage"
451
+ : "everything",
452
+ loc: specifier.loc,
453
+ data: {
454
+ importSource,
455
+ importNames: restrictedImportNames,
456
+ customMessage,
457
+ },
458
+ });
459
+ } else if (allowedImportNames) {
460
+ context.report({
461
+ node,
462
+ messageId: customMessage
463
+ ? "everythingWithAllowImportNamesAndCustomMessage"
464
+ : "everythingWithAllowImportNames",
465
+ loc: specifier.loc,
466
+ data: {
467
+ importSource,
468
+ allowedImportNames,
469
+ customMessage,
470
+ },
471
+ });
472
+ }
473
+
474
+ return;
475
+ }
476
+
477
+ if (
478
+ restrictedImportNames &&
479
+ restrictedImportNames.includes(importName)
480
+ ) {
481
+ specifiers.forEach(specifier => {
482
+ // Skip if this is a type-only import specifier and type imports are allowed
483
+ if (
484
+ allowTypeImports &&
485
+ isTypeOnlySpecifier(specifier.specifier)
486
+ ) {
487
+ return;
488
+ }
489
+
490
+ context.report({
491
+ node,
492
+ messageId: customMessage
493
+ ? "importNameWithCustomMessage"
494
+ : "importName",
495
+ loc: specifier.loc,
496
+ data: {
497
+ importSource,
498
+ customMessage,
499
+ importName,
500
+ },
501
+ });
502
+ });
503
+ }
504
+
505
+ if (
506
+ allowedImportNames &&
507
+ !allowedImportNames.includes(importName)
508
+ ) {
509
+ specifiers.forEach(specifier => {
510
+ // Skip if this is a type-only import specifier and type imports are allowed
511
+ if (
512
+ allowTypeImports &&
513
+ isTypeOnlySpecifier(specifier.specifier)
514
+ ) {
515
+ return;
516
+ }
517
+
518
+ context.report({
519
+ node,
520
+ loc: specifier.loc,
521
+ messageId: customMessage
522
+ ? "allowedImportNameWithCustomMessage"
523
+ : "allowedImportName",
524
+ data: {
525
+ importSource,
526
+ customMessage,
527
+ importName,
528
+ allowedImportNames,
529
+ },
530
+ });
531
+ });
532
+ }
533
+ });
534
+ },
535
+ );
536
+ }
537
+
538
+ /**
539
+ * Report a restricted path specifically for patterns.
540
+ * @param {node} node representing the restricted path reference
541
+ * @param {Object} group contains an Ignore instance for paths, the customMessage to show on failure,
542
+ * and any restricted import names that have been specified in the config
543
+ * @param {Map<string,Object[]>} importNames Map of import names that are being imported
544
+ * @param {string} importSource the import source string
545
+ * @returns {void}
546
+ * @private
547
+ */
548
+ function reportPathForPatterns(node, group, importNames, importSource) {
549
+ // Skip if this is a type-only import and it's allowed
550
+ if (
551
+ group.allowTypeImports &&
552
+ (node.type === "ImportDeclaration" ||
553
+ node.type === "TSImportEqualsDeclaration") &&
554
+ isTypeOnlyImport(node)
555
+ ) {
556
+ return;
557
+ }
558
+
559
+ // Skip if this is a type-only export and it's allowed
560
+ if (
561
+ group.allowTypeImports &&
562
+ (node.type === "ExportNamedDeclaration" ||
563
+ node.type === "ExportAllDeclaration") &&
564
+ isTypeOnlyExport(node)
565
+ ) {
566
+ return;
567
+ }
568
+
569
+ const customMessage = group.customMessage;
570
+ const restrictedImportNames = group.importNames;
571
+ const restrictedImportNamePattern = group.importNamePattern
572
+ ? new RegExp(group.importNamePattern, "u")
573
+ : null;
574
+ const allowedImportNames = group.allowImportNames;
575
+ const allowedImportNamePattern = group.allowImportNamePattern
576
+ ? new RegExp(group.allowImportNamePattern, "u")
577
+ : null;
578
+
579
+ /**
580
+ * If we are not restricting to any specific import names and just the pattern itself,
581
+ * report the error and move on
582
+ */
583
+ if (
584
+ !restrictedImportNames &&
585
+ !allowedImportNames &&
586
+ !restrictedImportNamePattern &&
587
+ !allowedImportNamePattern
588
+ ) {
589
+ context.report({
590
+ node,
591
+ messageId: customMessage
592
+ ? "patternWithCustomMessage"
593
+ : "patterns",
594
+ data: {
595
+ importSource,
596
+ customMessage,
597
+ },
598
+ });
599
+ return;
600
+ }
601
+
602
+ importNames.forEach((specifiers, importName) => {
603
+ if (importName === "*") {
604
+ const [specifier] = specifiers;
605
+
606
+ if (restrictedImportNames) {
607
+ context.report({
608
+ node,
609
+ messageId: customMessage
610
+ ? "patternAndEverythingWithCustomMessage"
611
+ : "patternAndEverything",
612
+ loc: specifier.loc,
613
+ data: {
614
+ importSource,
615
+ importNames: restrictedImportNames,
616
+ customMessage,
617
+ },
618
+ });
619
+ } else if (allowedImportNames) {
620
+ context.report({
621
+ node,
622
+ messageId: customMessage
623
+ ? "everythingWithAllowImportNamesAndCustomMessage"
624
+ : "everythingWithAllowImportNames",
625
+ loc: specifier.loc,
626
+ data: {
627
+ importSource,
628
+ allowedImportNames,
629
+ customMessage,
630
+ },
631
+ });
632
+ } else if (allowedImportNamePattern) {
633
+ context.report({
634
+ node,
635
+ messageId: customMessage
636
+ ? "everythingWithAllowedImportNamePatternWithCustomMessage"
637
+ : "everythingWithAllowedImportNamePattern",
638
+ loc: specifier.loc,
639
+ data: {
640
+ importSource,
641
+ allowedImportNamePattern,
642
+ customMessage,
643
+ },
644
+ });
645
+ } else {
646
+ context.report({
647
+ node,
648
+ messageId: customMessage
649
+ ? "patternAndEverythingWithRegexImportNameAndCustomMessage"
650
+ : "patternAndEverythingWithRegexImportName",
651
+ loc: specifier.loc,
652
+ data: {
653
+ importSource,
654
+ importNames: restrictedImportNamePattern,
655
+ customMessage,
656
+ },
657
+ });
658
+ }
659
+
660
+ return;
661
+ }
662
+
663
+ if (
664
+ (restrictedImportNames &&
665
+ restrictedImportNames.includes(importName)) ||
666
+ (restrictedImportNamePattern &&
667
+ restrictedImportNamePattern.test(importName))
668
+ ) {
669
+ specifiers.forEach(specifier => {
670
+ // Skip if this is a type-only import specifier and type imports are allowed
671
+ if (
672
+ group.allowTypeImports &&
673
+ isTypeOnlySpecifier(specifier.specifier)
674
+ ) {
675
+ return;
676
+ }
677
+
678
+ context.report({
679
+ node,
680
+ messageId: customMessage
681
+ ? "patternAndImportNameWithCustomMessage"
682
+ : "patternAndImportName",
683
+ loc: specifier.loc,
684
+ data: {
685
+ importSource,
686
+ customMessage,
687
+ importName,
688
+ },
689
+ });
690
+ });
691
+ }
692
+
693
+ if (
694
+ allowedImportNames &&
695
+ !allowedImportNames.includes(importName)
696
+ ) {
697
+ specifiers.forEach(specifier => {
698
+ // Skip if this is a type-only import specifier and type imports are allowed
699
+ if (
700
+ group.allowTypeImports &&
701
+ isTypeOnlySpecifier(specifier.specifier)
702
+ ) {
703
+ return;
704
+ }
705
+
706
+ context.report({
707
+ node,
708
+ messageId: customMessage
709
+ ? "allowedImportNameWithCustomMessage"
710
+ : "allowedImportName",
711
+ loc: specifier.loc,
712
+ data: {
713
+ importSource,
714
+ customMessage,
715
+ importName,
716
+ allowedImportNames,
717
+ },
718
+ });
719
+ });
720
+ } else if (
721
+ allowedImportNamePattern &&
722
+ !allowedImportNamePattern.test(importName)
723
+ ) {
724
+ specifiers.forEach(specifier => {
725
+ // Skip if this is a type-only import specifier and type imports are allowed
726
+ if (
727
+ group.allowTypeImports &&
728
+ isTypeOnlySpecifier(specifier.specifier)
729
+ ) {
730
+ return;
731
+ }
732
+
733
+ context.report({
734
+ node,
735
+ messageId: customMessage
736
+ ? "allowedImportNamePatternWithCustomMessage"
737
+ : "allowedImportNamePattern",
738
+ loc: specifier.loc,
739
+ data: {
740
+ importSource,
741
+ customMessage,
742
+ importName,
743
+ allowedImportNamePattern,
744
+ },
745
+ });
746
+ });
747
+ }
748
+ });
749
+ }
750
+
751
+ /**
752
+ * Check if the given importSource is restricted by a pattern.
753
+ * @param {string} importSource path of the import
754
+ * @param {Object} group contains a Ignore instance for paths, and the customMessage to show if it fails
755
+ * @returns {boolean} whether the variable is a restricted pattern or not
756
+ * @private
757
+ */
758
+ function isRestrictedPattern(importSource, group) {
759
+ return group.regexMatcher
760
+ ? group.regexMatcher.test(importSource)
761
+ : group.matcher.ignores(importSource);
762
+ }
763
+
764
+ /**
765
+ * Checks a node to see if any problems should be reported.
766
+ * @param {ASTNode} node The node to check.
767
+ * @returns {void}
768
+ * @private
769
+ */
770
+ function checkNode(node) {
771
+ const importSource = node.source.value.trim();
772
+ const importNames = new Map();
773
+
774
+ if (node.type === "ExportAllDeclaration") {
775
+ const starToken = sourceCode.getFirstToken(node, 1);
776
+
777
+ importNames.set("*", [{ loc: starToken.loc }]);
778
+ } else if (node.specifiers) {
779
+ for (const specifier of node.specifiers) {
780
+ let name;
781
+ const specifierData = { loc: specifier.loc, specifier };
782
+
783
+ if (specifier.type === "ImportDefaultSpecifier") {
784
+ name = "default";
785
+ } else if (specifier.type === "ImportNamespaceSpecifier") {
786
+ name = "*";
787
+ } else if (specifier.imported) {
788
+ name = astUtils.getModuleExportName(specifier.imported);
789
+ } else if (specifier.local) {
790
+ name = astUtils.getModuleExportName(specifier.local);
791
+ }
792
+
793
+ if (typeof name === "string") {
794
+ if (importNames.has(name)) {
795
+ importNames.get(name).push(specifierData);
796
+ } else {
797
+ importNames.set(name, [specifierData]);
798
+ }
799
+ }
800
+ }
801
+ }
802
+
803
+ checkRestrictedPathAndReport(importSource, importNames, node);
804
+ restrictedPatternGroups.forEach(group => {
805
+ if (isRestrictedPattern(importSource, group)) {
806
+ reportPathForPatterns(
807
+ node,
808
+ group,
809
+ importNames,
810
+ importSource,
811
+ );
812
+ }
813
+ });
814
+ }
815
+
816
+ return {
817
+ ImportDeclaration: checkNode,
818
+ ExportNamedDeclaration(node) {
819
+ if (node.source) {
820
+ checkNode(node);
821
+ }
822
+ },
823
+ ExportAllDeclaration: checkNode,
824
+ // Add support for TypeScript import equals declarations
825
+ TSImportEqualsDeclaration(node) {
826
+ if (node.moduleReference.type === "TSExternalModuleReference") {
827
+ const importSource = node.moduleReference.expression.value;
828
+ const importNames = new Map();
829
+
830
+ // Use existing logic with the actual node
831
+ checkRestrictedPathAndReport(
832
+ importSource,
833
+ importNames,
834
+ node,
835
+ );
836
+ restrictedPatternGroups.forEach(group => {
837
+ if (isRestrictedPattern(importSource, group)) {
838
+ reportPathForPatterns(
839
+ node,
840
+ group,
841
+ importNames,
842
+ importSource,
843
+ );
844
+ }
845
+ });
846
+ }
847
+ },
848
+ };
849
+ },
850
+ };
server/node_modules/eslint/lib/rules/no-restricted-modules.js ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Restrict usage of specified node modules.
3
+ * @author Christian Schulz
4
+ * @deprecated in ESLint v7.0.0
5
+ */
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Rule Definition
16
+ //------------------------------------------------------------------------------
17
+
18
+ const ignore = require("ignore");
19
+
20
+ const arrayOfStrings = {
21
+ type: "array",
22
+ items: { type: "string" },
23
+ uniqueItems: true,
24
+ };
25
+
26
+ const arrayOfStringsOrObjects = {
27
+ type: "array",
28
+ items: {
29
+ anyOf: [
30
+ { type: "string" },
31
+ {
32
+ type: "object",
33
+ properties: {
34
+ name: { type: "string" },
35
+ message: {
36
+ type: "string",
37
+ minLength: 1,
38
+ },
39
+ },
40
+ additionalProperties: false,
41
+ required: ["name"],
42
+ },
43
+ ],
44
+ },
45
+ uniqueItems: true,
46
+ };
47
+
48
+ /** @type {import('../types').Rule.RuleModule} */
49
+ module.exports = {
50
+ meta: {
51
+ deprecated: {
52
+ message: "Node.js rules were moved out of ESLint core.",
53
+ url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
54
+ deprecatedSince: "7.0.0",
55
+ availableUntil: "11.0.0",
56
+ replacedBy: [
57
+ {
58
+ message:
59
+ "eslint-plugin-n now maintains deprecated Node.js-related rules.",
60
+ plugin: {
61
+ name: "eslint-plugin-n",
62
+ url: "https://github.com/eslint-community/eslint-plugin-n",
63
+ },
64
+ rule: {
65
+ name: "no-restricted-require",
66
+ url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-restricted-require.md",
67
+ },
68
+ },
69
+ ],
70
+ },
71
+
72
+ type: "suggestion",
73
+
74
+ docs: {
75
+ description: "Disallow specified modules when loaded by `require`",
76
+ recommended: false,
77
+ url: "https://eslint.org/docs/latest/rules/no-restricted-modules",
78
+ },
79
+
80
+ schema: {
81
+ anyOf: [
82
+ arrayOfStringsOrObjects,
83
+ {
84
+ type: "array",
85
+ items: {
86
+ type: "object",
87
+ properties: {
88
+ paths: arrayOfStringsOrObjects,
89
+ patterns: arrayOfStrings,
90
+ },
91
+ additionalProperties: false,
92
+ },
93
+ additionalItems: false,
94
+ },
95
+ ],
96
+ },
97
+
98
+ messages: {
99
+ defaultMessage: "'{{name}}' module is restricted from being used.",
100
+ customMessage:
101
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
102
+ "'{{name}}' module is restricted from being used. {{customMessage}}",
103
+ patternMessage:
104
+ "'{{name}}' module is restricted from being used by a pattern.",
105
+ },
106
+ },
107
+
108
+ create(context) {
109
+ const options = Array.isArray(context.options) ? context.options : [];
110
+ const isPathAndPatternsObject =
111
+ typeof options[0] === "object" &&
112
+ (Object.hasOwn(options[0], "paths") ||
113
+ Object.hasOwn(options[0], "patterns"));
114
+
115
+ const restrictedPaths =
116
+ (isPathAndPatternsObject ? options[0].paths : context.options) ||
117
+ [];
118
+ const restrictedPatterns =
119
+ (isPathAndPatternsObject ? options[0].patterns : []) || [];
120
+
121
+ const restrictedPathMessages = restrictedPaths.reduce(
122
+ (memo, importName) => {
123
+ if (typeof importName === "string") {
124
+ memo[importName] = null;
125
+ } else {
126
+ memo[importName.name] = importName.message;
127
+ }
128
+ return memo;
129
+ },
130
+ {},
131
+ );
132
+
133
+ // if no imports are restricted we don't need to check
134
+ if (
135
+ Object.keys(restrictedPaths).length === 0 &&
136
+ restrictedPatterns.length === 0
137
+ ) {
138
+ return {};
139
+ }
140
+
141
+ // relative paths are supported for this rule
142
+ const ig = ignore({ allowRelativePaths: true }).add(restrictedPatterns);
143
+
144
+ /**
145
+ * Function to check if a node is a string literal.
146
+ * @param {ASTNode} node The node to check.
147
+ * @returns {boolean} If the node is a string literal.
148
+ */
149
+ function isStringLiteral(node) {
150
+ return (
151
+ node &&
152
+ node.type === "Literal" &&
153
+ typeof node.value === "string"
154
+ );
155
+ }
156
+
157
+ /**
158
+ * Function to check if a node is a require call.
159
+ * @param {ASTNode} node The node to check.
160
+ * @returns {boolean} If the node is a require call.
161
+ */
162
+ function isRequireCall(node) {
163
+ return (
164
+ node.callee.type === "Identifier" &&
165
+ node.callee.name === "require"
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Extract string from Literal or TemplateLiteral node
171
+ * @param {ASTNode} node The node to extract from
172
+ * @returns {string|null} Extracted string or null if node doesn't represent a string
173
+ */
174
+ function getFirstArgumentString(node) {
175
+ if (isStringLiteral(node)) {
176
+ return node.value.trim();
177
+ }
178
+
179
+ if (astUtils.isStaticTemplateLiteral(node)) {
180
+ return node.quasis[0].value.cooked.trim();
181
+ }
182
+
183
+ return null;
184
+ }
185
+
186
+ /**
187
+ * Report a restricted path.
188
+ * @param {node} node representing the restricted path reference
189
+ * @param {string} name restricted path
190
+ * @returns {void}
191
+ * @private
192
+ */
193
+ function reportPath(node, name) {
194
+ const customMessage = restrictedPathMessages[name];
195
+ const messageId = customMessage
196
+ ? "customMessage"
197
+ : "defaultMessage";
198
+
199
+ context.report({
200
+ node,
201
+ messageId,
202
+ data: {
203
+ name,
204
+ customMessage,
205
+ },
206
+ });
207
+ }
208
+
209
+ /**
210
+ * Check if the given name is a restricted path name
211
+ * @param {string} name name of a variable
212
+ * @returns {boolean} whether the variable is a restricted path or not
213
+ * @private
214
+ */
215
+ function isRestrictedPath(name) {
216
+ return Object.hasOwn(restrictedPathMessages, name);
217
+ }
218
+
219
+ return {
220
+ CallExpression(node) {
221
+ if (isRequireCall(node)) {
222
+ // node has arguments
223
+ if (node.arguments.length) {
224
+ const name = getFirstArgumentString(node.arguments[0]);
225
+
226
+ // if first argument is a string literal or a static string template literal
227
+ if (name) {
228
+ // check if argument value is in restricted modules array
229
+ if (isRestrictedPath(name)) {
230
+ reportPath(node, name);
231
+ }
232
+
233
+ if (
234
+ restrictedPatterns.length > 0 &&
235
+ ig.ignores(name)
236
+ ) {
237
+ context.report({
238
+ node,
239
+ messageId: "patternMessage",
240
+ data: { name },
241
+ });
242
+ }
243
+ }
244
+ }
245
+ }
246
+ },
247
+ };
248
+ },
249
+ };
server/node_modules/eslint/lib/rules/no-restricted-properties.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow certain object properties
3
+ * @author Will Klein & Eli White
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const astUtils = require("./utils/ast-utils");
9
+
10
+ //------------------------------------------------------------------------------
11
+ // Rule Definition
12
+ //------------------------------------------------------------------------------
13
+
14
+ /** @type {import('../types').Rule.RuleModule} */
15
+ module.exports = {
16
+ meta: {
17
+ type: "suggestion",
18
+
19
+ docs: {
20
+ description: "Disallow certain properties on certain objects",
21
+ recommended: false,
22
+ url: "https://eslint.org/docs/latest/rules/no-restricted-properties",
23
+ },
24
+
25
+ schema: {
26
+ type: "array",
27
+ items: {
28
+ type: "object",
29
+ properties: {
30
+ object: {
31
+ type: "string",
32
+ },
33
+ property: {
34
+ type: "string",
35
+ },
36
+ allowObjects: {
37
+ type: "array",
38
+ items: {
39
+ type: "string",
40
+ },
41
+ uniqueItems: true,
42
+ },
43
+ allowProperties: {
44
+ type: "array",
45
+ items: {
46
+ type: "string",
47
+ },
48
+ uniqueItems: true,
49
+ },
50
+ message: {
51
+ type: "string",
52
+ },
53
+ },
54
+ anyOf: [
55
+ {
56
+ required: ["object"],
57
+ },
58
+ {
59
+ required: ["property"],
60
+ },
61
+ ],
62
+ not: {
63
+ anyOf: [
64
+ { required: ["allowObjects", "object"] },
65
+ { required: ["allowProperties", "property"] },
66
+ ],
67
+ },
68
+ additionalProperties: false,
69
+ },
70
+ uniqueItems: true,
71
+ },
72
+
73
+ messages: {
74
+ restrictedObjectProperty:
75
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
76
+ "'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{message}}",
77
+ restrictedProperty:
78
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
79
+ "'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{message}}",
80
+ },
81
+ },
82
+
83
+ create(context) {
84
+ const restrictedCalls = context.options;
85
+
86
+ if (restrictedCalls.length === 0) {
87
+ return {};
88
+ }
89
+
90
+ const restrictedProperties = new Map();
91
+ const globallyRestrictedObjects = new Map();
92
+ const globallyRestrictedProperties = new Map();
93
+
94
+ restrictedCalls.forEach(option => {
95
+ const objectName = option.object;
96
+ const propertyName = option.property;
97
+
98
+ if (typeof objectName === "undefined") {
99
+ globallyRestrictedProperties.set(propertyName, {
100
+ allowObjects: option.allowObjects,
101
+ message: option.message,
102
+ });
103
+ } else if (typeof propertyName === "undefined") {
104
+ globallyRestrictedObjects.set(objectName, {
105
+ allowProperties: option.allowProperties,
106
+ message: option.message,
107
+ });
108
+ } else {
109
+ if (!restrictedProperties.has(objectName)) {
110
+ restrictedProperties.set(objectName, new Map());
111
+ }
112
+
113
+ restrictedProperties.get(objectName).set(propertyName, {
114
+ message: option.message,
115
+ });
116
+ }
117
+ });
118
+
119
+ /**
120
+ * Checks if a name is in the allowed list.
121
+ * @param {string} name The name to check
122
+ * @param {string[]} [allowedList] The list of allowed names
123
+ * @returns {boolean} True if the name is allowed, false otherwise
124
+ */
125
+ function isAllowed(name, allowedList) {
126
+ if (!allowedList) {
127
+ return false;
128
+ }
129
+
130
+ return allowedList.includes(name);
131
+ }
132
+
133
+ /**
134
+ * Checks to see whether a property access is restricted, and reports it if so.
135
+ * @param {ASTNode} node The node to report
136
+ * @param {string} objectName The name of the object
137
+ * @param {string} propertyName The name of the property
138
+ * @returns {undefined}
139
+ */
140
+ function checkPropertyAccess(node, objectName, propertyName) {
141
+ if (propertyName === null) {
142
+ return;
143
+ }
144
+ const matchedObject = restrictedProperties.get(objectName);
145
+ const matchedObjectProperty = matchedObject
146
+ ? matchedObject.get(propertyName)
147
+ : globallyRestrictedObjects.get(objectName);
148
+ const globalMatchedProperty =
149
+ globallyRestrictedProperties.get(propertyName);
150
+
151
+ if (
152
+ matchedObjectProperty &&
153
+ !isAllowed(propertyName, matchedObjectProperty.allowProperties)
154
+ ) {
155
+ const message = matchedObjectProperty.message
156
+ ? ` ${matchedObjectProperty.message}`
157
+ : "";
158
+ const allowedPropertiesMessage =
159
+ matchedObjectProperty.allowProperties
160
+ ? ` Only these properties are allowed: ${matchedObjectProperty.allowProperties.join(", ")}.`
161
+ : "";
162
+
163
+ context.report({
164
+ node,
165
+ messageId: "restrictedObjectProperty",
166
+ data: {
167
+ objectName,
168
+ propertyName,
169
+ message,
170
+ allowedPropertiesMessage,
171
+ },
172
+ });
173
+ } else if (
174
+ globalMatchedProperty &&
175
+ !isAllowed(objectName, globalMatchedProperty.allowObjects)
176
+ ) {
177
+ const message = globalMatchedProperty.message
178
+ ? ` ${globalMatchedProperty.message}`
179
+ : "";
180
+ const allowedObjectsMessage = globalMatchedProperty.allowObjects
181
+ ? ` Property '${propertyName}' is only allowed on these objects: ${globalMatchedProperty.allowObjects.join(", ")}.`
182
+ : "";
183
+
184
+ context.report({
185
+ node,
186
+ messageId: "restrictedProperty",
187
+ data: {
188
+ propertyName,
189
+ message,
190
+ allowedObjectsMessage,
191
+ },
192
+ });
193
+ }
194
+ }
195
+
196
+ return {
197
+ MemberExpression(node) {
198
+ checkPropertyAccess(
199
+ node,
200
+ node.object && node.object.name,
201
+ astUtils.getStaticPropertyName(node),
202
+ );
203
+ },
204
+ ObjectPattern(node) {
205
+ let objectName = null;
206
+
207
+ if (node.parent.type === "VariableDeclarator") {
208
+ if (
209
+ node.parent.init &&
210
+ node.parent.init.type === "Identifier"
211
+ ) {
212
+ objectName = node.parent.init.name;
213
+ }
214
+ } else if (
215
+ node.parent.type === "AssignmentExpression" ||
216
+ node.parent.type === "AssignmentPattern"
217
+ ) {
218
+ if (node.parent.right.type === "Identifier") {
219
+ objectName = node.parent.right.name;
220
+ }
221
+ }
222
+
223
+ node.properties.forEach(property => {
224
+ checkPropertyAccess(
225
+ node,
226
+ objectName,
227
+ astUtils.getStaticPropertyName(property),
228
+ );
229
+ });
230
+ },
231
+ };
232
+ },
233
+ };
server/node_modules/eslint/lib/rules/no-restricted-syntax.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag use of certain node types
3
+ * @author Burak Yigit Kaya
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Rule Definition
9
+ //------------------------------------------------------------------------------
10
+
11
+ /** @type {import('../types').Rule.RuleModule} */
12
+ module.exports = {
13
+ meta: {
14
+ type: "suggestion",
15
+
16
+ docs: {
17
+ description: "Disallow specified syntax",
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/latest/rules/no-restricted-syntax",
20
+ },
21
+
22
+ schema: {
23
+ type: "array",
24
+ items: {
25
+ oneOf: [
26
+ {
27
+ type: "string",
28
+ },
29
+ {
30
+ type: "object",
31
+ properties: {
32
+ selector: { type: "string" },
33
+ message: { type: "string" },
34
+ },
35
+ required: ["selector"],
36
+ additionalProperties: false,
37
+ },
38
+ ],
39
+ },
40
+ uniqueItems: true,
41
+ minItems: 0,
42
+ },
43
+
44
+ messages: {
45
+ // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
46
+ restrictedSyntax: "{{message}}",
47
+ },
48
+ },
49
+
50
+ create(context) {
51
+ return context.options.reduce((result, selectorOrObject) => {
52
+ const isStringFormat = typeof selectorOrObject === "string";
53
+ const hasCustomMessage =
54
+ !isStringFormat && Boolean(selectorOrObject.message);
55
+
56
+ const selector = isStringFormat
57
+ ? selectorOrObject
58
+ : selectorOrObject.selector;
59
+ const message = hasCustomMessage
60
+ ? selectorOrObject.message
61
+ : `Using '${selector}' is not allowed.`;
62
+
63
+ return Object.assign(result, {
64
+ [selector](node) {
65
+ context.report({
66
+ node,
67
+ messageId: "restrictedSyntax",
68
+ data: { message },
69
+ });
70
+ },
71
+ });
72
+ }, {});
73
+ },
74
+ };
server/node_modules/eslint/lib/rules/no-return-assign.js ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to flag when return statement contains assignment
3
+ * @author Ilya Volodin
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Helpers
15
+ //------------------------------------------------------------------------------
16
+
17
+ const SENTINEL_TYPE =
18
+ /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u;
19
+
20
+ //------------------------------------------------------------------------------
21
+ // Rule Definition
22
+ //------------------------------------------------------------------------------
23
+
24
+ /** @type {import('../types').Rule.RuleModule} */
25
+ module.exports = {
26
+ meta: {
27
+ type: "suggestion",
28
+
29
+ defaultOptions: ["except-parens"],
30
+
31
+ docs: {
32
+ description: "Disallow assignment operators in `return` statements",
33
+ recommended: false,
34
+ url: "https://eslint.org/docs/latest/rules/no-return-assign",
35
+ },
36
+
37
+ schema: [
38
+ {
39
+ enum: ["except-parens", "always"],
40
+ },
41
+ ],
42
+
43
+ messages: {
44
+ returnAssignment: "Return statement should not contain assignment.",
45
+ arrowAssignment: "Arrow function should not return assignment.",
46
+ },
47
+ },
48
+
49
+ create(context) {
50
+ const always = context.options[0] !== "except-parens";
51
+ const sourceCode = context.sourceCode;
52
+
53
+ return {
54
+ AssignmentExpression(node) {
55
+ if (!always && astUtils.isParenthesised(sourceCode, node)) {
56
+ return;
57
+ }
58
+
59
+ let currentChild = node;
60
+ let parent = currentChild.parent;
61
+
62
+ // Find ReturnStatement or ArrowFunctionExpression in ancestors.
63
+ while (parent && !SENTINEL_TYPE.test(parent.type)) {
64
+ currentChild = parent;
65
+ parent = parent.parent;
66
+ }
67
+
68
+ // Reports.
69
+ if (parent && parent.type === "ReturnStatement") {
70
+ context.report({
71
+ node: parent,
72
+ messageId: "returnAssignment",
73
+ });
74
+ } else if (
75
+ parent &&
76
+ parent.type === "ArrowFunctionExpression" &&
77
+ parent.body === currentChild
78
+ ) {
79
+ context.report({
80
+ node: parent,
81
+ messageId: "arrowAssignment",
82
+ });
83
+ }
84
+ },
85
+ };
86
+ },
87
+ };
server/node_modules/eslint/lib/rules/no-return-await.js ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Disallows unnecessary `return await`
3
+ * @author Jordan Harband
4
+ * @deprecated in ESLint v8.46.0
5
+ */
6
+ "use strict";
7
+
8
+ const astUtils = require("./utils/ast-utils");
9
+
10
+ //------------------------------------------------------------------------------
11
+ // Rule Definition
12
+ //------------------------------------------------------------------------------
13
+
14
+ /** @type {import('../types').Rule.RuleModule} */
15
+ module.exports = {
16
+ meta: {
17
+ hasSuggestions: true,
18
+ type: "suggestion",
19
+
20
+ docs: {
21
+ description: "Disallow unnecessary `return await`",
22
+
23
+ recommended: false,
24
+
25
+ url: "https://eslint.org/docs/latest/rules/no-return-await",
26
+ },
27
+
28
+ fixable: null,
29
+
30
+ deprecated: {
31
+ message:
32
+ "The original assumption of the rule no longer holds true because of engine optimization.",
33
+ deprecatedSince: "8.46.0",
34
+ availableUntil: null,
35
+ replacedBy: [],
36
+ },
37
+
38
+ schema: [],
39
+
40
+ messages: {
41
+ removeAwait: "Remove redundant `await`.",
42
+ redundantUseOfAwait: "Redundant use of `await` on a return value.",
43
+ },
44
+ },
45
+
46
+ create(context) {
47
+ /**
48
+ * Reports a found unnecessary `await` expression.
49
+ * @param {ASTNode} node The node representing the `await` expression to report
50
+ * @returns {void}
51
+ */
52
+ function reportUnnecessaryAwait(node) {
53
+ context.report({
54
+ node: context.sourceCode.getFirstToken(node),
55
+ loc: node.loc,
56
+ messageId: "redundantUseOfAwait",
57
+ suggest: [
58
+ {
59
+ messageId: "removeAwait",
60
+ fix(fixer) {
61
+ const sourceCode = context.sourceCode;
62
+ const [awaitToken, tokenAfterAwait] =
63
+ sourceCode.getFirstTokens(node, 2);
64
+
65
+ const areAwaitAndAwaitedExpressionOnTheSameLine =
66
+ awaitToken.loc.start.line ===
67
+ tokenAfterAwait.loc.start.line;
68
+
69
+ if (!areAwaitAndAwaitedExpressionOnTheSameLine) {
70
+ return null;
71
+ }
72
+
73
+ const [startOfAwait, endOfAwait] = awaitToken.range;
74
+
75
+ const characterAfterAwait =
76
+ sourceCode.text[endOfAwait];
77
+ const trimLength =
78
+ characterAfterAwait === " " ? 1 : 0;
79
+
80
+ const range = [
81
+ startOfAwait,
82
+ endOfAwait + trimLength,
83
+ ];
84
+
85
+ return fixer.removeRange(range);
86
+ },
87
+ },
88
+ ],
89
+ });
90
+ }
91
+
92
+ /**
93
+ * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
94
+ * this function. For example, a statement in a `try` block will always have an error handler. A statement in
95
+ * a `catch` block will only have an error handler if there is also a `finally` block.
96
+ * @param {ASTNode} node A node representing a location where an could be thrown
97
+ * @returns {boolean} `true` if a thrown error will be caught/handled in this function
98
+ */
99
+ function hasErrorHandler(node) {
100
+ let ancestor = node;
101
+
102
+ while (
103
+ !astUtils.isFunction(ancestor) &&
104
+ ancestor.type !== "Program"
105
+ ) {
106
+ if (
107
+ ancestor.parent.type === "TryStatement" &&
108
+ (ancestor === ancestor.parent.block ||
109
+ (ancestor === ancestor.parent.handler &&
110
+ ancestor.parent.finalizer))
111
+ ) {
112
+ return true;
113
+ }
114
+ ancestor = ancestor.parent;
115
+ }
116
+ return false;
117
+ }
118
+
119
+ /**
120
+ * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression,
121
+ * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position.
122
+ * @param {ASTNode} node A node representing the `await` expression to check
123
+ * @returns {boolean} The checking result
124
+ */
125
+ function isInTailCallPosition(node) {
126
+ if (node.parent.type === "ArrowFunctionExpression") {
127
+ return true;
128
+ }
129
+ if (node.parent.type === "ReturnStatement") {
130
+ return !hasErrorHandler(node.parent);
131
+ }
132
+ if (
133
+ node.parent.type === "ConditionalExpression" &&
134
+ (node === node.parent.consequent ||
135
+ node === node.parent.alternate)
136
+ ) {
137
+ return isInTailCallPosition(node.parent);
138
+ }
139
+ if (
140
+ node.parent.type === "LogicalExpression" &&
141
+ node === node.parent.right
142
+ ) {
143
+ return isInTailCallPosition(node.parent);
144
+ }
145
+ if (
146
+ node.parent.type === "SequenceExpression" &&
147
+ node === node.parent.expressions.at(-1)
148
+ ) {
149
+ return isInTailCallPosition(node.parent);
150
+ }
151
+ return false;
152
+ }
153
+
154
+ return {
155
+ AwaitExpression(node) {
156
+ if (isInTailCallPosition(node) && !hasErrorHandler(node)) {
157
+ reportUnnecessaryAwait(node);
158
+ }
159
+ },
160
+ };
161
+ },
162
+ };
server/node_modules/eslint/lib/rules/no-script-url.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Rule to disallow `javascript:` URLs
3
+ * @author Ilya Volodin
4
+ */
5
+ /* eslint no-script-url: 0 -- Code is checking to report such URLs */
6
+
7
+ "use strict";
8
+
9
+ const astUtils = require("./utils/ast-utils");
10
+
11
+ //------------------------------------------------------------------------------
12
+ // Rule Definition
13
+ //------------------------------------------------------------------------------
14
+
15
+ /** @type {import('../types').Rule.RuleModule} */
16
+ module.exports = {
17
+ meta: {
18
+ type: "suggestion",
19
+
20
+ docs: {
21
+ description: "Disallow `javascript:` URLs",
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/latest/rules/no-script-url",
24
+ },
25
+
26
+ schema: [],
27
+
28
+ messages: {
29
+ unexpectedScriptURL: "Script URL is a form of eval.",
30
+ },
31
+ },
32
+
33
+ create(context) {
34
+ /**
35
+ * Check whether a node's static value starts with `javascript:` or not.
36
+ * And report an error for unexpected script URL.
37
+ * @param {ASTNode} node node to check
38
+ * @returns {void}
39
+ */
40
+ function check(node) {
41
+ const value = astUtils.getStaticStringValue(node);
42
+
43
+ if (
44
+ typeof value === "string" &&
45
+ value.toLowerCase().indexOf("javascript:") === 0
46
+ ) {
47
+ context.report({ node, messageId: "unexpectedScriptURL" });
48
+ }
49
+ }
50
+ return {
51
+ Literal(node) {
52
+ if (node.value && typeof node.value === "string") {
53
+ check(node);
54
+ }
55
+ },
56
+ TemplateLiteral(node) {
57
+ if (
58
+ !(
59
+ node.parent &&
60
+ node.parent.type === "TaggedTemplateExpression"
61
+ )
62
+ ) {
63
+ check(node);
64
+ }
65
+ },
66
+ };
67
+ },
68
+ };