Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/README.md +3 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/bin/esbuild +3 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/package.json +20 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/README.md +37 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.d.mts +217 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.d.ts +217 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.js +2494 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.js.map +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.mjs +2453 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.mjs.map +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE +201 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/README.md +105 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +384 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +27 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/index.d.ts +16 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +12 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js +65 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.js +315 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json +74 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/package.json +89 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/LICENSE +21 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/README.md +177 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.d.ts +1163 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.js +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.js.map +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.mjs +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.mjs.map +0 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/package.json +91 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/createProjectService.d.ts +60 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/createProjectService.d.ts.map +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/createProjectService.js +137 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.d.ts +3 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.d.ts.map +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.js +15 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.d.ts +2 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.d.ts.map +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.js +17 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.d.ts +87 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/TypeVisitor.d.ts +32 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/Visitor.d.ts +14 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/VisitorBase.d.ts +22 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.d.ts +33 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.d.ts.map +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.js +35 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.d.ts +28 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.d.ts.map +1 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.js +26 -0
- novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/Variable.d.ts +17 -0
.gitattributes
CHANGED
|
@@ -3520,3 +3520,4 @@ novas/novacore-zephyr/claude-code-router/ui/node_modules/@rollup/rollup-linux-x6
|
|
| 3520 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 3521 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 3522 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@tailwindcss/oxide-linux-x64-musl/tailwindcss-oxide.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 3520 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 3521 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 3522 |
novas/novacore-zephyr/claude-code-router/ui/node_modules/@tailwindcss/oxide-linux-x64-musl/tailwindcss-oxide.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 3523 |
+
novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/bin/esbuild filter=lfs diff=lfs merge=lfs -text
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esbuild
|
| 2 |
+
|
| 3 |
+
This is the Linux 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/bin/esbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1804240da84ec9976ae33333f256ae9cf731a9d656dad8f83d2ba31098b50547
|
| 3 |
+
size 10297496
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@esbuild/linux-x64/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@esbuild/linux-x64",
|
| 3 |
+
"version": "0.25.8",
|
| 4 |
+
"description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.",
|
| 5 |
+
"repository": {
|
| 6 |
+
"type": "git",
|
| 7 |
+
"url": "git+https://github.com/evanw/esbuild.git"
|
| 8 |
+
},
|
| 9 |
+
"license": "MIT",
|
| 10 |
+
"preferUnplugged": true,
|
| 11 |
+
"engines": {
|
| 12 |
+
"node": ">=18"
|
| 13 |
+
},
|
| 14 |
+
"os": [
|
| 15 |
+
"linux"
|
| 16 |
+
],
|
| 17 |
+
"cpu": [
|
| 18 |
+
"x64"
|
| 19 |
+
]
|
| 20 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Toru Nagashima
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eslint-community/eslint-utils
|
| 2 |
+
|
| 3 |
+
[](https://www.npmjs.com/package/@eslint-community/eslint-utils)
|
| 4 |
+
[](http://www.npmtrends.com/@eslint-community/eslint-utils)
|
| 5 |
+
[](https://github.com/eslint-community/eslint-utils/actions)
|
| 6 |
+
[](https://codecov.io/gh/eslint-community/eslint-utils)
|
| 7 |
+
|
| 8 |
+
## 🏁 Goal
|
| 9 |
+
|
| 10 |
+
This package provides utility functions and classes for make ESLint custom rules.
|
| 11 |
+
|
| 12 |
+
For examples:
|
| 13 |
+
|
| 14 |
+
- [`getStaticValue`](https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue) evaluates static value on AST.
|
| 15 |
+
- [`ReferenceTracker`](https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring.
|
| 16 |
+
|
| 17 |
+
## 📖 Usage
|
| 18 |
+
|
| 19 |
+
See [documentation](https://eslint-community.github.io/eslint-utils).
|
| 20 |
+
|
| 21 |
+
## 📰 Changelog
|
| 22 |
+
|
| 23 |
+
See [releases](https://github.com/eslint-community/eslint-utils/releases).
|
| 24 |
+
|
| 25 |
+
## ❤️ Contributing
|
| 26 |
+
|
| 27 |
+
Welcome contributing!
|
| 28 |
+
|
| 29 |
+
Please use GitHub's Issues/PRs.
|
| 30 |
+
|
| 31 |
+
### Development Tools
|
| 32 |
+
|
| 33 |
+
- `npm run test-coverage` runs tests and measures coverage.
|
| 34 |
+
- `npm run clean` removes the coverage result of `npm run test-coverage` command.
|
| 35 |
+
- `npm run coverage` shows the coverage result of the last `npm run test-coverage` command.
|
| 36 |
+
- `npm run lint` runs ESLint.
|
| 37 |
+
- `npm run watch` runs tests on each file change.
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.d.mts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as eslint from 'eslint';
|
| 2 |
+
import { Rule, AST } from 'eslint';
|
| 3 |
+
import * as estree from 'estree';
|
| 4 |
+
|
| 5 |
+
declare const READ: unique symbol;
|
| 6 |
+
declare const CALL: unique symbol;
|
| 7 |
+
declare const CONSTRUCT: unique symbol;
|
| 8 |
+
declare const ESM: unique symbol;
|
| 9 |
+
declare class ReferenceTracker {
|
| 10 |
+
constructor(globalScope: Scope$2, options?: {
|
| 11 |
+
mode?: "legacy" | "strict" | undefined;
|
| 12 |
+
globalObjectNames?: string[] | undefined;
|
| 13 |
+
} | undefined);
|
| 14 |
+
private variableStack;
|
| 15 |
+
private globalScope;
|
| 16 |
+
private mode;
|
| 17 |
+
private globalObjectNames;
|
| 18 |
+
iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
|
| 19 |
+
iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
|
| 20 |
+
iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
|
| 21 |
+
iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
|
| 22 |
+
private _iterateVariableReferences;
|
| 23 |
+
private _iteratePropertyReferences;
|
| 24 |
+
private _iterateLhsReferences;
|
| 25 |
+
private _iterateImportReferences;
|
| 26 |
+
}
|
| 27 |
+
declare namespace ReferenceTracker {
|
| 28 |
+
export { READ };
|
| 29 |
+
export { CALL };
|
| 30 |
+
export { CONSTRUCT };
|
| 31 |
+
export { ESM };
|
| 32 |
+
}
|
| 33 |
+
type Scope$2 = eslint.Scope.Scope;
|
| 34 |
+
type Expression = estree.Expression;
|
| 35 |
+
type TraceMap$2<T> = TraceMap$1<T>;
|
| 36 |
+
type TrackedReferences$2<T> = TrackedReferences$1<T>;
|
| 37 |
+
|
| 38 |
+
type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
|
| 39 |
+
type StaticValueProvided$1 = {
|
| 40 |
+
optional?: undefined;
|
| 41 |
+
value: unknown;
|
| 42 |
+
};
|
| 43 |
+
type StaticValueOptional$1 = {
|
| 44 |
+
optional?: true;
|
| 45 |
+
value: undefined;
|
| 46 |
+
};
|
| 47 |
+
type ReferenceTrackerOptions$1 = {
|
| 48 |
+
globalObjectNames?: string[];
|
| 49 |
+
mode?: "legacy" | "strict";
|
| 50 |
+
};
|
| 51 |
+
type TraceMap$1<T = unknown> = {
|
| 52 |
+
[i: string]: TraceMapObject<T>;
|
| 53 |
+
};
|
| 54 |
+
type TraceMapObject<T> = {
|
| 55 |
+
[i: string]: TraceMapObject<T>;
|
| 56 |
+
[CALL]?: T;
|
| 57 |
+
[CONSTRUCT]?: T;
|
| 58 |
+
[READ]?: T;
|
| 59 |
+
[ESM]?: boolean;
|
| 60 |
+
};
|
| 61 |
+
type TrackedReferences$1<T> = {
|
| 62 |
+
info: T;
|
| 63 |
+
node: Rule.Node;
|
| 64 |
+
path: string[];
|
| 65 |
+
type: typeof CALL | typeof CONSTRUCT | typeof READ;
|
| 66 |
+
};
|
| 67 |
+
type HasSideEffectOptions$1 = {
|
| 68 |
+
considerGetters?: boolean;
|
| 69 |
+
considerImplicitTypeConversion?: boolean;
|
| 70 |
+
};
|
| 71 |
+
type PunctuatorToken<Value extends string> = AST.Token & {
|
| 72 |
+
type: "Punctuator";
|
| 73 |
+
value: Value;
|
| 74 |
+
};
|
| 75 |
+
type ArrowToken$1 = PunctuatorToken<"=>">;
|
| 76 |
+
type CommaToken$1 = PunctuatorToken<",">;
|
| 77 |
+
type SemicolonToken$1 = PunctuatorToken<";">;
|
| 78 |
+
type ColonToken$1 = PunctuatorToken<":">;
|
| 79 |
+
type OpeningParenToken$1 = PunctuatorToken<"(">;
|
| 80 |
+
type ClosingParenToken$1 = PunctuatorToken<")">;
|
| 81 |
+
type OpeningBracketToken$1 = PunctuatorToken<"[">;
|
| 82 |
+
type ClosingBracketToken$1 = PunctuatorToken<"]">;
|
| 83 |
+
type OpeningBraceToken$1 = PunctuatorToken<"{">;
|
| 84 |
+
type ClosingBraceToken$1 = PunctuatorToken<"}">;
|
| 85 |
+
|
| 86 |
+
declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
|
| 87 |
+
type Scope$1 = eslint.Scope.Scope;
|
| 88 |
+
type Variable = eslint.Scope.Variable;
|
| 89 |
+
type Identifier = estree.Identifier;
|
| 90 |
+
|
| 91 |
+
declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
|
| 92 |
+
type SourceCode$2 = eslint.SourceCode;
|
| 93 |
+
type FunctionNode$1 = estree.Function;
|
| 94 |
+
type SourceLocation = estree.SourceLocation;
|
| 95 |
+
|
| 96 |
+
declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
|
| 97 |
+
type FunctionNode = estree.Function;
|
| 98 |
+
|
| 99 |
+
declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
|
| 100 |
+
type Scope = eslint.Scope.Scope;
|
| 101 |
+
type Node$4 = estree.Node;
|
| 102 |
+
|
| 103 |
+
declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
|
| 104 |
+
type MemberExpression = estree.MemberExpression;
|
| 105 |
+
type MethodDefinition = estree.MethodDefinition;
|
| 106 |
+
type Property = estree.Property;
|
| 107 |
+
type PropertyDefinition = estree.PropertyDefinition;
|
| 108 |
+
|
| 109 |
+
declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
|
| 110 |
+
type StaticValue$1 = StaticValue$2;
|
| 111 |
+
type Node$3 = estree.Node;
|
| 112 |
+
|
| 113 |
+
declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
|
| 114 |
+
type Node$2 = estree.Node;
|
| 115 |
+
|
| 116 |
+
declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
|
| 117 |
+
type Node$1 = estree.Node;
|
| 118 |
+
type SourceCode$1 = eslint.SourceCode;
|
| 119 |
+
|
| 120 |
+
declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
|
| 121 |
+
declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
|
| 122 |
+
declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
|
| 123 |
+
declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
|
| 124 |
+
declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
|
| 125 |
+
declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
|
| 126 |
+
declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
|
| 127 |
+
declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
|
| 128 |
+
declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
|
| 129 |
+
declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
|
| 130 |
+
declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
|
| 131 |
+
declare function isNotArrowToken(arg0: CommentOrToken): boolean;
|
| 132 |
+
declare function isNotCommaToken(arg0: CommentOrToken): boolean;
|
| 133 |
+
declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
|
| 134 |
+
declare function isNotColonToken(arg0: CommentOrToken): boolean;
|
| 135 |
+
declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
|
| 136 |
+
declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
|
| 137 |
+
declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
|
| 138 |
+
declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
|
| 139 |
+
declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
|
| 140 |
+
declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
|
| 141 |
+
declare function isNotCommentToken(arg0: CommentOrToken): boolean;
|
| 142 |
+
type Token = eslint.AST.Token;
|
| 143 |
+
type Comment = estree.Comment;
|
| 144 |
+
type CommentOrToken = Comment | Token;
|
| 145 |
+
|
| 146 |
+
declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
|
| 147 |
+
type Node = estree.Node;
|
| 148 |
+
type SourceCode = eslint.SourceCode;
|
| 149 |
+
|
| 150 |
+
declare class PatternMatcher {
|
| 151 |
+
constructor(pattern: RegExp, options?: {
|
| 152 |
+
escaped?: boolean | undefined;
|
| 153 |
+
} | undefined);
|
| 154 |
+
execAll(str: string): IterableIterator<RegExpExecArray>;
|
| 155 |
+
test(str: string): boolean;
|
| 156 |
+
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
declare namespace _default {
|
| 160 |
+
export { CALL };
|
| 161 |
+
export { CONSTRUCT };
|
| 162 |
+
export { ESM };
|
| 163 |
+
export { findVariable };
|
| 164 |
+
export { getFunctionHeadLocation };
|
| 165 |
+
export { getFunctionNameWithKind };
|
| 166 |
+
export { getInnermostScope };
|
| 167 |
+
export { getPropertyName };
|
| 168 |
+
export { getStaticValue };
|
| 169 |
+
export { getStringIfConstant };
|
| 170 |
+
export { hasSideEffect };
|
| 171 |
+
export { isArrowToken };
|
| 172 |
+
export { isClosingBraceToken };
|
| 173 |
+
export { isClosingBracketToken };
|
| 174 |
+
export { isClosingParenToken };
|
| 175 |
+
export { isColonToken };
|
| 176 |
+
export { isCommaToken };
|
| 177 |
+
export { isCommentToken };
|
| 178 |
+
export { isNotArrowToken };
|
| 179 |
+
export { isNotClosingBraceToken };
|
| 180 |
+
export { isNotClosingBracketToken };
|
| 181 |
+
export { isNotClosingParenToken };
|
| 182 |
+
export { isNotColonToken };
|
| 183 |
+
export { isNotCommaToken };
|
| 184 |
+
export { isNotCommentToken };
|
| 185 |
+
export { isNotOpeningBraceToken };
|
| 186 |
+
export { isNotOpeningBracketToken };
|
| 187 |
+
export { isNotOpeningParenToken };
|
| 188 |
+
export { isNotSemicolonToken };
|
| 189 |
+
export { isOpeningBraceToken };
|
| 190 |
+
export { isOpeningBracketToken };
|
| 191 |
+
export { isOpeningParenToken };
|
| 192 |
+
export { isParenthesized };
|
| 193 |
+
export { isSemicolonToken };
|
| 194 |
+
export { PatternMatcher };
|
| 195 |
+
export { READ };
|
| 196 |
+
export { ReferenceTracker };
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
type StaticValue = StaticValue$2;
|
| 200 |
+
type StaticValueOptional = StaticValueOptional$1;
|
| 201 |
+
type StaticValueProvided = StaticValueProvided$1;
|
| 202 |
+
type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
|
| 203 |
+
type TraceMap<T> = TraceMap$1<T>;
|
| 204 |
+
type TrackedReferences<T> = TrackedReferences$1<T>;
|
| 205 |
+
type HasSideEffectOptions = HasSideEffectOptions$1;
|
| 206 |
+
type ArrowToken = ArrowToken$1;
|
| 207 |
+
type CommaToken = CommaToken$1;
|
| 208 |
+
type SemicolonToken = SemicolonToken$1;
|
| 209 |
+
type ColonToken = ColonToken$1;
|
| 210 |
+
type OpeningParenToken = OpeningParenToken$1;
|
| 211 |
+
type ClosingParenToken = ClosingParenToken$1;
|
| 212 |
+
type OpeningBracketToken = OpeningBracketToken$1;
|
| 213 |
+
type ClosingBracketToken = ClosingBracketToken$1;
|
| 214 |
+
type OpeningBraceToken = OpeningBraceToken$1;
|
| 215 |
+
type ClosingBraceToken = ClosingBraceToken$1;
|
| 216 |
+
|
| 217 |
+
export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as eslint from 'eslint';
|
| 2 |
+
import { Rule, AST } from 'eslint';
|
| 3 |
+
import * as estree from 'estree';
|
| 4 |
+
|
| 5 |
+
declare const READ: unique symbol;
|
| 6 |
+
declare const CALL: unique symbol;
|
| 7 |
+
declare const CONSTRUCT: unique symbol;
|
| 8 |
+
declare const ESM: unique symbol;
|
| 9 |
+
declare class ReferenceTracker {
|
| 10 |
+
constructor(globalScope: Scope$2, options?: {
|
| 11 |
+
mode?: "legacy" | "strict" | undefined;
|
| 12 |
+
globalObjectNames?: string[] | undefined;
|
| 13 |
+
} | undefined);
|
| 14 |
+
private variableStack;
|
| 15 |
+
private globalScope;
|
| 16 |
+
private mode;
|
| 17 |
+
private globalObjectNames;
|
| 18 |
+
iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
|
| 19 |
+
iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
|
| 20 |
+
iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
|
| 21 |
+
iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
|
| 22 |
+
private _iterateVariableReferences;
|
| 23 |
+
private _iteratePropertyReferences;
|
| 24 |
+
private _iterateLhsReferences;
|
| 25 |
+
private _iterateImportReferences;
|
| 26 |
+
}
|
| 27 |
+
declare namespace ReferenceTracker {
|
| 28 |
+
export { READ };
|
| 29 |
+
export { CALL };
|
| 30 |
+
export { CONSTRUCT };
|
| 31 |
+
export { ESM };
|
| 32 |
+
}
|
| 33 |
+
type Scope$2 = eslint.Scope.Scope;
|
| 34 |
+
type Expression = estree.Expression;
|
| 35 |
+
type TraceMap$2<T> = TraceMap$1<T>;
|
| 36 |
+
type TrackedReferences$2<T> = TrackedReferences$1<T>;
|
| 37 |
+
|
| 38 |
+
type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
|
| 39 |
+
type StaticValueProvided$1 = {
|
| 40 |
+
optional?: undefined;
|
| 41 |
+
value: unknown;
|
| 42 |
+
};
|
| 43 |
+
type StaticValueOptional$1 = {
|
| 44 |
+
optional?: true;
|
| 45 |
+
value: undefined;
|
| 46 |
+
};
|
| 47 |
+
type ReferenceTrackerOptions$1 = {
|
| 48 |
+
globalObjectNames?: string[];
|
| 49 |
+
mode?: "legacy" | "strict";
|
| 50 |
+
};
|
| 51 |
+
type TraceMap$1<T = unknown> = {
|
| 52 |
+
[i: string]: TraceMapObject<T>;
|
| 53 |
+
};
|
| 54 |
+
type TraceMapObject<T> = {
|
| 55 |
+
[i: string]: TraceMapObject<T>;
|
| 56 |
+
[CALL]?: T;
|
| 57 |
+
[CONSTRUCT]?: T;
|
| 58 |
+
[READ]?: T;
|
| 59 |
+
[ESM]?: boolean;
|
| 60 |
+
};
|
| 61 |
+
type TrackedReferences$1<T> = {
|
| 62 |
+
info: T;
|
| 63 |
+
node: Rule.Node;
|
| 64 |
+
path: string[];
|
| 65 |
+
type: typeof CALL | typeof CONSTRUCT | typeof READ;
|
| 66 |
+
};
|
| 67 |
+
type HasSideEffectOptions$1 = {
|
| 68 |
+
considerGetters?: boolean;
|
| 69 |
+
considerImplicitTypeConversion?: boolean;
|
| 70 |
+
};
|
| 71 |
+
type PunctuatorToken<Value extends string> = AST.Token & {
|
| 72 |
+
type: "Punctuator";
|
| 73 |
+
value: Value;
|
| 74 |
+
};
|
| 75 |
+
type ArrowToken$1 = PunctuatorToken<"=>">;
|
| 76 |
+
type CommaToken$1 = PunctuatorToken<",">;
|
| 77 |
+
type SemicolonToken$1 = PunctuatorToken<";">;
|
| 78 |
+
type ColonToken$1 = PunctuatorToken<":">;
|
| 79 |
+
type OpeningParenToken$1 = PunctuatorToken<"(">;
|
| 80 |
+
type ClosingParenToken$1 = PunctuatorToken<")">;
|
| 81 |
+
type OpeningBracketToken$1 = PunctuatorToken<"[">;
|
| 82 |
+
type ClosingBracketToken$1 = PunctuatorToken<"]">;
|
| 83 |
+
type OpeningBraceToken$1 = PunctuatorToken<"{">;
|
| 84 |
+
type ClosingBraceToken$1 = PunctuatorToken<"}">;
|
| 85 |
+
|
| 86 |
+
declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
|
| 87 |
+
type Scope$1 = eslint.Scope.Scope;
|
| 88 |
+
type Variable = eslint.Scope.Variable;
|
| 89 |
+
type Identifier = estree.Identifier;
|
| 90 |
+
|
| 91 |
+
declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
|
| 92 |
+
type SourceCode$2 = eslint.SourceCode;
|
| 93 |
+
type FunctionNode$1 = estree.Function;
|
| 94 |
+
type SourceLocation = estree.SourceLocation;
|
| 95 |
+
|
| 96 |
+
declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
|
| 97 |
+
type FunctionNode = estree.Function;
|
| 98 |
+
|
| 99 |
+
declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
|
| 100 |
+
type Scope = eslint.Scope.Scope;
|
| 101 |
+
type Node$4 = estree.Node;
|
| 102 |
+
|
| 103 |
+
declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
|
| 104 |
+
type MemberExpression = estree.MemberExpression;
|
| 105 |
+
type MethodDefinition = estree.MethodDefinition;
|
| 106 |
+
type Property = estree.Property;
|
| 107 |
+
type PropertyDefinition = estree.PropertyDefinition;
|
| 108 |
+
|
| 109 |
+
declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
|
| 110 |
+
type StaticValue$1 = StaticValue$2;
|
| 111 |
+
type Node$3 = estree.Node;
|
| 112 |
+
|
| 113 |
+
declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
|
| 114 |
+
type Node$2 = estree.Node;
|
| 115 |
+
|
| 116 |
+
declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
|
| 117 |
+
type Node$1 = estree.Node;
|
| 118 |
+
type SourceCode$1 = eslint.SourceCode;
|
| 119 |
+
|
| 120 |
+
declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
|
| 121 |
+
declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
|
| 122 |
+
declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
|
| 123 |
+
declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
|
| 124 |
+
declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
|
| 125 |
+
declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
|
| 126 |
+
declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
|
| 127 |
+
declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
|
| 128 |
+
declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
|
| 129 |
+
declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
|
| 130 |
+
declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
|
| 131 |
+
declare function isNotArrowToken(arg0: CommentOrToken): boolean;
|
| 132 |
+
declare function isNotCommaToken(arg0: CommentOrToken): boolean;
|
| 133 |
+
declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
|
| 134 |
+
declare function isNotColonToken(arg0: CommentOrToken): boolean;
|
| 135 |
+
declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
|
| 136 |
+
declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
|
| 137 |
+
declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
|
| 138 |
+
declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
|
| 139 |
+
declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
|
| 140 |
+
declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
|
| 141 |
+
declare function isNotCommentToken(arg0: CommentOrToken): boolean;
|
| 142 |
+
type Token = eslint.AST.Token;
|
| 143 |
+
type Comment = estree.Comment;
|
| 144 |
+
type CommentOrToken = Comment | Token;
|
| 145 |
+
|
| 146 |
+
declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
|
| 147 |
+
type Node = estree.Node;
|
| 148 |
+
type SourceCode = eslint.SourceCode;
|
| 149 |
+
|
| 150 |
+
declare class PatternMatcher {
|
| 151 |
+
constructor(pattern: RegExp, options?: {
|
| 152 |
+
escaped?: boolean | undefined;
|
| 153 |
+
} | undefined);
|
| 154 |
+
execAll(str: string): IterableIterator<RegExpExecArray>;
|
| 155 |
+
test(str: string): boolean;
|
| 156 |
+
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
declare namespace _default {
|
| 160 |
+
export { CALL };
|
| 161 |
+
export { CONSTRUCT };
|
| 162 |
+
export { ESM };
|
| 163 |
+
export { findVariable };
|
| 164 |
+
export { getFunctionHeadLocation };
|
| 165 |
+
export { getFunctionNameWithKind };
|
| 166 |
+
export { getInnermostScope };
|
| 167 |
+
export { getPropertyName };
|
| 168 |
+
export { getStaticValue };
|
| 169 |
+
export { getStringIfConstant };
|
| 170 |
+
export { hasSideEffect };
|
| 171 |
+
export { isArrowToken };
|
| 172 |
+
export { isClosingBraceToken };
|
| 173 |
+
export { isClosingBracketToken };
|
| 174 |
+
export { isClosingParenToken };
|
| 175 |
+
export { isColonToken };
|
| 176 |
+
export { isCommaToken };
|
| 177 |
+
export { isCommentToken };
|
| 178 |
+
export { isNotArrowToken };
|
| 179 |
+
export { isNotClosingBraceToken };
|
| 180 |
+
export { isNotClosingBracketToken };
|
| 181 |
+
export { isNotClosingParenToken };
|
| 182 |
+
export { isNotColonToken };
|
| 183 |
+
export { isNotCommaToken };
|
| 184 |
+
export { isNotCommentToken };
|
| 185 |
+
export { isNotOpeningBraceToken };
|
| 186 |
+
export { isNotOpeningBracketToken };
|
| 187 |
+
export { isNotOpeningParenToken };
|
| 188 |
+
export { isNotSemicolonToken };
|
| 189 |
+
export { isOpeningBraceToken };
|
| 190 |
+
export { isOpeningBracketToken };
|
| 191 |
+
export { isOpeningParenToken };
|
| 192 |
+
export { isParenthesized };
|
| 193 |
+
export { isSemicolonToken };
|
| 194 |
+
export { PatternMatcher };
|
| 195 |
+
export { READ };
|
| 196 |
+
export { ReferenceTracker };
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
type StaticValue = StaticValue$2;
|
| 200 |
+
type StaticValueOptional = StaticValueOptional$1;
|
| 201 |
+
type StaticValueProvided = StaticValueProvided$1;
|
| 202 |
+
type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
|
| 203 |
+
type TraceMap<T> = TraceMap$1<T>;
|
| 204 |
+
type TrackedReferences<T> = TrackedReferences$1<T>;
|
| 205 |
+
type HasSideEffectOptions = HasSideEffectOptions$1;
|
| 206 |
+
type ArrowToken = ArrowToken$1;
|
| 207 |
+
type CommaToken = CommaToken$1;
|
| 208 |
+
type SemicolonToken = SemicolonToken$1;
|
| 209 |
+
type ColonToken = ColonToken$1;
|
| 210 |
+
type OpeningParenToken = OpeningParenToken$1;
|
| 211 |
+
type ClosingParenToken = ClosingParenToken$1;
|
| 212 |
+
type OpeningBracketToken = OpeningBracketToken$1;
|
| 213 |
+
type ClosingBracketToken = ClosingBracketToken$1;
|
| 214 |
+
type OpeningBraceToken = OpeningBraceToken$1;
|
| 215 |
+
type ClosingBraceToken = ClosingBraceToken$1;
|
| 216 |
+
|
| 217 |
+
export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.js
ADDED
|
@@ -0,0 +1,2494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', { value: true });
|
| 4 |
+
|
| 5 |
+
var eslintVisitorKeys = require('eslint-visitor-keys');
|
| 6 |
+
|
| 7 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 8 |
+
/** @typedef {import("estree").Node} Node */
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Get the innermost scope which contains a given location.
|
| 12 |
+
* @param {Scope} initialScope The initial scope to search.
|
| 13 |
+
* @param {Node} node The location to search.
|
| 14 |
+
* @returns {Scope} The innermost scope.
|
| 15 |
+
*/
|
| 16 |
+
function getInnermostScope(initialScope, node) {
|
| 17 |
+
const location = /** @type {[number, number]} */ (node.range)[0];
|
| 18 |
+
|
| 19 |
+
let scope = initialScope;
|
| 20 |
+
let found = false;
|
| 21 |
+
do {
|
| 22 |
+
found = false;
|
| 23 |
+
for (const childScope of scope.childScopes) {
|
| 24 |
+
const range = /** @type {[number, number]} */ (
|
| 25 |
+
childScope.block.range
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
if (range[0] <= location && location < range[1]) {
|
| 29 |
+
scope = childScope;
|
| 30 |
+
found = true;
|
| 31 |
+
break
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
} while (found)
|
| 35 |
+
|
| 36 |
+
return scope
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 40 |
+
/** @typedef {import("eslint").Scope.Variable} Variable */
|
| 41 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Find the variable of a given name.
|
| 45 |
+
* @param {Scope} initialScope The scope to start finding.
|
| 46 |
+
* @param {string|Identifier} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
|
| 47 |
+
* @returns {Variable|null} The found variable or null.
|
| 48 |
+
*/
|
| 49 |
+
function findVariable(initialScope, nameOrNode) {
|
| 50 |
+
let name = "";
|
| 51 |
+
/** @type {Scope|null} */
|
| 52 |
+
let scope = initialScope;
|
| 53 |
+
|
| 54 |
+
if (typeof nameOrNode === "string") {
|
| 55 |
+
name = nameOrNode;
|
| 56 |
+
} else {
|
| 57 |
+
name = nameOrNode.name;
|
| 58 |
+
scope = getInnermostScope(scope, nameOrNode);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
while (scope != null) {
|
| 62 |
+
const variable = scope.set.get(name);
|
| 63 |
+
if (variable != null) {
|
| 64 |
+
return variable
|
| 65 |
+
}
|
| 66 |
+
scope = scope.upper;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
return null
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 73 |
+
/** @typedef {import("estree").Comment} Comment */
|
| 74 |
+
/** @typedef {import("./types.mjs").ArrowToken} ArrowToken */
|
| 75 |
+
/** @typedef {import("./types.mjs").CommaToken} CommaToken */
|
| 76 |
+
/** @typedef {import("./types.mjs").SemicolonToken} SemicolonToken */
|
| 77 |
+
/** @typedef {import("./types.mjs").ColonToken} ColonToken */
|
| 78 |
+
/** @typedef {import("./types.mjs").OpeningParenToken} OpeningParenToken */
|
| 79 |
+
/** @typedef {import("./types.mjs").ClosingParenToken} ClosingParenToken */
|
| 80 |
+
/** @typedef {import("./types.mjs").OpeningBracketToken} OpeningBracketToken */
|
| 81 |
+
/** @typedef {import("./types.mjs").ClosingBracketToken} ClosingBracketToken */
|
| 82 |
+
/** @typedef {import("./types.mjs").OpeningBraceToken} OpeningBraceToken */
|
| 83 |
+
/** @typedef {import("./types.mjs").ClosingBraceToken} ClosingBraceToken */
|
| 84 |
+
/**
|
| 85 |
+
* @template {string} Value
|
| 86 |
+
* @typedef {import("./types.mjs").PunctuatorToken<Value>} PunctuatorToken
|
| 87 |
+
*/
|
| 88 |
+
|
| 89 |
+
/** @typedef {Comment | Token} CommentOrToken */
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Creates the negate function of the given function.
|
| 93 |
+
* @param {function(CommentOrToken):boolean} f - The function to negate.
|
| 94 |
+
* @returns {function(CommentOrToken):boolean} Negated function.
|
| 95 |
+
*/
|
| 96 |
+
function negate(f) {
|
| 97 |
+
return (token) => !f(token)
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Checks if the given token is a PunctuatorToken with the given value
|
| 102 |
+
* @template {string} Value
|
| 103 |
+
* @param {CommentOrToken} token - The token to check.
|
| 104 |
+
* @param {Value} value - The value to check.
|
| 105 |
+
* @returns {token is PunctuatorToken<Value>} `true` if the token is a PunctuatorToken with the given value.
|
| 106 |
+
*/
|
| 107 |
+
function isPunctuatorTokenWithValue(token, value) {
|
| 108 |
+
return token.type === "Punctuator" && token.value === value
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* Checks if the given token is an arrow token or not.
|
| 113 |
+
* @param {CommentOrToken} token - The token to check.
|
| 114 |
+
* @returns {token is ArrowToken} `true` if the token is an arrow token.
|
| 115 |
+
*/
|
| 116 |
+
function isArrowToken(token) {
|
| 117 |
+
return isPunctuatorTokenWithValue(token, "=>")
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Checks if the given token is a comma token or not.
|
| 122 |
+
* @param {CommentOrToken} token - The token to check.
|
| 123 |
+
* @returns {token is CommaToken} `true` if the token is a comma token.
|
| 124 |
+
*/
|
| 125 |
+
function isCommaToken(token) {
|
| 126 |
+
return isPunctuatorTokenWithValue(token, ",")
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* Checks if the given token is a semicolon token or not.
|
| 131 |
+
* @param {CommentOrToken} token - The token to check.
|
| 132 |
+
* @returns {token is SemicolonToken} `true` if the token is a semicolon token.
|
| 133 |
+
*/
|
| 134 |
+
function isSemicolonToken(token) {
|
| 135 |
+
return isPunctuatorTokenWithValue(token, ";")
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Checks if the given token is a colon token or not.
|
| 140 |
+
* @param {CommentOrToken} token - The token to check.
|
| 141 |
+
* @returns {token is ColonToken} `true` if the token is a colon token.
|
| 142 |
+
*/
|
| 143 |
+
function isColonToken(token) {
|
| 144 |
+
return isPunctuatorTokenWithValue(token, ":")
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Checks if the given token is an opening parenthesis token or not.
|
| 149 |
+
* @param {CommentOrToken} token - The token to check.
|
| 150 |
+
* @returns {token is OpeningParenToken} `true` if the token is an opening parenthesis token.
|
| 151 |
+
*/
|
| 152 |
+
function isOpeningParenToken(token) {
|
| 153 |
+
return isPunctuatorTokenWithValue(token, "(")
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Checks if the given token is a closing parenthesis token or not.
|
| 158 |
+
* @param {CommentOrToken} token - The token to check.
|
| 159 |
+
* @returns {token is ClosingParenToken} `true` if the token is a closing parenthesis token.
|
| 160 |
+
*/
|
| 161 |
+
function isClosingParenToken(token) {
|
| 162 |
+
return isPunctuatorTokenWithValue(token, ")")
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Checks if the given token is an opening square bracket token or not.
|
| 167 |
+
* @param {CommentOrToken} token - The token to check.
|
| 168 |
+
* @returns {token is OpeningBracketToken} `true` if the token is an opening square bracket token.
|
| 169 |
+
*/
|
| 170 |
+
function isOpeningBracketToken(token) {
|
| 171 |
+
return isPunctuatorTokenWithValue(token, "[")
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* Checks if the given token is a closing square bracket token or not.
|
| 176 |
+
* @param {CommentOrToken} token - The token to check.
|
| 177 |
+
* @returns {token is ClosingBracketToken} `true` if the token is a closing square bracket token.
|
| 178 |
+
*/
|
| 179 |
+
function isClosingBracketToken(token) {
|
| 180 |
+
return isPunctuatorTokenWithValue(token, "]")
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* Checks if the given token is an opening brace token or not.
|
| 185 |
+
* @param {CommentOrToken} token - The token to check.
|
| 186 |
+
* @returns {token is OpeningBraceToken} `true` if the token is an opening brace token.
|
| 187 |
+
*/
|
| 188 |
+
function isOpeningBraceToken(token) {
|
| 189 |
+
return isPunctuatorTokenWithValue(token, "{")
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* Checks if the given token is a closing brace token or not.
|
| 194 |
+
* @param {CommentOrToken} token - The token to check.
|
| 195 |
+
* @returns {token is ClosingBraceToken} `true` if the token is a closing brace token.
|
| 196 |
+
*/
|
| 197 |
+
function isClosingBraceToken(token) {
|
| 198 |
+
return isPunctuatorTokenWithValue(token, "}")
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Checks if the given token is a comment token or not.
|
| 203 |
+
* @param {CommentOrToken} token - The token to check.
|
| 204 |
+
* @returns {token is Comment} `true` if the token is a comment token.
|
| 205 |
+
*/
|
| 206 |
+
function isCommentToken(token) {
|
| 207 |
+
return ["Block", "Line", "Shebang"].includes(token.type)
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
const isNotArrowToken = negate(isArrowToken);
|
| 211 |
+
const isNotCommaToken = negate(isCommaToken);
|
| 212 |
+
const isNotSemicolonToken = negate(isSemicolonToken);
|
| 213 |
+
const isNotColonToken = negate(isColonToken);
|
| 214 |
+
const isNotOpeningParenToken = negate(isOpeningParenToken);
|
| 215 |
+
const isNotClosingParenToken = negate(isClosingParenToken);
|
| 216 |
+
const isNotOpeningBracketToken = negate(isOpeningBracketToken);
|
| 217 |
+
const isNotClosingBracketToken = negate(isClosingBracketToken);
|
| 218 |
+
const isNotOpeningBraceToken = negate(isOpeningBraceToken);
|
| 219 |
+
const isNotClosingBraceToken = negate(isClosingBraceToken);
|
| 220 |
+
const isNotCommentToken = negate(isCommentToken);
|
| 221 |
+
|
| 222 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 223 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 224 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 225 |
+
/** @typedef {import("estree").Function} FunctionNode */
|
| 226 |
+
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
|
| 227 |
+
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
| 228 |
+
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
| 229 |
+
/** @typedef {import("estree").Position} Position */
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Get the `(` token of the given function node.
|
| 233 |
+
* @param {FunctionExpression | FunctionDeclaration} node - The function node to get.
|
| 234 |
+
* @param {SourceCode} sourceCode - The source code object to get tokens.
|
| 235 |
+
* @returns {Token} `(` token.
|
| 236 |
+
*/
|
| 237 |
+
function getOpeningParenOfParams(node, sourceCode) {
|
| 238 |
+
return node.id
|
| 239 |
+
? /** @type {Token} */ (
|
| 240 |
+
sourceCode.getTokenAfter(node.id, isOpeningParenToken)
|
| 241 |
+
)
|
| 242 |
+
: /** @type {Token} */ (
|
| 243 |
+
sourceCode.getFirstToken(node, isOpeningParenToken)
|
| 244 |
+
)
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* Get the location of the given function node for reporting.
|
| 249 |
+
* @param {FunctionNode} node - The function node to get.
|
| 250 |
+
* @param {SourceCode} sourceCode - The source code object to get tokens.
|
| 251 |
+
* @returns {SourceLocation|null} The location of the function node for reporting.
|
| 252 |
+
*/
|
| 253 |
+
function getFunctionHeadLocation(node, sourceCode) {
|
| 254 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 255 |
+
|
| 256 |
+
/** @type {Position|null} */
|
| 257 |
+
let start = null;
|
| 258 |
+
/** @type {Position|null} */
|
| 259 |
+
let end = null;
|
| 260 |
+
|
| 261 |
+
if (node.type === "ArrowFunctionExpression") {
|
| 262 |
+
const arrowToken = /** @type {Token} */ (
|
| 263 |
+
sourceCode.getTokenBefore(node.body, isArrowToken)
|
| 264 |
+
);
|
| 265 |
+
|
| 266 |
+
start = arrowToken.loc.start;
|
| 267 |
+
end = arrowToken.loc.end;
|
| 268 |
+
} else if (
|
| 269 |
+
parent.type === "Property" ||
|
| 270 |
+
parent.type === "MethodDefinition" ||
|
| 271 |
+
parent.type === "PropertyDefinition"
|
| 272 |
+
) {
|
| 273 |
+
start = /** @type {SourceLocation} */ (parent.loc).start;
|
| 274 |
+
end = getOpeningParenOfParams(node, sourceCode).loc.start;
|
| 275 |
+
} else {
|
| 276 |
+
start = /** @type {SourceLocation} */ (node.loc).start;
|
| 277 |
+
end = getOpeningParenOfParams(node, sourceCode).loc.start;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
return {
|
| 281 |
+
start: { ...start },
|
| 282 |
+
end: { ...end },
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* globals globalThis, global, self, window */
|
| 287 |
+
/** @typedef {import("./types.mjs").StaticValue} StaticValue */
|
| 288 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 289 |
+
/** @typedef {import("estree").Node} Node */
|
| 290 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
|
| 291 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.AST_NODE_TYPES} TSESTreeNodeTypes */
|
| 292 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.MemberExpression} MemberExpression */
|
| 293 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Property} Property */
|
| 294 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.RegExpLiteral} RegExpLiteral */
|
| 295 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.BigIntLiteral} BigIntLiteral */
|
| 296 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Literal} Literal */
|
| 297 |
+
|
| 298 |
+
const globalObject =
|
| 299 |
+
typeof globalThis !== "undefined"
|
| 300 |
+
? globalThis
|
| 301 |
+
: // @ts-ignore
|
| 302 |
+
typeof self !== "undefined"
|
| 303 |
+
? // @ts-ignore
|
| 304 |
+
self
|
| 305 |
+
: // @ts-ignore
|
| 306 |
+
typeof window !== "undefined"
|
| 307 |
+
? // @ts-ignore
|
| 308 |
+
window
|
| 309 |
+
: typeof global !== "undefined"
|
| 310 |
+
? global
|
| 311 |
+
: {};
|
| 312 |
+
|
| 313 |
+
const builtinNames = Object.freeze(
|
| 314 |
+
new Set([
|
| 315 |
+
"Array",
|
| 316 |
+
"ArrayBuffer",
|
| 317 |
+
"BigInt",
|
| 318 |
+
"BigInt64Array",
|
| 319 |
+
"BigUint64Array",
|
| 320 |
+
"Boolean",
|
| 321 |
+
"DataView",
|
| 322 |
+
"Date",
|
| 323 |
+
"decodeURI",
|
| 324 |
+
"decodeURIComponent",
|
| 325 |
+
"encodeURI",
|
| 326 |
+
"encodeURIComponent",
|
| 327 |
+
"escape",
|
| 328 |
+
"Float32Array",
|
| 329 |
+
"Float64Array",
|
| 330 |
+
"Function",
|
| 331 |
+
"Infinity",
|
| 332 |
+
"Int16Array",
|
| 333 |
+
"Int32Array",
|
| 334 |
+
"Int8Array",
|
| 335 |
+
"isFinite",
|
| 336 |
+
"isNaN",
|
| 337 |
+
"isPrototypeOf",
|
| 338 |
+
"JSON",
|
| 339 |
+
"Map",
|
| 340 |
+
"Math",
|
| 341 |
+
"NaN",
|
| 342 |
+
"Number",
|
| 343 |
+
"Object",
|
| 344 |
+
"parseFloat",
|
| 345 |
+
"parseInt",
|
| 346 |
+
"Promise",
|
| 347 |
+
"Proxy",
|
| 348 |
+
"Reflect",
|
| 349 |
+
"RegExp",
|
| 350 |
+
"Set",
|
| 351 |
+
"String",
|
| 352 |
+
"Symbol",
|
| 353 |
+
"Uint16Array",
|
| 354 |
+
"Uint32Array",
|
| 355 |
+
"Uint8Array",
|
| 356 |
+
"Uint8ClampedArray",
|
| 357 |
+
"undefined",
|
| 358 |
+
"unescape",
|
| 359 |
+
"WeakMap",
|
| 360 |
+
"WeakSet",
|
| 361 |
+
]),
|
| 362 |
+
);
|
| 363 |
+
const callAllowed = new Set(
|
| 364 |
+
[
|
| 365 |
+
Array.isArray,
|
| 366 |
+
Array.of,
|
| 367 |
+
Array.prototype.at,
|
| 368 |
+
Array.prototype.concat,
|
| 369 |
+
Array.prototype.entries,
|
| 370 |
+
Array.prototype.every,
|
| 371 |
+
Array.prototype.filter,
|
| 372 |
+
Array.prototype.find,
|
| 373 |
+
Array.prototype.findIndex,
|
| 374 |
+
Array.prototype.flat,
|
| 375 |
+
Array.prototype.includes,
|
| 376 |
+
Array.prototype.indexOf,
|
| 377 |
+
Array.prototype.join,
|
| 378 |
+
Array.prototype.keys,
|
| 379 |
+
Array.prototype.lastIndexOf,
|
| 380 |
+
Array.prototype.slice,
|
| 381 |
+
Array.prototype.some,
|
| 382 |
+
Array.prototype.toString,
|
| 383 |
+
Array.prototype.values,
|
| 384 |
+
typeof BigInt === "function" ? BigInt : undefined,
|
| 385 |
+
Boolean,
|
| 386 |
+
Date,
|
| 387 |
+
Date.parse,
|
| 388 |
+
decodeURI,
|
| 389 |
+
decodeURIComponent,
|
| 390 |
+
encodeURI,
|
| 391 |
+
encodeURIComponent,
|
| 392 |
+
escape,
|
| 393 |
+
isFinite,
|
| 394 |
+
isNaN,
|
| 395 |
+
// @ts-ignore
|
| 396 |
+
isPrototypeOf,
|
| 397 |
+
Map,
|
| 398 |
+
Map.prototype.entries,
|
| 399 |
+
Map.prototype.get,
|
| 400 |
+
Map.prototype.has,
|
| 401 |
+
Map.prototype.keys,
|
| 402 |
+
Map.prototype.values,
|
| 403 |
+
.../** @type {(keyof typeof Math)[]} */ (
|
| 404 |
+
Object.getOwnPropertyNames(Math)
|
| 405 |
+
)
|
| 406 |
+
.filter((k) => k !== "random")
|
| 407 |
+
.map((k) => Math[k])
|
| 408 |
+
.filter((f) => typeof f === "function"),
|
| 409 |
+
Number,
|
| 410 |
+
Number.isFinite,
|
| 411 |
+
Number.isNaN,
|
| 412 |
+
Number.parseFloat,
|
| 413 |
+
Number.parseInt,
|
| 414 |
+
Number.prototype.toExponential,
|
| 415 |
+
Number.prototype.toFixed,
|
| 416 |
+
Number.prototype.toPrecision,
|
| 417 |
+
Number.prototype.toString,
|
| 418 |
+
Object,
|
| 419 |
+
Object.entries,
|
| 420 |
+
Object.is,
|
| 421 |
+
Object.isExtensible,
|
| 422 |
+
Object.isFrozen,
|
| 423 |
+
Object.isSealed,
|
| 424 |
+
Object.keys,
|
| 425 |
+
Object.values,
|
| 426 |
+
parseFloat,
|
| 427 |
+
parseInt,
|
| 428 |
+
RegExp,
|
| 429 |
+
Set,
|
| 430 |
+
Set.prototype.entries,
|
| 431 |
+
Set.prototype.has,
|
| 432 |
+
Set.prototype.keys,
|
| 433 |
+
Set.prototype.values,
|
| 434 |
+
String,
|
| 435 |
+
String.fromCharCode,
|
| 436 |
+
String.fromCodePoint,
|
| 437 |
+
String.raw,
|
| 438 |
+
String.prototype.at,
|
| 439 |
+
String.prototype.charAt,
|
| 440 |
+
String.prototype.charCodeAt,
|
| 441 |
+
String.prototype.codePointAt,
|
| 442 |
+
String.prototype.concat,
|
| 443 |
+
String.prototype.endsWith,
|
| 444 |
+
String.prototype.includes,
|
| 445 |
+
String.prototype.indexOf,
|
| 446 |
+
String.prototype.lastIndexOf,
|
| 447 |
+
String.prototype.normalize,
|
| 448 |
+
String.prototype.padEnd,
|
| 449 |
+
String.prototype.padStart,
|
| 450 |
+
String.prototype.slice,
|
| 451 |
+
String.prototype.startsWith,
|
| 452 |
+
String.prototype.substr,
|
| 453 |
+
String.prototype.substring,
|
| 454 |
+
String.prototype.toLowerCase,
|
| 455 |
+
String.prototype.toString,
|
| 456 |
+
String.prototype.toUpperCase,
|
| 457 |
+
String.prototype.trim,
|
| 458 |
+
String.prototype.trimEnd,
|
| 459 |
+
String.prototype.trimLeft,
|
| 460 |
+
String.prototype.trimRight,
|
| 461 |
+
String.prototype.trimStart,
|
| 462 |
+
Symbol.for,
|
| 463 |
+
Symbol.keyFor,
|
| 464 |
+
unescape,
|
| 465 |
+
].filter((f) => typeof f === "function"),
|
| 466 |
+
);
|
| 467 |
+
const callPassThrough = new Set([
|
| 468 |
+
Object.freeze,
|
| 469 |
+
Object.preventExtensions,
|
| 470 |
+
Object.seal,
|
| 471 |
+
]);
|
| 472 |
+
|
| 473 |
+
/** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
|
| 474 |
+
const getterAllowed = [
|
| 475 |
+
[Map, new Set(["size"])],
|
| 476 |
+
[
|
| 477 |
+
RegExp,
|
| 478 |
+
new Set([
|
| 479 |
+
"dotAll",
|
| 480 |
+
"flags",
|
| 481 |
+
"global",
|
| 482 |
+
"hasIndices",
|
| 483 |
+
"ignoreCase",
|
| 484 |
+
"multiline",
|
| 485 |
+
"source",
|
| 486 |
+
"sticky",
|
| 487 |
+
"unicode",
|
| 488 |
+
]),
|
| 489 |
+
],
|
| 490 |
+
[Set, new Set(["size"])],
|
| 491 |
+
];
|
| 492 |
+
|
| 493 |
+
/**
|
| 494 |
+
* Get the property descriptor.
|
| 495 |
+
* @param {object} object The object to get.
|
| 496 |
+
* @param {string|number|symbol} name The property name to get.
|
| 497 |
+
*/
|
| 498 |
+
function getPropertyDescriptor(object, name) {
|
| 499 |
+
let x = object;
|
| 500 |
+
while ((typeof x === "object" || typeof x === "function") && x !== null) {
|
| 501 |
+
const d = Object.getOwnPropertyDescriptor(x, name);
|
| 502 |
+
if (d) {
|
| 503 |
+
return d
|
| 504 |
+
}
|
| 505 |
+
x = Object.getPrototypeOf(x);
|
| 506 |
+
}
|
| 507 |
+
return null
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
/**
|
| 511 |
+
* Check if a property is getter or not.
|
| 512 |
+
* @param {object} object The object to check.
|
| 513 |
+
* @param {string|number|symbol} name The property name to check.
|
| 514 |
+
*/
|
| 515 |
+
function isGetter(object, name) {
|
| 516 |
+
const d = getPropertyDescriptor(object, name);
|
| 517 |
+
return d != null && d.get != null
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
/**
|
| 521 |
+
* Get the element values of a given node list.
|
| 522 |
+
* @param {(Node|TSESTreeNode|null)[]} nodeList The node list to get values.
|
| 523 |
+
* @param {Scope|undefined|null} initialScope The initial scope to find variables.
|
| 524 |
+
* @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
|
| 525 |
+
*/
|
| 526 |
+
function getElementValues(nodeList, initialScope) {
|
| 527 |
+
const valueList = [];
|
| 528 |
+
|
| 529 |
+
for (let i = 0; i < nodeList.length; ++i) {
|
| 530 |
+
const elementNode = nodeList[i];
|
| 531 |
+
|
| 532 |
+
if (elementNode == null) {
|
| 533 |
+
valueList.length = i + 1;
|
| 534 |
+
} else if (elementNode.type === "SpreadElement") {
|
| 535 |
+
const argument = getStaticValueR(elementNode.argument, initialScope);
|
| 536 |
+
if (argument == null) {
|
| 537 |
+
return null
|
| 538 |
+
}
|
| 539 |
+
valueList.push(.../** @type {Iterable<any>} */ (argument.value));
|
| 540 |
+
} else {
|
| 541 |
+
const element = getStaticValueR(elementNode, initialScope);
|
| 542 |
+
if (element == null) {
|
| 543 |
+
return null
|
| 544 |
+
}
|
| 545 |
+
valueList.push(element.value);
|
| 546 |
+
}
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
return valueList
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
* Returns whether the given variable is never written to after initialization.
|
| 554 |
+
* @param {import("eslint").Scope.Variable} variable
|
| 555 |
+
* @returns {boolean}
|
| 556 |
+
*/
|
| 557 |
+
function isEffectivelyConst(variable) {
|
| 558 |
+
const refs = variable.references;
|
| 559 |
+
|
| 560 |
+
const inits = refs.filter((r) => r.init).length;
|
| 561 |
+
const reads = refs.filter((r) => r.isReadOnly()).length;
|
| 562 |
+
if (inits === 1 && reads + inits === refs.length) {
|
| 563 |
+
// there is only one init and all other references only read
|
| 564 |
+
return true
|
| 565 |
+
}
|
| 566 |
+
return false
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
/**
|
| 570 |
+
* @template {TSESTreeNodeTypes} T
|
| 571 |
+
* @callback VisitorCallback
|
| 572 |
+
* @param {TSESTreeNode & { type: T }} node
|
| 573 |
+
* @param {Scope|undefined|null} initialScope
|
| 574 |
+
* @returns {StaticValue | null}
|
| 575 |
+
*/
|
| 576 |
+
/**
|
| 577 |
+
* @typedef { { [K in TSESTreeNodeTypes]?: VisitorCallback<K> } } Operations
|
| 578 |
+
*/
|
| 579 |
+
/**
|
| 580 |
+
* @type {Operations}
|
| 581 |
+
*/
|
| 582 |
+
const operations = Object.freeze({
|
| 583 |
+
ArrayExpression(node, initialScope) {
|
| 584 |
+
const elements = getElementValues(node.elements, initialScope);
|
| 585 |
+
return elements != null ? { value: elements } : null
|
| 586 |
+
},
|
| 587 |
+
|
| 588 |
+
AssignmentExpression(node, initialScope) {
|
| 589 |
+
if (node.operator === "=") {
|
| 590 |
+
return getStaticValueR(node.right, initialScope)
|
| 591 |
+
}
|
| 592 |
+
return null
|
| 593 |
+
},
|
| 594 |
+
|
| 595 |
+
//eslint-disable-next-line complexity
|
| 596 |
+
BinaryExpression(node, initialScope) {
|
| 597 |
+
if (node.operator === "in" || node.operator === "instanceof") {
|
| 598 |
+
// Not supported.
|
| 599 |
+
return null
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
const left = getStaticValueR(node.left, initialScope);
|
| 603 |
+
const right = getStaticValueR(node.right, initialScope);
|
| 604 |
+
if (left != null && right != null) {
|
| 605 |
+
switch (node.operator) {
|
| 606 |
+
case "==":
|
| 607 |
+
return { value: left.value == right.value } //eslint-disable-line eqeqeq
|
| 608 |
+
case "!=":
|
| 609 |
+
return { value: left.value != right.value } //eslint-disable-line eqeqeq
|
| 610 |
+
case "===":
|
| 611 |
+
return { value: left.value === right.value }
|
| 612 |
+
case "!==":
|
| 613 |
+
return { value: left.value !== right.value }
|
| 614 |
+
case "<":
|
| 615 |
+
return {
|
| 616 |
+
value:
|
| 617 |
+
/** @type {any} */ (left.value) <
|
| 618 |
+
/** @type {any} */ (right.value),
|
| 619 |
+
}
|
| 620 |
+
case "<=":
|
| 621 |
+
return {
|
| 622 |
+
value:
|
| 623 |
+
/** @type {any} */ (left.value) <=
|
| 624 |
+
/** @type {any} */ (right.value),
|
| 625 |
+
}
|
| 626 |
+
case ">":
|
| 627 |
+
return {
|
| 628 |
+
value:
|
| 629 |
+
/** @type {any} */ (left.value) >
|
| 630 |
+
/** @type {any} */ (right.value),
|
| 631 |
+
}
|
| 632 |
+
case ">=":
|
| 633 |
+
return {
|
| 634 |
+
value:
|
| 635 |
+
/** @type {any} */ (left.value) >=
|
| 636 |
+
/** @type {any} */ (right.value),
|
| 637 |
+
}
|
| 638 |
+
case "<<":
|
| 639 |
+
return {
|
| 640 |
+
value:
|
| 641 |
+
/** @type {any} */ (left.value) <<
|
| 642 |
+
/** @type {any} */ (right.value),
|
| 643 |
+
}
|
| 644 |
+
case ">>":
|
| 645 |
+
return {
|
| 646 |
+
value:
|
| 647 |
+
/** @type {any} */ (left.value) >>
|
| 648 |
+
/** @type {any} */ (right.value),
|
| 649 |
+
}
|
| 650 |
+
case ">>>":
|
| 651 |
+
return {
|
| 652 |
+
value:
|
| 653 |
+
/** @type {any} */ (left.value) >>>
|
| 654 |
+
/** @type {any} */ (right.value),
|
| 655 |
+
}
|
| 656 |
+
case "+":
|
| 657 |
+
return {
|
| 658 |
+
value:
|
| 659 |
+
/** @type {any} */ (left.value) +
|
| 660 |
+
/** @type {any} */ (right.value),
|
| 661 |
+
}
|
| 662 |
+
case "-":
|
| 663 |
+
return {
|
| 664 |
+
value:
|
| 665 |
+
/** @type {any} */ (left.value) -
|
| 666 |
+
/** @type {any} */ (right.value),
|
| 667 |
+
}
|
| 668 |
+
case "*":
|
| 669 |
+
return {
|
| 670 |
+
value:
|
| 671 |
+
/** @type {any} */ (left.value) *
|
| 672 |
+
/** @type {any} */ (right.value),
|
| 673 |
+
}
|
| 674 |
+
case "/":
|
| 675 |
+
return {
|
| 676 |
+
value:
|
| 677 |
+
/** @type {any} */ (left.value) /
|
| 678 |
+
/** @type {any} */ (right.value),
|
| 679 |
+
}
|
| 680 |
+
case "%":
|
| 681 |
+
return {
|
| 682 |
+
value:
|
| 683 |
+
/** @type {any} */ (left.value) %
|
| 684 |
+
/** @type {any} */ (right.value),
|
| 685 |
+
}
|
| 686 |
+
case "**":
|
| 687 |
+
return {
|
| 688 |
+
value:
|
| 689 |
+
/** @type {any} */ (left.value) **
|
| 690 |
+
/** @type {any} */ (right.value),
|
| 691 |
+
}
|
| 692 |
+
case "|":
|
| 693 |
+
return {
|
| 694 |
+
value:
|
| 695 |
+
/** @type {any} */ (left.value) |
|
| 696 |
+
/** @type {any} */ (right.value),
|
| 697 |
+
}
|
| 698 |
+
case "^":
|
| 699 |
+
return {
|
| 700 |
+
value:
|
| 701 |
+
/** @type {any} */ (left.value) ^
|
| 702 |
+
/** @type {any} */ (right.value),
|
| 703 |
+
}
|
| 704 |
+
case "&":
|
| 705 |
+
return {
|
| 706 |
+
value:
|
| 707 |
+
/** @type {any} */ (left.value) &
|
| 708 |
+
/** @type {any} */ (right.value),
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
// no default
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
return null
|
| 716 |
+
},
|
| 717 |
+
|
| 718 |
+
CallExpression(node, initialScope) {
|
| 719 |
+
const calleeNode = node.callee;
|
| 720 |
+
const args = getElementValues(node.arguments, initialScope);
|
| 721 |
+
|
| 722 |
+
if (args != null) {
|
| 723 |
+
if (calleeNode.type === "MemberExpression") {
|
| 724 |
+
if (calleeNode.property.type === "PrivateIdentifier") {
|
| 725 |
+
return null
|
| 726 |
+
}
|
| 727 |
+
const object = getStaticValueR(calleeNode.object, initialScope);
|
| 728 |
+
if (object != null) {
|
| 729 |
+
if (
|
| 730 |
+
object.value == null &&
|
| 731 |
+
(object.optional || node.optional)
|
| 732 |
+
) {
|
| 733 |
+
return { value: undefined, optional: true }
|
| 734 |
+
}
|
| 735 |
+
const property = getStaticPropertyNameValue(
|
| 736 |
+
calleeNode,
|
| 737 |
+
initialScope,
|
| 738 |
+
);
|
| 739 |
+
|
| 740 |
+
if (property != null) {
|
| 741 |
+
const receiver =
|
| 742 |
+
/** @type {Record<PropertyKey, (...args: any[]) => any>} */ (
|
| 743 |
+
object.value
|
| 744 |
+
);
|
| 745 |
+
const methodName = /** @type {PropertyKey} */ (
|
| 746 |
+
property.value
|
| 747 |
+
);
|
| 748 |
+
if (callAllowed.has(receiver[methodName])) {
|
| 749 |
+
return {
|
| 750 |
+
value: receiver[methodName](...args),
|
| 751 |
+
}
|
| 752 |
+
}
|
| 753 |
+
if (callPassThrough.has(receiver[methodName])) {
|
| 754 |
+
return { value: args[0] }
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
} else {
|
| 759 |
+
const callee = getStaticValueR(calleeNode, initialScope);
|
| 760 |
+
if (callee != null) {
|
| 761 |
+
if (callee.value == null && node.optional) {
|
| 762 |
+
return { value: undefined, optional: true }
|
| 763 |
+
}
|
| 764 |
+
const func = /** @type {(...args: any[]) => any} */ (
|
| 765 |
+
callee.value
|
| 766 |
+
);
|
| 767 |
+
if (callAllowed.has(func)) {
|
| 768 |
+
return { value: func(...args) }
|
| 769 |
+
}
|
| 770 |
+
if (callPassThrough.has(func)) {
|
| 771 |
+
return { value: args[0] }
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
}
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
return null
|
| 778 |
+
},
|
| 779 |
+
|
| 780 |
+
ConditionalExpression(node, initialScope) {
|
| 781 |
+
const test = getStaticValueR(node.test, initialScope);
|
| 782 |
+
if (test != null) {
|
| 783 |
+
return test.value
|
| 784 |
+
? getStaticValueR(node.consequent, initialScope)
|
| 785 |
+
: getStaticValueR(node.alternate, initialScope)
|
| 786 |
+
}
|
| 787 |
+
return null
|
| 788 |
+
},
|
| 789 |
+
|
| 790 |
+
ExpressionStatement(node, initialScope) {
|
| 791 |
+
return getStaticValueR(node.expression, initialScope)
|
| 792 |
+
},
|
| 793 |
+
|
| 794 |
+
Identifier(node, initialScope) {
|
| 795 |
+
if (initialScope != null) {
|
| 796 |
+
const variable = findVariable(initialScope, node);
|
| 797 |
+
|
| 798 |
+
// Built-in globals.
|
| 799 |
+
if (
|
| 800 |
+
variable != null &&
|
| 801 |
+
variable.defs.length === 0 &&
|
| 802 |
+
builtinNames.has(variable.name) &&
|
| 803 |
+
variable.name in globalObject
|
| 804 |
+
) {
|
| 805 |
+
return { value: globalObject[variable.name] }
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
// Constants.
|
| 809 |
+
if (variable != null && variable.defs.length === 1) {
|
| 810 |
+
const def = variable.defs[0];
|
| 811 |
+
if (
|
| 812 |
+
def.parent &&
|
| 813 |
+
def.type === "Variable" &&
|
| 814 |
+
(def.parent.kind === "const" ||
|
| 815 |
+
isEffectivelyConst(variable)) &&
|
| 816 |
+
// TODO(mysticatea): don't support destructuring here.
|
| 817 |
+
def.node.id.type === "Identifier"
|
| 818 |
+
) {
|
| 819 |
+
return getStaticValueR(def.node.init, initialScope)
|
| 820 |
+
}
|
| 821 |
+
}
|
| 822 |
+
}
|
| 823 |
+
return null
|
| 824 |
+
},
|
| 825 |
+
|
| 826 |
+
Literal(node) {
|
| 827 |
+
const literal =
|
| 828 |
+
/** @type {Partial<Literal> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
|
| 829 |
+
node
|
| 830 |
+
);
|
| 831 |
+
//istanbul ignore if : this is implementation-specific behavior.
|
| 832 |
+
if (
|
| 833 |
+
(literal.regex != null || literal.bigint != null) &&
|
| 834 |
+
literal.value == null
|
| 835 |
+
) {
|
| 836 |
+
// It was a RegExp/BigInt literal, but Node.js didn't support it.
|
| 837 |
+
return null
|
| 838 |
+
}
|
| 839 |
+
return { value: literal.value }
|
| 840 |
+
},
|
| 841 |
+
|
| 842 |
+
LogicalExpression(node, initialScope) {
|
| 843 |
+
const left = getStaticValueR(node.left, initialScope);
|
| 844 |
+
if (left != null) {
|
| 845 |
+
if (
|
| 846 |
+
(node.operator === "||" && Boolean(left.value) === true) ||
|
| 847 |
+
(node.operator === "&&" && Boolean(left.value) === false) ||
|
| 848 |
+
(node.operator === "??" && left.value != null)
|
| 849 |
+
) {
|
| 850 |
+
return left
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
const right = getStaticValueR(node.right, initialScope);
|
| 854 |
+
if (right != null) {
|
| 855 |
+
return right
|
| 856 |
+
}
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
return null
|
| 860 |
+
},
|
| 861 |
+
|
| 862 |
+
MemberExpression(node, initialScope) {
|
| 863 |
+
if (node.property.type === "PrivateIdentifier") {
|
| 864 |
+
return null
|
| 865 |
+
}
|
| 866 |
+
const object = getStaticValueR(node.object, initialScope);
|
| 867 |
+
if (object != null) {
|
| 868 |
+
if (object.value == null && (object.optional || node.optional)) {
|
| 869 |
+
return { value: undefined, optional: true }
|
| 870 |
+
}
|
| 871 |
+
const property = getStaticPropertyNameValue(node, initialScope);
|
| 872 |
+
|
| 873 |
+
if (property != null) {
|
| 874 |
+
if (
|
| 875 |
+
!isGetter(
|
| 876 |
+
/** @type {object} */ (object.value),
|
| 877 |
+
/** @type {PropertyKey} */ (property.value),
|
| 878 |
+
)
|
| 879 |
+
) {
|
| 880 |
+
return {
|
| 881 |
+
value: /** @type {Record<PropertyKey, unknown>} */ (
|
| 882 |
+
object.value
|
| 883 |
+
)[/** @type {PropertyKey} */ (property.value)],
|
| 884 |
+
}
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
for (const [classFn, allowed] of getterAllowed) {
|
| 888 |
+
if (
|
| 889 |
+
object.value instanceof classFn &&
|
| 890 |
+
allowed.has(/** @type {string} */ (property.value))
|
| 891 |
+
) {
|
| 892 |
+
return {
|
| 893 |
+
value: /** @type {Record<PropertyKey, unknown>} */ (
|
| 894 |
+
object.value
|
| 895 |
+
)[/** @type {PropertyKey} */ (property.value)],
|
| 896 |
+
}
|
| 897 |
+
}
|
| 898 |
+
}
|
| 899 |
+
}
|
| 900 |
+
}
|
| 901 |
+
return null
|
| 902 |
+
},
|
| 903 |
+
|
| 904 |
+
ChainExpression(node, initialScope) {
|
| 905 |
+
const expression = getStaticValueR(node.expression, initialScope);
|
| 906 |
+
if (expression != null) {
|
| 907 |
+
return { value: expression.value }
|
| 908 |
+
}
|
| 909 |
+
return null
|
| 910 |
+
},
|
| 911 |
+
|
| 912 |
+
NewExpression(node, initialScope) {
|
| 913 |
+
const callee = getStaticValueR(node.callee, initialScope);
|
| 914 |
+
const args = getElementValues(node.arguments, initialScope);
|
| 915 |
+
|
| 916 |
+
if (callee != null && args != null) {
|
| 917 |
+
const Func = /** @type {new (...args: any[]) => any} */ (
|
| 918 |
+
callee.value
|
| 919 |
+
);
|
| 920 |
+
if (callAllowed.has(Func)) {
|
| 921 |
+
return { value: new Func(...args) }
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
|
| 925 |
+
return null
|
| 926 |
+
},
|
| 927 |
+
|
| 928 |
+
ObjectExpression(node, initialScope) {
|
| 929 |
+
/** @type {Record<PropertyKey, unknown>} */
|
| 930 |
+
const object = {};
|
| 931 |
+
|
| 932 |
+
for (const propertyNode of node.properties) {
|
| 933 |
+
if (propertyNode.type === "Property") {
|
| 934 |
+
if (propertyNode.kind !== "init") {
|
| 935 |
+
return null
|
| 936 |
+
}
|
| 937 |
+
const key = getStaticPropertyNameValue(
|
| 938 |
+
propertyNode,
|
| 939 |
+
initialScope,
|
| 940 |
+
);
|
| 941 |
+
const value = getStaticValueR(propertyNode.value, initialScope);
|
| 942 |
+
if (key == null || value == null) {
|
| 943 |
+
return null
|
| 944 |
+
}
|
| 945 |
+
object[/** @type {PropertyKey} */ (key.value)] = value.value;
|
| 946 |
+
} else if (
|
| 947 |
+
propertyNode.type === "SpreadElement" ||
|
| 948 |
+
// @ts-expect-error -- Backward compatibility
|
| 949 |
+
propertyNode.type === "ExperimentalSpreadProperty"
|
| 950 |
+
) {
|
| 951 |
+
const argument = getStaticValueR(
|
| 952 |
+
propertyNode.argument,
|
| 953 |
+
initialScope,
|
| 954 |
+
);
|
| 955 |
+
if (argument == null) {
|
| 956 |
+
return null
|
| 957 |
+
}
|
| 958 |
+
Object.assign(object, argument.value);
|
| 959 |
+
} else {
|
| 960 |
+
return null
|
| 961 |
+
}
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
return { value: object }
|
| 965 |
+
},
|
| 966 |
+
|
| 967 |
+
SequenceExpression(node, initialScope) {
|
| 968 |
+
const last = node.expressions[node.expressions.length - 1];
|
| 969 |
+
return getStaticValueR(last, initialScope)
|
| 970 |
+
},
|
| 971 |
+
|
| 972 |
+
TaggedTemplateExpression(node, initialScope) {
|
| 973 |
+
const tag = getStaticValueR(node.tag, initialScope);
|
| 974 |
+
const expressions = getElementValues(
|
| 975 |
+
node.quasi.expressions,
|
| 976 |
+
initialScope,
|
| 977 |
+
);
|
| 978 |
+
|
| 979 |
+
if (tag != null && expressions != null) {
|
| 980 |
+
const func = /** @type {(...args: any[]) => any} */ (tag.value);
|
| 981 |
+
/** @type {any[] & { raw?: string[] }} */
|
| 982 |
+
const strings = node.quasi.quasis.map((q) => q.value.cooked);
|
| 983 |
+
strings.raw = node.quasi.quasis.map((q) => q.value.raw);
|
| 984 |
+
|
| 985 |
+
if (func === String.raw) {
|
| 986 |
+
return { value: func(strings, ...expressions) }
|
| 987 |
+
}
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
return null
|
| 991 |
+
},
|
| 992 |
+
|
| 993 |
+
TemplateLiteral(node, initialScope) {
|
| 994 |
+
const expressions = getElementValues(node.expressions, initialScope);
|
| 995 |
+
if (expressions != null) {
|
| 996 |
+
let value = node.quasis[0].value.cooked;
|
| 997 |
+
for (let i = 0; i < expressions.length; ++i) {
|
| 998 |
+
value += expressions[i];
|
| 999 |
+
value += /** @type {string} */ (node.quasis[i + 1].value.cooked);
|
| 1000 |
+
}
|
| 1001 |
+
return { value }
|
| 1002 |
+
}
|
| 1003 |
+
return null
|
| 1004 |
+
},
|
| 1005 |
+
|
| 1006 |
+
UnaryExpression(node, initialScope) {
|
| 1007 |
+
if (node.operator === "delete") {
|
| 1008 |
+
// Not supported.
|
| 1009 |
+
return null
|
| 1010 |
+
}
|
| 1011 |
+
if (node.operator === "void") {
|
| 1012 |
+
return { value: undefined }
|
| 1013 |
+
}
|
| 1014 |
+
|
| 1015 |
+
const arg = getStaticValueR(node.argument, initialScope);
|
| 1016 |
+
if (arg != null) {
|
| 1017 |
+
switch (node.operator) {
|
| 1018 |
+
case "-":
|
| 1019 |
+
return { value: -(/** @type {any} */ (arg.value)) }
|
| 1020 |
+
case "+":
|
| 1021 |
+
return { value: +(/** @type {any} */ (arg.value)) } //eslint-disable-line no-implicit-coercion
|
| 1022 |
+
case "!":
|
| 1023 |
+
return { value: !arg.value }
|
| 1024 |
+
case "~":
|
| 1025 |
+
return { value: ~(/** @type {any} */ (arg.value)) }
|
| 1026 |
+
case "typeof":
|
| 1027 |
+
return { value: typeof arg.value }
|
| 1028 |
+
|
| 1029 |
+
// no default
|
| 1030 |
+
}
|
| 1031 |
+
}
|
| 1032 |
+
|
| 1033 |
+
return null
|
| 1034 |
+
},
|
| 1035 |
+
TSAsExpression(node, initialScope) {
|
| 1036 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1037 |
+
},
|
| 1038 |
+
TSSatisfiesExpression(node, initialScope) {
|
| 1039 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1040 |
+
},
|
| 1041 |
+
TSTypeAssertion(node, initialScope) {
|
| 1042 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1043 |
+
},
|
| 1044 |
+
TSNonNullExpression(node, initialScope) {
|
| 1045 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1046 |
+
},
|
| 1047 |
+
TSInstantiationExpression(node, initialScope) {
|
| 1048 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1049 |
+
},
|
| 1050 |
+
});
|
| 1051 |
+
|
| 1052 |
+
/**
|
| 1053 |
+
* Get the value of a given node if it's a static value.
|
| 1054 |
+
* @param {Node|TSESTreeNode|null|undefined} node The node to get.
|
| 1055 |
+
* @param {Scope|undefined|null} initialScope The scope to start finding variable.
|
| 1056 |
+
* @returns {StaticValue|null} The static value of the node, or `null`.
|
| 1057 |
+
*/
|
| 1058 |
+
function getStaticValueR(node, initialScope) {
|
| 1059 |
+
if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
|
| 1060 |
+
return /** @type {VisitorCallback<any>} */ (operations[node.type])(
|
| 1061 |
+
/** @type {TSESTreeNode} */ (node),
|
| 1062 |
+
initialScope,
|
| 1063 |
+
)
|
| 1064 |
+
}
|
| 1065 |
+
return null
|
| 1066 |
+
}
|
| 1067 |
+
|
| 1068 |
+
/**
|
| 1069 |
+
* Get the static value of property name from a MemberExpression node or a Property node.
|
| 1070 |
+
* @param {MemberExpression|Property} node The node to get.
|
| 1071 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
|
| 1072 |
+
* @returns {StaticValue|null} The static value of the property name of the node, or `null`.
|
| 1073 |
+
*/
|
| 1074 |
+
function getStaticPropertyNameValue(node, initialScope) {
|
| 1075 |
+
const nameNode = node.type === "Property" ? node.key : node.property;
|
| 1076 |
+
|
| 1077 |
+
if (node.computed) {
|
| 1078 |
+
return getStaticValueR(nameNode, initialScope)
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
if (nameNode.type === "Identifier") {
|
| 1082 |
+
return { value: nameNode.name }
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
if (nameNode.type === "Literal") {
|
| 1086 |
+
if (/** @type {Partial<BigIntLiteral>} */ (nameNode).bigint) {
|
| 1087 |
+
return { value: /** @type {BigIntLiteral} */ (nameNode).bigint }
|
| 1088 |
+
}
|
| 1089 |
+
return { value: String(nameNode.value) }
|
| 1090 |
+
}
|
| 1091 |
+
|
| 1092 |
+
return null
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
/**
|
| 1096 |
+
* Get the value of a given node if it's a static value.
|
| 1097 |
+
* @param {Node} node The node to get.
|
| 1098 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
|
| 1099 |
+
* @returns {StaticValue | null} The static value of the node, or `null`.
|
| 1100 |
+
*/
|
| 1101 |
+
function getStaticValue(node, initialScope = null) {
|
| 1102 |
+
try {
|
| 1103 |
+
return getStaticValueR(node, initialScope)
|
| 1104 |
+
} catch (_error) {
|
| 1105 |
+
return null
|
| 1106 |
+
}
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1110 |
+
/** @typedef {import("estree").Node} Node */
|
| 1111 |
+
/** @typedef {import("estree").RegExpLiteral} RegExpLiteral */
|
| 1112 |
+
/** @typedef {import("estree").BigIntLiteral} BigIntLiteral */
|
| 1113 |
+
/** @typedef {import("estree").SimpleLiteral} SimpleLiteral */
|
| 1114 |
+
|
| 1115 |
+
/**
|
| 1116 |
+
* Get the value of a given node if it's a literal or a template literal.
|
| 1117 |
+
* @param {Node} node The node to get.
|
| 1118 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
|
| 1119 |
+
* @returns {string|null} The value of the node, or `null`.
|
| 1120 |
+
*/
|
| 1121 |
+
function getStringIfConstant(node, initialScope = null) {
|
| 1122 |
+
// Handle the literals that the platform doesn't support natively.
|
| 1123 |
+
if (node && node.type === "Literal" && node.value === null) {
|
| 1124 |
+
const literal =
|
| 1125 |
+
/** @type {Partial<SimpleLiteral> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
|
| 1126 |
+
node
|
| 1127 |
+
);
|
| 1128 |
+
if (literal.regex) {
|
| 1129 |
+
return `/${literal.regex.pattern}/${literal.regex.flags}`
|
| 1130 |
+
}
|
| 1131 |
+
if (literal.bigint) {
|
| 1132 |
+
return literal.bigint
|
| 1133 |
+
}
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
const evaluated = getStaticValue(node, initialScope);
|
| 1137 |
+
|
| 1138 |
+
if (evaluated) {
|
| 1139 |
+
// `String(Symbol.prototype)` throws error
|
| 1140 |
+
try {
|
| 1141 |
+
return String(evaluated.value)
|
| 1142 |
+
} catch {
|
| 1143 |
+
// No op
|
| 1144 |
+
}
|
| 1145 |
+
}
|
| 1146 |
+
|
| 1147 |
+
return null
|
| 1148 |
+
}
|
| 1149 |
+
|
| 1150 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1151 |
+
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
| 1152 |
+
/** @typedef {import("estree").MethodDefinition} MethodDefinition */
|
| 1153 |
+
/** @typedef {import("estree").Property} Property */
|
| 1154 |
+
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
|
| 1155 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1156 |
+
|
| 1157 |
+
/**
|
| 1158 |
+
* Get the property name from a MemberExpression node or a Property node.
|
| 1159 |
+
* @param {MemberExpression | MethodDefinition | Property | PropertyDefinition} node The node to get.
|
| 1160 |
+
* @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
|
| 1161 |
+
* @returns {string|null|undefined} The property name of the node.
|
| 1162 |
+
*/
|
| 1163 |
+
function getPropertyName(node, initialScope) {
|
| 1164 |
+
switch (node.type) {
|
| 1165 |
+
case "MemberExpression":
|
| 1166 |
+
if (node.computed) {
|
| 1167 |
+
return getStringIfConstant(node.property, initialScope)
|
| 1168 |
+
}
|
| 1169 |
+
if (node.property.type === "PrivateIdentifier") {
|
| 1170 |
+
return null
|
| 1171 |
+
}
|
| 1172 |
+
return /** @type {Partial<Identifier>} */ (node.property).name
|
| 1173 |
+
|
| 1174 |
+
case "Property":
|
| 1175 |
+
case "MethodDefinition":
|
| 1176 |
+
case "PropertyDefinition":
|
| 1177 |
+
if (node.computed) {
|
| 1178 |
+
return getStringIfConstant(node.key, initialScope)
|
| 1179 |
+
}
|
| 1180 |
+
if (node.key.type === "Literal") {
|
| 1181 |
+
return String(node.key.value)
|
| 1182 |
+
}
|
| 1183 |
+
if (node.key.type === "PrivateIdentifier") {
|
| 1184 |
+
return null
|
| 1185 |
+
}
|
| 1186 |
+
return /** @type {Partial<Identifier>} */ (node.key).name
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
return null
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1193 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1194 |
+
/** @typedef {import("estree").Function} FunctionNode */
|
| 1195 |
+
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
|
| 1196 |
+
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
| 1197 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1198 |
+
|
| 1199 |
+
/**
|
| 1200 |
+
* Get the name and kind of the given function node.
|
| 1201 |
+
* @param {FunctionNode} node - The function node to get.
|
| 1202 |
+
* @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
|
| 1203 |
+
* @returns {string} The name and kind of the function node.
|
| 1204 |
+
*/
|
| 1205 |
+
// eslint-disable-next-line complexity
|
| 1206 |
+
function getFunctionNameWithKind(node, sourceCode) {
|
| 1207 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 1208 |
+
const tokens = [];
|
| 1209 |
+
const isObjectMethod = parent.type === "Property" && parent.value === node;
|
| 1210 |
+
const isClassMethod =
|
| 1211 |
+
parent.type === "MethodDefinition" && parent.value === node;
|
| 1212 |
+
const isClassFieldMethod =
|
| 1213 |
+
parent.type === "PropertyDefinition" && parent.value === node;
|
| 1214 |
+
|
| 1215 |
+
// Modifiers.
|
| 1216 |
+
if (isClassMethod || isClassFieldMethod) {
|
| 1217 |
+
if (parent.static) {
|
| 1218 |
+
tokens.push("static");
|
| 1219 |
+
}
|
| 1220 |
+
if (parent.key.type === "PrivateIdentifier") {
|
| 1221 |
+
tokens.push("private");
|
| 1222 |
+
}
|
| 1223 |
+
}
|
| 1224 |
+
if (node.async) {
|
| 1225 |
+
tokens.push("async");
|
| 1226 |
+
}
|
| 1227 |
+
if (node.generator) {
|
| 1228 |
+
tokens.push("generator");
|
| 1229 |
+
}
|
| 1230 |
+
|
| 1231 |
+
// Kinds.
|
| 1232 |
+
if (isObjectMethod || isClassMethod) {
|
| 1233 |
+
if (parent.kind === "constructor") {
|
| 1234 |
+
return "constructor"
|
| 1235 |
+
}
|
| 1236 |
+
if (parent.kind === "get") {
|
| 1237 |
+
tokens.push("getter");
|
| 1238 |
+
} else if (parent.kind === "set") {
|
| 1239 |
+
tokens.push("setter");
|
| 1240 |
+
} else {
|
| 1241 |
+
tokens.push("method");
|
| 1242 |
+
}
|
| 1243 |
+
} else if (isClassFieldMethod) {
|
| 1244 |
+
tokens.push("method");
|
| 1245 |
+
} else {
|
| 1246 |
+
if (node.type === "ArrowFunctionExpression") {
|
| 1247 |
+
tokens.push("arrow");
|
| 1248 |
+
}
|
| 1249 |
+
tokens.push("function");
|
| 1250 |
+
}
|
| 1251 |
+
|
| 1252 |
+
// Names.
|
| 1253 |
+
if (isObjectMethod || isClassMethod || isClassFieldMethod) {
|
| 1254 |
+
if (parent.key.type === "PrivateIdentifier") {
|
| 1255 |
+
tokens.push(`#${parent.key.name}`);
|
| 1256 |
+
} else {
|
| 1257 |
+
const name = getPropertyName(parent);
|
| 1258 |
+
if (name) {
|
| 1259 |
+
tokens.push(`'${name}'`);
|
| 1260 |
+
} else if (sourceCode) {
|
| 1261 |
+
const keyText = sourceCode.getText(parent.key);
|
| 1262 |
+
if (!keyText.includes("\n")) {
|
| 1263 |
+
tokens.push(`[${keyText}]`);
|
| 1264 |
+
}
|
| 1265 |
+
}
|
| 1266 |
+
}
|
| 1267 |
+
} else if (hasId(node)) {
|
| 1268 |
+
tokens.push(`'${node.id.name}'`);
|
| 1269 |
+
} else if (
|
| 1270 |
+
parent.type === "VariableDeclarator" &&
|
| 1271 |
+
parent.id &&
|
| 1272 |
+
parent.id.type === "Identifier"
|
| 1273 |
+
) {
|
| 1274 |
+
tokens.push(`'${parent.id.name}'`);
|
| 1275 |
+
} else if (
|
| 1276 |
+
(parent.type === "AssignmentExpression" ||
|
| 1277 |
+
parent.type === "AssignmentPattern") &&
|
| 1278 |
+
parent.left &&
|
| 1279 |
+
parent.left.type === "Identifier"
|
| 1280 |
+
) {
|
| 1281 |
+
tokens.push(`'${parent.left.name}'`);
|
| 1282 |
+
} else if (
|
| 1283 |
+
parent.type === "ExportDefaultDeclaration" &&
|
| 1284 |
+
parent.declaration === node
|
| 1285 |
+
) {
|
| 1286 |
+
tokens.push("'default'");
|
| 1287 |
+
}
|
| 1288 |
+
|
| 1289 |
+
return tokens.join(" ")
|
| 1290 |
+
}
|
| 1291 |
+
|
| 1292 |
+
/**
|
| 1293 |
+
* @param {FunctionNode} node
|
| 1294 |
+
* @returns {node is FunctionDeclaration | FunctionExpression & { id: Identifier }}
|
| 1295 |
+
*/
|
| 1296 |
+
function hasId(node) {
|
| 1297 |
+
return Boolean(
|
| 1298 |
+
/** @type {Partial<FunctionDeclaration | FunctionExpression>} */ (node)
|
| 1299 |
+
.id,
|
| 1300 |
+
)
|
| 1301 |
+
}
|
| 1302 |
+
|
| 1303 |
+
/** @typedef {import("estree").Node} Node */
|
| 1304 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1305 |
+
/** @typedef {import("./types.mjs").HasSideEffectOptions} HasSideEffectOptions */
|
| 1306 |
+
/** @typedef {import("estree").BinaryExpression} BinaryExpression */
|
| 1307 |
+
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
| 1308 |
+
/** @typedef {import("estree").MethodDefinition} MethodDefinition */
|
| 1309 |
+
/** @typedef {import("estree").Property} Property */
|
| 1310 |
+
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
|
| 1311 |
+
/** @typedef {import("estree").UnaryExpression} UnaryExpression */
|
| 1312 |
+
|
| 1313 |
+
const typeConversionBinaryOps = Object.freeze(
|
| 1314 |
+
new Set([
|
| 1315 |
+
"==",
|
| 1316 |
+
"!=",
|
| 1317 |
+
"<",
|
| 1318 |
+
"<=",
|
| 1319 |
+
">",
|
| 1320 |
+
">=",
|
| 1321 |
+
"<<",
|
| 1322 |
+
">>",
|
| 1323 |
+
">>>",
|
| 1324 |
+
"+",
|
| 1325 |
+
"-",
|
| 1326 |
+
"*",
|
| 1327 |
+
"/",
|
| 1328 |
+
"%",
|
| 1329 |
+
"|",
|
| 1330 |
+
"^",
|
| 1331 |
+
"&",
|
| 1332 |
+
"in",
|
| 1333 |
+
]),
|
| 1334 |
+
);
|
| 1335 |
+
const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
|
| 1336 |
+
|
| 1337 |
+
/**
|
| 1338 |
+
* Check whether the given value is an ASTNode or not.
|
| 1339 |
+
* @param {any} x The value to check.
|
| 1340 |
+
* @returns {x is Node} `true` if the value is an ASTNode.
|
| 1341 |
+
*/
|
| 1342 |
+
function isNode(x) {
|
| 1343 |
+
return x !== null && typeof x === "object" && typeof x.type === "string"
|
| 1344 |
+
}
|
| 1345 |
+
|
| 1346 |
+
const visitor = Object.freeze(
|
| 1347 |
+
Object.assign(Object.create(null), {
|
| 1348 |
+
/**
|
| 1349 |
+
* @param {Node} node
|
| 1350 |
+
* @param {HasSideEffectOptions} options
|
| 1351 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1352 |
+
*/
|
| 1353 |
+
$visit(node, options, visitorKeys) {
|
| 1354 |
+
const { type } = node;
|
| 1355 |
+
|
| 1356 |
+
if (typeof (/** @type {any} */ (this)[type]) === "function") {
|
| 1357 |
+
return /** @type {any} */ (this)[type](
|
| 1358 |
+
node,
|
| 1359 |
+
options,
|
| 1360 |
+
visitorKeys,
|
| 1361 |
+
)
|
| 1362 |
+
}
|
| 1363 |
+
|
| 1364 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1365 |
+
},
|
| 1366 |
+
|
| 1367 |
+
/**
|
| 1368 |
+
* @param {Node} node
|
| 1369 |
+
* @param {HasSideEffectOptions} options
|
| 1370 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1371 |
+
*/
|
| 1372 |
+
$visitChildren(node, options, visitorKeys) {
|
| 1373 |
+
const { type } = node;
|
| 1374 |
+
|
| 1375 |
+
for (const key of /** @type {(keyof Node)[]} */ (
|
| 1376 |
+
visitorKeys[type] || eslintVisitorKeys.getKeys(node)
|
| 1377 |
+
)) {
|
| 1378 |
+
const value = node[key];
|
| 1379 |
+
|
| 1380 |
+
if (Array.isArray(value)) {
|
| 1381 |
+
for (const element of value) {
|
| 1382 |
+
if (
|
| 1383 |
+
isNode(element) &&
|
| 1384 |
+
this.$visit(element, options, visitorKeys)
|
| 1385 |
+
) {
|
| 1386 |
+
return true
|
| 1387 |
+
}
|
| 1388 |
+
}
|
| 1389 |
+
} else if (
|
| 1390 |
+
isNode(value) &&
|
| 1391 |
+
this.$visit(value, options, visitorKeys)
|
| 1392 |
+
) {
|
| 1393 |
+
return true
|
| 1394 |
+
}
|
| 1395 |
+
}
|
| 1396 |
+
|
| 1397 |
+
return false
|
| 1398 |
+
},
|
| 1399 |
+
|
| 1400 |
+
ArrowFunctionExpression() {
|
| 1401 |
+
return false
|
| 1402 |
+
},
|
| 1403 |
+
AssignmentExpression() {
|
| 1404 |
+
return true
|
| 1405 |
+
},
|
| 1406 |
+
AwaitExpression() {
|
| 1407 |
+
return true
|
| 1408 |
+
},
|
| 1409 |
+
/**
|
| 1410 |
+
* @param {BinaryExpression} node
|
| 1411 |
+
* @param {HasSideEffectOptions} options
|
| 1412 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1413 |
+
*/
|
| 1414 |
+
BinaryExpression(node, options, visitorKeys) {
|
| 1415 |
+
if (
|
| 1416 |
+
options.considerImplicitTypeConversion &&
|
| 1417 |
+
typeConversionBinaryOps.has(node.operator) &&
|
| 1418 |
+
(node.left.type !== "Literal" || node.right.type !== "Literal")
|
| 1419 |
+
) {
|
| 1420 |
+
return true
|
| 1421 |
+
}
|
| 1422 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1423 |
+
},
|
| 1424 |
+
CallExpression() {
|
| 1425 |
+
return true
|
| 1426 |
+
},
|
| 1427 |
+
FunctionExpression() {
|
| 1428 |
+
return false
|
| 1429 |
+
},
|
| 1430 |
+
ImportExpression() {
|
| 1431 |
+
return true
|
| 1432 |
+
},
|
| 1433 |
+
/**
|
| 1434 |
+
* @param {MemberExpression} node
|
| 1435 |
+
* @param {HasSideEffectOptions} options
|
| 1436 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1437 |
+
*/
|
| 1438 |
+
MemberExpression(node, options, visitorKeys) {
|
| 1439 |
+
if (options.considerGetters) {
|
| 1440 |
+
return true
|
| 1441 |
+
}
|
| 1442 |
+
if (
|
| 1443 |
+
options.considerImplicitTypeConversion &&
|
| 1444 |
+
node.computed &&
|
| 1445 |
+
node.property.type !== "Literal"
|
| 1446 |
+
) {
|
| 1447 |
+
return true
|
| 1448 |
+
}
|
| 1449 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1450 |
+
},
|
| 1451 |
+
/**
|
| 1452 |
+
* @param {MethodDefinition} node
|
| 1453 |
+
* @param {HasSideEffectOptions} options
|
| 1454 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1455 |
+
*/
|
| 1456 |
+
MethodDefinition(node, options, visitorKeys) {
|
| 1457 |
+
if (
|
| 1458 |
+
options.considerImplicitTypeConversion &&
|
| 1459 |
+
node.computed &&
|
| 1460 |
+
node.key.type !== "Literal"
|
| 1461 |
+
) {
|
| 1462 |
+
return true
|
| 1463 |
+
}
|
| 1464 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1465 |
+
},
|
| 1466 |
+
NewExpression() {
|
| 1467 |
+
return true
|
| 1468 |
+
},
|
| 1469 |
+
/**
|
| 1470 |
+
* @param {Property} node
|
| 1471 |
+
* @param {HasSideEffectOptions} options
|
| 1472 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1473 |
+
*/
|
| 1474 |
+
Property(node, options, visitorKeys) {
|
| 1475 |
+
if (
|
| 1476 |
+
options.considerImplicitTypeConversion &&
|
| 1477 |
+
node.computed &&
|
| 1478 |
+
node.key.type !== "Literal"
|
| 1479 |
+
) {
|
| 1480 |
+
return true
|
| 1481 |
+
}
|
| 1482 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1483 |
+
},
|
| 1484 |
+
/**
|
| 1485 |
+
* @param {PropertyDefinition} node
|
| 1486 |
+
* @param {HasSideEffectOptions} options
|
| 1487 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1488 |
+
*/
|
| 1489 |
+
PropertyDefinition(node, options, visitorKeys) {
|
| 1490 |
+
if (
|
| 1491 |
+
options.considerImplicitTypeConversion &&
|
| 1492 |
+
node.computed &&
|
| 1493 |
+
node.key.type !== "Literal"
|
| 1494 |
+
) {
|
| 1495 |
+
return true
|
| 1496 |
+
}
|
| 1497 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1498 |
+
},
|
| 1499 |
+
/**
|
| 1500 |
+
* @param {UnaryExpression} node
|
| 1501 |
+
* @param {HasSideEffectOptions} options
|
| 1502 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1503 |
+
*/
|
| 1504 |
+
UnaryExpression(node, options, visitorKeys) {
|
| 1505 |
+
if (node.operator === "delete") {
|
| 1506 |
+
return true
|
| 1507 |
+
}
|
| 1508 |
+
if (
|
| 1509 |
+
options.considerImplicitTypeConversion &&
|
| 1510 |
+
typeConversionUnaryOps.has(node.operator) &&
|
| 1511 |
+
node.argument.type !== "Literal"
|
| 1512 |
+
) {
|
| 1513 |
+
return true
|
| 1514 |
+
}
|
| 1515 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1516 |
+
},
|
| 1517 |
+
UpdateExpression() {
|
| 1518 |
+
return true
|
| 1519 |
+
},
|
| 1520 |
+
YieldExpression() {
|
| 1521 |
+
return true
|
| 1522 |
+
},
|
| 1523 |
+
}),
|
| 1524 |
+
);
|
| 1525 |
+
|
| 1526 |
+
/**
|
| 1527 |
+
* Check whether a given node has any side effect or not.
|
| 1528 |
+
* @param {Node} node The node to get.
|
| 1529 |
+
* @param {SourceCode} sourceCode The source code object.
|
| 1530 |
+
* @param {HasSideEffectOptions} [options] The option object.
|
| 1531 |
+
* @returns {boolean} `true` if the node has a certain side effect.
|
| 1532 |
+
*/
|
| 1533 |
+
function hasSideEffect(node, sourceCode, options = {}) {
|
| 1534 |
+
const { considerGetters = false, considerImplicitTypeConversion = false } =
|
| 1535 |
+
options;
|
| 1536 |
+
return visitor.$visit(
|
| 1537 |
+
node,
|
| 1538 |
+
{ considerGetters, considerImplicitTypeConversion },
|
| 1539 |
+
sourceCode.visitorKeys || eslintVisitorKeys.KEYS,
|
| 1540 |
+
)
|
| 1541 |
+
}
|
| 1542 |
+
|
| 1543 |
+
/** @typedef {import("estree").Node} Node */
|
| 1544 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1545 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 1546 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1547 |
+
|
| 1548 |
+
/**
|
| 1549 |
+
* Get the left parenthesis of the parent node syntax if it exists.
|
| 1550 |
+
* E.g., `if (a) {}` then the `(`.
|
| 1551 |
+
* @param {Node} node The AST node to check.
|
| 1552 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1553 |
+
* @returns {Token|null} The left parenthesis of the parent node syntax
|
| 1554 |
+
*/
|
| 1555 |
+
function getParentSyntaxParen(node, sourceCode) {
|
| 1556 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 1557 |
+
|
| 1558 |
+
switch (parent.type) {
|
| 1559 |
+
case "CallExpression":
|
| 1560 |
+
case "NewExpression":
|
| 1561 |
+
if (parent.arguments.length === 1 && parent.arguments[0] === node) {
|
| 1562 |
+
return sourceCode.getTokenAfter(
|
| 1563 |
+
parent.callee,
|
| 1564 |
+
isOpeningParenToken,
|
| 1565 |
+
)
|
| 1566 |
+
}
|
| 1567 |
+
return null
|
| 1568 |
+
|
| 1569 |
+
case "DoWhileStatement":
|
| 1570 |
+
if (parent.test === node) {
|
| 1571 |
+
return sourceCode.getTokenAfter(
|
| 1572 |
+
parent.body,
|
| 1573 |
+
isOpeningParenToken,
|
| 1574 |
+
)
|
| 1575 |
+
}
|
| 1576 |
+
return null
|
| 1577 |
+
|
| 1578 |
+
case "IfStatement":
|
| 1579 |
+
case "WhileStatement":
|
| 1580 |
+
if (parent.test === node) {
|
| 1581 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1582 |
+
}
|
| 1583 |
+
return null
|
| 1584 |
+
|
| 1585 |
+
case "ImportExpression":
|
| 1586 |
+
if (parent.source === node) {
|
| 1587 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1588 |
+
}
|
| 1589 |
+
return null
|
| 1590 |
+
|
| 1591 |
+
case "SwitchStatement":
|
| 1592 |
+
if (parent.discriminant === node) {
|
| 1593 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1594 |
+
}
|
| 1595 |
+
return null
|
| 1596 |
+
|
| 1597 |
+
case "WithStatement":
|
| 1598 |
+
if (parent.object === node) {
|
| 1599 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1600 |
+
}
|
| 1601 |
+
return null
|
| 1602 |
+
|
| 1603 |
+
default:
|
| 1604 |
+
return null
|
| 1605 |
+
}
|
| 1606 |
+
}
|
| 1607 |
+
|
| 1608 |
+
/**
|
| 1609 |
+
* Check whether a given node is parenthesized or not.
|
| 1610 |
+
* @param {number} times The number of parantheses.
|
| 1611 |
+
* @param {Node} node The AST node to check.
|
| 1612 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1613 |
+
* @returns {boolean} `true` if the node is parenthesized the given times.
|
| 1614 |
+
*/
|
| 1615 |
+
/**
|
| 1616 |
+
* Check whether a given node is parenthesized or not.
|
| 1617 |
+
* @param {Node} node The AST node to check.
|
| 1618 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1619 |
+
* @returns {boolean} `true` if the node is parenthesized.
|
| 1620 |
+
*/
|
| 1621 |
+
/**
|
| 1622 |
+
* Check whether a given node is parenthesized or not.
|
| 1623 |
+
* @param {Node|number} timesOrNode The first parameter.
|
| 1624 |
+
* @param {Node|SourceCode} nodeOrSourceCode The second parameter.
|
| 1625 |
+
* @param {SourceCode} [optionalSourceCode] The third parameter.
|
| 1626 |
+
* @returns {boolean} `true` if the node is parenthesized.
|
| 1627 |
+
*/
|
| 1628 |
+
function isParenthesized(
|
| 1629 |
+
timesOrNode,
|
| 1630 |
+
nodeOrSourceCode,
|
| 1631 |
+
optionalSourceCode,
|
| 1632 |
+
) {
|
| 1633 |
+
/** @type {number} */
|
| 1634 |
+
let times,
|
| 1635 |
+
/** @type {RuleNode} */
|
| 1636 |
+
node,
|
| 1637 |
+
/** @type {SourceCode} */
|
| 1638 |
+
sourceCode,
|
| 1639 |
+
maybeLeftParen,
|
| 1640 |
+
maybeRightParen;
|
| 1641 |
+
if (typeof timesOrNode === "number") {
|
| 1642 |
+
times = timesOrNode | 0;
|
| 1643 |
+
node = /** @type {RuleNode} */ (nodeOrSourceCode);
|
| 1644 |
+
sourceCode = /** @type {SourceCode} */ (optionalSourceCode);
|
| 1645 |
+
if (!(times >= 1)) {
|
| 1646 |
+
throw new TypeError("'times' should be a positive integer.")
|
| 1647 |
+
}
|
| 1648 |
+
} else {
|
| 1649 |
+
times = 1;
|
| 1650 |
+
node = /** @type {RuleNode} */ (timesOrNode);
|
| 1651 |
+
sourceCode = /** @type {SourceCode} */ (nodeOrSourceCode);
|
| 1652 |
+
}
|
| 1653 |
+
|
| 1654 |
+
if (
|
| 1655 |
+
node == null ||
|
| 1656 |
+
// `Program` can't be parenthesized
|
| 1657 |
+
node.parent == null ||
|
| 1658 |
+
// `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
|
| 1659 |
+
(node.parent.type === "CatchClause" && node.parent.param === node)
|
| 1660 |
+
) {
|
| 1661 |
+
return false
|
| 1662 |
+
}
|
| 1663 |
+
|
| 1664 |
+
maybeLeftParen = maybeRightParen = node;
|
| 1665 |
+
do {
|
| 1666 |
+
maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
|
| 1667 |
+
maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
|
| 1668 |
+
} while (
|
| 1669 |
+
maybeLeftParen != null &&
|
| 1670 |
+
maybeRightParen != null &&
|
| 1671 |
+
isOpeningParenToken(maybeLeftParen) &&
|
| 1672 |
+
isClosingParenToken(maybeRightParen) &&
|
| 1673 |
+
// Avoid false positive such as `if (a) {}`
|
| 1674 |
+
maybeLeftParen !== getParentSyntaxParen(node, sourceCode) &&
|
| 1675 |
+
--times > 0
|
| 1676 |
+
)
|
| 1677 |
+
|
| 1678 |
+
return times === 0
|
| 1679 |
+
}
|
| 1680 |
+
|
| 1681 |
+
/**
|
| 1682 |
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
| 1683 |
+
* See LICENSE file in root directory for full license.
|
| 1684 |
+
*/
|
| 1685 |
+
|
| 1686 |
+
const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
|
| 1687 |
+
|
| 1688 |
+
/** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
|
| 1689 |
+
const internal = new WeakMap();
|
| 1690 |
+
|
| 1691 |
+
/**
|
| 1692 |
+
* Check whether a given character is escaped or not.
|
| 1693 |
+
* @param {string} str The string to check.
|
| 1694 |
+
* @param {number} index The location of the character to check.
|
| 1695 |
+
* @returns {boolean} `true` if the character is escaped.
|
| 1696 |
+
*/
|
| 1697 |
+
function isEscaped(str, index) {
|
| 1698 |
+
let escaped = false;
|
| 1699 |
+
for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
|
| 1700 |
+
escaped = !escaped;
|
| 1701 |
+
}
|
| 1702 |
+
return escaped
|
| 1703 |
+
}
|
| 1704 |
+
|
| 1705 |
+
/**
|
| 1706 |
+
* Replace a given string by a given matcher.
|
| 1707 |
+
* @param {PatternMatcher} matcher The pattern matcher.
|
| 1708 |
+
* @param {string} str The string to be replaced.
|
| 1709 |
+
* @param {string} replacement The new substring to replace each matched part.
|
| 1710 |
+
* @returns {string} The replaced string.
|
| 1711 |
+
*/
|
| 1712 |
+
function replaceS(matcher, str, replacement) {
|
| 1713 |
+
const chunks = [];
|
| 1714 |
+
let index = 0;
|
| 1715 |
+
|
| 1716 |
+
/**
|
| 1717 |
+
* @param {string} key The placeholder.
|
| 1718 |
+
* @param {RegExpExecArray} match The matched information.
|
| 1719 |
+
* @returns {string} The replaced string.
|
| 1720 |
+
*/
|
| 1721 |
+
function replacer(key, match) {
|
| 1722 |
+
switch (key) {
|
| 1723 |
+
case "$$":
|
| 1724 |
+
return "$"
|
| 1725 |
+
case "$&":
|
| 1726 |
+
return match[0]
|
| 1727 |
+
case "$`":
|
| 1728 |
+
return str.slice(0, match.index)
|
| 1729 |
+
case "$'":
|
| 1730 |
+
return str.slice(match.index + match[0].length)
|
| 1731 |
+
default: {
|
| 1732 |
+
const i = key.slice(1);
|
| 1733 |
+
if (i in match) {
|
| 1734 |
+
return match[/** @type {any} */ (i)]
|
| 1735 |
+
}
|
| 1736 |
+
return key
|
| 1737 |
+
}
|
| 1738 |
+
}
|
| 1739 |
+
}
|
| 1740 |
+
|
| 1741 |
+
for (const match of matcher.execAll(str)) {
|
| 1742 |
+
chunks.push(str.slice(index, match.index));
|
| 1743 |
+
chunks.push(
|
| 1744 |
+
replacement.replace(placeholder, (key) => replacer(key, match)),
|
| 1745 |
+
);
|
| 1746 |
+
index = match.index + match[0].length;
|
| 1747 |
+
}
|
| 1748 |
+
chunks.push(str.slice(index));
|
| 1749 |
+
|
| 1750 |
+
return chunks.join("")
|
| 1751 |
+
}
|
| 1752 |
+
|
| 1753 |
+
/**
|
| 1754 |
+
* Replace a given string by a given matcher.
|
| 1755 |
+
* @param {PatternMatcher} matcher The pattern matcher.
|
| 1756 |
+
* @param {string} str The string to be replaced.
|
| 1757 |
+
* @param {(substring: string, ...args: any[]) => string} replace The function to replace each matched part.
|
| 1758 |
+
* @returns {string} The replaced string.
|
| 1759 |
+
*/
|
| 1760 |
+
function replaceF(matcher, str, replace) {
|
| 1761 |
+
const chunks = [];
|
| 1762 |
+
let index = 0;
|
| 1763 |
+
|
| 1764 |
+
for (const match of matcher.execAll(str)) {
|
| 1765 |
+
chunks.push(str.slice(index, match.index));
|
| 1766 |
+
chunks.push(
|
| 1767 |
+
String(
|
| 1768 |
+
replace(
|
| 1769 |
+
.../** @type {[string, ...string[]]} */ (
|
| 1770 |
+
/** @type {string[]} */ (match)
|
| 1771 |
+
),
|
| 1772 |
+
match.index,
|
| 1773 |
+
match.input,
|
| 1774 |
+
),
|
| 1775 |
+
),
|
| 1776 |
+
);
|
| 1777 |
+
index = match.index + match[0].length;
|
| 1778 |
+
}
|
| 1779 |
+
chunks.push(str.slice(index));
|
| 1780 |
+
|
| 1781 |
+
return chunks.join("")
|
| 1782 |
+
}
|
| 1783 |
+
|
| 1784 |
+
/**
|
| 1785 |
+
* The class to find patterns as considering escape sequences.
|
| 1786 |
+
*/
|
| 1787 |
+
class PatternMatcher {
|
| 1788 |
+
/**
|
| 1789 |
+
* Initialize this matcher.
|
| 1790 |
+
* @param {RegExp} pattern The pattern to match.
|
| 1791 |
+
* @param {{escaped?:boolean}} [options] The options.
|
| 1792 |
+
*/
|
| 1793 |
+
constructor(pattern, options = {}) {
|
| 1794 |
+
const { escaped = false } = options;
|
| 1795 |
+
if (!(pattern instanceof RegExp)) {
|
| 1796 |
+
throw new TypeError("'pattern' should be a RegExp instance.")
|
| 1797 |
+
}
|
| 1798 |
+
if (!pattern.flags.includes("g")) {
|
| 1799 |
+
throw new Error("'pattern' should contains 'g' flag.")
|
| 1800 |
+
}
|
| 1801 |
+
|
| 1802 |
+
internal.set(this, {
|
| 1803 |
+
pattern: new RegExp(pattern.source, pattern.flags),
|
| 1804 |
+
escaped: Boolean(escaped),
|
| 1805 |
+
});
|
| 1806 |
+
}
|
| 1807 |
+
|
| 1808 |
+
/**
|
| 1809 |
+
* Find the pattern in a given string.
|
| 1810 |
+
* @param {string} str The string to find.
|
| 1811 |
+
* @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
|
| 1812 |
+
*/
|
| 1813 |
+
*execAll(str) {
|
| 1814 |
+
const { pattern, escaped } =
|
| 1815 |
+
/** @type {{pattern:RegExp,escaped:boolean}} */ (internal.get(this));
|
| 1816 |
+
let match = null;
|
| 1817 |
+
let lastIndex = 0;
|
| 1818 |
+
|
| 1819 |
+
pattern.lastIndex = 0;
|
| 1820 |
+
while ((match = pattern.exec(str)) != null) {
|
| 1821 |
+
if (escaped || !isEscaped(str, match.index)) {
|
| 1822 |
+
lastIndex = pattern.lastIndex;
|
| 1823 |
+
yield match;
|
| 1824 |
+
pattern.lastIndex = lastIndex;
|
| 1825 |
+
}
|
| 1826 |
+
}
|
| 1827 |
+
}
|
| 1828 |
+
|
| 1829 |
+
/**
|
| 1830 |
+
* Check whether the pattern is found in a given string.
|
| 1831 |
+
* @param {string} str The string to check.
|
| 1832 |
+
* @returns {boolean} `true` if the pattern was found in the string.
|
| 1833 |
+
*/
|
| 1834 |
+
test(str) {
|
| 1835 |
+
const it = this.execAll(str);
|
| 1836 |
+
const ret = it.next();
|
| 1837 |
+
return !ret.done
|
| 1838 |
+
}
|
| 1839 |
+
|
| 1840 |
+
/**
|
| 1841 |
+
* Replace a given string.
|
| 1842 |
+
* @param {string} str The string to be replaced.
|
| 1843 |
+
* @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
|
| 1844 |
+
* @returns {string} The replaced string.
|
| 1845 |
+
*/
|
| 1846 |
+
[Symbol.replace](str, replacer) {
|
| 1847 |
+
return typeof replacer === "function"
|
| 1848 |
+
? replaceF(this, String(str), replacer)
|
| 1849 |
+
: replaceS(this, String(str), String(replacer))
|
| 1850 |
+
}
|
| 1851 |
+
}
|
| 1852 |
+
|
| 1853 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1854 |
+
/** @typedef {import("eslint").Scope.Variable} Variable */
|
| 1855 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1856 |
+
/** @typedef {import("estree").Node} Node */
|
| 1857 |
+
/** @typedef {import("estree").Expression} Expression */
|
| 1858 |
+
/** @typedef {import("estree").Pattern} Pattern */
|
| 1859 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1860 |
+
/** @typedef {import("estree").SimpleCallExpression} CallExpression */
|
| 1861 |
+
/** @typedef {import("estree").Program} Program */
|
| 1862 |
+
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
|
| 1863 |
+
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
|
| 1864 |
+
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
|
| 1865 |
+
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
|
| 1866 |
+
/** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
|
| 1867 |
+
/** @typedef {import("estree").ImportDefaultSpecifier} ImportDefaultSpecifier */
|
| 1868 |
+
/** @typedef {import("estree").ImportNamespaceSpecifier} ImportNamespaceSpecifier */
|
| 1869 |
+
/** @typedef {import("estree").ExportSpecifier} ExportSpecifier */
|
| 1870 |
+
/** @typedef {import("estree").Property} Property */
|
| 1871 |
+
/** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
|
| 1872 |
+
/** @typedef {import("estree").Literal} Literal */
|
| 1873 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
|
| 1874 |
+
/** @typedef {import("./types.mjs").ReferenceTrackerOptions} ReferenceTrackerOptions */
|
| 1875 |
+
/**
|
| 1876 |
+
* @template T
|
| 1877 |
+
* @typedef {import("./types.mjs").TraceMap<T>} TraceMap
|
| 1878 |
+
*/
|
| 1879 |
+
/**
|
| 1880 |
+
* @template T
|
| 1881 |
+
* @typedef {import("./types.mjs").TraceMapObject<T>} TraceMapObject
|
| 1882 |
+
*/
|
| 1883 |
+
/**
|
| 1884 |
+
* @template T
|
| 1885 |
+
* @typedef {import("./types.mjs").TrackedReferences<T>} TrackedReferences
|
| 1886 |
+
*/
|
| 1887 |
+
|
| 1888 |
+
const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
|
| 1889 |
+
|
| 1890 |
+
/**
|
| 1891 |
+
* Check whether a given node is an import node or not.
|
| 1892 |
+
* @param {Node} node
|
| 1893 |
+
* @returns {node is ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration&{source: Literal}} `true` if the node is an import node.
|
| 1894 |
+
*/
|
| 1895 |
+
function isHasSource(node) {
|
| 1896 |
+
return (
|
| 1897 |
+
IMPORT_TYPE.test(node.type) &&
|
| 1898 |
+
/** @type {ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration} */ (
|
| 1899 |
+
node
|
| 1900 |
+
).source != null
|
| 1901 |
+
)
|
| 1902 |
+
}
|
| 1903 |
+
const has =
|
| 1904 |
+
/** @type {<T>(traceMap: TraceMap<unknown>, v: T) => v is (string extends T ? string : T)} */ (
|
| 1905 |
+
Function.call.bind(Object.hasOwnProperty)
|
| 1906 |
+
);
|
| 1907 |
+
|
| 1908 |
+
const READ = Symbol("read");
|
| 1909 |
+
const CALL = Symbol("call");
|
| 1910 |
+
const CONSTRUCT = Symbol("construct");
|
| 1911 |
+
const ESM = Symbol("esm");
|
| 1912 |
+
|
| 1913 |
+
const requireCall = { require: { [CALL]: true } };
|
| 1914 |
+
|
| 1915 |
+
/**
|
| 1916 |
+
* Check whether a given variable is modified or not.
|
| 1917 |
+
* @param {Variable|undefined} variable The variable to check.
|
| 1918 |
+
* @returns {boolean} `true` if the variable is modified.
|
| 1919 |
+
*/
|
| 1920 |
+
function isModifiedGlobal(variable) {
|
| 1921 |
+
return (
|
| 1922 |
+
variable == null ||
|
| 1923 |
+
variable.defs.length !== 0 ||
|
| 1924 |
+
variable.references.some((r) => r.isWrite())
|
| 1925 |
+
)
|
| 1926 |
+
}
|
| 1927 |
+
|
| 1928 |
+
/**
|
| 1929 |
+
* Check if the value of a given node is passed through to the parent syntax as-is.
|
| 1930 |
+
* For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
|
| 1931 |
+
* @param {Node} node A node to check.
|
| 1932 |
+
* @returns {node is RuleNode & {parent: Expression}} `true` if the node is passed through.
|
| 1933 |
+
*/
|
| 1934 |
+
function isPassThrough(node) {
|
| 1935 |
+
const parent = /** @type {TSESTreeNode} */ (node).parent;
|
| 1936 |
+
|
| 1937 |
+
if (parent) {
|
| 1938 |
+
switch (parent.type) {
|
| 1939 |
+
case "ConditionalExpression":
|
| 1940 |
+
return parent.consequent === node || parent.alternate === node
|
| 1941 |
+
case "LogicalExpression":
|
| 1942 |
+
return true
|
| 1943 |
+
case "SequenceExpression":
|
| 1944 |
+
return (
|
| 1945 |
+
parent.expressions[parent.expressions.length - 1] === node
|
| 1946 |
+
)
|
| 1947 |
+
case "ChainExpression":
|
| 1948 |
+
return true
|
| 1949 |
+
case "TSAsExpression":
|
| 1950 |
+
case "TSSatisfiesExpression":
|
| 1951 |
+
case "TSTypeAssertion":
|
| 1952 |
+
case "TSNonNullExpression":
|
| 1953 |
+
case "TSInstantiationExpression":
|
| 1954 |
+
return true
|
| 1955 |
+
|
| 1956 |
+
default:
|
| 1957 |
+
return false
|
| 1958 |
+
}
|
| 1959 |
+
}
|
| 1960 |
+
return false
|
| 1961 |
+
}
|
| 1962 |
+
|
| 1963 |
+
/**
|
| 1964 |
+
* The reference tracker.
|
| 1965 |
+
*/
|
| 1966 |
+
class ReferenceTracker {
|
| 1967 |
+
/**
|
| 1968 |
+
* Initialize this tracker.
|
| 1969 |
+
* @param {Scope} globalScope The global scope.
|
| 1970 |
+
* @param {object} [options] The options.
|
| 1971 |
+
* @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
|
| 1972 |
+
* @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
|
| 1973 |
+
*/
|
| 1974 |
+
constructor(globalScope, options = {}) {
|
| 1975 |
+
const {
|
| 1976 |
+
mode = "strict",
|
| 1977 |
+
globalObjectNames = ["global", "globalThis", "self", "window"],
|
| 1978 |
+
} = options;
|
| 1979 |
+
/** @private @type {Variable[]} */
|
| 1980 |
+
this.variableStack = [];
|
| 1981 |
+
/** @private */
|
| 1982 |
+
this.globalScope = globalScope;
|
| 1983 |
+
/** @private */
|
| 1984 |
+
this.mode = mode;
|
| 1985 |
+
/** @private */
|
| 1986 |
+
this.globalObjectNames = globalObjectNames.slice(0);
|
| 1987 |
+
}
|
| 1988 |
+
|
| 1989 |
+
/**
|
| 1990 |
+
* Iterate the references of global variables.
|
| 1991 |
+
* @template T
|
| 1992 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 1993 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 1994 |
+
*/
|
| 1995 |
+
*iterateGlobalReferences(traceMap) {
|
| 1996 |
+
for (const key of Object.keys(traceMap)) {
|
| 1997 |
+
const nextTraceMap = traceMap[key];
|
| 1998 |
+
const path = [key];
|
| 1999 |
+
const variable = this.globalScope.set.get(key);
|
| 2000 |
+
|
| 2001 |
+
if (isModifiedGlobal(variable)) {
|
| 2002 |
+
continue
|
| 2003 |
+
}
|
| 2004 |
+
|
| 2005 |
+
yield* this._iterateVariableReferences(
|
| 2006 |
+
/** @type {Variable} */ (variable),
|
| 2007 |
+
path,
|
| 2008 |
+
nextTraceMap,
|
| 2009 |
+
true,
|
| 2010 |
+
);
|
| 2011 |
+
}
|
| 2012 |
+
|
| 2013 |
+
for (const key of this.globalObjectNames) {
|
| 2014 |
+
/** @type {string[]} */
|
| 2015 |
+
const path = [];
|
| 2016 |
+
const variable = this.globalScope.set.get(key);
|
| 2017 |
+
|
| 2018 |
+
if (isModifiedGlobal(variable)) {
|
| 2019 |
+
continue
|
| 2020 |
+
}
|
| 2021 |
+
|
| 2022 |
+
yield* this._iterateVariableReferences(
|
| 2023 |
+
/** @type {Variable} */ (variable),
|
| 2024 |
+
path,
|
| 2025 |
+
traceMap,
|
| 2026 |
+
false,
|
| 2027 |
+
);
|
| 2028 |
+
}
|
| 2029 |
+
}
|
| 2030 |
+
|
| 2031 |
+
/**
|
| 2032 |
+
* Iterate the references of CommonJS modules.
|
| 2033 |
+
* @template T
|
| 2034 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2035 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2036 |
+
*/
|
| 2037 |
+
*iterateCjsReferences(traceMap) {
|
| 2038 |
+
for (const { node } of this.iterateGlobalReferences(requireCall)) {
|
| 2039 |
+
const key = getStringIfConstant(
|
| 2040 |
+
/** @type {CallExpression} */ (node).arguments[0],
|
| 2041 |
+
);
|
| 2042 |
+
if (key == null || !has(traceMap, key)) {
|
| 2043 |
+
continue
|
| 2044 |
+
}
|
| 2045 |
+
|
| 2046 |
+
const nextTraceMap = traceMap[key];
|
| 2047 |
+
const path = [key];
|
| 2048 |
+
|
| 2049 |
+
if (nextTraceMap[READ]) {
|
| 2050 |
+
yield {
|
| 2051 |
+
node,
|
| 2052 |
+
path,
|
| 2053 |
+
type: READ,
|
| 2054 |
+
info: nextTraceMap[READ],
|
| 2055 |
+
};
|
| 2056 |
+
}
|
| 2057 |
+
yield* this._iteratePropertyReferences(
|
| 2058 |
+
/** @type {CallExpression} */ (node),
|
| 2059 |
+
path,
|
| 2060 |
+
nextTraceMap,
|
| 2061 |
+
);
|
| 2062 |
+
}
|
| 2063 |
+
}
|
| 2064 |
+
|
| 2065 |
+
/**
|
| 2066 |
+
* Iterate the references of ES modules.
|
| 2067 |
+
* @template T
|
| 2068 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2069 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2070 |
+
*/
|
| 2071 |
+
*iterateEsmReferences(traceMap) {
|
| 2072 |
+
const programNode = /** @type {Program} */ (this.globalScope.block);
|
| 2073 |
+
|
| 2074 |
+
for (const node of programNode.body) {
|
| 2075 |
+
if (!isHasSource(node)) {
|
| 2076 |
+
continue
|
| 2077 |
+
}
|
| 2078 |
+
const moduleId = /** @type {string} */ (node.source.value);
|
| 2079 |
+
|
| 2080 |
+
if (!has(traceMap, moduleId)) {
|
| 2081 |
+
continue
|
| 2082 |
+
}
|
| 2083 |
+
const nextTraceMap = traceMap[moduleId];
|
| 2084 |
+
const path = [moduleId];
|
| 2085 |
+
|
| 2086 |
+
if (nextTraceMap[READ]) {
|
| 2087 |
+
yield {
|
| 2088 |
+
// eslint-disable-next-line object-shorthand -- apply type
|
| 2089 |
+
node: /** @type {RuleNode} */ (node),
|
| 2090 |
+
path,
|
| 2091 |
+
type: READ,
|
| 2092 |
+
info: nextTraceMap[READ],
|
| 2093 |
+
};
|
| 2094 |
+
}
|
| 2095 |
+
|
| 2096 |
+
if (node.type === "ExportAllDeclaration") {
|
| 2097 |
+
for (const key of Object.keys(nextTraceMap)) {
|
| 2098 |
+
const exportTraceMap = nextTraceMap[key];
|
| 2099 |
+
if (exportTraceMap[READ]) {
|
| 2100 |
+
yield {
|
| 2101 |
+
// eslint-disable-next-line object-shorthand -- apply type
|
| 2102 |
+
node: /** @type {RuleNode} */ (node),
|
| 2103 |
+
path: path.concat(key),
|
| 2104 |
+
type: READ,
|
| 2105 |
+
info: exportTraceMap[READ],
|
| 2106 |
+
};
|
| 2107 |
+
}
|
| 2108 |
+
}
|
| 2109 |
+
} else {
|
| 2110 |
+
for (const specifier of node.specifiers) {
|
| 2111 |
+
const esm = has(nextTraceMap, ESM);
|
| 2112 |
+
const it = this._iterateImportReferences(
|
| 2113 |
+
specifier,
|
| 2114 |
+
path,
|
| 2115 |
+
esm
|
| 2116 |
+
? nextTraceMap
|
| 2117 |
+
: this.mode === "legacy"
|
| 2118 |
+
? { default: nextTraceMap, ...nextTraceMap }
|
| 2119 |
+
: { default: nextTraceMap },
|
| 2120 |
+
);
|
| 2121 |
+
|
| 2122 |
+
if (esm) {
|
| 2123 |
+
yield* it;
|
| 2124 |
+
} else {
|
| 2125 |
+
for (const report of it) {
|
| 2126 |
+
report.path = report.path.filter(exceptDefault);
|
| 2127 |
+
if (
|
| 2128 |
+
report.path.length >= 2 ||
|
| 2129 |
+
report.type !== READ
|
| 2130 |
+
) {
|
| 2131 |
+
yield report;
|
| 2132 |
+
}
|
| 2133 |
+
}
|
| 2134 |
+
}
|
| 2135 |
+
}
|
| 2136 |
+
}
|
| 2137 |
+
}
|
| 2138 |
+
}
|
| 2139 |
+
|
| 2140 |
+
/**
|
| 2141 |
+
* Iterate the property references for a given expression AST node.
|
| 2142 |
+
* @template T
|
| 2143 |
+
* @param {Expression} node The expression AST node to iterate property references.
|
| 2144 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2145 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate property references.
|
| 2146 |
+
*/
|
| 2147 |
+
*iteratePropertyReferences(node, traceMap) {
|
| 2148 |
+
yield* this._iteratePropertyReferences(node, [], traceMap);
|
| 2149 |
+
}
|
| 2150 |
+
|
| 2151 |
+
/**
|
| 2152 |
+
* Iterate the references for a given variable.
|
| 2153 |
+
* @private
|
| 2154 |
+
* @template T
|
| 2155 |
+
* @param {Variable} variable The variable to iterate that references.
|
| 2156 |
+
* @param {string[]} path The current path.
|
| 2157 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2158 |
+
* @param {boolean} shouldReport = The flag to report those references.
|
| 2159 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2160 |
+
*/
|
| 2161 |
+
*_iterateVariableReferences(variable, path, traceMap, shouldReport) {
|
| 2162 |
+
if (this.variableStack.includes(variable)) {
|
| 2163 |
+
return
|
| 2164 |
+
}
|
| 2165 |
+
this.variableStack.push(variable);
|
| 2166 |
+
try {
|
| 2167 |
+
for (const reference of variable.references) {
|
| 2168 |
+
if (!reference.isRead()) {
|
| 2169 |
+
continue
|
| 2170 |
+
}
|
| 2171 |
+
const node = /** @type {RuleNode & Identifier} */ (
|
| 2172 |
+
reference.identifier
|
| 2173 |
+
);
|
| 2174 |
+
|
| 2175 |
+
if (shouldReport && traceMap[READ]) {
|
| 2176 |
+
yield { node, path, type: READ, info: traceMap[READ] };
|
| 2177 |
+
}
|
| 2178 |
+
yield* this._iteratePropertyReferences(node, path, traceMap);
|
| 2179 |
+
}
|
| 2180 |
+
} finally {
|
| 2181 |
+
this.variableStack.pop();
|
| 2182 |
+
}
|
| 2183 |
+
}
|
| 2184 |
+
|
| 2185 |
+
/**
|
| 2186 |
+
* Iterate the references for a given AST node.
|
| 2187 |
+
* @private
|
| 2188 |
+
* @template T
|
| 2189 |
+
* @param {Expression} rootNode The AST node to iterate references.
|
| 2190 |
+
* @param {string[]} path The current path.
|
| 2191 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2192 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2193 |
+
*/
|
| 2194 |
+
//eslint-disable-next-line complexity
|
| 2195 |
+
*_iteratePropertyReferences(rootNode, path, traceMap) {
|
| 2196 |
+
let node = rootNode;
|
| 2197 |
+
while (isPassThrough(node)) {
|
| 2198 |
+
node = node.parent;
|
| 2199 |
+
}
|
| 2200 |
+
|
| 2201 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 2202 |
+
if (parent.type === "MemberExpression") {
|
| 2203 |
+
if (parent.object === node) {
|
| 2204 |
+
const key = getPropertyName(parent);
|
| 2205 |
+
if (key == null || !has(traceMap, key)) {
|
| 2206 |
+
return
|
| 2207 |
+
}
|
| 2208 |
+
|
| 2209 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2210 |
+
const nextTraceMap = traceMap[key];
|
| 2211 |
+
if (nextTraceMap[READ]) {
|
| 2212 |
+
yield {
|
| 2213 |
+
node: parent,
|
| 2214 |
+
path,
|
| 2215 |
+
type: READ,
|
| 2216 |
+
info: nextTraceMap[READ],
|
| 2217 |
+
};
|
| 2218 |
+
}
|
| 2219 |
+
yield* this._iteratePropertyReferences(
|
| 2220 |
+
parent,
|
| 2221 |
+
path,
|
| 2222 |
+
nextTraceMap,
|
| 2223 |
+
);
|
| 2224 |
+
}
|
| 2225 |
+
return
|
| 2226 |
+
}
|
| 2227 |
+
if (parent.type === "CallExpression") {
|
| 2228 |
+
if (parent.callee === node && traceMap[CALL]) {
|
| 2229 |
+
yield { node: parent, path, type: CALL, info: traceMap[CALL] };
|
| 2230 |
+
}
|
| 2231 |
+
return
|
| 2232 |
+
}
|
| 2233 |
+
if (parent.type === "NewExpression") {
|
| 2234 |
+
if (parent.callee === node && traceMap[CONSTRUCT]) {
|
| 2235 |
+
yield {
|
| 2236 |
+
node: parent,
|
| 2237 |
+
path,
|
| 2238 |
+
type: CONSTRUCT,
|
| 2239 |
+
info: traceMap[CONSTRUCT],
|
| 2240 |
+
};
|
| 2241 |
+
}
|
| 2242 |
+
return
|
| 2243 |
+
}
|
| 2244 |
+
if (parent.type === "AssignmentExpression") {
|
| 2245 |
+
if (parent.right === node) {
|
| 2246 |
+
yield* this._iterateLhsReferences(parent.left, path, traceMap);
|
| 2247 |
+
yield* this._iteratePropertyReferences(parent, path, traceMap);
|
| 2248 |
+
}
|
| 2249 |
+
return
|
| 2250 |
+
}
|
| 2251 |
+
if (parent.type === "AssignmentPattern") {
|
| 2252 |
+
if (parent.right === node) {
|
| 2253 |
+
yield* this._iterateLhsReferences(parent.left, path, traceMap);
|
| 2254 |
+
}
|
| 2255 |
+
return
|
| 2256 |
+
}
|
| 2257 |
+
if (parent.type === "VariableDeclarator") {
|
| 2258 |
+
if (parent.init === node) {
|
| 2259 |
+
yield* this._iterateLhsReferences(parent.id, path, traceMap);
|
| 2260 |
+
}
|
| 2261 |
+
}
|
| 2262 |
+
}
|
| 2263 |
+
|
| 2264 |
+
/**
|
| 2265 |
+
* Iterate the references for a given Pattern node.
|
| 2266 |
+
* @private
|
| 2267 |
+
* @template T
|
| 2268 |
+
* @param {Pattern} patternNode The Pattern node to iterate references.
|
| 2269 |
+
* @param {string[]} path The current path.
|
| 2270 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2271 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2272 |
+
*/
|
| 2273 |
+
*_iterateLhsReferences(patternNode, path, traceMap) {
|
| 2274 |
+
if (patternNode.type === "Identifier") {
|
| 2275 |
+
const variable = findVariable(this.globalScope, patternNode);
|
| 2276 |
+
if (variable != null) {
|
| 2277 |
+
yield* this._iterateVariableReferences(
|
| 2278 |
+
variable,
|
| 2279 |
+
path,
|
| 2280 |
+
traceMap,
|
| 2281 |
+
false,
|
| 2282 |
+
);
|
| 2283 |
+
}
|
| 2284 |
+
return
|
| 2285 |
+
}
|
| 2286 |
+
if (patternNode.type === "ObjectPattern") {
|
| 2287 |
+
for (const property of patternNode.properties) {
|
| 2288 |
+
const key = getPropertyName(
|
| 2289 |
+
/** @type {AssignmentProperty} */ (property),
|
| 2290 |
+
);
|
| 2291 |
+
|
| 2292 |
+
if (key == null || !has(traceMap, key)) {
|
| 2293 |
+
continue
|
| 2294 |
+
}
|
| 2295 |
+
|
| 2296 |
+
const nextPath = path.concat(key);
|
| 2297 |
+
const nextTraceMap = traceMap[key];
|
| 2298 |
+
if (nextTraceMap[READ]) {
|
| 2299 |
+
yield {
|
| 2300 |
+
node: /** @type {RuleNode} */ (property),
|
| 2301 |
+
path: nextPath,
|
| 2302 |
+
type: READ,
|
| 2303 |
+
info: nextTraceMap[READ],
|
| 2304 |
+
};
|
| 2305 |
+
}
|
| 2306 |
+
yield* this._iterateLhsReferences(
|
| 2307 |
+
/** @type {AssignmentProperty} */ (property).value,
|
| 2308 |
+
nextPath,
|
| 2309 |
+
nextTraceMap,
|
| 2310 |
+
);
|
| 2311 |
+
}
|
| 2312 |
+
return
|
| 2313 |
+
}
|
| 2314 |
+
if (patternNode.type === "AssignmentPattern") {
|
| 2315 |
+
yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
|
| 2316 |
+
}
|
| 2317 |
+
}
|
| 2318 |
+
|
| 2319 |
+
/**
|
| 2320 |
+
* Iterate the references for a given ModuleSpecifier node.
|
| 2321 |
+
* @private
|
| 2322 |
+
* @template T
|
| 2323 |
+
* @param {ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier} specifierNode The ModuleSpecifier node to iterate references.
|
| 2324 |
+
* @param {string[]} path The current path.
|
| 2325 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2326 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2327 |
+
*/
|
| 2328 |
+
*_iterateImportReferences(specifierNode, path, traceMap) {
|
| 2329 |
+
const type = specifierNode.type;
|
| 2330 |
+
|
| 2331 |
+
if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
|
| 2332 |
+
const key =
|
| 2333 |
+
type === "ImportDefaultSpecifier"
|
| 2334 |
+
? "default"
|
| 2335 |
+
: specifierNode.imported.type === "Identifier"
|
| 2336 |
+
? specifierNode.imported.name
|
| 2337 |
+
: specifierNode.imported.value;
|
| 2338 |
+
if (!has(traceMap, key)) {
|
| 2339 |
+
return
|
| 2340 |
+
}
|
| 2341 |
+
|
| 2342 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2343 |
+
const nextTraceMap = traceMap[key];
|
| 2344 |
+
if (nextTraceMap[READ]) {
|
| 2345 |
+
yield {
|
| 2346 |
+
node: /** @type {RuleNode} */ (specifierNode),
|
| 2347 |
+
path,
|
| 2348 |
+
type: READ,
|
| 2349 |
+
info: nextTraceMap[READ],
|
| 2350 |
+
};
|
| 2351 |
+
}
|
| 2352 |
+
yield* this._iterateVariableReferences(
|
| 2353 |
+
/** @type {Variable} */ (
|
| 2354 |
+
findVariable(this.globalScope, specifierNode.local)
|
| 2355 |
+
),
|
| 2356 |
+
path,
|
| 2357 |
+
nextTraceMap,
|
| 2358 |
+
false,
|
| 2359 |
+
);
|
| 2360 |
+
|
| 2361 |
+
return
|
| 2362 |
+
}
|
| 2363 |
+
|
| 2364 |
+
if (type === "ImportNamespaceSpecifier") {
|
| 2365 |
+
yield* this._iterateVariableReferences(
|
| 2366 |
+
/** @type {Variable} */ (
|
| 2367 |
+
findVariable(this.globalScope, specifierNode.local)
|
| 2368 |
+
),
|
| 2369 |
+
path,
|
| 2370 |
+
traceMap,
|
| 2371 |
+
false,
|
| 2372 |
+
);
|
| 2373 |
+
return
|
| 2374 |
+
}
|
| 2375 |
+
|
| 2376 |
+
if (type === "ExportSpecifier") {
|
| 2377 |
+
const key =
|
| 2378 |
+
specifierNode.local.type === "Identifier"
|
| 2379 |
+
? specifierNode.local.name
|
| 2380 |
+
: specifierNode.local.value;
|
| 2381 |
+
if (!has(traceMap, key)) {
|
| 2382 |
+
return
|
| 2383 |
+
}
|
| 2384 |
+
|
| 2385 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2386 |
+
const nextTraceMap = traceMap[key];
|
| 2387 |
+
if (nextTraceMap[READ]) {
|
| 2388 |
+
yield {
|
| 2389 |
+
node: /** @type {RuleNode} */ (specifierNode),
|
| 2390 |
+
path,
|
| 2391 |
+
type: READ,
|
| 2392 |
+
info: nextTraceMap[READ],
|
| 2393 |
+
};
|
| 2394 |
+
}
|
| 2395 |
+
}
|
| 2396 |
+
}
|
| 2397 |
+
}
|
| 2398 |
+
|
| 2399 |
+
ReferenceTracker.READ = READ;
|
| 2400 |
+
ReferenceTracker.CALL = CALL;
|
| 2401 |
+
ReferenceTracker.CONSTRUCT = CONSTRUCT;
|
| 2402 |
+
ReferenceTracker.ESM = ESM;
|
| 2403 |
+
|
| 2404 |
+
/**
|
| 2405 |
+
* This is a predicate function for Array#filter.
|
| 2406 |
+
* @param {string} name A name part.
|
| 2407 |
+
* @param {number} index The index of the name.
|
| 2408 |
+
* @returns {boolean} `false` if it's default.
|
| 2409 |
+
*/
|
| 2410 |
+
function exceptDefault(name, index) {
|
| 2411 |
+
return !(index === 1 && name === "default")
|
| 2412 |
+
}
|
| 2413 |
+
|
| 2414 |
+
/** @typedef {import("./types.mjs").StaticValue} StaticValue */
|
| 2415 |
+
|
| 2416 |
+
var index = {
|
| 2417 |
+
CALL,
|
| 2418 |
+
CONSTRUCT,
|
| 2419 |
+
ESM,
|
| 2420 |
+
findVariable,
|
| 2421 |
+
getFunctionHeadLocation,
|
| 2422 |
+
getFunctionNameWithKind,
|
| 2423 |
+
getInnermostScope,
|
| 2424 |
+
getPropertyName,
|
| 2425 |
+
getStaticValue,
|
| 2426 |
+
getStringIfConstant,
|
| 2427 |
+
hasSideEffect,
|
| 2428 |
+
isArrowToken,
|
| 2429 |
+
isClosingBraceToken,
|
| 2430 |
+
isClosingBracketToken,
|
| 2431 |
+
isClosingParenToken,
|
| 2432 |
+
isColonToken,
|
| 2433 |
+
isCommaToken,
|
| 2434 |
+
isCommentToken,
|
| 2435 |
+
isNotArrowToken,
|
| 2436 |
+
isNotClosingBraceToken,
|
| 2437 |
+
isNotClosingBracketToken,
|
| 2438 |
+
isNotClosingParenToken,
|
| 2439 |
+
isNotColonToken,
|
| 2440 |
+
isNotCommaToken,
|
| 2441 |
+
isNotCommentToken,
|
| 2442 |
+
isNotOpeningBraceToken,
|
| 2443 |
+
isNotOpeningBracketToken,
|
| 2444 |
+
isNotOpeningParenToken,
|
| 2445 |
+
isNotSemicolonToken,
|
| 2446 |
+
isOpeningBraceToken,
|
| 2447 |
+
isOpeningBracketToken,
|
| 2448 |
+
isOpeningParenToken,
|
| 2449 |
+
isParenthesized,
|
| 2450 |
+
isSemicolonToken,
|
| 2451 |
+
PatternMatcher,
|
| 2452 |
+
READ,
|
| 2453 |
+
ReferenceTracker,
|
| 2454 |
+
};
|
| 2455 |
+
|
| 2456 |
+
exports.CALL = CALL;
|
| 2457 |
+
exports.CONSTRUCT = CONSTRUCT;
|
| 2458 |
+
exports.ESM = ESM;
|
| 2459 |
+
exports.PatternMatcher = PatternMatcher;
|
| 2460 |
+
exports.READ = READ;
|
| 2461 |
+
exports.ReferenceTracker = ReferenceTracker;
|
| 2462 |
+
exports["default"] = index;
|
| 2463 |
+
exports.findVariable = findVariable;
|
| 2464 |
+
exports.getFunctionHeadLocation = getFunctionHeadLocation;
|
| 2465 |
+
exports.getFunctionNameWithKind = getFunctionNameWithKind;
|
| 2466 |
+
exports.getInnermostScope = getInnermostScope;
|
| 2467 |
+
exports.getPropertyName = getPropertyName;
|
| 2468 |
+
exports.getStaticValue = getStaticValue;
|
| 2469 |
+
exports.getStringIfConstant = getStringIfConstant;
|
| 2470 |
+
exports.hasSideEffect = hasSideEffect;
|
| 2471 |
+
exports.isArrowToken = isArrowToken;
|
| 2472 |
+
exports.isClosingBraceToken = isClosingBraceToken;
|
| 2473 |
+
exports.isClosingBracketToken = isClosingBracketToken;
|
| 2474 |
+
exports.isClosingParenToken = isClosingParenToken;
|
| 2475 |
+
exports.isColonToken = isColonToken;
|
| 2476 |
+
exports.isCommaToken = isCommaToken;
|
| 2477 |
+
exports.isCommentToken = isCommentToken;
|
| 2478 |
+
exports.isNotArrowToken = isNotArrowToken;
|
| 2479 |
+
exports.isNotClosingBraceToken = isNotClosingBraceToken;
|
| 2480 |
+
exports.isNotClosingBracketToken = isNotClosingBracketToken;
|
| 2481 |
+
exports.isNotClosingParenToken = isNotClosingParenToken;
|
| 2482 |
+
exports.isNotColonToken = isNotColonToken;
|
| 2483 |
+
exports.isNotCommaToken = isNotCommaToken;
|
| 2484 |
+
exports.isNotCommentToken = isNotCommentToken;
|
| 2485 |
+
exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
|
| 2486 |
+
exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
|
| 2487 |
+
exports.isNotOpeningParenToken = isNotOpeningParenToken;
|
| 2488 |
+
exports.isNotSemicolonToken = isNotSemicolonToken;
|
| 2489 |
+
exports.isOpeningBraceToken = isOpeningBraceToken;
|
| 2490 |
+
exports.isOpeningBracketToken = isOpeningBracketToken;
|
| 2491 |
+
exports.isOpeningParenToken = isOpeningParenToken;
|
| 2492 |
+
exports.isParenthesized = isParenthesized;
|
| 2493 |
+
exports.isSemicolonToken = isSemicolonToken;
|
| 2494 |
+
//# sourceMappingURL=index.js.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.mjs
ADDED
|
@@ -0,0 +1,2453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getKeys, KEYS } from 'eslint-visitor-keys';
|
| 2 |
+
|
| 3 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 4 |
+
/** @typedef {import("estree").Node} Node */
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Get the innermost scope which contains a given location.
|
| 8 |
+
* @param {Scope} initialScope The initial scope to search.
|
| 9 |
+
* @param {Node} node The location to search.
|
| 10 |
+
* @returns {Scope} The innermost scope.
|
| 11 |
+
*/
|
| 12 |
+
function getInnermostScope(initialScope, node) {
|
| 13 |
+
const location = /** @type {[number, number]} */ (node.range)[0];
|
| 14 |
+
|
| 15 |
+
let scope = initialScope;
|
| 16 |
+
let found = false;
|
| 17 |
+
do {
|
| 18 |
+
found = false;
|
| 19 |
+
for (const childScope of scope.childScopes) {
|
| 20 |
+
const range = /** @type {[number, number]} */ (
|
| 21 |
+
childScope.block.range
|
| 22 |
+
);
|
| 23 |
+
|
| 24 |
+
if (range[0] <= location && location < range[1]) {
|
| 25 |
+
scope = childScope;
|
| 26 |
+
found = true;
|
| 27 |
+
break
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
} while (found)
|
| 31 |
+
|
| 32 |
+
return scope
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 36 |
+
/** @typedef {import("eslint").Scope.Variable} Variable */
|
| 37 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Find the variable of a given name.
|
| 41 |
+
* @param {Scope} initialScope The scope to start finding.
|
| 42 |
+
* @param {string|Identifier} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
|
| 43 |
+
* @returns {Variable|null} The found variable or null.
|
| 44 |
+
*/
|
| 45 |
+
function findVariable(initialScope, nameOrNode) {
|
| 46 |
+
let name = "";
|
| 47 |
+
/** @type {Scope|null} */
|
| 48 |
+
let scope = initialScope;
|
| 49 |
+
|
| 50 |
+
if (typeof nameOrNode === "string") {
|
| 51 |
+
name = nameOrNode;
|
| 52 |
+
} else {
|
| 53 |
+
name = nameOrNode.name;
|
| 54 |
+
scope = getInnermostScope(scope, nameOrNode);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
while (scope != null) {
|
| 58 |
+
const variable = scope.set.get(name);
|
| 59 |
+
if (variable != null) {
|
| 60 |
+
return variable
|
| 61 |
+
}
|
| 62 |
+
scope = scope.upper;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return null
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 69 |
+
/** @typedef {import("estree").Comment} Comment */
|
| 70 |
+
/** @typedef {import("./types.mjs").ArrowToken} ArrowToken */
|
| 71 |
+
/** @typedef {import("./types.mjs").CommaToken} CommaToken */
|
| 72 |
+
/** @typedef {import("./types.mjs").SemicolonToken} SemicolonToken */
|
| 73 |
+
/** @typedef {import("./types.mjs").ColonToken} ColonToken */
|
| 74 |
+
/** @typedef {import("./types.mjs").OpeningParenToken} OpeningParenToken */
|
| 75 |
+
/** @typedef {import("./types.mjs").ClosingParenToken} ClosingParenToken */
|
| 76 |
+
/** @typedef {import("./types.mjs").OpeningBracketToken} OpeningBracketToken */
|
| 77 |
+
/** @typedef {import("./types.mjs").ClosingBracketToken} ClosingBracketToken */
|
| 78 |
+
/** @typedef {import("./types.mjs").OpeningBraceToken} OpeningBraceToken */
|
| 79 |
+
/** @typedef {import("./types.mjs").ClosingBraceToken} ClosingBraceToken */
|
| 80 |
+
/**
|
| 81 |
+
* @template {string} Value
|
| 82 |
+
* @typedef {import("./types.mjs").PunctuatorToken<Value>} PunctuatorToken
|
| 83 |
+
*/
|
| 84 |
+
|
| 85 |
+
/** @typedef {Comment | Token} CommentOrToken */
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Creates the negate function of the given function.
|
| 89 |
+
* @param {function(CommentOrToken):boolean} f - The function to negate.
|
| 90 |
+
* @returns {function(CommentOrToken):boolean} Negated function.
|
| 91 |
+
*/
|
| 92 |
+
function negate(f) {
|
| 93 |
+
return (token) => !f(token)
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Checks if the given token is a PunctuatorToken with the given value
|
| 98 |
+
* @template {string} Value
|
| 99 |
+
* @param {CommentOrToken} token - The token to check.
|
| 100 |
+
* @param {Value} value - The value to check.
|
| 101 |
+
* @returns {token is PunctuatorToken<Value>} `true` if the token is a PunctuatorToken with the given value.
|
| 102 |
+
*/
|
| 103 |
+
function isPunctuatorTokenWithValue(token, value) {
|
| 104 |
+
return token.type === "Punctuator" && token.value === value
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Checks if the given token is an arrow token or not.
|
| 109 |
+
* @param {CommentOrToken} token - The token to check.
|
| 110 |
+
* @returns {token is ArrowToken} `true` if the token is an arrow token.
|
| 111 |
+
*/
|
| 112 |
+
function isArrowToken(token) {
|
| 113 |
+
return isPunctuatorTokenWithValue(token, "=>")
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Checks if the given token is a comma token or not.
|
| 118 |
+
* @param {CommentOrToken} token - The token to check.
|
| 119 |
+
* @returns {token is CommaToken} `true` if the token is a comma token.
|
| 120 |
+
*/
|
| 121 |
+
function isCommaToken(token) {
|
| 122 |
+
return isPunctuatorTokenWithValue(token, ",")
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* Checks if the given token is a semicolon token or not.
|
| 127 |
+
* @param {CommentOrToken} token - The token to check.
|
| 128 |
+
* @returns {token is SemicolonToken} `true` if the token is a semicolon token.
|
| 129 |
+
*/
|
| 130 |
+
function isSemicolonToken(token) {
|
| 131 |
+
return isPunctuatorTokenWithValue(token, ";")
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Checks if the given token is a colon token or not.
|
| 136 |
+
* @param {CommentOrToken} token - The token to check.
|
| 137 |
+
* @returns {token is ColonToken} `true` if the token is a colon token.
|
| 138 |
+
*/
|
| 139 |
+
function isColonToken(token) {
|
| 140 |
+
return isPunctuatorTokenWithValue(token, ":")
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* Checks if the given token is an opening parenthesis token or not.
|
| 145 |
+
* @param {CommentOrToken} token - The token to check.
|
| 146 |
+
* @returns {token is OpeningParenToken} `true` if the token is an opening parenthesis token.
|
| 147 |
+
*/
|
| 148 |
+
function isOpeningParenToken(token) {
|
| 149 |
+
return isPunctuatorTokenWithValue(token, "(")
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* Checks if the given token is a closing parenthesis token or not.
|
| 154 |
+
* @param {CommentOrToken} token - The token to check.
|
| 155 |
+
* @returns {token is ClosingParenToken} `true` if the token is a closing parenthesis token.
|
| 156 |
+
*/
|
| 157 |
+
function isClosingParenToken(token) {
|
| 158 |
+
return isPunctuatorTokenWithValue(token, ")")
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* Checks if the given token is an opening square bracket token or not.
|
| 163 |
+
* @param {CommentOrToken} token - The token to check.
|
| 164 |
+
* @returns {token is OpeningBracketToken} `true` if the token is an opening square bracket token.
|
| 165 |
+
*/
|
| 166 |
+
function isOpeningBracketToken(token) {
|
| 167 |
+
return isPunctuatorTokenWithValue(token, "[")
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Checks if the given token is a closing square bracket token or not.
|
| 172 |
+
* @param {CommentOrToken} token - The token to check.
|
| 173 |
+
* @returns {token is ClosingBracketToken} `true` if the token is a closing square bracket token.
|
| 174 |
+
*/
|
| 175 |
+
function isClosingBracketToken(token) {
|
| 176 |
+
return isPunctuatorTokenWithValue(token, "]")
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Checks if the given token is an opening brace token or not.
|
| 181 |
+
* @param {CommentOrToken} token - The token to check.
|
| 182 |
+
* @returns {token is OpeningBraceToken} `true` if the token is an opening brace token.
|
| 183 |
+
*/
|
| 184 |
+
function isOpeningBraceToken(token) {
|
| 185 |
+
return isPunctuatorTokenWithValue(token, "{")
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Checks if the given token is a closing brace token or not.
|
| 190 |
+
* @param {CommentOrToken} token - The token to check.
|
| 191 |
+
* @returns {token is ClosingBraceToken} `true` if the token is a closing brace token.
|
| 192 |
+
*/
|
| 193 |
+
function isClosingBraceToken(token) {
|
| 194 |
+
return isPunctuatorTokenWithValue(token, "}")
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Checks if the given token is a comment token or not.
|
| 199 |
+
* @param {CommentOrToken} token - The token to check.
|
| 200 |
+
* @returns {token is Comment} `true` if the token is a comment token.
|
| 201 |
+
*/
|
| 202 |
+
function isCommentToken(token) {
|
| 203 |
+
return ["Block", "Line", "Shebang"].includes(token.type)
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
const isNotArrowToken = negate(isArrowToken);
|
| 207 |
+
const isNotCommaToken = negate(isCommaToken);
|
| 208 |
+
const isNotSemicolonToken = negate(isSemicolonToken);
|
| 209 |
+
const isNotColonToken = negate(isColonToken);
|
| 210 |
+
const isNotOpeningParenToken = negate(isOpeningParenToken);
|
| 211 |
+
const isNotClosingParenToken = negate(isClosingParenToken);
|
| 212 |
+
const isNotOpeningBracketToken = negate(isOpeningBracketToken);
|
| 213 |
+
const isNotClosingBracketToken = negate(isClosingBracketToken);
|
| 214 |
+
const isNotOpeningBraceToken = negate(isOpeningBraceToken);
|
| 215 |
+
const isNotClosingBraceToken = negate(isClosingBraceToken);
|
| 216 |
+
const isNotCommentToken = negate(isCommentToken);
|
| 217 |
+
|
| 218 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 219 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 220 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 221 |
+
/** @typedef {import("estree").Function} FunctionNode */
|
| 222 |
+
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
|
| 223 |
+
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
| 224 |
+
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
| 225 |
+
/** @typedef {import("estree").Position} Position */
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Get the `(` token of the given function node.
|
| 229 |
+
* @param {FunctionExpression | FunctionDeclaration} node - The function node to get.
|
| 230 |
+
* @param {SourceCode} sourceCode - The source code object to get tokens.
|
| 231 |
+
* @returns {Token} `(` token.
|
| 232 |
+
*/
|
| 233 |
+
function getOpeningParenOfParams(node, sourceCode) {
|
| 234 |
+
return node.id
|
| 235 |
+
? /** @type {Token} */ (
|
| 236 |
+
sourceCode.getTokenAfter(node.id, isOpeningParenToken)
|
| 237 |
+
)
|
| 238 |
+
: /** @type {Token} */ (
|
| 239 |
+
sourceCode.getFirstToken(node, isOpeningParenToken)
|
| 240 |
+
)
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* Get the location of the given function node for reporting.
|
| 245 |
+
* @param {FunctionNode} node - The function node to get.
|
| 246 |
+
* @param {SourceCode} sourceCode - The source code object to get tokens.
|
| 247 |
+
* @returns {SourceLocation|null} The location of the function node for reporting.
|
| 248 |
+
*/
|
| 249 |
+
function getFunctionHeadLocation(node, sourceCode) {
|
| 250 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 251 |
+
|
| 252 |
+
/** @type {Position|null} */
|
| 253 |
+
let start = null;
|
| 254 |
+
/** @type {Position|null} */
|
| 255 |
+
let end = null;
|
| 256 |
+
|
| 257 |
+
if (node.type === "ArrowFunctionExpression") {
|
| 258 |
+
const arrowToken = /** @type {Token} */ (
|
| 259 |
+
sourceCode.getTokenBefore(node.body, isArrowToken)
|
| 260 |
+
);
|
| 261 |
+
|
| 262 |
+
start = arrowToken.loc.start;
|
| 263 |
+
end = arrowToken.loc.end;
|
| 264 |
+
} else if (
|
| 265 |
+
parent.type === "Property" ||
|
| 266 |
+
parent.type === "MethodDefinition" ||
|
| 267 |
+
parent.type === "PropertyDefinition"
|
| 268 |
+
) {
|
| 269 |
+
start = /** @type {SourceLocation} */ (parent.loc).start;
|
| 270 |
+
end = getOpeningParenOfParams(node, sourceCode).loc.start;
|
| 271 |
+
} else {
|
| 272 |
+
start = /** @type {SourceLocation} */ (node.loc).start;
|
| 273 |
+
end = getOpeningParenOfParams(node, sourceCode).loc.start;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
return {
|
| 277 |
+
start: { ...start },
|
| 278 |
+
end: { ...end },
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/* globals globalThis, global, self, window */
|
| 283 |
+
/** @typedef {import("./types.mjs").StaticValue} StaticValue */
|
| 284 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 285 |
+
/** @typedef {import("estree").Node} Node */
|
| 286 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
|
| 287 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.AST_NODE_TYPES} TSESTreeNodeTypes */
|
| 288 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.MemberExpression} MemberExpression */
|
| 289 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Property} Property */
|
| 290 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.RegExpLiteral} RegExpLiteral */
|
| 291 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.BigIntLiteral} BigIntLiteral */
|
| 292 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Literal} Literal */
|
| 293 |
+
|
| 294 |
+
const globalObject =
|
| 295 |
+
typeof globalThis !== "undefined"
|
| 296 |
+
? globalThis
|
| 297 |
+
: // @ts-ignore
|
| 298 |
+
typeof self !== "undefined"
|
| 299 |
+
? // @ts-ignore
|
| 300 |
+
self
|
| 301 |
+
: // @ts-ignore
|
| 302 |
+
typeof window !== "undefined"
|
| 303 |
+
? // @ts-ignore
|
| 304 |
+
window
|
| 305 |
+
: typeof global !== "undefined"
|
| 306 |
+
? global
|
| 307 |
+
: {};
|
| 308 |
+
|
| 309 |
+
const builtinNames = Object.freeze(
|
| 310 |
+
new Set([
|
| 311 |
+
"Array",
|
| 312 |
+
"ArrayBuffer",
|
| 313 |
+
"BigInt",
|
| 314 |
+
"BigInt64Array",
|
| 315 |
+
"BigUint64Array",
|
| 316 |
+
"Boolean",
|
| 317 |
+
"DataView",
|
| 318 |
+
"Date",
|
| 319 |
+
"decodeURI",
|
| 320 |
+
"decodeURIComponent",
|
| 321 |
+
"encodeURI",
|
| 322 |
+
"encodeURIComponent",
|
| 323 |
+
"escape",
|
| 324 |
+
"Float32Array",
|
| 325 |
+
"Float64Array",
|
| 326 |
+
"Function",
|
| 327 |
+
"Infinity",
|
| 328 |
+
"Int16Array",
|
| 329 |
+
"Int32Array",
|
| 330 |
+
"Int8Array",
|
| 331 |
+
"isFinite",
|
| 332 |
+
"isNaN",
|
| 333 |
+
"isPrototypeOf",
|
| 334 |
+
"JSON",
|
| 335 |
+
"Map",
|
| 336 |
+
"Math",
|
| 337 |
+
"NaN",
|
| 338 |
+
"Number",
|
| 339 |
+
"Object",
|
| 340 |
+
"parseFloat",
|
| 341 |
+
"parseInt",
|
| 342 |
+
"Promise",
|
| 343 |
+
"Proxy",
|
| 344 |
+
"Reflect",
|
| 345 |
+
"RegExp",
|
| 346 |
+
"Set",
|
| 347 |
+
"String",
|
| 348 |
+
"Symbol",
|
| 349 |
+
"Uint16Array",
|
| 350 |
+
"Uint32Array",
|
| 351 |
+
"Uint8Array",
|
| 352 |
+
"Uint8ClampedArray",
|
| 353 |
+
"undefined",
|
| 354 |
+
"unescape",
|
| 355 |
+
"WeakMap",
|
| 356 |
+
"WeakSet",
|
| 357 |
+
]),
|
| 358 |
+
);
|
| 359 |
+
const callAllowed = new Set(
|
| 360 |
+
[
|
| 361 |
+
Array.isArray,
|
| 362 |
+
Array.of,
|
| 363 |
+
Array.prototype.at,
|
| 364 |
+
Array.prototype.concat,
|
| 365 |
+
Array.prototype.entries,
|
| 366 |
+
Array.prototype.every,
|
| 367 |
+
Array.prototype.filter,
|
| 368 |
+
Array.prototype.find,
|
| 369 |
+
Array.prototype.findIndex,
|
| 370 |
+
Array.prototype.flat,
|
| 371 |
+
Array.prototype.includes,
|
| 372 |
+
Array.prototype.indexOf,
|
| 373 |
+
Array.prototype.join,
|
| 374 |
+
Array.prototype.keys,
|
| 375 |
+
Array.prototype.lastIndexOf,
|
| 376 |
+
Array.prototype.slice,
|
| 377 |
+
Array.prototype.some,
|
| 378 |
+
Array.prototype.toString,
|
| 379 |
+
Array.prototype.values,
|
| 380 |
+
typeof BigInt === "function" ? BigInt : undefined,
|
| 381 |
+
Boolean,
|
| 382 |
+
Date,
|
| 383 |
+
Date.parse,
|
| 384 |
+
decodeURI,
|
| 385 |
+
decodeURIComponent,
|
| 386 |
+
encodeURI,
|
| 387 |
+
encodeURIComponent,
|
| 388 |
+
escape,
|
| 389 |
+
isFinite,
|
| 390 |
+
isNaN,
|
| 391 |
+
// @ts-ignore
|
| 392 |
+
isPrototypeOf,
|
| 393 |
+
Map,
|
| 394 |
+
Map.prototype.entries,
|
| 395 |
+
Map.prototype.get,
|
| 396 |
+
Map.prototype.has,
|
| 397 |
+
Map.prototype.keys,
|
| 398 |
+
Map.prototype.values,
|
| 399 |
+
.../** @type {(keyof typeof Math)[]} */ (
|
| 400 |
+
Object.getOwnPropertyNames(Math)
|
| 401 |
+
)
|
| 402 |
+
.filter((k) => k !== "random")
|
| 403 |
+
.map((k) => Math[k])
|
| 404 |
+
.filter((f) => typeof f === "function"),
|
| 405 |
+
Number,
|
| 406 |
+
Number.isFinite,
|
| 407 |
+
Number.isNaN,
|
| 408 |
+
Number.parseFloat,
|
| 409 |
+
Number.parseInt,
|
| 410 |
+
Number.prototype.toExponential,
|
| 411 |
+
Number.prototype.toFixed,
|
| 412 |
+
Number.prototype.toPrecision,
|
| 413 |
+
Number.prototype.toString,
|
| 414 |
+
Object,
|
| 415 |
+
Object.entries,
|
| 416 |
+
Object.is,
|
| 417 |
+
Object.isExtensible,
|
| 418 |
+
Object.isFrozen,
|
| 419 |
+
Object.isSealed,
|
| 420 |
+
Object.keys,
|
| 421 |
+
Object.values,
|
| 422 |
+
parseFloat,
|
| 423 |
+
parseInt,
|
| 424 |
+
RegExp,
|
| 425 |
+
Set,
|
| 426 |
+
Set.prototype.entries,
|
| 427 |
+
Set.prototype.has,
|
| 428 |
+
Set.prototype.keys,
|
| 429 |
+
Set.prototype.values,
|
| 430 |
+
String,
|
| 431 |
+
String.fromCharCode,
|
| 432 |
+
String.fromCodePoint,
|
| 433 |
+
String.raw,
|
| 434 |
+
String.prototype.at,
|
| 435 |
+
String.prototype.charAt,
|
| 436 |
+
String.prototype.charCodeAt,
|
| 437 |
+
String.prototype.codePointAt,
|
| 438 |
+
String.prototype.concat,
|
| 439 |
+
String.prototype.endsWith,
|
| 440 |
+
String.prototype.includes,
|
| 441 |
+
String.prototype.indexOf,
|
| 442 |
+
String.prototype.lastIndexOf,
|
| 443 |
+
String.prototype.normalize,
|
| 444 |
+
String.prototype.padEnd,
|
| 445 |
+
String.prototype.padStart,
|
| 446 |
+
String.prototype.slice,
|
| 447 |
+
String.prototype.startsWith,
|
| 448 |
+
String.prototype.substr,
|
| 449 |
+
String.prototype.substring,
|
| 450 |
+
String.prototype.toLowerCase,
|
| 451 |
+
String.prototype.toString,
|
| 452 |
+
String.prototype.toUpperCase,
|
| 453 |
+
String.prototype.trim,
|
| 454 |
+
String.prototype.trimEnd,
|
| 455 |
+
String.prototype.trimLeft,
|
| 456 |
+
String.prototype.trimRight,
|
| 457 |
+
String.prototype.trimStart,
|
| 458 |
+
Symbol.for,
|
| 459 |
+
Symbol.keyFor,
|
| 460 |
+
unescape,
|
| 461 |
+
].filter((f) => typeof f === "function"),
|
| 462 |
+
);
|
| 463 |
+
const callPassThrough = new Set([
|
| 464 |
+
Object.freeze,
|
| 465 |
+
Object.preventExtensions,
|
| 466 |
+
Object.seal,
|
| 467 |
+
]);
|
| 468 |
+
|
| 469 |
+
/** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
|
| 470 |
+
const getterAllowed = [
|
| 471 |
+
[Map, new Set(["size"])],
|
| 472 |
+
[
|
| 473 |
+
RegExp,
|
| 474 |
+
new Set([
|
| 475 |
+
"dotAll",
|
| 476 |
+
"flags",
|
| 477 |
+
"global",
|
| 478 |
+
"hasIndices",
|
| 479 |
+
"ignoreCase",
|
| 480 |
+
"multiline",
|
| 481 |
+
"source",
|
| 482 |
+
"sticky",
|
| 483 |
+
"unicode",
|
| 484 |
+
]),
|
| 485 |
+
],
|
| 486 |
+
[Set, new Set(["size"])],
|
| 487 |
+
];
|
| 488 |
+
|
| 489 |
+
/**
|
| 490 |
+
* Get the property descriptor.
|
| 491 |
+
* @param {object} object The object to get.
|
| 492 |
+
* @param {string|number|symbol} name The property name to get.
|
| 493 |
+
*/
|
| 494 |
+
function getPropertyDescriptor(object, name) {
|
| 495 |
+
let x = object;
|
| 496 |
+
while ((typeof x === "object" || typeof x === "function") && x !== null) {
|
| 497 |
+
const d = Object.getOwnPropertyDescriptor(x, name);
|
| 498 |
+
if (d) {
|
| 499 |
+
return d
|
| 500 |
+
}
|
| 501 |
+
x = Object.getPrototypeOf(x);
|
| 502 |
+
}
|
| 503 |
+
return null
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
/**
|
| 507 |
+
* Check if a property is getter or not.
|
| 508 |
+
* @param {object} object The object to check.
|
| 509 |
+
* @param {string|number|symbol} name The property name to check.
|
| 510 |
+
*/
|
| 511 |
+
function isGetter(object, name) {
|
| 512 |
+
const d = getPropertyDescriptor(object, name);
|
| 513 |
+
return d != null && d.get != null
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
/**
|
| 517 |
+
* Get the element values of a given node list.
|
| 518 |
+
* @param {(Node|TSESTreeNode|null)[]} nodeList The node list to get values.
|
| 519 |
+
* @param {Scope|undefined|null} initialScope The initial scope to find variables.
|
| 520 |
+
* @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
|
| 521 |
+
*/
|
| 522 |
+
function getElementValues(nodeList, initialScope) {
|
| 523 |
+
const valueList = [];
|
| 524 |
+
|
| 525 |
+
for (let i = 0; i < nodeList.length; ++i) {
|
| 526 |
+
const elementNode = nodeList[i];
|
| 527 |
+
|
| 528 |
+
if (elementNode == null) {
|
| 529 |
+
valueList.length = i + 1;
|
| 530 |
+
} else if (elementNode.type === "SpreadElement") {
|
| 531 |
+
const argument = getStaticValueR(elementNode.argument, initialScope);
|
| 532 |
+
if (argument == null) {
|
| 533 |
+
return null
|
| 534 |
+
}
|
| 535 |
+
valueList.push(.../** @type {Iterable<any>} */ (argument.value));
|
| 536 |
+
} else {
|
| 537 |
+
const element = getStaticValueR(elementNode, initialScope);
|
| 538 |
+
if (element == null) {
|
| 539 |
+
return null
|
| 540 |
+
}
|
| 541 |
+
valueList.push(element.value);
|
| 542 |
+
}
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
return valueList
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
/**
|
| 549 |
+
* Returns whether the given variable is never written to after initialization.
|
| 550 |
+
* @param {import("eslint").Scope.Variable} variable
|
| 551 |
+
* @returns {boolean}
|
| 552 |
+
*/
|
| 553 |
+
function isEffectivelyConst(variable) {
|
| 554 |
+
const refs = variable.references;
|
| 555 |
+
|
| 556 |
+
const inits = refs.filter((r) => r.init).length;
|
| 557 |
+
const reads = refs.filter((r) => r.isReadOnly()).length;
|
| 558 |
+
if (inits === 1 && reads + inits === refs.length) {
|
| 559 |
+
// there is only one init and all other references only read
|
| 560 |
+
return true
|
| 561 |
+
}
|
| 562 |
+
return false
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
/**
|
| 566 |
+
* @template {TSESTreeNodeTypes} T
|
| 567 |
+
* @callback VisitorCallback
|
| 568 |
+
* @param {TSESTreeNode & { type: T }} node
|
| 569 |
+
* @param {Scope|undefined|null} initialScope
|
| 570 |
+
* @returns {StaticValue | null}
|
| 571 |
+
*/
|
| 572 |
+
/**
|
| 573 |
+
* @typedef { { [K in TSESTreeNodeTypes]?: VisitorCallback<K> } } Operations
|
| 574 |
+
*/
|
| 575 |
+
/**
|
| 576 |
+
* @type {Operations}
|
| 577 |
+
*/
|
| 578 |
+
const operations = Object.freeze({
|
| 579 |
+
ArrayExpression(node, initialScope) {
|
| 580 |
+
const elements = getElementValues(node.elements, initialScope);
|
| 581 |
+
return elements != null ? { value: elements } : null
|
| 582 |
+
},
|
| 583 |
+
|
| 584 |
+
AssignmentExpression(node, initialScope) {
|
| 585 |
+
if (node.operator === "=") {
|
| 586 |
+
return getStaticValueR(node.right, initialScope)
|
| 587 |
+
}
|
| 588 |
+
return null
|
| 589 |
+
},
|
| 590 |
+
|
| 591 |
+
//eslint-disable-next-line complexity
|
| 592 |
+
BinaryExpression(node, initialScope) {
|
| 593 |
+
if (node.operator === "in" || node.operator === "instanceof") {
|
| 594 |
+
// Not supported.
|
| 595 |
+
return null
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
const left = getStaticValueR(node.left, initialScope);
|
| 599 |
+
const right = getStaticValueR(node.right, initialScope);
|
| 600 |
+
if (left != null && right != null) {
|
| 601 |
+
switch (node.operator) {
|
| 602 |
+
case "==":
|
| 603 |
+
return { value: left.value == right.value } //eslint-disable-line eqeqeq
|
| 604 |
+
case "!=":
|
| 605 |
+
return { value: left.value != right.value } //eslint-disable-line eqeqeq
|
| 606 |
+
case "===":
|
| 607 |
+
return { value: left.value === right.value }
|
| 608 |
+
case "!==":
|
| 609 |
+
return { value: left.value !== right.value }
|
| 610 |
+
case "<":
|
| 611 |
+
return {
|
| 612 |
+
value:
|
| 613 |
+
/** @type {any} */ (left.value) <
|
| 614 |
+
/** @type {any} */ (right.value),
|
| 615 |
+
}
|
| 616 |
+
case "<=":
|
| 617 |
+
return {
|
| 618 |
+
value:
|
| 619 |
+
/** @type {any} */ (left.value) <=
|
| 620 |
+
/** @type {any} */ (right.value),
|
| 621 |
+
}
|
| 622 |
+
case ">":
|
| 623 |
+
return {
|
| 624 |
+
value:
|
| 625 |
+
/** @type {any} */ (left.value) >
|
| 626 |
+
/** @type {any} */ (right.value),
|
| 627 |
+
}
|
| 628 |
+
case ">=":
|
| 629 |
+
return {
|
| 630 |
+
value:
|
| 631 |
+
/** @type {any} */ (left.value) >=
|
| 632 |
+
/** @type {any} */ (right.value),
|
| 633 |
+
}
|
| 634 |
+
case "<<":
|
| 635 |
+
return {
|
| 636 |
+
value:
|
| 637 |
+
/** @type {any} */ (left.value) <<
|
| 638 |
+
/** @type {any} */ (right.value),
|
| 639 |
+
}
|
| 640 |
+
case ">>":
|
| 641 |
+
return {
|
| 642 |
+
value:
|
| 643 |
+
/** @type {any} */ (left.value) >>
|
| 644 |
+
/** @type {any} */ (right.value),
|
| 645 |
+
}
|
| 646 |
+
case ">>>":
|
| 647 |
+
return {
|
| 648 |
+
value:
|
| 649 |
+
/** @type {any} */ (left.value) >>>
|
| 650 |
+
/** @type {any} */ (right.value),
|
| 651 |
+
}
|
| 652 |
+
case "+":
|
| 653 |
+
return {
|
| 654 |
+
value:
|
| 655 |
+
/** @type {any} */ (left.value) +
|
| 656 |
+
/** @type {any} */ (right.value),
|
| 657 |
+
}
|
| 658 |
+
case "-":
|
| 659 |
+
return {
|
| 660 |
+
value:
|
| 661 |
+
/** @type {any} */ (left.value) -
|
| 662 |
+
/** @type {any} */ (right.value),
|
| 663 |
+
}
|
| 664 |
+
case "*":
|
| 665 |
+
return {
|
| 666 |
+
value:
|
| 667 |
+
/** @type {any} */ (left.value) *
|
| 668 |
+
/** @type {any} */ (right.value),
|
| 669 |
+
}
|
| 670 |
+
case "/":
|
| 671 |
+
return {
|
| 672 |
+
value:
|
| 673 |
+
/** @type {any} */ (left.value) /
|
| 674 |
+
/** @type {any} */ (right.value),
|
| 675 |
+
}
|
| 676 |
+
case "%":
|
| 677 |
+
return {
|
| 678 |
+
value:
|
| 679 |
+
/** @type {any} */ (left.value) %
|
| 680 |
+
/** @type {any} */ (right.value),
|
| 681 |
+
}
|
| 682 |
+
case "**":
|
| 683 |
+
return {
|
| 684 |
+
value:
|
| 685 |
+
/** @type {any} */ (left.value) **
|
| 686 |
+
/** @type {any} */ (right.value),
|
| 687 |
+
}
|
| 688 |
+
case "|":
|
| 689 |
+
return {
|
| 690 |
+
value:
|
| 691 |
+
/** @type {any} */ (left.value) |
|
| 692 |
+
/** @type {any} */ (right.value),
|
| 693 |
+
}
|
| 694 |
+
case "^":
|
| 695 |
+
return {
|
| 696 |
+
value:
|
| 697 |
+
/** @type {any} */ (left.value) ^
|
| 698 |
+
/** @type {any} */ (right.value),
|
| 699 |
+
}
|
| 700 |
+
case "&":
|
| 701 |
+
return {
|
| 702 |
+
value:
|
| 703 |
+
/** @type {any} */ (left.value) &
|
| 704 |
+
/** @type {any} */ (right.value),
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
// no default
|
| 708 |
+
}
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
return null
|
| 712 |
+
},
|
| 713 |
+
|
| 714 |
+
CallExpression(node, initialScope) {
|
| 715 |
+
const calleeNode = node.callee;
|
| 716 |
+
const args = getElementValues(node.arguments, initialScope);
|
| 717 |
+
|
| 718 |
+
if (args != null) {
|
| 719 |
+
if (calleeNode.type === "MemberExpression") {
|
| 720 |
+
if (calleeNode.property.type === "PrivateIdentifier") {
|
| 721 |
+
return null
|
| 722 |
+
}
|
| 723 |
+
const object = getStaticValueR(calleeNode.object, initialScope);
|
| 724 |
+
if (object != null) {
|
| 725 |
+
if (
|
| 726 |
+
object.value == null &&
|
| 727 |
+
(object.optional || node.optional)
|
| 728 |
+
) {
|
| 729 |
+
return { value: undefined, optional: true }
|
| 730 |
+
}
|
| 731 |
+
const property = getStaticPropertyNameValue(
|
| 732 |
+
calleeNode,
|
| 733 |
+
initialScope,
|
| 734 |
+
);
|
| 735 |
+
|
| 736 |
+
if (property != null) {
|
| 737 |
+
const receiver =
|
| 738 |
+
/** @type {Record<PropertyKey, (...args: any[]) => any>} */ (
|
| 739 |
+
object.value
|
| 740 |
+
);
|
| 741 |
+
const methodName = /** @type {PropertyKey} */ (
|
| 742 |
+
property.value
|
| 743 |
+
);
|
| 744 |
+
if (callAllowed.has(receiver[methodName])) {
|
| 745 |
+
return {
|
| 746 |
+
value: receiver[methodName](...args),
|
| 747 |
+
}
|
| 748 |
+
}
|
| 749 |
+
if (callPassThrough.has(receiver[methodName])) {
|
| 750 |
+
return { value: args[0] }
|
| 751 |
+
}
|
| 752 |
+
}
|
| 753 |
+
}
|
| 754 |
+
} else {
|
| 755 |
+
const callee = getStaticValueR(calleeNode, initialScope);
|
| 756 |
+
if (callee != null) {
|
| 757 |
+
if (callee.value == null && node.optional) {
|
| 758 |
+
return { value: undefined, optional: true }
|
| 759 |
+
}
|
| 760 |
+
const func = /** @type {(...args: any[]) => any} */ (
|
| 761 |
+
callee.value
|
| 762 |
+
);
|
| 763 |
+
if (callAllowed.has(func)) {
|
| 764 |
+
return { value: func(...args) }
|
| 765 |
+
}
|
| 766 |
+
if (callPassThrough.has(func)) {
|
| 767 |
+
return { value: args[0] }
|
| 768 |
+
}
|
| 769 |
+
}
|
| 770 |
+
}
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
return null
|
| 774 |
+
},
|
| 775 |
+
|
| 776 |
+
ConditionalExpression(node, initialScope) {
|
| 777 |
+
const test = getStaticValueR(node.test, initialScope);
|
| 778 |
+
if (test != null) {
|
| 779 |
+
return test.value
|
| 780 |
+
? getStaticValueR(node.consequent, initialScope)
|
| 781 |
+
: getStaticValueR(node.alternate, initialScope)
|
| 782 |
+
}
|
| 783 |
+
return null
|
| 784 |
+
},
|
| 785 |
+
|
| 786 |
+
ExpressionStatement(node, initialScope) {
|
| 787 |
+
return getStaticValueR(node.expression, initialScope)
|
| 788 |
+
},
|
| 789 |
+
|
| 790 |
+
Identifier(node, initialScope) {
|
| 791 |
+
if (initialScope != null) {
|
| 792 |
+
const variable = findVariable(initialScope, node);
|
| 793 |
+
|
| 794 |
+
// Built-in globals.
|
| 795 |
+
if (
|
| 796 |
+
variable != null &&
|
| 797 |
+
variable.defs.length === 0 &&
|
| 798 |
+
builtinNames.has(variable.name) &&
|
| 799 |
+
variable.name in globalObject
|
| 800 |
+
) {
|
| 801 |
+
return { value: globalObject[variable.name] }
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
// Constants.
|
| 805 |
+
if (variable != null && variable.defs.length === 1) {
|
| 806 |
+
const def = variable.defs[0];
|
| 807 |
+
if (
|
| 808 |
+
def.parent &&
|
| 809 |
+
def.type === "Variable" &&
|
| 810 |
+
(def.parent.kind === "const" ||
|
| 811 |
+
isEffectivelyConst(variable)) &&
|
| 812 |
+
// TODO(mysticatea): don't support destructuring here.
|
| 813 |
+
def.node.id.type === "Identifier"
|
| 814 |
+
) {
|
| 815 |
+
return getStaticValueR(def.node.init, initialScope)
|
| 816 |
+
}
|
| 817 |
+
}
|
| 818 |
+
}
|
| 819 |
+
return null
|
| 820 |
+
},
|
| 821 |
+
|
| 822 |
+
Literal(node) {
|
| 823 |
+
const literal =
|
| 824 |
+
/** @type {Partial<Literal> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
|
| 825 |
+
node
|
| 826 |
+
);
|
| 827 |
+
//istanbul ignore if : this is implementation-specific behavior.
|
| 828 |
+
if (
|
| 829 |
+
(literal.regex != null || literal.bigint != null) &&
|
| 830 |
+
literal.value == null
|
| 831 |
+
) {
|
| 832 |
+
// It was a RegExp/BigInt literal, but Node.js didn't support it.
|
| 833 |
+
return null
|
| 834 |
+
}
|
| 835 |
+
return { value: literal.value }
|
| 836 |
+
},
|
| 837 |
+
|
| 838 |
+
LogicalExpression(node, initialScope) {
|
| 839 |
+
const left = getStaticValueR(node.left, initialScope);
|
| 840 |
+
if (left != null) {
|
| 841 |
+
if (
|
| 842 |
+
(node.operator === "||" && Boolean(left.value) === true) ||
|
| 843 |
+
(node.operator === "&&" && Boolean(left.value) === false) ||
|
| 844 |
+
(node.operator === "??" && left.value != null)
|
| 845 |
+
) {
|
| 846 |
+
return left
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
const right = getStaticValueR(node.right, initialScope);
|
| 850 |
+
if (right != null) {
|
| 851 |
+
return right
|
| 852 |
+
}
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
return null
|
| 856 |
+
},
|
| 857 |
+
|
| 858 |
+
MemberExpression(node, initialScope) {
|
| 859 |
+
if (node.property.type === "PrivateIdentifier") {
|
| 860 |
+
return null
|
| 861 |
+
}
|
| 862 |
+
const object = getStaticValueR(node.object, initialScope);
|
| 863 |
+
if (object != null) {
|
| 864 |
+
if (object.value == null && (object.optional || node.optional)) {
|
| 865 |
+
return { value: undefined, optional: true }
|
| 866 |
+
}
|
| 867 |
+
const property = getStaticPropertyNameValue(node, initialScope);
|
| 868 |
+
|
| 869 |
+
if (property != null) {
|
| 870 |
+
if (
|
| 871 |
+
!isGetter(
|
| 872 |
+
/** @type {object} */ (object.value),
|
| 873 |
+
/** @type {PropertyKey} */ (property.value),
|
| 874 |
+
)
|
| 875 |
+
) {
|
| 876 |
+
return {
|
| 877 |
+
value: /** @type {Record<PropertyKey, unknown>} */ (
|
| 878 |
+
object.value
|
| 879 |
+
)[/** @type {PropertyKey} */ (property.value)],
|
| 880 |
+
}
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
for (const [classFn, allowed] of getterAllowed) {
|
| 884 |
+
if (
|
| 885 |
+
object.value instanceof classFn &&
|
| 886 |
+
allowed.has(/** @type {string} */ (property.value))
|
| 887 |
+
) {
|
| 888 |
+
return {
|
| 889 |
+
value: /** @type {Record<PropertyKey, unknown>} */ (
|
| 890 |
+
object.value
|
| 891 |
+
)[/** @type {PropertyKey} */ (property.value)],
|
| 892 |
+
}
|
| 893 |
+
}
|
| 894 |
+
}
|
| 895 |
+
}
|
| 896 |
+
}
|
| 897 |
+
return null
|
| 898 |
+
},
|
| 899 |
+
|
| 900 |
+
ChainExpression(node, initialScope) {
|
| 901 |
+
const expression = getStaticValueR(node.expression, initialScope);
|
| 902 |
+
if (expression != null) {
|
| 903 |
+
return { value: expression.value }
|
| 904 |
+
}
|
| 905 |
+
return null
|
| 906 |
+
},
|
| 907 |
+
|
| 908 |
+
NewExpression(node, initialScope) {
|
| 909 |
+
const callee = getStaticValueR(node.callee, initialScope);
|
| 910 |
+
const args = getElementValues(node.arguments, initialScope);
|
| 911 |
+
|
| 912 |
+
if (callee != null && args != null) {
|
| 913 |
+
const Func = /** @type {new (...args: any[]) => any} */ (
|
| 914 |
+
callee.value
|
| 915 |
+
);
|
| 916 |
+
if (callAllowed.has(Func)) {
|
| 917 |
+
return { value: new Func(...args) }
|
| 918 |
+
}
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
return null
|
| 922 |
+
},
|
| 923 |
+
|
| 924 |
+
ObjectExpression(node, initialScope) {
|
| 925 |
+
/** @type {Record<PropertyKey, unknown>} */
|
| 926 |
+
const object = {};
|
| 927 |
+
|
| 928 |
+
for (const propertyNode of node.properties) {
|
| 929 |
+
if (propertyNode.type === "Property") {
|
| 930 |
+
if (propertyNode.kind !== "init") {
|
| 931 |
+
return null
|
| 932 |
+
}
|
| 933 |
+
const key = getStaticPropertyNameValue(
|
| 934 |
+
propertyNode,
|
| 935 |
+
initialScope,
|
| 936 |
+
);
|
| 937 |
+
const value = getStaticValueR(propertyNode.value, initialScope);
|
| 938 |
+
if (key == null || value == null) {
|
| 939 |
+
return null
|
| 940 |
+
}
|
| 941 |
+
object[/** @type {PropertyKey} */ (key.value)] = value.value;
|
| 942 |
+
} else if (
|
| 943 |
+
propertyNode.type === "SpreadElement" ||
|
| 944 |
+
// @ts-expect-error -- Backward compatibility
|
| 945 |
+
propertyNode.type === "ExperimentalSpreadProperty"
|
| 946 |
+
) {
|
| 947 |
+
const argument = getStaticValueR(
|
| 948 |
+
propertyNode.argument,
|
| 949 |
+
initialScope,
|
| 950 |
+
);
|
| 951 |
+
if (argument == null) {
|
| 952 |
+
return null
|
| 953 |
+
}
|
| 954 |
+
Object.assign(object, argument.value);
|
| 955 |
+
} else {
|
| 956 |
+
return null
|
| 957 |
+
}
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
return { value: object }
|
| 961 |
+
},
|
| 962 |
+
|
| 963 |
+
SequenceExpression(node, initialScope) {
|
| 964 |
+
const last = node.expressions[node.expressions.length - 1];
|
| 965 |
+
return getStaticValueR(last, initialScope)
|
| 966 |
+
},
|
| 967 |
+
|
| 968 |
+
TaggedTemplateExpression(node, initialScope) {
|
| 969 |
+
const tag = getStaticValueR(node.tag, initialScope);
|
| 970 |
+
const expressions = getElementValues(
|
| 971 |
+
node.quasi.expressions,
|
| 972 |
+
initialScope,
|
| 973 |
+
);
|
| 974 |
+
|
| 975 |
+
if (tag != null && expressions != null) {
|
| 976 |
+
const func = /** @type {(...args: any[]) => any} */ (tag.value);
|
| 977 |
+
/** @type {any[] & { raw?: string[] }} */
|
| 978 |
+
const strings = node.quasi.quasis.map((q) => q.value.cooked);
|
| 979 |
+
strings.raw = node.quasi.quasis.map((q) => q.value.raw);
|
| 980 |
+
|
| 981 |
+
if (func === String.raw) {
|
| 982 |
+
return { value: func(strings, ...expressions) }
|
| 983 |
+
}
|
| 984 |
+
}
|
| 985 |
+
|
| 986 |
+
return null
|
| 987 |
+
},
|
| 988 |
+
|
| 989 |
+
TemplateLiteral(node, initialScope) {
|
| 990 |
+
const expressions = getElementValues(node.expressions, initialScope);
|
| 991 |
+
if (expressions != null) {
|
| 992 |
+
let value = node.quasis[0].value.cooked;
|
| 993 |
+
for (let i = 0; i < expressions.length; ++i) {
|
| 994 |
+
value += expressions[i];
|
| 995 |
+
value += /** @type {string} */ (node.quasis[i + 1].value.cooked);
|
| 996 |
+
}
|
| 997 |
+
return { value }
|
| 998 |
+
}
|
| 999 |
+
return null
|
| 1000 |
+
},
|
| 1001 |
+
|
| 1002 |
+
UnaryExpression(node, initialScope) {
|
| 1003 |
+
if (node.operator === "delete") {
|
| 1004 |
+
// Not supported.
|
| 1005 |
+
return null
|
| 1006 |
+
}
|
| 1007 |
+
if (node.operator === "void") {
|
| 1008 |
+
return { value: undefined }
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
const arg = getStaticValueR(node.argument, initialScope);
|
| 1012 |
+
if (arg != null) {
|
| 1013 |
+
switch (node.operator) {
|
| 1014 |
+
case "-":
|
| 1015 |
+
return { value: -(/** @type {any} */ (arg.value)) }
|
| 1016 |
+
case "+":
|
| 1017 |
+
return { value: +(/** @type {any} */ (arg.value)) } //eslint-disable-line no-implicit-coercion
|
| 1018 |
+
case "!":
|
| 1019 |
+
return { value: !arg.value }
|
| 1020 |
+
case "~":
|
| 1021 |
+
return { value: ~(/** @type {any} */ (arg.value)) }
|
| 1022 |
+
case "typeof":
|
| 1023 |
+
return { value: typeof arg.value }
|
| 1024 |
+
|
| 1025 |
+
// no default
|
| 1026 |
+
}
|
| 1027 |
+
}
|
| 1028 |
+
|
| 1029 |
+
return null
|
| 1030 |
+
},
|
| 1031 |
+
TSAsExpression(node, initialScope) {
|
| 1032 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1033 |
+
},
|
| 1034 |
+
TSSatisfiesExpression(node, initialScope) {
|
| 1035 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1036 |
+
},
|
| 1037 |
+
TSTypeAssertion(node, initialScope) {
|
| 1038 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1039 |
+
},
|
| 1040 |
+
TSNonNullExpression(node, initialScope) {
|
| 1041 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1042 |
+
},
|
| 1043 |
+
TSInstantiationExpression(node, initialScope) {
|
| 1044 |
+
return getStaticValueR(node.expression, initialScope)
|
| 1045 |
+
},
|
| 1046 |
+
});
|
| 1047 |
+
|
| 1048 |
+
/**
|
| 1049 |
+
* Get the value of a given node if it's a static value.
|
| 1050 |
+
* @param {Node|TSESTreeNode|null|undefined} node The node to get.
|
| 1051 |
+
* @param {Scope|undefined|null} initialScope The scope to start finding variable.
|
| 1052 |
+
* @returns {StaticValue|null} The static value of the node, or `null`.
|
| 1053 |
+
*/
|
| 1054 |
+
function getStaticValueR(node, initialScope) {
|
| 1055 |
+
if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
|
| 1056 |
+
return /** @type {VisitorCallback<any>} */ (operations[node.type])(
|
| 1057 |
+
/** @type {TSESTreeNode} */ (node),
|
| 1058 |
+
initialScope,
|
| 1059 |
+
)
|
| 1060 |
+
}
|
| 1061 |
+
return null
|
| 1062 |
+
}
|
| 1063 |
+
|
| 1064 |
+
/**
|
| 1065 |
+
* Get the static value of property name from a MemberExpression node or a Property node.
|
| 1066 |
+
* @param {MemberExpression|Property} node The node to get.
|
| 1067 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
|
| 1068 |
+
* @returns {StaticValue|null} The static value of the property name of the node, or `null`.
|
| 1069 |
+
*/
|
| 1070 |
+
function getStaticPropertyNameValue(node, initialScope) {
|
| 1071 |
+
const nameNode = node.type === "Property" ? node.key : node.property;
|
| 1072 |
+
|
| 1073 |
+
if (node.computed) {
|
| 1074 |
+
return getStaticValueR(nameNode, initialScope)
|
| 1075 |
+
}
|
| 1076 |
+
|
| 1077 |
+
if (nameNode.type === "Identifier") {
|
| 1078 |
+
return { value: nameNode.name }
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
if (nameNode.type === "Literal") {
|
| 1082 |
+
if (/** @type {Partial<BigIntLiteral>} */ (nameNode).bigint) {
|
| 1083 |
+
return { value: /** @type {BigIntLiteral} */ (nameNode).bigint }
|
| 1084 |
+
}
|
| 1085 |
+
return { value: String(nameNode.value) }
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
return null
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
/**
|
| 1092 |
+
* Get the value of a given node if it's a static value.
|
| 1093 |
+
* @param {Node} node The node to get.
|
| 1094 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
|
| 1095 |
+
* @returns {StaticValue | null} The static value of the node, or `null`.
|
| 1096 |
+
*/
|
| 1097 |
+
function getStaticValue(node, initialScope = null) {
|
| 1098 |
+
try {
|
| 1099 |
+
return getStaticValueR(node, initialScope)
|
| 1100 |
+
} catch (_error) {
|
| 1101 |
+
return null
|
| 1102 |
+
}
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1106 |
+
/** @typedef {import("estree").Node} Node */
|
| 1107 |
+
/** @typedef {import("estree").RegExpLiteral} RegExpLiteral */
|
| 1108 |
+
/** @typedef {import("estree").BigIntLiteral} BigIntLiteral */
|
| 1109 |
+
/** @typedef {import("estree").SimpleLiteral} SimpleLiteral */
|
| 1110 |
+
|
| 1111 |
+
/**
|
| 1112 |
+
* Get the value of a given node if it's a literal or a template literal.
|
| 1113 |
+
* @param {Node} node The node to get.
|
| 1114 |
+
* @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
|
| 1115 |
+
* @returns {string|null} The value of the node, or `null`.
|
| 1116 |
+
*/
|
| 1117 |
+
function getStringIfConstant(node, initialScope = null) {
|
| 1118 |
+
// Handle the literals that the platform doesn't support natively.
|
| 1119 |
+
if (node && node.type === "Literal" && node.value === null) {
|
| 1120 |
+
const literal =
|
| 1121 |
+
/** @type {Partial<SimpleLiteral> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
|
| 1122 |
+
node
|
| 1123 |
+
);
|
| 1124 |
+
if (literal.regex) {
|
| 1125 |
+
return `/${literal.regex.pattern}/${literal.regex.flags}`
|
| 1126 |
+
}
|
| 1127 |
+
if (literal.bigint) {
|
| 1128 |
+
return literal.bigint
|
| 1129 |
+
}
|
| 1130 |
+
}
|
| 1131 |
+
|
| 1132 |
+
const evaluated = getStaticValue(node, initialScope);
|
| 1133 |
+
|
| 1134 |
+
if (evaluated) {
|
| 1135 |
+
// `String(Symbol.prototype)` throws error
|
| 1136 |
+
try {
|
| 1137 |
+
return String(evaluated.value)
|
| 1138 |
+
} catch {
|
| 1139 |
+
// No op
|
| 1140 |
+
}
|
| 1141 |
+
}
|
| 1142 |
+
|
| 1143 |
+
return null
|
| 1144 |
+
}
|
| 1145 |
+
|
| 1146 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1147 |
+
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
| 1148 |
+
/** @typedef {import("estree").MethodDefinition} MethodDefinition */
|
| 1149 |
+
/** @typedef {import("estree").Property} Property */
|
| 1150 |
+
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
|
| 1151 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1152 |
+
|
| 1153 |
+
/**
|
| 1154 |
+
* Get the property name from a MemberExpression node or a Property node.
|
| 1155 |
+
* @param {MemberExpression | MethodDefinition | Property | PropertyDefinition} node The node to get.
|
| 1156 |
+
* @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
|
| 1157 |
+
* @returns {string|null|undefined} The property name of the node.
|
| 1158 |
+
*/
|
| 1159 |
+
function getPropertyName(node, initialScope) {
|
| 1160 |
+
switch (node.type) {
|
| 1161 |
+
case "MemberExpression":
|
| 1162 |
+
if (node.computed) {
|
| 1163 |
+
return getStringIfConstant(node.property, initialScope)
|
| 1164 |
+
}
|
| 1165 |
+
if (node.property.type === "PrivateIdentifier") {
|
| 1166 |
+
return null
|
| 1167 |
+
}
|
| 1168 |
+
return /** @type {Partial<Identifier>} */ (node.property).name
|
| 1169 |
+
|
| 1170 |
+
case "Property":
|
| 1171 |
+
case "MethodDefinition":
|
| 1172 |
+
case "PropertyDefinition":
|
| 1173 |
+
if (node.computed) {
|
| 1174 |
+
return getStringIfConstant(node.key, initialScope)
|
| 1175 |
+
}
|
| 1176 |
+
if (node.key.type === "Literal") {
|
| 1177 |
+
return String(node.key.value)
|
| 1178 |
+
}
|
| 1179 |
+
if (node.key.type === "PrivateIdentifier") {
|
| 1180 |
+
return null
|
| 1181 |
+
}
|
| 1182 |
+
return /** @type {Partial<Identifier>} */ (node.key).name
|
| 1183 |
+
}
|
| 1184 |
+
|
| 1185 |
+
return null
|
| 1186 |
+
}
|
| 1187 |
+
|
| 1188 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1189 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1190 |
+
/** @typedef {import("estree").Function} FunctionNode */
|
| 1191 |
+
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
|
| 1192 |
+
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
| 1193 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1194 |
+
|
| 1195 |
+
/**
|
| 1196 |
+
* Get the name and kind of the given function node.
|
| 1197 |
+
* @param {FunctionNode} node - The function node to get.
|
| 1198 |
+
* @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
|
| 1199 |
+
* @returns {string} The name and kind of the function node.
|
| 1200 |
+
*/
|
| 1201 |
+
// eslint-disable-next-line complexity
|
| 1202 |
+
function getFunctionNameWithKind(node, sourceCode) {
|
| 1203 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 1204 |
+
const tokens = [];
|
| 1205 |
+
const isObjectMethod = parent.type === "Property" && parent.value === node;
|
| 1206 |
+
const isClassMethod =
|
| 1207 |
+
parent.type === "MethodDefinition" && parent.value === node;
|
| 1208 |
+
const isClassFieldMethod =
|
| 1209 |
+
parent.type === "PropertyDefinition" && parent.value === node;
|
| 1210 |
+
|
| 1211 |
+
// Modifiers.
|
| 1212 |
+
if (isClassMethod || isClassFieldMethod) {
|
| 1213 |
+
if (parent.static) {
|
| 1214 |
+
tokens.push("static");
|
| 1215 |
+
}
|
| 1216 |
+
if (parent.key.type === "PrivateIdentifier") {
|
| 1217 |
+
tokens.push("private");
|
| 1218 |
+
}
|
| 1219 |
+
}
|
| 1220 |
+
if (node.async) {
|
| 1221 |
+
tokens.push("async");
|
| 1222 |
+
}
|
| 1223 |
+
if (node.generator) {
|
| 1224 |
+
tokens.push("generator");
|
| 1225 |
+
}
|
| 1226 |
+
|
| 1227 |
+
// Kinds.
|
| 1228 |
+
if (isObjectMethod || isClassMethod) {
|
| 1229 |
+
if (parent.kind === "constructor") {
|
| 1230 |
+
return "constructor"
|
| 1231 |
+
}
|
| 1232 |
+
if (parent.kind === "get") {
|
| 1233 |
+
tokens.push("getter");
|
| 1234 |
+
} else if (parent.kind === "set") {
|
| 1235 |
+
tokens.push("setter");
|
| 1236 |
+
} else {
|
| 1237 |
+
tokens.push("method");
|
| 1238 |
+
}
|
| 1239 |
+
} else if (isClassFieldMethod) {
|
| 1240 |
+
tokens.push("method");
|
| 1241 |
+
} else {
|
| 1242 |
+
if (node.type === "ArrowFunctionExpression") {
|
| 1243 |
+
tokens.push("arrow");
|
| 1244 |
+
}
|
| 1245 |
+
tokens.push("function");
|
| 1246 |
+
}
|
| 1247 |
+
|
| 1248 |
+
// Names.
|
| 1249 |
+
if (isObjectMethod || isClassMethod || isClassFieldMethod) {
|
| 1250 |
+
if (parent.key.type === "PrivateIdentifier") {
|
| 1251 |
+
tokens.push(`#${parent.key.name}`);
|
| 1252 |
+
} else {
|
| 1253 |
+
const name = getPropertyName(parent);
|
| 1254 |
+
if (name) {
|
| 1255 |
+
tokens.push(`'${name}'`);
|
| 1256 |
+
} else if (sourceCode) {
|
| 1257 |
+
const keyText = sourceCode.getText(parent.key);
|
| 1258 |
+
if (!keyText.includes("\n")) {
|
| 1259 |
+
tokens.push(`[${keyText}]`);
|
| 1260 |
+
}
|
| 1261 |
+
}
|
| 1262 |
+
}
|
| 1263 |
+
} else if (hasId(node)) {
|
| 1264 |
+
tokens.push(`'${node.id.name}'`);
|
| 1265 |
+
} else if (
|
| 1266 |
+
parent.type === "VariableDeclarator" &&
|
| 1267 |
+
parent.id &&
|
| 1268 |
+
parent.id.type === "Identifier"
|
| 1269 |
+
) {
|
| 1270 |
+
tokens.push(`'${parent.id.name}'`);
|
| 1271 |
+
} else if (
|
| 1272 |
+
(parent.type === "AssignmentExpression" ||
|
| 1273 |
+
parent.type === "AssignmentPattern") &&
|
| 1274 |
+
parent.left &&
|
| 1275 |
+
parent.left.type === "Identifier"
|
| 1276 |
+
) {
|
| 1277 |
+
tokens.push(`'${parent.left.name}'`);
|
| 1278 |
+
} else if (
|
| 1279 |
+
parent.type === "ExportDefaultDeclaration" &&
|
| 1280 |
+
parent.declaration === node
|
| 1281 |
+
) {
|
| 1282 |
+
tokens.push("'default'");
|
| 1283 |
+
}
|
| 1284 |
+
|
| 1285 |
+
return tokens.join(" ")
|
| 1286 |
+
}
|
| 1287 |
+
|
| 1288 |
+
/**
|
| 1289 |
+
* @param {FunctionNode} node
|
| 1290 |
+
* @returns {node is FunctionDeclaration | FunctionExpression & { id: Identifier }}
|
| 1291 |
+
*/
|
| 1292 |
+
function hasId(node) {
|
| 1293 |
+
return Boolean(
|
| 1294 |
+
/** @type {Partial<FunctionDeclaration | FunctionExpression>} */ (node)
|
| 1295 |
+
.id,
|
| 1296 |
+
)
|
| 1297 |
+
}
|
| 1298 |
+
|
| 1299 |
+
/** @typedef {import("estree").Node} Node */
|
| 1300 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1301 |
+
/** @typedef {import("./types.mjs").HasSideEffectOptions} HasSideEffectOptions */
|
| 1302 |
+
/** @typedef {import("estree").BinaryExpression} BinaryExpression */
|
| 1303 |
+
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
| 1304 |
+
/** @typedef {import("estree").MethodDefinition} MethodDefinition */
|
| 1305 |
+
/** @typedef {import("estree").Property} Property */
|
| 1306 |
+
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
|
| 1307 |
+
/** @typedef {import("estree").UnaryExpression} UnaryExpression */
|
| 1308 |
+
|
| 1309 |
+
const typeConversionBinaryOps = Object.freeze(
|
| 1310 |
+
new Set([
|
| 1311 |
+
"==",
|
| 1312 |
+
"!=",
|
| 1313 |
+
"<",
|
| 1314 |
+
"<=",
|
| 1315 |
+
">",
|
| 1316 |
+
">=",
|
| 1317 |
+
"<<",
|
| 1318 |
+
">>",
|
| 1319 |
+
">>>",
|
| 1320 |
+
"+",
|
| 1321 |
+
"-",
|
| 1322 |
+
"*",
|
| 1323 |
+
"/",
|
| 1324 |
+
"%",
|
| 1325 |
+
"|",
|
| 1326 |
+
"^",
|
| 1327 |
+
"&",
|
| 1328 |
+
"in",
|
| 1329 |
+
]),
|
| 1330 |
+
);
|
| 1331 |
+
const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
|
| 1332 |
+
|
| 1333 |
+
/**
|
| 1334 |
+
* Check whether the given value is an ASTNode or not.
|
| 1335 |
+
* @param {any} x The value to check.
|
| 1336 |
+
* @returns {x is Node} `true` if the value is an ASTNode.
|
| 1337 |
+
*/
|
| 1338 |
+
function isNode(x) {
|
| 1339 |
+
return x !== null && typeof x === "object" && typeof x.type === "string"
|
| 1340 |
+
}
|
| 1341 |
+
|
| 1342 |
+
const visitor = Object.freeze(
|
| 1343 |
+
Object.assign(Object.create(null), {
|
| 1344 |
+
/**
|
| 1345 |
+
* @param {Node} node
|
| 1346 |
+
* @param {HasSideEffectOptions} options
|
| 1347 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1348 |
+
*/
|
| 1349 |
+
$visit(node, options, visitorKeys) {
|
| 1350 |
+
const { type } = node;
|
| 1351 |
+
|
| 1352 |
+
if (typeof (/** @type {any} */ (this)[type]) === "function") {
|
| 1353 |
+
return /** @type {any} */ (this)[type](
|
| 1354 |
+
node,
|
| 1355 |
+
options,
|
| 1356 |
+
visitorKeys,
|
| 1357 |
+
)
|
| 1358 |
+
}
|
| 1359 |
+
|
| 1360 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1361 |
+
},
|
| 1362 |
+
|
| 1363 |
+
/**
|
| 1364 |
+
* @param {Node} node
|
| 1365 |
+
* @param {HasSideEffectOptions} options
|
| 1366 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1367 |
+
*/
|
| 1368 |
+
$visitChildren(node, options, visitorKeys) {
|
| 1369 |
+
const { type } = node;
|
| 1370 |
+
|
| 1371 |
+
for (const key of /** @type {(keyof Node)[]} */ (
|
| 1372 |
+
visitorKeys[type] || getKeys(node)
|
| 1373 |
+
)) {
|
| 1374 |
+
const value = node[key];
|
| 1375 |
+
|
| 1376 |
+
if (Array.isArray(value)) {
|
| 1377 |
+
for (const element of value) {
|
| 1378 |
+
if (
|
| 1379 |
+
isNode(element) &&
|
| 1380 |
+
this.$visit(element, options, visitorKeys)
|
| 1381 |
+
) {
|
| 1382 |
+
return true
|
| 1383 |
+
}
|
| 1384 |
+
}
|
| 1385 |
+
} else if (
|
| 1386 |
+
isNode(value) &&
|
| 1387 |
+
this.$visit(value, options, visitorKeys)
|
| 1388 |
+
) {
|
| 1389 |
+
return true
|
| 1390 |
+
}
|
| 1391 |
+
}
|
| 1392 |
+
|
| 1393 |
+
return false
|
| 1394 |
+
},
|
| 1395 |
+
|
| 1396 |
+
ArrowFunctionExpression() {
|
| 1397 |
+
return false
|
| 1398 |
+
},
|
| 1399 |
+
AssignmentExpression() {
|
| 1400 |
+
return true
|
| 1401 |
+
},
|
| 1402 |
+
AwaitExpression() {
|
| 1403 |
+
return true
|
| 1404 |
+
},
|
| 1405 |
+
/**
|
| 1406 |
+
* @param {BinaryExpression} node
|
| 1407 |
+
* @param {HasSideEffectOptions} options
|
| 1408 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1409 |
+
*/
|
| 1410 |
+
BinaryExpression(node, options, visitorKeys) {
|
| 1411 |
+
if (
|
| 1412 |
+
options.considerImplicitTypeConversion &&
|
| 1413 |
+
typeConversionBinaryOps.has(node.operator) &&
|
| 1414 |
+
(node.left.type !== "Literal" || node.right.type !== "Literal")
|
| 1415 |
+
) {
|
| 1416 |
+
return true
|
| 1417 |
+
}
|
| 1418 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1419 |
+
},
|
| 1420 |
+
CallExpression() {
|
| 1421 |
+
return true
|
| 1422 |
+
},
|
| 1423 |
+
FunctionExpression() {
|
| 1424 |
+
return false
|
| 1425 |
+
},
|
| 1426 |
+
ImportExpression() {
|
| 1427 |
+
return true
|
| 1428 |
+
},
|
| 1429 |
+
/**
|
| 1430 |
+
* @param {MemberExpression} node
|
| 1431 |
+
* @param {HasSideEffectOptions} options
|
| 1432 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1433 |
+
*/
|
| 1434 |
+
MemberExpression(node, options, visitorKeys) {
|
| 1435 |
+
if (options.considerGetters) {
|
| 1436 |
+
return true
|
| 1437 |
+
}
|
| 1438 |
+
if (
|
| 1439 |
+
options.considerImplicitTypeConversion &&
|
| 1440 |
+
node.computed &&
|
| 1441 |
+
node.property.type !== "Literal"
|
| 1442 |
+
) {
|
| 1443 |
+
return true
|
| 1444 |
+
}
|
| 1445 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1446 |
+
},
|
| 1447 |
+
/**
|
| 1448 |
+
* @param {MethodDefinition} node
|
| 1449 |
+
* @param {HasSideEffectOptions} options
|
| 1450 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1451 |
+
*/
|
| 1452 |
+
MethodDefinition(node, options, visitorKeys) {
|
| 1453 |
+
if (
|
| 1454 |
+
options.considerImplicitTypeConversion &&
|
| 1455 |
+
node.computed &&
|
| 1456 |
+
node.key.type !== "Literal"
|
| 1457 |
+
) {
|
| 1458 |
+
return true
|
| 1459 |
+
}
|
| 1460 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1461 |
+
},
|
| 1462 |
+
NewExpression() {
|
| 1463 |
+
return true
|
| 1464 |
+
},
|
| 1465 |
+
/**
|
| 1466 |
+
* @param {Property} node
|
| 1467 |
+
* @param {HasSideEffectOptions} options
|
| 1468 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1469 |
+
*/
|
| 1470 |
+
Property(node, options, visitorKeys) {
|
| 1471 |
+
if (
|
| 1472 |
+
options.considerImplicitTypeConversion &&
|
| 1473 |
+
node.computed &&
|
| 1474 |
+
node.key.type !== "Literal"
|
| 1475 |
+
) {
|
| 1476 |
+
return true
|
| 1477 |
+
}
|
| 1478 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1479 |
+
},
|
| 1480 |
+
/**
|
| 1481 |
+
* @param {PropertyDefinition} node
|
| 1482 |
+
* @param {HasSideEffectOptions} options
|
| 1483 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1484 |
+
*/
|
| 1485 |
+
PropertyDefinition(node, options, visitorKeys) {
|
| 1486 |
+
if (
|
| 1487 |
+
options.considerImplicitTypeConversion &&
|
| 1488 |
+
node.computed &&
|
| 1489 |
+
node.key.type !== "Literal"
|
| 1490 |
+
) {
|
| 1491 |
+
return true
|
| 1492 |
+
}
|
| 1493 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1494 |
+
},
|
| 1495 |
+
/**
|
| 1496 |
+
* @param {UnaryExpression} node
|
| 1497 |
+
* @param {HasSideEffectOptions} options
|
| 1498 |
+
* @param {Record<string, string[]>} visitorKeys
|
| 1499 |
+
*/
|
| 1500 |
+
UnaryExpression(node, options, visitorKeys) {
|
| 1501 |
+
if (node.operator === "delete") {
|
| 1502 |
+
return true
|
| 1503 |
+
}
|
| 1504 |
+
if (
|
| 1505 |
+
options.considerImplicitTypeConversion &&
|
| 1506 |
+
typeConversionUnaryOps.has(node.operator) &&
|
| 1507 |
+
node.argument.type !== "Literal"
|
| 1508 |
+
) {
|
| 1509 |
+
return true
|
| 1510 |
+
}
|
| 1511 |
+
return this.$visitChildren(node, options, visitorKeys)
|
| 1512 |
+
},
|
| 1513 |
+
UpdateExpression() {
|
| 1514 |
+
return true
|
| 1515 |
+
},
|
| 1516 |
+
YieldExpression() {
|
| 1517 |
+
return true
|
| 1518 |
+
},
|
| 1519 |
+
}),
|
| 1520 |
+
);
|
| 1521 |
+
|
| 1522 |
+
/**
|
| 1523 |
+
* Check whether a given node has any side effect or not.
|
| 1524 |
+
* @param {Node} node The node to get.
|
| 1525 |
+
* @param {SourceCode} sourceCode The source code object.
|
| 1526 |
+
* @param {HasSideEffectOptions} [options] The option object.
|
| 1527 |
+
* @returns {boolean} `true` if the node has a certain side effect.
|
| 1528 |
+
*/
|
| 1529 |
+
function hasSideEffect(node, sourceCode, options = {}) {
|
| 1530 |
+
const { considerGetters = false, considerImplicitTypeConversion = false } =
|
| 1531 |
+
options;
|
| 1532 |
+
return visitor.$visit(
|
| 1533 |
+
node,
|
| 1534 |
+
{ considerGetters, considerImplicitTypeConversion },
|
| 1535 |
+
sourceCode.visitorKeys || KEYS,
|
| 1536 |
+
)
|
| 1537 |
+
}
|
| 1538 |
+
|
| 1539 |
+
/** @typedef {import("estree").Node} Node */
|
| 1540 |
+
/** @typedef {import("eslint").SourceCode} SourceCode */
|
| 1541 |
+
/** @typedef {import("eslint").AST.Token} Token */
|
| 1542 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1543 |
+
|
| 1544 |
+
/**
|
| 1545 |
+
* Get the left parenthesis of the parent node syntax if it exists.
|
| 1546 |
+
* E.g., `if (a) {}` then the `(`.
|
| 1547 |
+
* @param {Node} node The AST node to check.
|
| 1548 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1549 |
+
* @returns {Token|null} The left parenthesis of the parent node syntax
|
| 1550 |
+
*/
|
| 1551 |
+
function getParentSyntaxParen(node, sourceCode) {
|
| 1552 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 1553 |
+
|
| 1554 |
+
switch (parent.type) {
|
| 1555 |
+
case "CallExpression":
|
| 1556 |
+
case "NewExpression":
|
| 1557 |
+
if (parent.arguments.length === 1 && parent.arguments[0] === node) {
|
| 1558 |
+
return sourceCode.getTokenAfter(
|
| 1559 |
+
parent.callee,
|
| 1560 |
+
isOpeningParenToken,
|
| 1561 |
+
)
|
| 1562 |
+
}
|
| 1563 |
+
return null
|
| 1564 |
+
|
| 1565 |
+
case "DoWhileStatement":
|
| 1566 |
+
if (parent.test === node) {
|
| 1567 |
+
return sourceCode.getTokenAfter(
|
| 1568 |
+
parent.body,
|
| 1569 |
+
isOpeningParenToken,
|
| 1570 |
+
)
|
| 1571 |
+
}
|
| 1572 |
+
return null
|
| 1573 |
+
|
| 1574 |
+
case "IfStatement":
|
| 1575 |
+
case "WhileStatement":
|
| 1576 |
+
if (parent.test === node) {
|
| 1577 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1578 |
+
}
|
| 1579 |
+
return null
|
| 1580 |
+
|
| 1581 |
+
case "ImportExpression":
|
| 1582 |
+
if (parent.source === node) {
|
| 1583 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1584 |
+
}
|
| 1585 |
+
return null
|
| 1586 |
+
|
| 1587 |
+
case "SwitchStatement":
|
| 1588 |
+
if (parent.discriminant === node) {
|
| 1589 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1590 |
+
}
|
| 1591 |
+
return null
|
| 1592 |
+
|
| 1593 |
+
case "WithStatement":
|
| 1594 |
+
if (parent.object === node) {
|
| 1595 |
+
return sourceCode.getFirstToken(parent, 1)
|
| 1596 |
+
}
|
| 1597 |
+
return null
|
| 1598 |
+
|
| 1599 |
+
default:
|
| 1600 |
+
return null
|
| 1601 |
+
}
|
| 1602 |
+
}
|
| 1603 |
+
|
| 1604 |
+
/**
|
| 1605 |
+
* Check whether a given node is parenthesized or not.
|
| 1606 |
+
* @param {number} times The number of parantheses.
|
| 1607 |
+
* @param {Node} node The AST node to check.
|
| 1608 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1609 |
+
* @returns {boolean} `true` if the node is parenthesized the given times.
|
| 1610 |
+
*/
|
| 1611 |
+
/**
|
| 1612 |
+
* Check whether a given node is parenthesized or not.
|
| 1613 |
+
* @param {Node} node The AST node to check.
|
| 1614 |
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
| 1615 |
+
* @returns {boolean} `true` if the node is parenthesized.
|
| 1616 |
+
*/
|
| 1617 |
+
/**
|
| 1618 |
+
* Check whether a given node is parenthesized or not.
|
| 1619 |
+
* @param {Node|number} timesOrNode The first parameter.
|
| 1620 |
+
* @param {Node|SourceCode} nodeOrSourceCode The second parameter.
|
| 1621 |
+
* @param {SourceCode} [optionalSourceCode] The third parameter.
|
| 1622 |
+
* @returns {boolean} `true` if the node is parenthesized.
|
| 1623 |
+
*/
|
| 1624 |
+
function isParenthesized(
|
| 1625 |
+
timesOrNode,
|
| 1626 |
+
nodeOrSourceCode,
|
| 1627 |
+
optionalSourceCode,
|
| 1628 |
+
) {
|
| 1629 |
+
/** @type {number} */
|
| 1630 |
+
let times,
|
| 1631 |
+
/** @type {RuleNode} */
|
| 1632 |
+
node,
|
| 1633 |
+
/** @type {SourceCode} */
|
| 1634 |
+
sourceCode,
|
| 1635 |
+
maybeLeftParen,
|
| 1636 |
+
maybeRightParen;
|
| 1637 |
+
if (typeof timesOrNode === "number") {
|
| 1638 |
+
times = timesOrNode | 0;
|
| 1639 |
+
node = /** @type {RuleNode} */ (nodeOrSourceCode);
|
| 1640 |
+
sourceCode = /** @type {SourceCode} */ (optionalSourceCode);
|
| 1641 |
+
if (!(times >= 1)) {
|
| 1642 |
+
throw new TypeError("'times' should be a positive integer.")
|
| 1643 |
+
}
|
| 1644 |
+
} else {
|
| 1645 |
+
times = 1;
|
| 1646 |
+
node = /** @type {RuleNode} */ (timesOrNode);
|
| 1647 |
+
sourceCode = /** @type {SourceCode} */ (nodeOrSourceCode);
|
| 1648 |
+
}
|
| 1649 |
+
|
| 1650 |
+
if (
|
| 1651 |
+
node == null ||
|
| 1652 |
+
// `Program` can't be parenthesized
|
| 1653 |
+
node.parent == null ||
|
| 1654 |
+
// `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
|
| 1655 |
+
(node.parent.type === "CatchClause" && node.parent.param === node)
|
| 1656 |
+
) {
|
| 1657 |
+
return false
|
| 1658 |
+
}
|
| 1659 |
+
|
| 1660 |
+
maybeLeftParen = maybeRightParen = node;
|
| 1661 |
+
do {
|
| 1662 |
+
maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
|
| 1663 |
+
maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
|
| 1664 |
+
} while (
|
| 1665 |
+
maybeLeftParen != null &&
|
| 1666 |
+
maybeRightParen != null &&
|
| 1667 |
+
isOpeningParenToken(maybeLeftParen) &&
|
| 1668 |
+
isClosingParenToken(maybeRightParen) &&
|
| 1669 |
+
// Avoid false positive such as `if (a) {}`
|
| 1670 |
+
maybeLeftParen !== getParentSyntaxParen(node, sourceCode) &&
|
| 1671 |
+
--times > 0
|
| 1672 |
+
)
|
| 1673 |
+
|
| 1674 |
+
return times === 0
|
| 1675 |
+
}
|
| 1676 |
+
|
| 1677 |
+
/**
|
| 1678 |
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
| 1679 |
+
* See LICENSE file in root directory for full license.
|
| 1680 |
+
*/
|
| 1681 |
+
|
| 1682 |
+
const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
|
| 1683 |
+
|
| 1684 |
+
/** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
|
| 1685 |
+
const internal = new WeakMap();
|
| 1686 |
+
|
| 1687 |
+
/**
|
| 1688 |
+
* Check whether a given character is escaped or not.
|
| 1689 |
+
* @param {string} str The string to check.
|
| 1690 |
+
* @param {number} index The location of the character to check.
|
| 1691 |
+
* @returns {boolean} `true` if the character is escaped.
|
| 1692 |
+
*/
|
| 1693 |
+
function isEscaped(str, index) {
|
| 1694 |
+
let escaped = false;
|
| 1695 |
+
for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
|
| 1696 |
+
escaped = !escaped;
|
| 1697 |
+
}
|
| 1698 |
+
return escaped
|
| 1699 |
+
}
|
| 1700 |
+
|
| 1701 |
+
/**
|
| 1702 |
+
* Replace a given string by a given matcher.
|
| 1703 |
+
* @param {PatternMatcher} matcher The pattern matcher.
|
| 1704 |
+
* @param {string} str The string to be replaced.
|
| 1705 |
+
* @param {string} replacement The new substring to replace each matched part.
|
| 1706 |
+
* @returns {string} The replaced string.
|
| 1707 |
+
*/
|
| 1708 |
+
function replaceS(matcher, str, replacement) {
|
| 1709 |
+
const chunks = [];
|
| 1710 |
+
let index = 0;
|
| 1711 |
+
|
| 1712 |
+
/**
|
| 1713 |
+
* @param {string} key The placeholder.
|
| 1714 |
+
* @param {RegExpExecArray} match The matched information.
|
| 1715 |
+
* @returns {string} The replaced string.
|
| 1716 |
+
*/
|
| 1717 |
+
function replacer(key, match) {
|
| 1718 |
+
switch (key) {
|
| 1719 |
+
case "$$":
|
| 1720 |
+
return "$"
|
| 1721 |
+
case "$&":
|
| 1722 |
+
return match[0]
|
| 1723 |
+
case "$`":
|
| 1724 |
+
return str.slice(0, match.index)
|
| 1725 |
+
case "$'":
|
| 1726 |
+
return str.slice(match.index + match[0].length)
|
| 1727 |
+
default: {
|
| 1728 |
+
const i = key.slice(1);
|
| 1729 |
+
if (i in match) {
|
| 1730 |
+
return match[/** @type {any} */ (i)]
|
| 1731 |
+
}
|
| 1732 |
+
return key
|
| 1733 |
+
}
|
| 1734 |
+
}
|
| 1735 |
+
}
|
| 1736 |
+
|
| 1737 |
+
for (const match of matcher.execAll(str)) {
|
| 1738 |
+
chunks.push(str.slice(index, match.index));
|
| 1739 |
+
chunks.push(
|
| 1740 |
+
replacement.replace(placeholder, (key) => replacer(key, match)),
|
| 1741 |
+
);
|
| 1742 |
+
index = match.index + match[0].length;
|
| 1743 |
+
}
|
| 1744 |
+
chunks.push(str.slice(index));
|
| 1745 |
+
|
| 1746 |
+
return chunks.join("")
|
| 1747 |
+
}
|
| 1748 |
+
|
| 1749 |
+
/**
|
| 1750 |
+
* Replace a given string by a given matcher.
|
| 1751 |
+
* @param {PatternMatcher} matcher The pattern matcher.
|
| 1752 |
+
* @param {string} str The string to be replaced.
|
| 1753 |
+
* @param {(substring: string, ...args: any[]) => string} replace The function to replace each matched part.
|
| 1754 |
+
* @returns {string} The replaced string.
|
| 1755 |
+
*/
|
| 1756 |
+
function replaceF(matcher, str, replace) {
|
| 1757 |
+
const chunks = [];
|
| 1758 |
+
let index = 0;
|
| 1759 |
+
|
| 1760 |
+
for (const match of matcher.execAll(str)) {
|
| 1761 |
+
chunks.push(str.slice(index, match.index));
|
| 1762 |
+
chunks.push(
|
| 1763 |
+
String(
|
| 1764 |
+
replace(
|
| 1765 |
+
.../** @type {[string, ...string[]]} */ (
|
| 1766 |
+
/** @type {string[]} */ (match)
|
| 1767 |
+
),
|
| 1768 |
+
match.index,
|
| 1769 |
+
match.input,
|
| 1770 |
+
),
|
| 1771 |
+
),
|
| 1772 |
+
);
|
| 1773 |
+
index = match.index + match[0].length;
|
| 1774 |
+
}
|
| 1775 |
+
chunks.push(str.slice(index));
|
| 1776 |
+
|
| 1777 |
+
return chunks.join("")
|
| 1778 |
+
}
|
| 1779 |
+
|
| 1780 |
+
/**
|
| 1781 |
+
* The class to find patterns as considering escape sequences.
|
| 1782 |
+
*/
|
| 1783 |
+
class PatternMatcher {
|
| 1784 |
+
/**
|
| 1785 |
+
* Initialize this matcher.
|
| 1786 |
+
* @param {RegExp} pattern The pattern to match.
|
| 1787 |
+
* @param {{escaped?:boolean}} [options] The options.
|
| 1788 |
+
*/
|
| 1789 |
+
constructor(pattern, options = {}) {
|
| 1790 |
+
const { escaped = false } = options;
|
| 1791 |
+
if (!(pattern instanceof RegExp)) {
|
| 1792 |
+
throw new TypeError("'pattern' should be a RegExp instance.")
|
| 1793 |
+
}
|
| 1794 |
+
if (!pattern.flags.includes("g")) {
|
| 1795 |
+
throw new Error("'pattern' should contains 'g' flag.")
|
| 1796 |
+
}
|
| 1797 |
+
|
| 1798 |
+
internal.set(this, {
|
| 1799 |
+
pattern: new RegExp(pattern.source, pattern.flags),
|
| 1800 |
+
escaped: Boolean(escaped),
|
| 1801 |
+
});
|
| 1802 |
+
}
|
| 1803 |
+
|
| 1804 |
+
/**
|
| 1805 |
+
* Find the pattern in a given string.
|
| 1806 |
+
* @param {string} str The string to find.
|
| 1807 |
+
* @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
|
| 1808 |
+
*/
|
| 1809 |
+
*execAll(str) {
|
| 1810 |
+
const { pattern, escaped } =
|
| 1811 |
+
/** @type {{pattern:RegExp,escaped:boolean}} */ (internal.get(this));
|
| 1812 |
+
let match = null;
|
| 1813 |
+
let lastIndex = 0;
|
| 1814 |
+
|
| 1815 |
+
pattern.lastIndex = 0;
|
| 1816 |
+
while ((match = pattern.exec(str)) != null) {
|
| 1817 |
+
if (escaped || !isEscaped(str, match.index)) {
|
| 1818 |
+
lastIndex = pattern.lastIndex;
|
| 1819 |
+
yield match;
|
| 1820 |
+
pattern.lastIndex = lastIndex;
|
| 1821 |
+
}
|
| 1822 |
+
}
|
| 1823 |
+
}
|
| 1824 |
+
|
| 1825 |
+
/**
|
| 1826 |
+
* Check whether the pattern is found in a given string.
|
| 1827 |
+
* @param {string} str The string to check.
|
| 1828 |
+
* @returns {boolean} `true` if the pattern was found in the string.
|
| 1829 |
+
*/
|
| 1830 |
+
test(str) {
|
| 1831 |
+
const it = this.execAll(str);
|
| 1832 |
+
const ret = it.next();
|
| 1833 |
+
return !ret.done
|
| 1834 |
+
}
|
| 1835 |
+
|
| 1836 |
+
/**
|
| 1837 |
+
* Replace a given string.
|
| 1838 |
+
* @param {string} str The string to be replaced.
|
| 1839 |
+
* @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
|
| 1840 |
+
* @returns {string} The replaced string.
|
| 1841 |
+
*/
|
| 1842 |
+
[Symbol.replace](str, replacer) {
|
| 1843 |
+
return typeof replacer === "function"
|
| 1844 |
+
? replaceF(this, String(str), replacer)
|
| 1845 |
+
: replaceS(this, String(str), String(replacer))
|
| 1846 |
+
}
|
| 1847 |
+
}
|
| 1848 |
+
|
| 1849 |
+
/** @typedef {import("eslint").Scope.Scope} Scope */
|
| 1850 |
+
/** @typedef {import("eslint").Scope.Variable} Variable */
|
| 1851 |
+
/** @typedef {import("eslint").Rule.Node} RuleNode */
|
| 1852 |
+
/** @typedef {import("estree").Node} Node */
|
| 1853 |
+
/** @typedef {import("estree").Expression} Expression */
|
| 1854 |
+
/** @typedef {import("estree").Pattern} Pattern */
|
| 1855 |
+
/** @typedef {import("estree").Identifier} Identifier */
|
| 1856 |
+
/** @typedef {import("estree").SimpleCallExpression} CallExpression */
|
| 1857 |
+
/** @typedef {import("estree").Program} Program */
|
| 1858 |
+
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
|
| 1859 |
+
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
|
| 1860 |
+
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
|
| 1861 |
+
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
|
| 1862 |
+
/** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
|
| 1863 |
+
/** @typedef {import("estree").ImportDefaultSpecifier} ImportDefaultSpecifier */
|
| 1864 |
+
/** @typedef {import("estree").ImportNamespaceSpecifier} ImportNamespaceSpecifier */
|
| 1865 |
+
/** @typedef {import("estree").ExportSpecifier} ExportSpecifier */
|
| 1866 |
+
/** @typedef {import("estree").Property} Property */
|
| 1867 |
+
/** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
|
| 1868 |
+
/** @typedef {import("estree").Literal} Literal */
|
| 1869 |
+
/** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
|
| 1870 |
+
/** @typedef {import("./types.mjs").ReferenceTrackerOptions} ReferenceTrackerOptions */
|
| 1871 |
+
/**
|
| 1872 |
+
* @template T
|
| 1873 |
+
* @typedef {import("./types.mjs").TraceMap<T>} TraceMap
|
| 1874 |
+
*/
|
| 1875 |
+
/**
|
| 1876 |
+
* @template T
|
| 1877 |
+
* @typedef {import("./types.mjs").TraceMapObject<T>} TraceMapObject
|
| 1878 |
+
*/
|
| 1879 |
+
/**
|
| 1880 |
+
* @template T
|
| 1881 |
+
* @typedef {import("./types.mjs").TrackedReferences<T>} TrackedReferences
|
| 1882 |
+
*/
|
| 1883 |
+
|
| 1884 |
+
const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
|
| 1885 |
+
|
| 1886 |
+
/**
|
| 1887 |
+
* Check whether a given node is an import node or not.
|
| 1888 |
+
* @param {Node} node
|
| 1889 |
+
* @returns {node is ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration&{source: Literal}} `true` if the node is an import node.
|
| 1890 |
+
*/
|
| 1891 |
+
function isHasSource(node) {
|
| 1892 |
+
return (
|
| 1893 |
+
IMPORT_TYPE.test(node.type) &&
|
| 1894 |
+
/** @type {ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration} */ (
|
| 1895 |
+
node
|
| 1896 |
+
).source != null
|
| 1897 |
+
)
|
| 1898 |
+
}
|
| 1899 |
+
const has =
|
| 1900 |
+
/** @type {<T>(traceMap: TraceMap<unknown>, v: T) => v is (string extends T ? string : T)} */ (
|
| 1901 |
+
Function.call.bind(Object.hasOwnProperty)
|
| 1902 |
+
);
|
| 1903 |
+
|
| 1904 |
+
const READ = Symbol("read");
|
| 1905 |
+
const CALL = Symbol("call");
|
| 1906 |
+
const CONSTRUCT = Symbol("construct");
|
| 1907 |
+
const ESM = Symbol("esm");
|
| 1908 |
+
|
| 1909 |
+
const requireCall = { require: { [CALL]: true } };
|
| 1910 |
+
|
| 1911 |
+
/**
|
| 1912 |
+
* Check whether a given variable is modified or not.
|
| 1913 |
+
* @param {Variable|undefined} variable The variable to check.
|
| 1914 |
+
* @returns {boolean} `true` if the variable is modified.
|
| 1915 |
+
*/
|
| 1916 |
+
function isModifiedGlobal(variable) {
|
| 1917 |
+
return (
|
| 1918 |
+
variable == null ||
|
| 1919 |
+
variable.defs.length !== 0 ||
|
| 1920 |
+
variable.references.some((r) => r.isWrite())
|
| 1921 |
+
)
|
| 1922 |
+
}
|
| 1923 |
+
|
| 1924 |
+
/**
|
| 1925 |
+
* Check if the value of a given node is passed through to the parent syntax as-is.
|
| 1926 |
+
* For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
|
| 1927 |
+
* @param {Node} node A node to check.
|
| 1928 |
+
* @returns {node is RuleNode & {parent: Expression}} `true` if the node is passed through.
|
| 1929 |
+
*/
|
| 1930 |
+
function isPassThrough(node) {
|
| 1931 |
+
const parent = /** @type {TSESTreeNode} */ (node).parent;
|
| 1932 |
+
|
| 1933 |
+
if (parent) {
|
| 1934 |
+
switch (parent.type) {
|
| 1935 |
+
case "ConditionalExpression":
|
| 1936 |
+
return parent.consequent === node || parent.alternate === node
|
| 1937 |
+
case "LogicalExpression":
|
| 1938 |
+
return true
|
| 1939 |
+
case "SequenceExpression":
|
| 1940 |
+
return (
|
| 1941 |
+
parent.expressions[parent.expressions.length - 1] === node
|
| 1942 |
+
)
|
| 1943 |
+
case "ChainExpression":
|
| 1944 |
+
return true
|
| 1945 |
+
case "TSAsExpression":
|
| 1946 |
+
case "TSSatisfiesExpression":
|
| 1947 |
+
case "TSTypeAssertion":
|
| 1948 |
+
case "TSNonNullExpression":
|
| 1949 |
+
case "TSInstantiationExpression":
|
| 1950 |
+
return true
|
| 1951 |
+
|
| 1952 |
+
default:
|
| 1953 |
+
return false
|
| 1954 |
+
}
|
| 1955 |
+
}
|
| 1956 |
+
return false
|
| 1957 |
+
}
|
| 1958 |
+
|
| 1959 |
+
/**
|
| 1960 |
+
* The reference tracker.
|
| 1961 |
+
*/
|
| 1962 |
+
class ReferenceTracker {
|
| 1963 |
+
/**
|
| 1964 |
+
* Initialize this tracker.
|
| 1965 |
+
* @param {Scope} globalScope The global scope.
|
| 1966 |
+
* @param {object} [options] The options.
|
| 1967 |
+
* @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
|
| 1968 |
+
* @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
|
| 1969 |
+
*/
|
| 1970 |
+
constructor(globalScope, options = {}) {
|
| 1971 |
+
const {
|
| 1972 |
+
mode = "strict",
|
| 1973 |
+
globalObjectNames = ["global", "globalThis", "self", "window"],
|
| 1974 |
+
} = options;
|
| 1975 |
+
/** @private @type {Variable[]} */
|
| 1976 |
+
this.variableStack = [];
|
| 1977 |
+
/** @private */
|
| 1978 |
+
this.globalScope = globalScope;
|
| 1979 |
+
/** @private */
|
| 1980 |
+
this.mode = mode;
|
| 1981 |
+
/** @private */
|
| 1982 |
+
this.globalObjectNames = globalObjectNames.slice(0);
|
| 1983 |
+
}
|
| 1984 |
+
|
| 1985 |
+
/**
|
| 1986 |
+
* Iterate the references of global variables.
|
| 1987 |
+
* @template T
|
| 1988 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 1989 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 1990 |
+
*/
|
| 1991 |
+
*iterateGlobalReferences(traceMap) {
|
| 1992 |
+
for (const key of Object.keys(traceMap)) {
|
| 1993 |
+
const nextTraceMap = traceMap[key];
|
| 1994 |
+
const path = [key];
|
| 1995 |
+
const variable = this.globalScope.set.get(key);
|
| 1996 |
+
|
| 1997 |
+
if (isModifiedGlobal(variable)) {
|
| 1998 |
+
continue
|
| 1999 |
+
}
|
| 2000 |
+
|
| 2001 |
+
yield* this._iterateVariableReferences(
|
| 2002 |
+
/** @type {Variable} */ (variable),
|
| 2003 |
+
path,
|
| 2004 |
+
nextTraceMap,
|
| 2005 |
+
true,
|
| 2006 |
+
);
|
| 2007 |
+
}
|
| 2008 |
+
|
| 2009 |
+
for (const key of this.globalObjectNames) {
|
| 2010 |
+
/** @type {string[]} */
|
| 2011 |
+
const path = [];
|
| 2012 |
+
const variable = this.globalScope.set.get(key);
|
| 2013 |
+
|
| 2014 |
+
if (isModifiedGlobal(variable)) {
|
| 2015 |
+
continue
|
| 2016 |
+
}
|
| 2017 |
+
|
| 2018 |
+
yield* this._iterateVariableReferences(
|
| 2019 |
+
/** @type {Variable} */ (variable),
|
| 2020 |
+
path,
|
| 2021 |
+
traceMap,
|
| 2022 |
+
false,
|
| 2023 |
+
);
|
| 2024 |
+
}
|
| 2025 |
+
}
|
| 2026 |
+
|
| 2027 |
+
/**
|
| 2028 |
+
* Iterate the references of CommonJS modules.
|
| 2029 |
+
* @template T
|
| 2030 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2031 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2032 |
+
*/
|
| 2033 |
+
*iterateCjsReferences(traceMap) {
|
| 2034 |
+
for (const { node } of this.iterateGlobalReferences(requireCall)) {
|
| 2035 |
+
const key = getStringIfConstant(
|
| 2036 |
+
/** @type {CallExpression} */ (node).arguments[0],
|
| 2037 |
+
);
|
| 2038 |
+
if (key == null || !has(traceMap, key)) {
|
| 2039 |
+
continue
|
| 2040 |
+
}
|
| 2041 |
+
|
| 2042 |
+
const nextTraceMap = traceMap[key];
|
| 2043 |
+
const path = [key];
|
| 2044 |
+
|
| 2045 |
+
if (nextTraceMap[READ]) {
|
| 2046 |
+
yield {
|
| 2047 |
+
node,
|
| 2048 |
+
path,
|
| 2049 |
+
type: READ,
|
| 2050 |
+
info: nextTraceMap[READ],
|
| 2051 |
+
};
|
| 2052 |
+
}
|
| 2053 |
+
yield* this._iteratePropertyReferences(
|
| 2054 |
+
/** @type {CallExpression} */ (node),
|
| 2055 |
+
path,
|
| 2056 |
+
nextTraceMap,
|
| 2057 |
+
);
|
| 2058 |
+
}
|
| 2059 |
+
}
|
| 2060 |
+
|
| 2061 |
+
/**
|
| 2062 |
+
* Iterate the references of ES modules.
|
| 2063 |
+
* @template T
|
| 2064 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2065 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2066 |
+
*/
|
| 2067 |
+
*iterateEsmReferences(traceMap) {
|
| 2068 |
+
const programNode = /** @type {Program} */ (this.globalScope.block);
|
| 2069 |
+
|
| 2070 |
+
for (const node of programNode.body) {
|
| 2071 |
+
if (!isHasSource(node)) {
|
| 2072 |
+
continue
|
| 2073 |
+
}
|
| 2074 |
+
const moduleId = /** @type {string} */ (node.source.value);
|
| 2075 |
+
|
| 2076 |
+
if (!has(traceMap, moduleId)) {
|
| 2077 |
+
continue
|
| 2078 |
+
}
|
| 2079 |
+
const nextTraceMap = traceMap[moduleId];
|
| 2080 |
+
const path = [moduleId];
|
| 2081 |
+
|
| 2082 |
+
if (nextTraceMap[READ]) {
|
| 2083 |
+
yield {
|
| 2084 |
+
// eslint-disable-next-line object-shorthand -- apply type
|
| 2085 |
+
node: /** @type {RuleNode} */ (node),
|
| 2086 |
+
path,
|
| 2087 |
+
type: READ,
|
| 2088 |
+
info: nextTraceMap[READ],
|
| 2089 |
+
};
|
| 2090 |
+
}
|
| 2091 |
+
|
| 2092 |
+
if (node.type === "ExportAllDeclaration") {
|
| 2093 |
+
for (const key of Object.keys(nextTraceMap)) {
|
| 2094 |
+
const exportTraceMap = nextTraceMap[key];
|
| 2095 |
+
if (exportTraceMap[READ]) {
|
| 2096 |
+
yield {
|
| 2097 |
+
// eslint-disable-next-line object-shorthand -- apply type
|
| 2098 |
+
node: /** @type {RuleNode} */ (node),
|
| 2099 |
+
path: path.concat(key),
|
| 2100 |
+
type: READ,
|
| 2101 |
+
info: exportTraceMap[READ],
|
| 2102 |
+
};
|
| 2103 |
+
}
|
| 2104 |
+
}
|
| 2105 |
+
} else {
|
| 2106 |
+
for (const specifier of node.specifiers) {
|
| 2107 |
+
const esm = has(nextTraceMap, ESM);
|
| 2108 |
+
const it = this._iterateImportReferences(
|
| 2109 |
+
specifier,
|
| 2110 |
+
path,
|
| 2111 |
+
esm
|
| 2112 |
+
? nextTraceMap
|
| 2113 |
+
: this.mode === "legacy"
|
| 2114 |
+
? { default: nextTraceMap, ...nextTraceMap }
|
| 2115 |
+
: { default: nextTraceMap },
|
| 2116 |
+
);
|
| 2117 |
+
|
| 2118 |
+
if (esm) {
|
| 2119 |
+
yield* it;
|
| 2120 |
+
} else {
|
| 2121 |
+
for (const report of it) {
|
| 2122 |
+
report.path = report.path.filter(exceptDefault);
|
| 2123 |
+
if (
|
| 2124 |
+
report.path.length >= 2 ||
|
| 2125 |
+
report.type !== READ
|
| 2126 |
+
) {
|
| 2127 |
+
yield report;
|
| 2128 |
+
}
|
| 2129 |
+
}
|
| 2130 |
+
}
|
| 2131 |
+
}
|
| 2132 |
+
}
|
| 2133 |
+
}
|
| 2134 |
+
}
|
| 2135 |
+
|
| 2136 |
+
/**
|
| 2137 |
+
* Iterate the property references for a given expression AST node.
|
| 2138 |
+
* @template T
|
| 2139 |
+
* @param {Expression} node The expression AST node to iterate property references.
|
| 2140 |
+
* @param {TraceMap<T>} traceMap The trace map.
|
| 2141 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate property references.
|
| 2142 |
+
*/
|
| 2143 |
+
*iteratePropertyReferences(node, traceMap) {
|
| 2144 |
+
yield* this._iteratePropertyReferences(node, [], traceMap);
|
| 2145 |
+
}
|
| 2146 |
+
|
| 2147 |
+
/**
|
| 2148 |
+
* Iterate the references for a given variable.
|
| 2149 |
+
* @private
|
| 2150 |
+
* @template T
|
| 2151 |
+
* @param {Variable} variable The variable to iterate that references.
|
| 2152 |
+
* @param {string[]} path The current path.
|
| 2153 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2154 |
+
* @param {boolean} shouldReport = The flag to report those references.
|
| 2155 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2156 |
+
*/
|
| 2157 |
+
*_iterateVariableReferences(variable, path, traceMap, shouldReport) {
|
| 2158 |
+
if (this.variableStack.includes(variable)) {
|
| 2159 |
+
return
|
| 2160 |
+
}
|
| 2161 |
+
this.variableStack.push(variable);
|
| 2162 |
+
try {
|
| 2163 |
+
for (const reference of variable.references) {
|
| 2164 |
+
if (!reference.isRead()) {
|
| 2165 |
+
continue
|
| 2166 |
+
}
|
| 2167 |
+
const node = /** @type {RuleNode & Identifier} */ (
|
| 2168 |
+
reference.identifier
|
| 2169 |
+
);
|
| 2170 |
+
|
| 2171 |
+
if (shouldReport && traceMap[READ]) {
|
| 2172 |
+
yield { node, path, type: READ, info: traceMap[READ] };
|
| 2173 |
+
}
|
| 2174 |
+
yield* this._iteratePropertyReferences(node, path, traceMap);
|
| 2175 |
+
}
|
| 2176 |
+
} finally {
|
| 2177 |
+
this.variableStack.pop();
|
| 2178 |
+
}
|
| 2179 |
+
}
|
| 2180 |
+
|
| 2181 |
+
/**
|
| 2182 |
+
* Iterate the references for a given AST node.
|
| 2183 |
+
* @private
|
| 2184 |
+
* @template T
|
| 2185 |
+
* @param {Expression} rootNode The AST node to iterate references.
|
| 2186 |
+
* @param {string[]} path The current path.
|
| 2187 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2188 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2189 |
+
*/
|
| 2190 |
+
//eslint-disable-next-line complexity
|
| 2191 |
+
*_iteratePropertyReferences(rootNode, path, traceMap) {
|
| 2192 |
+
let node = rootNode;
|
| 2193 |
+
while (isPassThrough(node)) {
|
| 2194 |
+
node = node.parent;
|
| 2195 |
+
}
|
| 2196 |
+
|
| 2197 |
+
const parent = /** @type {RuleNode} */ (node).parent;
|
| 2198 |
+
if (parent.type === "MemberExpression") {
|
| 2199 |
+
if (parent.object === node) {
|
| 2200 |
+
const key = getPropertyName(parent);
|
| 2201 |
+
if (key == null || !has(traceMap, key)) {
|
| 2202 |
+
return
|
| 2203 |
+
}
|
| 2204 |
+
|
| 2205 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2206 |
+
const nextTraceMap = traceMap[key];
|
| 2207 |
+
if (nextTraceMap[READ]) {
|
| 2208 |
+
yield {
|
| 2209 |
+
node: parent,
|
| 2210 |
+
path,
|
| 2211 |
+
type: READ,
|
| 2212 |
+
info: nextTraceMap[READ],
|
| 2213 |
+
};
|
| 2214 |
+
}
|
| 2215 |
+
yield* this._iteratePropertyReferences(
|
| 2216 |
+
parent,
|
| 2217 |
+
path,
|
| 2218 |
+
nextTraceMap,
|
| 2219 |
+
);
|
| 2220 |
+
}
|
| 2221 |
+
return
|
| 2222 |
+
}
|
| 2223 |
+
if (parent.type === "CallExpression") {
|
| 2224 |
+
if (parent.callee === node && traceMap[CALL]) {
|
| 2225 |
+
yield { node: parent, path, type: CALL, info: traceMap[CALL] };
|
| 2226 |
+
}
|
| 2227 |
+
return
|
| 2228 |
+
}
|
| 2229 |
+
if (parent.type === "NewExpression") {
|
| 2230 |
+
if (parent.callee === node && traceMap[CONSTRUCT]) {
|
| 2231 |
+
yield {
|
| 2232 |
+
node: parent,
|
| 2233 |
+
path,
|
| 2234 |
+
type: CONSTRUCT,
|
| 2235 |
+
info: traceMap[CONSTRUCT],
|
| 2236 |
+
};
|
| 2237 |
+
}
|
| 2238 |
+
return
|
| 2239 |
+
}
|
| 2240 |
+
if (parent.type === "AssignmentExpression") {
|
| 2241 |
+
if (parent.right === node) {
|
| 2242 |
+
yield* this._iterateLhsReferences(parent.left, path, traceMap);
|
| 2243 |
+
yield* this._iteratePropertyReferences(parent, path, traceMap);
|
| 2244 |
+
}
|
| 2245 |
+
return
|
| 2246 |
+
}
|
| 2247 |
+
if (parent.type === "AssignmentPattern") {
|
| 2248 |
+
if (parent.right === node) {
|
| 2249 |
+
yield* this._iterateLhsReferences(parent.left, path, traceMap);
|
| 2250 |
+
}
|
| 2251 |
+
return
|
| 2252 |
+
}
|
| 2253 |
+
if (parent.type === "VariableDeclarator") {
|
| 2254 |
+
if (parent.init === node) {
|
| 2255 |
+
yield* this._iterateLhsReferences(parent.id, path, traceMap);
|
| 2256 |
+
}
|
| 2257 |
+
}
|
| 2258 |
+
}
|
| 2259 |
+
|
| 2260 |
+
/**
|
| 2261 |
+
* Iterate the references for a given Pattern node.
|
| 2262 |
+
* @private
|
| 2263 |
+
* @template T
|
| 2264 |
+
* @param {Pattern} patternNode The Pattern node to iterate references.
|
| 2265 |
+
* @param {string[]} path The current path.
|
| 2266 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2267 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2268 |
+
*/
|
| 2269 |
+
*_iterateLhsReferences(patternNode, path, traceMap) {
|
| 2270 |
+
if (patternNode.type === "Identifier") {
|
| 2271 |
+
const variable = findVariable(this.globalScope, patternNode);
|
| 2272 |
+
if (variable != null) {
|
| 2273 |
+
yield* this._iterateVariableReferences(
|
| 2274 |
+
variable,
|
| 2275 |
+
path,
|
| 2276 |
+
traceMap,
|
| 2277 |
+
false,
|
| 2278 |
+
);
|
| 2279 |
+
}
|
| 2280 |
+
return
|
| 2281 |
+
}
|
| 2282 |
+
if (patternNode.type === "ObjectPattern") {
|
| 2283 |
+
for (const property of patternNode.properties) {
|
| 2284 |
+
const key = getPropertyName(
|
| 2285 |
+
/** @type {AssignmentProperty} */ (property),
|
| 2286 |
+
);
|
| 2287 |
+
|
| 2288 |
+
if (key == null || !has(traceMap, key)) {
|
| 2289 |
+
continue
|
| 2290 |
+
}
|
| 2291 |
+
|
| 2292 |
+
const nextPath = path.concat(key);
|
| 2293 |
+
const nextTraceMap = traceMap[key];
|
| 2294 |
+
if (nextTraceMap[READ]) {
|
| 2295 |
+
yield {
|
| 2296 |
+
node: /** @type {RuleNode} */ (property),
|
| 2297 |
+
path: nextPath,
|
| 2298 |
+
type: READ,
|
| 2299 |
+
info: nextTraceMap[READ],
|
| 2300 |
+
};
|
| 2301 |
+
}
|
| 2302 |
+
yield* this._iterateLhsReferences(
|
| 2303 |
+
/** @type {AssignmentProperty} */ (property).value,
|
| 2304 |
+
nextPath,
|
| 2305 |
+
nextTraceMap,
|
| 2306 |
+
);
|
| 2307 |
+
}
|
| 2308 |
+
return
|
| 2309 |
+
}
|
| 2310 |
+
if (patternNode.type === "AssignmentPattern") {
|
| 2311 |
+
yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
|
| 2312 |
+
}
|
| 2313 |
+
}
|
| 2314 |
+
|
| 2315 |
+
/**
|
| 2316 |
+
* Iterate the references for a given ModuleSpecifier node.
|
| 2317 |
+
* @private
|
| 2318 |
+
* @template T
|
| 2319 |
+
* @param {ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier} specifierNode The ModuleSpecifier node to iterate references.
|
| 2320 |
+
* @param {string[]} path The current path.
|
| 2321 |
+
* @param {TraceMapObject<T>} traceMap The trace map.
|
| 2322 |
+
* @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
|
| 2323 |
+
*/
|
| 2324 |
+
*_iterateImportReferences(specifierNode, path, traceMap) {
|
| 2325 |
+
const type = specifierNode.type;
|
| 2326 |
+
|
| 2327 |
+
if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
|
| 2328 |
+
const key =
|
| 2329 |
+
type === "ImportDefaultSpecifier"
|
| 2330 |
+
? "default"
|
| 2331 |
+
: specifierNode.imported.type === "Identifier"
|
| 2332 |
+
? specifierNode.imported.name
|
| 2333 |
+
: specifierNode.imported.value;
|
| 2334 |
+
if (!has(traceMap, key)) {
|
| 2335 |
+
return
|
| 2336 |
+
}
|
| 2337 |
+
|
| 2338 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2339 |
+
const nextTraceMap = traceMap[key];
|
| 2340 |
+
if (nextTraceMap[READ]) {
|
| 2341 |
+
yield {
|
| 2342 |
+
node: /** @type {RuleNode} */ (specifierNode),
|
| 2343 |
+
path,
|
| 2344 |
+
type: READ,
|
| 2345 |
+
info: nextTraceMap[READ],
|
| 2346 |
+
};
|
| 2347 |
+
}
|
| 2348 |
+
yield* this._iterateVariableReferences(
|
| 2349 |
+
/** @type {Variable} */ (
|
| 2350 |
+
findVariable(this.globalScope, specifierNode.local)
|
| 2351 |
+
),
|
| 2352 |
+
path,
|
| 2353 |
+
nextTraceMap,
|
| 2354 |
+
false,
|
| 2355 |
+
);
|
| 2356 |
+
|
| 2357 |
+
return
|
| 2358 |
+
}
|
| 2359 |
+
|
| 2360 |
+
if (type === "ImportNamespaceSpecifier") {
|
| 2361 |
+
yield* this._iterateVariableReferences(
|
| 2362 |
+
/** @type {Variable} */ (
|
| 2363 |
+
findVariable(this.globalScope, specifierNode.local)
|
| 2364 |
+
),
|
| 2365 |
+
path,
|
| 2366 |
+
traceMap,
|
| 2367 |
+
false,
|
| 2368 |
+
);
|
| 2369 |
+
return
|
| 2370 |
+
}
|
| 2371 |
+
|
| 2372 |
+
if (type === "ExportSpecifier") {
|
| 2373 |
+
const key =
|
| 2374 |
+
specifierNode.local.type === "Identifier"
|
| 2375 |
+
? specifierNode.local.name
|
| 2376 |
+
: specifierNode.local.value;
|
| 2377 |
+
if (!has(traceMap, key)) {
|
| 2378 |
+
return
|
| 2379 |
+
}
|
| 2380 |
+
|
| 2381 |
+
path = path.concat(key); //eslint-disable-line no-param-reassign
|
| 2382 |
+
const nextTraceMap = traceMap[key];
|
| 2383 |
+
if (nextTraceMap[READ]) {
|
| 2384 |
+
yield {
|
| 2385 |
+
node: /** @type {RuleNode} */ (specifierNode),
|
| 2386 |
+
path,
|
| 2387 |
+
type: READ,
|
| 2388 |
+
info: nextTraceMap[READ],
|
| 2389 |
+
};
|
| 2390 |
+
}
|
| 2391 |
+
}
|
| 2392 |
+
}
|
| 2393 |
+
}
|
| 2394 |
+
|
| 2395 |
+
ReferenceTracker.READ = READ;
|
| 2396 |
+
ReferenceTracker.CALL = CALL;
|
| 2397 |
+
ReferenceTracker.CONSTRUCT = CONSTRUCT;
|
| 2398 |
+
ReferenceTracker.ESM = ESM;
|
| 2399 |
+
|
| 2400 |
+
/**
|
| 2401 |
+
* This is a predicate function for Array#filter.
|
| 2402 |
+
* @param {string} name A name part.
|
| 2403 |
+
* @param {number} index The index of the name.
|
| 2404 |
+
* @returns {boolean} `false` if it's default.
|
| 2405 |
+
*/
|
| 2406 |
+
function exceptDefault(name, index) {
|
| 2407 |
+
return !(index === 1 && name === "default")
|
| 2408 |
+
}
|
| 2409 |
+
|
| 2410 |
+
/** @typedef {import("./types.mjs").StaticValue} StaticValue */
|
| 2411 |
+
|
| 2412 |
+
var index = {
|
| 2413 |
+
CALL,
|
| 2414 |
+
CONSTRUCT,
|
| 2415 |
+
ESM,
|
| 2416 |
+
findVariable,
|
| 2417 |
+
getFunctionHeadLocation,
|
| 2418 |
+
getFunctionNameWithKind,
|
| 2419 |
+
getInnermostScope,
|
| 2420 |
+
getPropertyName,
|
| 2421 |
+
getStaticValue,
|
| 2422 |
+
getStringIfConstant,
|
| 2423 |
+
hasSideEffect,
|
| 2424 |
+
isArrowToken,
|
| 2425 |
+
isClosingBraceToken,
|
| 2426 |
+
isClosingBracketToken,
|
| 2427 |
+
isClosingParenToken,
|
| 2428 |
+
isColonToken,
|
| 2429 |
+
isCommaToken,
|
| 2430 |
+
isCommentToken,
|
| 2431 |
+
isNotArrowToken,
|
| 2432 |
+
isNotClosingBraceToken,
|
| 2433 |
+
isNotClosingBracketToken,
|
| 2434 |
+
isNotClosingParenToken,
|
| 2435 |
+
isNotColonToken,
|
| 2436 |
+
isNotCommaToken,
|
| 2437 |
+
isNotCommentToken,
|
| 2438 |
+
isNotOpeningBraceToken,
|
| 2439 |
+
isNotOpeningBracketToken,
|
| 2440 |
+
isNotOpeningParenToken,
|
| 2441 |
+
isNotSemicolonToken,
|
| 2442 |
+
isOpeningBraceToken,
|
| 2443 |
+
isOpeningBracketToken,
|
| 2444 |
+
isOpeningParenToken,
|
| 2445 |
+
isParenthesized,
|
| 2446 |
+
isSemicolonToken,
|
| 2447 |
+
PatternMatcher,
|
| 2448 |
+
READ,
|
| 2449 |
+
ReferenceTracker,
|
| 2450 |
+
};
|
| 2451 |
+
|
| 2452 |
+
export { CALL, CONSTRUCT, ESM, PatternMatcher, READ, ReferenceTracker, index as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
|
| 2453 |
+
//# sourceMappingURL=index.mjs.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/index.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/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.
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# eslint-visitor-keys
|
| 2 |
+
|
| 3 |
+
[](https://www.npmjs.com/package/eslint-visitor-keys)
|
| 4 |
+
[](http://www.npmtrends.com/eslint-visitor-keys)
|
| 5 |
+
[](https://github.com/eslint/eslint-visitor-keys/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] `^12.22.0`, `^14.17.0`, or `>=16.0.0`
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
## 📖 Usage
|
| 23 |
+
|
| 24 |
+
To use in an ESM file:
|
| 25 |
+
|
| 26 |
+
```js
|
| 27 |
+
import * as evk from "eslint-visitor-keys"
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
To use in a CommonJS file:
|
| 31 |
+
|
| 32 |
+
```js
|
| 33 |
+
const evk = require("eslint-visitor-keys")
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### evk.KEYS
|
| 37 |
+
|
| 38 |
+
> type: `{ [type: string]: string[] | undefined }`
|
| 39 |
+
|
| 40 |
+
Visitor keys. This keys are frozen.
|
| 41 |
+
|
| 42 |
+
This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
|
| 43 |
+
|
| 44 |
+
For example:
|
| 45 |
+
|
| 46 |
+
```
|
| 47 |
+
console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### evk.getKeys(node)
|
| 51 |
+
|
| 52 |
+
> type: `(node: object) => string[]`
|
| 53 |
+
|
| 54 |
+
Get the visitor keys of a given AST node.
|
| 55 |
+
|
| 56 |
+
This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
|
| 57 |
+
|
| 58 |
+
This will be used to traverse unknown nodes.
|
| 59 |
+
|
| 60 |
+
For example:
|
| 61 |
+
|
| 62 |
+
```js
|
| 63 |
+
const node = {
|
| 64 |
+
type: "AssignmentExpression",
|
| 65 |
+
left: { type: "Identifier", name: "foo" },
|
| 66 |
+
right: { type: "Literal", value: 0 }
|
| 67 |
+
}
|
| 68 |
+
console.log(evk.getKeys(node)) // → ["type", "left", "right"]
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### evk.unionWith(additionalKeys)
|
| 72 |
+
|
| 73 |
+
> type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
|
| 74 |
+
|
| 75 |
+
Make the union set with `evk.KEYS` and the given keys.
|
| 76 |
+
|
| 77 |
+
- The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
|
| 78 |
+
- It removes duplicated keys as keeping the first one.
|
| 79 |
+
|
| 80 |
+
For example:
|
| 81 |
+
|
| 82 |
+
```js
|
| 83 |
+
console.log(evk.unionWith({
|
| 84 |
+
MethodDefinition: ["decorators"]
|
| 85 |
+
})) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## 📰 Change log
|
| 89 |
+
|
| 90 |
+
See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
|
| 91 |
+
|
| 92 |
+
## 🍻 Contributing
|
| 93 |
+
|
| 94 |
+
Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
|
| 95 |
+
|
| 96 |
+
### Development commands
|
| 97 |
+
|
| 98 |
+
- `npm test` runs tests and measures code coverage.
|
| 99 |
+
- `npm run lint` checks source codes with ESLint.
|
| 100 |
+
- `npm run test:open-coverage` opens the code coverage report of the previous test with your default browser.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
[npm]: https://www.npmjs.com/
|
| 104 |
+
[Node.js]: https://nodejs.org/
|
| 105 |
+
[ESTree]: https://github.com/estree/estree
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, '__esModule', { value: true });
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
| 7 |
+
*/
|
| 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 |
+
],
|
| 92 |
+
ExportDefaultDeclaration: [
|
| 93 |
+
"declaration"
|
| 94 |
+
],
|
| 95 |
+
ExportNamedDeclaration: [
|
| 96 |
+
"declaration",
|
| 97 |
+
"specifiers",
|
| 98 |
+
"source"
|
| 99 |
+
],
|
| 100 |
+
ExportSpecifier: [
|
| 101 |
+
"exported",
|
| 102 |
+
"local"
|
| 103 |
+
],
|
| 104 |
+
ExpressionStatement: [
|
| 105 |
+
"expression"
|
| 106 |
+
],
|
| 107 |
+
ForInStatement: [
|
| 108 |
+
"left",
|
| 109 |
+
"right",
|
| 110 |
+
"body"
|
| 111 |
+
],
|
| 112 |
+
ForOfStatement: [
|
| 113 |
+
"left",
|
| 114 |
+
"right",
|
| 115 |
+
"body"
|
| 116 |
+
],
|
| 117 |
+
ForStatement: [
|
| 118 |
+
"init",
|
| 119 |
+
"test",
|
| 120 |
+
"update",
|
| 121 |
+
"body"
|
| 122 |
+
],
|
| 123 |
+
FunctionDeclaration: [
|
| 124 |
+
"id",
|
| 125 |
+
"params",
|
| 126 |
+
"body"
|
| 127 |
+
],
|
| 128 |
+
FunctionExpression: [
|
| 129 |
+
"id",
|
| 130 |
+
"params",
|
| 131 |
+
"body"
|
| 132 |
+
],
|
| 133 |
+
Identifier: [],
|
| 134 |
+
IfStatement: [
|
| 135 |
+
"test",
|
| 136 |
+
"consequent",
|
| 137 |
+
"alternate"
|
| 138 |
+
],
|
| 139 |
+
ImportDeclaration: [
|
| 140 |
+
"specifiers",
|
| 141 |
+
"source"
|
| 142 |
+
],
|
| 143 |
+
ImportDefaultSpecifier: [
|
| 144 |
+
"local"
|
| 145 |
+
],
|
| 146 |
+
ImportExpression: [
|
| 147 |
+
"source"
|
| 148 |
+
],
|
| 149 |
+
ImportNamespaceSpecifier: [
|
| 150 |
+
"local"
|
| 151 |
+
],
|
| 152 |
+
ImportSpecifier: [
|
| 153 |
+
"imported",
|
| 154 |
+
"local"
|
| 155 |
+
],
|
| 156 |
+
JSXAttribute: [
|
| 157 |
+
"name",
|
| 158 |
+
"value"
|
| 159 |
+
],
|
| 160 |
+
JSXClosingElement: [
|
| 161 |
+
"name"
|
| 162 |
+
],
|
| 163 |
+
JSXClosingFragment: [],
|
| 164 |
+
JSXElement: [
|
| 165 |
+
"openingElement",
|
| 166 |
+
"children",
|
| 167 |
+
"closingElement"
|
| 168 |
+
],
|
| 169 |
+
JSXEmptyExpression: [],
|
| 170 |
+
JSXExpressionContainer: [
|
| 171 |
+
"expression"
|
| 172 |
+
],
|
| 173 |
+
JSXFragment: [
|
| 174 |
+
"openingFragment",
|
| 175 |
+
"children",
|
| 176 |
+
"closingFragment"
|
| 177 |
+
],
|
| 178 |
+
JSXIdentifier: [],
|
| 179 |
+
JSXMemberExpression: [
|
| 180 |
+
"object",
|
| 181 |
+
"property"
|
| 182 |
+
],
|
| 183 |
+
JSXNamespacedName: [
|
| 184 |
+
"namespace",
|
| 185 |
+
"name"
|
| 186 |
+
],
|
| 187 |
+
JSXOpeningElement: [
|
| 188 |
+
"name",
|
| 189 |
+
"attributes"
|
| 190 |
+
],
|
| 191 |
+
JSXOpeningFragment: [],
|
| 192 |
+
JSXSpreadAttribute: [
|
| 193 |
+
"argument"
|
| 194 |
+
],
|
| 195 |
+
JSXSpreadChild: [
|
| 196 |
+
"expression"
|
| 197 |
+
],
|
| 198 |
+
JSXText: [],
|
| 199 |
+
LabeledStatement: [
|
| 200 |
+
"label",
|
| 201 |
+
"body"
|
| 202 |
+
],
|
| 203 |
+
Literal: [],
|
| 204 |
+
LogicalExpression: [
|
| 205 |
+
"left",
|
| 206 |
+
"right"
|
| 207 |
+
],
|
| 208 |
+
MemberExpression: [
|
| 209 |
+
"object",
|
| 210 |
+
"property"
|
| 211 |
+
],
|
| 212 |
+
MetaProperty: [
|
| 213 |
+
"meta",
|
| 214 |
+
"property"
|
| 215 |
+
],
|
| 216 |
+
MethodDefinition: [
|
| 217 |
+
"key",
|
| 218 |
+
"value"
|
| 219 |
+
],
|
| 220 |
+
NewExpression: [
|
| 221 |
+
"callee",
|
| 222 |
+
"arguments"
|
| 223 |
+
],
|
| 224 |
+
ObjectExpression: [
|
| 225 |
+
"properties"
|
| 226 |
+
],
|
| 227 |
+
ObjectPattern: [
|
| 228 |
+
"properties"
|
| 229 |
+
],
|
| 230 |
+
PrivateIdentifier: [],
|
| 231 |
+
Program: [
|
| 232 |
+
"body"
|
| 233 |
+
],
|
| 234 |
+
Property: [
|
| 235 |
+
"key",
|
| 236 |
+
"value"
|
| 237 |
+
],
|
| 238 |
+
PropertyDefinition: [
|
| 239 |
+
"key",
|
| 240 |
+
"value"
|
| 241 |
+
],
|
| 242 |
+
RestElement: [
|
| 243 |
+
"argument"
|
| 244 |
+
],
|
| 245 |
+
ReturnStatement: [
|
| 246 |
+
"argument"
|
| 247 |
+
],
|
| 248 |
+
SequenceExpression: [
|
| 249 |
+
"expressions"
|
| 250 |
+
],
|
| 251 |
+
SpreadElement: [
|
| 252 |
+
"argument"
|
| 253 |
+
],
|
| 254 |
+
StaticBlock: [
|
| 255 |
+
"body"
|
| 256 |
+
],
|
| 257 |
+
Super: [],
|
| 258 |
+
SwitchCase: [
|
| 259 |
+
"test",
|
| 260 |
+
"consequent"
|
| 261 |
+
],
|
| 262 |
+
SwitchStatement: [
|
| 263 |
+
"discriminant",
|
| 264 |
+
"cases"
|
| 265 |
+
],
|
| 266 |
+
TaggedTemplateExpression: [
|
| 267 |
+
"tag",
|
| 268 |
+
"quasi"
|
| 269 |
+
],
|
| 270 |
+
TemplateElement: [],
|
| 271 |
+
TemplateLiteral: [
|
| 272 |
+
"quasis",
|
| 273 |
+
"expressions"
|
| 274 |
+
],
|
| 275 |
+
ThisExpression: [],
|
| 276 |
+
ThrowStatement: [
|
| 277 |
+
"argument"
|
| 278 |
+
],
|
| 279 |
+
TryStatement: [
|
| 280 |
+
"block",
|
| 281 |
+
"handler",
|
| 282 |
+
"finalizer"
|
| 283 |
+
],
|
| 284 |
+
UnaryExpression: [
|
| 285 |
+
"argument"
|
| 286 |
+
],
|
| 287 |
+
UpdateExpression: [
|
| 288 |
+
"argument"
|
| 289 |
+
],
|
| 290 |
+
VariableDeclaration: [
|
| 291 |
+
"declarations"
|
| 292 |
+
],
|
| 293 |
+
VariableDeclarator: [
|
| 294 |
+
"id",
|
| 295 |
+
"init"
|
| 296 |
+
],
|
| 297 |
+
WhileStatement: [
|
| 298 |
+
"test",
|
| 299 |
+
"body"
|
| 300 |
+
],
|
| 301 |
+
WithStatement: [
|
| 302 |
+
"object",
|
| 303 |
+
"body"
|
| 304 |
+
],
|
| 305 |
+
YieldExpression: [
|
| 306 |
+
"argument"
|
| 307 |
+
]
|
| 308 |
+
};
|
| 309 |
+
|
| 310 |
+
// Types.
|
| 311 |
+
const NODE_TYPES = Object.keys(KEYS);
|
| 312 |
+
|
| 313 |
+
// Freeze the keys.
|
| 314 |
+
for (const type of NODE_TYPES) {
|
| 315 |
+
Object.freeze(KEYS[type]);
|
| 316 |
+
}
|
| 317 |
+
Object.freeze(KEYS);
|
| 318 |
+
|
| 319 |
+
/**
|
| 320 |
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
| 321 |
+
* See LICENSE file in root directory for full license.
|
| 322 |
+
*/
|
| 323 |
+
|
| 324 |
+
/**
|
| 325 |
+
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
| 326 |
+
*/
|
| 327 |
+
|
| 328 |
+
// List to ignore keys.
|
| 329 |
+
const KEY_BLACKLIST = new Set([
|
| 330 |
+
"parent",
|
| 331 |
+
"leadingComments",
|
| 332 |
+
"trailingComments"
|
| 333 |
+
]);
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* Check whether a given key should be used or not.
|
| 337 |
+
* @param {string} key The key to check.
|
| 338 |
+
* @returns {boolean} `true` if the key should be used.
|
| 339 |
+
*/
|
| 340 |
+
function filterKey(key) {
|
| 341 |
+
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Get visitor keys of a given node.
|
| 346 |
+
* @param {object} node The AST node to get keys.
|
| 347 |
+
* @returns {readonly string[]} Visitor keys of the node.
|
| 348 |
+
*/
|
| 349 |
+
function getKeys(node) {
|
| 350 |
+
return Object.keys(node).filter(filterKey);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
| 354 |
+
// eslint-disable-next-line valid-jsdoc
|
| 355 |
+
/**
|
| 356 |
+
* Make the union set with `KEYS` and given keys.
|
| 357 |
+
* @param {VisitorKeys} additionalKeys The additional keys.
|
| 358 |
+
* @returns {VisitorKeys} The union set.
|
| 359 |
+
*/
|
| 360 |
+
function unionWith(additionalKeys) {
|
| 361 |
+
const retv = /** @type {{
|
| 362 |
+
[type: string]: ReadonlyArray<string>
|
| 363 |
+
}} */ (Object.assign({}, KEYS));
|
| 364 |
+
|
| 365 |
+
for (const type of Object.keys(additionalKeys)) {
|
| 366 |
+
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
| 367 |
+
const keys = new Set(additionalKeys[type]);
|
| 368 |
+
|
| 369 |
+
for (const key of retv[type]) {
|
| 370 |
+
keys.add(key);
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
retv[type] = Object.freeze(Array.from(keys));
|
| 374 |
+
} else {
|
| 375 |
+
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
return Object.freeze(retv);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
exports.KEYS = KEYS;
|
| 383 |
+
exports.getKeys = getKeys;
|
| 384 |
+
exports.unionWith = unionWith;
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type VisitorKeys$1 = {
|
| 2 |
+
readonly [type: string]: readonly 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, VisitorKeys, getKeys, unionWith };
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/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
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/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]: readonly 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
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
* Get visitor keys of a given node.
|
| 29 |
+
* @param {object} node The AST node to get keys.
|
| 30 |
+
* @returns {readonly string[]} Visitor keys of the node.
|
| 31 |
+
*/
|
| 32 |
+
export function getKeys(node) {
|
| 33 |
+
return Object.keys(node).filter(filterKey);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
| 37 |
+
// eslint-disable-next-line valid-jsdoc
|
| 38 |
+
/**
|
| 39 |
+
* Make the union set with `KEYS` and given keys.
|
| 40 |
+
* @param {VisitorKeys} additionalKeys The additional keys.
|
| 41 |
+
* @returns {VisitorKeys} The union set.
|
| 42 |
+
*/
|
| 43 |
+
export function unionWith(additionalKeys) {
|
| 44 |
+
const retv = /** @type {{
|
| 45 |
+
[type: string]: ReadonlyArray<string>
|
| 46 |
+
}} */ (Object.assign({}, KEYS));
|
| 47 |
+
|
| 48 |
+
for (const type of Object.keys(additionalKeys)) {
|
| 49 |
+
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
| 50 |
+
const keys = new Set(additionalKeys[type]);
|
| 51 |
+
|
| 52 |
+
for (const key of retv[type]) {
|
| 53 |
+
keys.add(key);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
retv[type] = Object.freeze(Array.from(keys));
|
| 57 |
+
} else {
|
| 58 |
+
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return Object.freeze(retv);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
export { KEYS };
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor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itorKeys}
|
| 7 |
+
*/
|
| 8 |
+
const KEYS = {
|
| 9 |
+
ArrayExpression: [
|
| 10 |
+
"elements"
|
| 11 |
+
],
|
| 12 |
+
ArrayPattern: [
|
| 13 |
+
"elements"
|
| 14 |
+
],
|
| 15 |
+
ArrowFunctionExpression: [
|
| 16 |
+
"params",
|
| 17 |
+
"body"
|
| 18 |
+
],
|
| 19 |
+
AssignmentExpression: [
|
| 20 |
+
"left",
|
| 21 |
+
"right"
|
| 22 |
+
],
|
| 23 |
+
AssignmentPattern: [
|
| 24 |
+
"left",
|
| 25 |
+
"right"
|
| 26 |
+
],
|
| 27 |
+
AwaitExpression: [
|
| 28 |
+
"argument"
|
| 29 |
+
],
|
| 30 |
+
BinaryExpression: [
|
| 31 |
+
"left",
|
| 32 |
+
"right"
|
| 33 |
+
],
|
| 34 |
+
BlockStatement: [
|
| 35 |
+
"body"
|
| 36 |
+
],
|
| 37 |
+
BreakStatement: [
|
| 38 |
+
"label"
|
| 39 |
+
],
|
| 40 |
+
CallExpression: [
|
| 41 |
+
"callee",
|
| 42 |
+
"arguments"
|
| 43 |
+
],
|
| 44 |
+
CatchClause: [
|
| 45 |
+
"param",
|
| 46 |
+
"body"
|
| 47 |
+
],
|
| 48 |
+
ChainExpression: [
|
| 49 |
+
"expression"
|
| 50 |
+
],
|
| 51 |
+
ClassBody: [
|
| 52 |
+
"body"
|
| 53 |
+
],
|
| 54 |
+
ClassDeclaration: [
|
| 55 |
+
"id",
|
| 56 |
+
"superClass",
|
| 57 |
+
"body"
|
| 58 |
+
],
|
| 59 |
+
ClassExpression: [
|
| 60 |
+
"id",
|
| 61 |
+
"superClass",
|
| 62 |
+
"body"
|
| 63 |
+
],
|
| 64 |
+
ConditionalExpression: [
|
| 65 |
+
"test",
|
| 66 |
+
"consequent",
|
| 67 |
+
"alternate"
|
| 68 |
+
],
|
| 69 |
+
ContinueStatement: [
|
| 70 |
+
"label"
|
| 71 |
+
],
|
| 72 |
+
DebuggerStatement: [],
|
| 73 |
+
DoWhileStatement: [
|
| 74 |
+
"body",
|
| 75 |
+
"test"
|
| 76 |
+
],
|
| 77 |
+
EmptyStatement: [],
|
| 78 |
+
ExperimentalRestProperty: [
|
| 79 |
+
"argument"
|
| 80 |
+
],
|
| 81 |
+
ExperimentalSpreadProperty: [
|
| 82 |
+
"argument"
|
| 83 |
+
],
|
| 84 |
+
ExportAllDeclaration: [
|
| 85 |
+
"exported",
|
| 86 |
+
"source"
|
| 87 |
+
],
|
| 88 |
+
ExportDefaultDeclaration: [
|
| 89 |
+
"declaration"
|
| 90 |
+
],
|
| 91 |
+
ExportNamedDeclaration: [
|
| 92 |
+
"declaration",
|
| 93 |
+
"specifiers",
|
| 94 |
+
"source"
|
| 95 |
+
],
|
| 96 |
+
ExportSpecifier: [
|
| 97 |
+
"exported",
|
| 98 |
+
"local"
|
| 99 |
+
],
|
| 100 |
+
ExpressionStatement: [
|
| 101 |
+
"expression"
|
| 102 |
+
],
|
| 103 |
+
ForInStatement: [
|
| 104 |
+
"left",
|
| 105 |
+
"right",
|
| 106 |
+
"body"
|
| 107 |
+
],
|
| 108 |
+
ForOfStatement: [
|
| 109 |
+
"left",
|
| 110 |
+
"right",
|
| 111 |
+
"body"
|
| 112 |
+
],
|
| 113 |
+
ForStatement: [
|
| 114 |
+
"init",
|
| 115 |
+
"test",
|
| 116 |
+
"update",
|
| 117 |
+
"body"
|
| 118 |
+
],
|
| 119 |
+
FunctionDeclaration: [
|
| 120 |
+
"id",
|
| 121 |
+
"params",
|
| 122 |
+
"body"
|
| 123 |
+
],
|
| 124 |
+
FunctionExpression: [
|
| 125 |
+
"id",
|
| 126 |
+
"params",
|
| 127 |
+
"body"
|
| 128 |
+
],
|
| 129 |
+
Identifier: [],
|
| 130 |
+
IfStatement: [
|
| 131 |
+
"test",
|
| 132 |
+
"consequent",
|
| 133 |
+
"alternate"
|
| 134 |
+
],
|
| 135 |
+
ImportDeclaration: [
|
| 136 |
+
"specifiers",
|
| 137 |
+
"source"
|
| 138 |
+
],
|
| 139 |
+
ImportDefaultSpecifier: [
|
| 140 |
+
"local"
|
| 141 |
+
],
|
| 142 |
+
ImportExpression: [
|
| 143 |
+
"source"
|
| 144 |
+
],
|
| 145 |
+
ImportNamespaceSpecifier: [
|
| 146 |
+
"local"
|
| 147 |
+
],
|
| 148 |
+
ImportSpecifier: [
|
| 149 |
+
"imported",
|
| 150 |
+
"local"
|
| 151 |
+
],
|
| 152 |
+
JSXAttribute: [
|
| 153 |
+
"name",
|
| 154 |
+
"value"
|
| 155 |
+
],
|
| 156 |
+
JSXClosingElement: [
|
| 157 |
+
"name"
|
| 158 |
+
],
|
| 159 |
+
JSXClosingFragment: [],
|
| 160 |
+
JSXElement: [
|
| 161 |
+
"openingElement",
|
| 162 |
+
"children",
|
| 163 |
+
"closingElement"
|
| 164 |
+
],
|
| 165 |
+
JSXEmptyExpression: [],
|
| 166 |
+
JSXExpressionContainer: [
|
| 167 |
+
"expression"
|
| 168 |
+
],
|
| 169 |
+
JSXFragment: [
|
| 170 |
+
"openingFragment",
|
| 171 |
+
"children",
|
| 172 |
+
"closingFragment"
|
| 173 |
+
],
|
| 174 |
+
JSXIdentifier: [],
|
| 175 |
+
JSXMemberExpression: [
|
| 176 |
+
"object",
|
| 177 |
+
"property"
|
| 178 |
+
],
|
| 179 |
+
JSXNamespacedName: [
|
| 180 |
+
"namespace",
|
| 181 |
+
"name"
|
| 182 |
+
],
|
| 183 |
+
JSXOpeningElement: [
|
| 184 |
+
"name",
|
| 185 |
+
"attributes"
|
| 186 |
+
],
|
| 187 |
+
JSXOpeningFragment: [],
|
| 188 |
+
JSXSpreadAttribute: [
|
| 189 |
+
"argument"
|
| 190 |
+
],
|
| 191 |
+
JSXSpreadChild: [
|
| 192 |
+
"expression"
|
| 193 |
+
],
|
| 194 |
+
JSXText: [],
|
| 195 |
+
LabeledStatement: [
|
| 196 |
+
"label",
|
| 197 |
+
"body"
|
| 198 |
+
],
|
| 199 |
+
Literal: [],
|
| 200 |
+
LogicalExpression: [
|
| 201 |
+
"left",
|
| 202 |
+
"right"
|
| 203 |
+
],
|
| 204 |
+
MemberExpression: [
|
| 205 |
+
"object",
|
| 206 |
+
"property"
|
| 207 |
+
],
|
| 208 |
+
MetaProperty: [
|
| 209 |
+
"meta",
|
| 210 |
+
"property"
|
| 211 |
+
],
|
| 212 |
+
MethodDefinition: [
|
| 213 |
+
"key",
|
| 214 |
+
"value"
|
| 215 |
+
],
|
| 216 |
+
NewExpression: [
|
| 217 |
+
"callee",
|
| 218 |
+
"arguments"
|
| 219 |
+
],
|
| 220 |
+
ObjectExpression: [
|
| 221 |
+
"properties"
|
| 222 |
+
],
|
| 223 |
+
ObjectPattern: [
|
| 224 |
+
"properties"
|
| 225 |
+
],
|
| 226 |
+
PrivateIdentifier: [],
|
| 227 |
+
Program: [
|
| 228 |
+
"body"
|
| 229 |
+
],
|
| 230 |
+
Property: [
|
| 231 |
+
"key",
|
| 232 |
+
"value"
|
| 233 |
+
],
|
| 234 |
+
PropertyDefinition: [
|
| 235 |
+
"key",
|
| 236 |
+
"value"
|
| 237 |
+
],
|
| 238 |
+
RestElement: [
|
| 239 |
+
"argument"
|
| 240 |
+
],
|
| 241 |
+
ReturnStatement: [
|
| 242 |
+
"argument"
|
| 243 |
+
],
|
| 244 |
+
SequenceExpression: [
|
| 245 |
+
"expressions"
|
| 246 |
+
],
|
| 247 |
+
SpreadElement: [
|
| 248 |
+
"argument"
|
| 249 |
+
],
|
| 250 |
+
StaticBlock: [
|
| 251 |
+
"body"
|
| 252 |
+
],
|
| 253 |
+
Super: [],
|
| 254 |
+
SwitchCase: [
|
| 255 |
+
"test",
|
| 256 |
+
"consequent"
|
| 257 |
+
],
|
| 258 |
+
SwitchStatement: [
|
| 259 |
+
"discriminant",
|
| 260 |
+
"cases"
|
| 261 |
+
],
|
| 262 |
+
TaggedTemplateExpression: [
|
| 263 |
+
"tag",
|
| 264 |
+
"quasi"
|
| 265 |
+
],
|
| 266 |
+
TemplateElement: [],
|
| 267 |
+
TemplateLiteral: [
|
| 268 |
+
"quasis",
|
| 269 |
+
"expressions"
|
| 270 |
+
],
|
| 271 |
+
ThisExpression: [],
|
| 272 |
+
ThrowStatement: [
|
| 273 |
+
"argument"
|
| 274 |
+
],
|
| 275 |
+
TryStatement: [
|
| 276 |
+
"block",
|
| 277 |
+
"handler",
|
| 278 |
+
"finalizer"
|
| 279 |
+
],
|
| 280 |
+
UnaryExpression: [
|
| 281 |
+
"argument"
|
| 282 |
+
],
|
| 283 |
+
UpdateExpression: [
|
| 284 |
+
"argument"
|
| 285 |
+
],
|
| 286 |
+
VariableDeclaration: [
|
| 287 |
+
"declarations"
|
| 288 |
+
],
|
| 289 |
+
VariableDeclarator: [
|
| 290 |
+
"id",
|
| 291 |
+
"init"
|
| 292 |
+
],
|
| 293 |
+
WhileStatement: [
|
| 294 |
+
"test",
|
| 295 |
+
"body"
|
| 296 |
+
],
|
| 297 |
+
WithStatement: [
|
| 298 |
+
"object",
|
| 299 |
+
"body"
|
| 300 |
+
],
|
| 301 |
+
YieldExpression: [
|
| 302 |
+
"argument"
|
| 303 |
+
]
|
| 304 |
+
};
|
| 305 |
+
|
| 306 |
+
// Types.
|
| 307 |
+
const NODE_TYPES = Object.keys(KEYS);
|
| 308 |
+
|
| 309 |
+
// Freeze the keys.
|
| 310 |
+
for (const type of NODE_TYPES) {
|
| 311 |
+
Object.freeze(KEYS[type]);
|
| 312 |
+
}
|
| 313 |
+
Object.freeze(KEYS);
|
| 314 |
+
|
| 315 |
+
export default KEYS;
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "eslint-visitor-keys",
|
| 3 |
+
"version": "3.4.3",
|
| 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": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
| 27 |
+
},
|
| 28 |
+
"devDependencies": {
|
| 29 |
+
"@types/estree": "^0.0.51",
|
| 30 |
+
"@types/estree-jsx": "^0.0.1",
|
| 31 |
+
"@typescript-eslint/parser": "^5.14.0",
|
| 32 |
+
"c8": "^7.11.0",
|
| 33 |
+
"chai": "^4.3.6",
|
| 34 |
+
"eslint": "^7.29.0",
|
| 35 |
+
"eslint-config-eslint": "^7.0.0",
|
| 36 |
+
"eslint-plugin-jsdoc": "^35.4.0",
|
| 37 |
+
"eslint-plugin-node": "^11.1.0",
|
| 38 |
+
"eslint-release": "^3.2.0",
|
| 39 |
+
"esquery": "^1.4.0",
|
| 40 |
+
"json-diff": "^0.7.3",
|
| 41 |
+
"mocha": "^9.2.1",
|
| 42 |
+
"opener": "^1.5.2",
|
| 43 |
+
"rollup": "^2.70.0",
|
| 44 |
+
"rollup-plugin-dts": "^4.2.3",
|
| 45 |
+
"tsd": "^0.19.1",
|
| 46 |
+
"typescript": "^4.6.2"
|
| 47 |
+
},
|
| 48 |
+
"scripts": {
|
| 49 |
+
"build": "npm run build:cjs && npm run build:types",
|
| 50 |
+
"build:cjs": "rollup -c",
|
| 51 |
+
"build:debug": "npm run build:cjs -- -m && npm run build:types",
|
| 52 |
+
"build:keys": "node tools/build-keys-from-ts",
|
| 53 |
+
"build:types": "tsc",
|
| 54 |
+
"lint": "eslint .",
|
| 55 |
+
"prepare": "npm run build",
|
| 56 |
+
"release:generate:latest": "eslint-generate-release",
|
| 57 |
+
"release:generate:alpha": "eslint-generate-prerelease alpha",
|
| 58 |
+
"release:generate:beta": "eslint-generate-prerelease beta",
|
| 59 |
+
"release:generate:rc": "eslint-generate-prerelease rc",
|
| 60 |
+
"release:publish": "eslint-publish-release",
|
| 61 |
+
"test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types",
|
| 62 |
+
"test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
|
| 63 |
+
"test:types": "tsd"
|
| 64 |
+
},
|
| 65 |
+
"repository": "eslint/eslint-visitor-keys",
|
| 66 |
+
"funding": "https://opencollective.com/eslint",
|
| 67 |
+
"keywords": [],
|
| 68 |
+
"author": "Toru Nagashima (https://github.com/mysticatea)",
|
| 69 |
+
"license": "Apache-2.0",
|
| 70 |
+
"bugs": {
|
| 71 |
+
"url": "https://github.com/eslint/eslint-visitor-keys/issues"
|
| 72 |
+
},
|
| 73 |
+
"homepage": "https://github.com/eslint/eslint-visitor-keys#readme"
|
| 74 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/eslint-utils/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@eslint-community/eslint-utils",
|
| 3 |
+
"version": "4.7.0",
|
| 4 |
+
"description": "Utilities for ESLint plugins.",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"eslint"
|
| 7 |
+
],
|
| 8 |
+
"homepage": "https://github.com/eslint-community/eslint-utils#readme",
|
| 9 |
+
"bugs": {
|
| 10 |
+
"url": "https://github.com/eslint-community/eslint-utils/issues"
|
| 11 |
+
},
|
| 12 |
+
"repository": {
|
| 13 |
+
"type": "git",
|
| 14 |
+
"url": "https://github.com/eslint-community/eslint-utils"
|
| 15 |
+
},
|
| 16 |
+
"license": "MIT",
|
| 17 |
+
"author": "Toru Nagashima",
|
| 18 |
+
"sideEffects": false,
|
| 19 |
+
"exports": {
|
| 20 |
+
".": {
|
| 21 |
+
"import": "./index.mjs",
|
| 22 |
+
"require": "./index.js"
|
| 23 |
+
},
|
| 24 |
+
"./package.json": "./package.json"
|
| 25 |
+
},
|
| 26 |
+
"main": "index",
|
| 27 |
+
"module": "index.mjs",
|
| 28 |
+
"files": [
|
| 29 |
+
"index.*"
|
| 30 |
+
],
|
| 31 |
+
"scripts": {
|
| 32 |
+
"prebuild": "npm run -s clean",
|
| 33 |
+
"build": "npm run build:dts && npm run build:rollup",
|
| 34 |
+
"build:dts": "tsc -p tsconfig.build.json",
|
| 35 |
+
"build:rollup": "rollup -c",
|
| 36 |
+
"clean": "rimraf .nyc_output coverage index.* dist",
|
| 37 |
+
"coverage": "opener ./coverage/lcov-report/index.html",
|
| 38 |
+
"docs:build": "vitepress build docs",
|
| 39 |
+
"docs:watch": "vitepress dev docs",
|
| 40 |
+
"format": "npm run -s format:prettier -- --write",
|
| 41 |
+
"format:prettier": "prettier .",
|
| 42 |
+
"format:check": "npm run -s format:prettier -- --check",
|
| 43 |
+
"lint:eslint": "eslint .",
|
| 44 |
+
"lint:format": "npm run -s format:check",
|
| 45 |
+
"lint:installed-check": "installed-check -v -i installed-check -i npm-run-all2 -i knip -i rollup-plugin-dts",
|
| 46 |
+
"lint:knip": "knip",
|
| 47 |
+
"lint": "run-p lint:*",
|
| 48 |
+
"test-coverage": "c8 mocha --reporter dot \"test/*.mjs\"",
|
| 49 |
+
"test": "mocha --reporter dot \"test/*.mjs\"",
|
| 50 |
+
"preversion": "npm run test-coverage && npm run -s build",
|
| 51 |
+
"postversion": "git push && git push --tags",
|
| 52 |
+
"prewatch": "npm run -s clean",
|
| 53 |
+
"watch": "warun \"{src,test}/**/*.mjs\" -- npm run -s test:mocha"
|
| 54 |
+
},
|
| 55 |
+
"dependencies": {
|
| 56 |
+
"eslint-visitor-keys": "^3.4.3"
|
| 57 |
+
},
|
| 58 |
+
"devDependencies": {
|
| 59 |
+
"@eslint-community/eslint-plugin-mysticatea": "^15.6.1",
|
| 60 |
+
"@types/eslint": "^9.6.1",
|
| 61 |
+
"@types/estree": "^1.0.7",
|
| 62 |
+
"@typescript-eslint/parser": "^5.62.0",
|
| 63 |
+
"@typescript-eslint/types": "^5.62.0",
|
| 64 |
+
"c8": "^8.0.1",
|
| 65 |
+
"dot-prop": "^7.2.0",
|
| 66 |
+
"eslint": "^8.57.1",
|
| 67 |
+
"installed-check": "^8.0.1",
|
| 68 |
+
"knip": "^5.33.3",
|
| 69 |
+
"mocha": "^9.2.2",
|
| 70 |
+
"npm-run-all2": "^6.2.3",
|
| 71 |
+
"opener": "^1.5.2",
|
| 72 |
+
"prettier": "2.8.8",
|
| 73 |
+
"rimraf": "^3.0.2",
|
| 74 |
+
"rollup": "^2.79.2",
|
| 75 |
+
"rollup-plugin-dts": "^4.2.3",
|
| 76 |
+
"rollup-plugin-sourcemaps": "^0.6.3",
|
| 77 |
+
"semver": "^7.6.3",
|
| 78 |
+
"typescript": "^4.9.5",
|
| 79 |
+
"vitepress": "^1.4.1",
|
| 80 |
+
"warun": "^1.0.0"
|
| 81 |
+
},
|
| 82 |
+
"peerDependencies": {
|
| 83 |
+
"eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
|
| 84 |
+
},
|
| 85 |
+
"engines": {
|
| 86 |
+
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
| 87 |
+
},
|
| 88 |
+
"funding": "https://opencollective.com/eslint"
|
| 89 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Toru Nagashima
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @eslint-community/regexpp
|
| 2 |
+
|
| 3 |
+
[](https://www.npmjs.com/package/@eslint-community/regexpp)
|
| 4 |
+
[](http://www.npmtrends.com/@eslint-community/regexpp)
|
| 5 |
+
[](https://github.com/eslint-community/regexpp/actions)
|
| 6 |
+
[](https://codecov.io/gh/eslint-community/regexpp)
|
| 7 |
+
|
| 8 |
+
A regular expression parser for ECMAScript.
|
| 9 |
+
|
| 10 |
+
## 💿 Installation
|
| 11 |
+
|
| 12 |
+
```bash
|
| 13 |
+
$ npm install @eslint-community/regexpp
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
- require Node@^12.0.0 || ^14.0.0 || >=16.0.0.
|
| 17 |
+
|
| 18 |
+
## 📖 Usage
|
| 19 |
+
|
| 20 |
+
```ts
|
| 21 |
+
import {
|
| 22 |
+
AST,
|
| 23 |
+
RegExpParser,
|
| 24 |
+
RegExpValidator,
|
| 25 |
+
RegExpVisitor,
|
| 26 |
+
parseRegExpLiteral,
|
| 27 |
+
validateRegExpLiteral,
|
| 28 |
+
visitRegExpAST
|
| 29 |
+
} from "@eslint-community/regexpp"
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
### parseRegExpLiteral(source, options?)
|
| 33 |
+
|
| 34 |
+
Parse a given regular expression literal then make AST object.
|
| 35 |
+
|
| 36 |
+
This is equivalent to `new RegExpParser(options).parseLiteral(source)`.
|
| 37 |
+
|
| 38 |
+
- **Parameters:**
|
| 39 |
+
- `source` (`string | RegExp`) The source code to parse.
|
| 40 |
+
- `options?` ([`RegExpParser.Options`]) The options to parse.
|
| 41 |
+
- **Return:**
|
| 42 |
+
- The AST of the regular expression.
|
| 43 |
+
|
| 44 |
+
### validateRegExpLiteral(source, options?)
|
| 45 |
+
|
| 46 |
+
Validate a given regular expression literal.
|
| 47 |
+
|
| 48 |
+
This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
|
| 49 |
+
|
| 50 |
+
- **Parameters:**
|
| 51 |
+
- `source` (`string`) The source code to validate.
|
| 52 |
+
- `options?` ([`RegExpValidator.Options`]) The options to validate.
|
| 53 |
+
|
| 54 |
+
### visitRegExpAST(ast, handlers)
|
| 55 |
+
|
| 56 |
+
Visit each node of a given AST.
|
| 57 |
+
|
| 58 |
+
This is equivalent to `new RegExpVisitor(handlers).visit(ast)`.
|
| 59 |
+
|
| 60 |
+
- **Parameters:**
|
| 61 |
+
- `ast` ([`AST.Node`]) The AST to visit.
|
| 62 |
+
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
|
| 63 |
+
|
| 64 |
+
### RegExpParser
|
| 65 |
+
|
| 66 |
+
#### new RegExpParser(options?)
|
| 67 |
+
|
| 68 |
+
- **Parameters:**
|
| 69 |
+
- `options?` ([`RegExpParser.Options`]) The options to parse.
|
| 70 |
+
|
| 71 |
+
#### parser.parseLiteral(source, start?, end?)
|
| 72 |
+
|
| 73 |
+
Parse a regular expression literal.
|
| 74 |
+
|
| 75 |
+
- **Parameters:**
|
| 76 |
+
- `source` (`string`) The source code to parse. E.g. `"/abc/g"`.
|
| 77 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 78 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 79 |
+
- **Return:**
|
| 80 |
+
- The AST of the regular expression.
|
| 81 |
+
|
| 82 |
+
#### parser.parsePattern(source, start?, end?, flags?)
|
| 83 |
+
|
| 84 |
+
Parse a regular expression pattern.
|
| 85 |
+
|
| 86 |
+
- **Parameters:**
|
| 87 |
+
- `source` (`string`) The source code to parse. E.g. `"abc"`.
|
| 88 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 89 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 90 |
+
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
|
| 91 |
+
- **Return:**
|
| 92 |
+
- The AST of the regular expression pattern.
|
| 93 |
+
|
| 94 |
+
#### parser.parseFlags(source, start?, end?)
|
| 95 |
+
|
| 96 |
+
Parse a regular expression flags.
|
| 97 |
+
|
| 98 |
+
- **Parameters:**
|
| 99 |
+
- `source` (`string`) The source code to parse. E.g. `"gim"`.
|
| 100 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 101 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 102 |
+
- **Return:**
|
| 103 |
+
- The AST of the regular expression flags.
|
| 104 |
+
|
| 105 |
+
### RegExpValidator
|
| 106 |
+
|
| 107 |
+
#### new RegExpValidator(options)
|
| 108 |
+
|
| 109 |
+
- **Parameters:**
|
| 110 |
+
- `options` ([`RegExpValidator.Options`]) The options to validate.
|
| 111 |
+
|
| 112 |
+
#### validator.validateLiteral(source, start, end)
|
| 113 |
+
|
| 114 |
+
Validate a regular expression literal.
|
| 115 |
+
|
| 116 |
+
- **Parameters:**
|
| 117 |
+
- `source` (`string`) The source code to validate.
|
| 118 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 119 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 120 |
+
|
| 121 |
+
#### validator.validatePattern(source, start, end, flags)
|
| 122 |
+
|
| 123 |
+
Validate a regular expression pattern.
|
| 124 |
+
|
| 125 |
+
- **Parameters:**
|
| 126 |
+
- `source` (`string`) The source code to validate.
|
| 127 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 128 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 129 |
+
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
|
| 130 |
+
|
| 131 |
+
#### validator.validateFlags(source, start, end)
|
| 132 |
+
|
| 133 |
+
Validate a regular expression flags.
|
| 134 |
+
|
| 135 |
+
- **Parameters:**
|
| 136 |
+
- `source` (`string`) The source code to validate.
|
| 137 |
+
- `start?` (`number`) The start index in the source code. Default is `0`.
|
| 138 |
+
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
| 139 |
+
|
| 140 |
+
### RegExpVisitor
|
| 141 |
+
|
| 142 |
+
#### new RegExpVisitor(handlers)
|
| 143 |
+
|
| 144 |
+
- **Parameters:**
|
| 145 |
+
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
|
| 146 |
+
|
| 147 |
+
#### visitor.visit(ast)
|
| 148 |
+
|
| 149 |
+
Validate a regular expression literal.
|
| 150 |
+
|
| 151 |
+
- **Parameters:**
|
| 152 |
+
- `ast` ([`AST.Node`]) The AST to visit.
|
| 153 |
+
|
| 154 |
+
## 📰 Changelog
|
| 155 |
+
|
| 156 |
+
- [GitHub Releases](https://github.com/eslint-community/regexpp/releases)
|
| 157 |
+
|
| 158 |
+
## 🍻 Contributing
|
| 159 |
+
|
| 160 |
+
Welcome contributing!
|
| 161 |
+
|
| 162 |
+
Please use GitHub's Issues/PRs.
|
| 163 |
+
|
| 164 |
+
### Development Tools
|
| 165 |
+
|
| 166 |
+
- `npm test` runs tests and measures coverage.
|
| 167 |
+
- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`.
|
| 168 |
+
- `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`.
|
| 169 |
+
- `npm run lint` runs ESLint.
|
| 170 |
+
- `npm run update:test` updates test fixtures.
|
| 171 |
+
- `npm run update:ids` updates `src/unicode/ids.ts`.
|
| 172 |
+
- `npm run watch` runs tests with `--watch` option.
|
| 173 |
+
|
| 174 |
+
[`AST.Node`]: src/ast.ts#L4
|
| 175 |
+
[`RegExpParser.Options`]: src/parser.ts#L743
|
| 176 |
+
[`RegExpValidator.Options`]: src/validator.ts#L220
|
| 177 |
+
[`RegExpVisitor.Handlers`]: src/visitor.ts#L291
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.d.ts
ADDED
|
@@ -0,0 +1,1163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generated by dts-bundle v0.7.3
|
| 2 |
+
|
| 3 |
+
declare module "@eslint-community/regexpp" {
|
| 4 |
+
import * as AST from "@eslint-community/regexpp/ast";
|
| 5 |
+
import { RegExpParser } from "@eslint-community/regexpp/parser";
|
| 6 |
+
import { RegExpValidator } from "@eslint-community/regexpp/validator";
|
| 7 |
+
import { RegExpVisitor } from "@eslint-community/regexpp/visitor";
|
| 8 |
+
export { RegExpSyntaxError } from "@eslint-community/regexpp/regexp-syntax-error";
|
| 9 |
+
export { AST, RegExpParser, RegExpValidator };
|
| 10 |
+
/**
|
| 11 |
+
* Parse a given regular expression literal then make AST object.
|
| 12 |
+
* @param source The source code to parse.
|
| 13 |
+
* @param options The options to parse.
|
| 14 |
+
* @returns The AST of the regular expression.
|
| 15 |
+
*/
|
| 16 |
+
export function parseRegExpLiteral(
|
| 17 |
+
source: RegExp | string,
|
| 18 |
+
options?: RegExpParser.Options
|
| 19 |
+
): AST.RegExpLiteral;
|
| 20 |
+
/**
|
| 21 |
+
* Validate a given regular expression literal.
|
| 22 |
+
* @param source The source code to validate.
|
| 23 |
+
* @param options The options to validate.
|
| 24 |
+
*/
|
| 25 |
+
export function validateRegExpLiteral(
|
| 26 |
+
source: string,
|
| 27 |
+
options?: RegExpValidator.Options
|
| 28 |
+
): void;
|
| 29 |
+
export function visitRegExpAST(
|
| 30 |
+
node: AST.Node,
|
| 31 |
+
handlers: RegExpVisitor.Handlers
|
| 32 |
+
): void;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
declare module "@eslint-community/regexpp/ast" {
|
| 36 |
+
/**
|
| 37 |
+
* The type which includes all nodes.
|
| 38 |
+
*/
|
| 39 |
+
export type Node = BranchNode | LeafNode;
|
| 40 |
+
/**
|
| 41 |
+
* The type which includes all branch nodes.
|
| 42 |
+
*/
|
| 43 |
+
export type BranchNode =
|
| 44 |
+
| Alternative
|
| 45 |
+
| CapturingGroup
|
| 46 |
+
| CharacterClass
|
| 47 |
+
| CharacterClassRange
|
| 48 |
+
| ClassIntersection
|
| 49 |
+
| ClassStringDisjunction
|
| 50 |
+
| ClassSubtraction
|
| 51 |
+
| ExpressionCharacterClass
|
| 52 |
+
| Group
|
| 53 |
+
| LookaroundAssertion
|
| 54 |
+
| Modifiers
|
| 55 |
+
| Pattern
|
| 56 |
+
| Quantifier
|
| 57 |
+
| RegExpLiteral
|
| 58 |
+
| StringAlternative;
|
| 59 |
+
/**
|
| 60 |
+
* The type which includes all leaf nodes.
|
| 61 |
+
*/
|
| 62 |
+
export type LeafNode =
|
| 63 |
+
| Backreference
|
| 64 |
+
| BoundaryAssertion
|
| 65 |
+
| Character
|
| 66 |
+
| CharacterSet
|
| 67 |
+
| Flags
|
| 68 |
+
| ModifierFlags;
|
| 69 |
+
/**
|
| 70 |
+
* The type which includes all atom nodes.
|
| 71 |
+
*/
|
| 72 |
+
export type Element = Assertion | QuantifiableElement | Quantifier;
|
| 73 |
+
/**
|
| 74 |
+
* The type which includes all atom nodes that Quantifier node can have as children.
|
| 75 |
+
*/
|
| 76 |
+
export type QuantifiableElement =
|
| 77 |
+
| Backreference
|
| 78 |
+
| CapturingGroup
|
| 79 |
+
| Character
|
| 80 |
+
| CharacterClass
|
| 81 |
+
| CharacterSet
|
| 82 |
+
| ExpressionCharacterClass
|
| 83 |
+
| Group
|
| 84 |
+
| LookaheadAssertion;
|
| 85 |
+
/**
|
| 86 |
+
* The type which includes all character class atom nodes.
|
| 87 |
+
*/
|
| 88 |
+
export type CharacterClassElement =
|
| 89 |
+
| ClassRangesCharacterClassElement
|
| 90 |
+
| UnicodeSetsCharacterClassElement;
|
| 91 |
+
export type ClassRangesCharacterClassElement =
|
| 92 |
+
| Character
|
| 93 |
+
| CharacterClassRange
|
| 94 |
+
| CharacterUnicodePropertyCharacterSet
|
| 95 |
+
| EscapeCharacterSet;
|
| 96 |
+
export type UnicodeSetsCharacterClassElement =
|
| 97 |
+
| Character
|
| 98 |
+
| CharacterClassRange
|
| 99 |
+
| ClassStringDisjunction
|
| 100 |
+
| EscapeCharacterSet
|
| 101 |
+
| ExpressionCharacterClass
|
| 102 |
+
| UnicodePropertyCharacterSet
|
| 103 |
+
| UnicodeSetsCharacterClass;
|
| 104 |
+
/**
|
| 105 |
+
* The type which defines common properties for all node types.
|
| 106 |
+
*/
|
| 107 |
+
export interface NodeBase {
|
| 108 |
+
/** The node type. */
|
| 109 |
+
type: Node["type"];
|
| 110 |
+
/** The parent node. */
|
| 111 |
+
parent: Node["parent"];
|
| 112 |
+
/** The 0-based index that this node starts. */
|
| 113 |
+
start: number;
|
| 114 |
+
/** The 0-based index that this node ends. */
|
| 115 |
+
end: number;
|
| 116 |
+
/** The raw text of this node. */
|
| 117 |
+
raw: string;
|
| 118 |
+
}
|
| 119 |
+
/**
|
| 120 |
+
* The root node.
|
| 121 |
+
*/
|
| 122 |
+
export interface RegExpLiteral extends NodeBase {
|
| 123 |
+
type: "RegExpLiteral";
|
| 124 |
+
parent: null;
|
| 125 |
+
pattern: Pattern;
|
| 126 |
+
flags: Flags;
|
| 127 |
+
}
|
| 128 |
+
/**
|
| 129 |
+
* The pattern.
|
| 130 |
+
*/
|
| 131 |
+
export interface Pattern extends NodeBase {
|
| 132 |
+
type: "Pattern";
|
| 133 |
+
parent: RegExpLiteral | null;
|
| 134 |
+
alternatives: Alternative[];
|
| 135 |
+
}
|
| 136 |
+
/**
|
| 137 |
+
* The alternative.
|
| 138 |
+
* E.g. `a|b`
|
| 139 |
+
*/
|
| 140 |
+
export interface Alternative extends NodeBase {
|
| 141 |
+
type: "Alternative";
|
| 142 |
+
parent: CapturingGroup | Group | LookaroundAssertion | Pattern;
|
| 143 |
+
elements: Element[];
|
| 144 |
+
}
|
| 145 |
+
/**
|
| 146 |
+
* The uncapturing group.
|
| 147 |
+
* E.g. `(?:ab)`
|
| 148 |
+
*/
|
| 149 |
+
export interface Group extends NodeBase {
|
| 150 |
+
type: "Group";
|
| 151 |
+
parent: Alternative | Quantifier;
|
| 152 |
+
modifiers: Modifiers | null;
|
| 153 |
+
alternatives: Alternative[];
|
| 154 |
+
}
|
| 155 |
+
/**
|
| 156 |
+
* The capturing group.
|
| 157 |
+
* E.g. `(ab)`, `(?<name>ab)`
|
| 158 |
+
*/
|
| 159 |
+
export interface CapturingGroup extends NodeBase {
|
| 160 |
+
type: "CapturingGroup";
|
| 161 |
+
parent: Alternative | Quantifier;
|
| 162 |
+
name: string | null;
|
| 163 |
+
alternatives: Alternative[];
|
| 164 |
+
references: Backreference[];
|
| 165 |
+
}
|
| 166 |
+
/**
|
| 167 |
+
* The lookaround assertion.
|
| 168 |
+
*/
|
| 169 |
+
export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion;
|
| 170 |
+
/**
|
| 171 |
+
* The lookahead assertion.
|
| 172 |
+
* E.g. `(?=ab)`, `(?!ab)`
|
| 173 |
+
*/
|
| 174 |
+
export interface LookaheadAssertion extends NodeBase {
|
| 175 |
+
type: "Assertion";
|
| 176 |
+
parent: Alternative | Quantifier;
|
| 177 |
+
kind: "lookahead";
|
| 178 |
+
negate: boolean;
|
| 179 |
+
alternatives: Alternative[];
|
| 180 |
+
}
|
| 181 |
+
/**
|
| 182 |
+
* The lookbehind assertion.
|
| 183 |
+
* E.g. `(?<=ab)`, `(?<!ab)`
|
| 184 |
+
*/
|
| 185 |
+
export interface LookbehindAssertion extends NodeBase {
|
| 186 |
+
type: "Assertion";
|
| 187 |
+
parent: Alternative;
|
| 188 |
+
kind: "lookbehind";
|
| 189 |
+
negate: boolean;
|
| 190 |
+
alternatives: Alternative[];
|
| 191 |
+
}
|
| 192 |
+
/**
|
| 193 |
+
* The quantifier.
|
| 194 |
+
* E.g. `a?`, `a*`, `a+`, `a{1,2}`, `a??`, `a*?`, `a+?`, `a{1,2}?`
|
| 195 |
+
*/
|
| 196 |
+
export interface Quantifier extends NodeBase {
|
| 197 |
+
type: "Quantifier";
|
| 198 |
+
parent: Alternative;
|
| 199 |
+
min: number;
|
| 200 |
+
max: number;
|
| 201 |
+
greedy: boolean;
|
| 202 |
+
element: QuantifiableElement;
|
| 203 |
+
}
|
| 204 |
+
/**
|
| 205 |
+
* The character class.
|
| 206 |
+
* E.g. `[ab]`, `[^ab]`
|
| 207 |
+
*/
|
| 208 |
+
export type CharacterClass =
|
| 209 |
+
| ClassRangesCharacterClass
|
| 210 |
+
| UnicodeSetsCharacterClass;
|
| 211 |
+
interface BaseCharacterClass extends NodeBase {
|
| 212 |
+
type: "CharacterClass";
|
| 213 |
+
parent:
|
| 214 |
+
| Alternative
|
| 215 |
+
| ClassIntersection
|
| 216 |
+
| ClassSubtraction
|
| 217 |
+
| Quantifier
|
| 218 |
+
| UnicodeSetsCharacterClass;
|
| 219 |
+
unicodeSets: boolean;
|
| 220 |
+
negate: boolean;
|
| 221 |
+
elements: CharacterClassElement[];
|
| 222 |
+
}
|
| 223 |
+
/**
|
| 224 |
+
* The character class used in legacy (neither `u` nor `v` flag) and Unicode mode (`u` flag).
|
| 225 |
+
*
|
| 226 |
+
* This character class is guaranteed to **not** contain strings.
|
| 227 |
+
*
|
| 228 |
+
* In Unicode sets mode (`v` flag), {@link UnicodeSetsCharacterClass} is used.
|
| 229 |
+
*/
|
| 230 |
+
export interface ClassRangesCharacterClass extends BaseCharacterClass {
|
| 231 |
+
parent: Alternative | Quantifier;
|
| 232 |
+
unicodeSets: false;
|
| 233 |
+
elements: ClassRangesCharacterClassElement[];
|
| 234 |
+
}
|
| 235 |
+
/**
|
| 236 |
+
* The character class used in Unicode sets mode (`v` flag).
|
| 237 |
+
*
|
| 238 |
+
* This character class may contain strings.
|
| 239 |
+
*/
|
| 240 |
+
export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
|
| 241 |
+
parent:
|
| 242 |
+
| Alternative
|
| 243 |
+
| ClassIntersection
|
| 244 |
+
| ClassSubtraction
|
| 245 |
+
| Quantifier
|
| 246 |
+
| UnicodeSetsCharacterClass;
|
| 247 |
+
unicodeSets: true;
|
| 248 |
+
elements: UnicodeSetsCharacterClassElement[];
|
| 249 |
+
}
|
| 250 |
+
/**
|
| 251 |
+
* The character class.
|
| 252 |
+
* E.g. `[a-b]`
|
| 253 |
+
*/
|
| 254 |
+
export interface CharacterClassRange extends NodeBase {
|
| 255 |
+
type: "CharacterClassRange";
|
| 256 |
+
parent: CharacterClass;
|
| 257 |
+
min: Character;
|
| 258 |
+
max: Character;
|
| 259 |
+
}
|
| 260 |
+
/**
|
| 261 |
+
* The assertion.
|
| 262 |
+
*/
|
| 263 |
+
export type Assertion = BoundaryAssertion | LookaroundAssertion;
|
| 264 |
+
/**
|
| 265 |
+
* The boundary assertion.
|
| 266 |
+
*/
|
| 267 |
+
export type BoundaryAssertion = EdgeAssertion | WordBoundaryAssertion;
|
| 268 |
+
/**
|
| 269 |
+
* The edge boundary assertion.
|
| 270 |
+
* E.g. `^`, `$`
|
| 271 |
+
*/
|
| 272 |
+
export interface EdgeAssertion extends NodeBase {
|
| 273 |
+
type: "Assertion";
|
| 274 |
+
parent: Alternative | Quantifier;
|
| 275 |
+
kind: "end" | "start";
|
| 276 |
+
}
|
| 277 |
+
/**
|
| 278 |
+
* The word bondary assertion.
|
| 279 |
+
* E.g. `\b`, `\B`
|
| 280 |
+
*/
|
| 281 |
+
export interface WordBoundaryAssertion extends NodeBase {
|
| 282 |
+
type: "Assertion";
|
| 283 |
+
parent: Alternative | Quantifier;
|
| 284 |
+
kind: "word";
|
| 285 |
+
negate: boolean;
|
| 286 |
+
}
|
| 287 |
+
/**
|
| 288 |
+
* The character set.
|
| 289 |
+
*/
|
| 290 |
+
export type CharacterSet =
|
| 291 |
+
| AnyCharacterSet
|
| 292 |
+
| EscapeCharacterSet
|
| 293 |
+
| UnicodePropertyCharacterSet;
|
| 294 |
+
/**
|
| 295 |
+
* The dot.
|
| 296 |
+
* E.g. `.`
|
| 297 |
+
*/
|
| 298 |
+
export interface AnyCharacterSet extends NodeBase {
|
| 299 |
+
type: "CharacterSet";
|
| 300 |
+
parent: Alternative | Quantifier;
|
| 301 |
+
kind: "any";
|
| 302 |
+
}
|
| 303 |
+
/**
|
| 304 |
+
* The character class escape.
|
| 305 |
+
* E.g. `\d`, `\s`, `\w`, `\D`, `\S`, `\W`
|
| 306 |
+
*/
|
| 307 |
+
export interface EscapeCharacterSet extends NodeBase {
|
| 308 |
+
type: "CharacterSet";
|
| 309 |
+
parent:
|
| 310 |
+
| Alternative
|
| 311 |
+
| CharacterClass
|
| 312 |
+
| ClassIntersection
|
| 313 |
+
| ClassSubtraction
|
| 314 |
+
| Quantifier;
|
| 315 |
+
kind: "digit" | "space" | "word";
|
| 316 |
+
negate: boolean;
|
| 317 |
+
}
|
| 318 |
+
/**
|
| 319 |
+
* The unicode property escape.
|
| 320 |
+
* E.g. `\p{ASCII}`, `\P{ASCII}`, `\p{Script=Hiragana}`
|
| 321 |
+
*/
|
| 322 |
+
export type UnicodePropertyCharacterSet =
|
| 323 |
+
| CharacterUnicodePropertyCharacterSet
|
| 324 |
+
| StringsUnicodePropertyCharacterSet;
|
| 325 |
+
interface BaseUnicodePropertyCharacterSet extends NodeBase {
|
| 326 |
+
type: "CharacterSet";
|
| 327 |
+
parent:
|
| 328 |
+
| Alternative
|
| 329 |
+
| CharacterClass
|
| 330 |
+
| ClassIntersection
|
| 331 |
+
| ClassSubtraction
|
| 332 |
+
| Quantifier;
|
| 333 |
+
kind: "property";
|
| 334 |
+
strings: boolean;
|
| 335 |
+
key: string;
|
| 336 |
+
value: string | null;
|
| 337 |
+
negate: boolean;
|
| 338 |
+
}
|
| 339 |
+
export interface CharacterUnicodePropertyCharacterSet
|
| 340 |
+
extends BaseUnicodePropertyCharacterSet {
|
| 341 |
+
strings: false;
|
| 342 |
+
value: string | null;
|
| 343 |
+
negate: boolean;
|
| 344 |
+
}
|
| 345 |
+
/** StringsUnicodePropertyCharacterSet is Unicode property escape with property of strings. */
|
| 346 |
+
export interface StringsUnicodePropertyCharacterSet
|
| 347 |
+
extends BaseUnicodePropertyCharacterSet {
|
| 348 |
+
parent:
|
| 349 |
+
| Alternative
|
| 350 |
+
| ClassIntersection
|
| 351 |
+
| ClassSubtraction
|
| 352 |
+
| Quantifier
|
| 353 |
+
| UnicodeSetsCharacterClass;
|
| 354 |
+
strings: true;
|
| 355 |
+
value: null;
|
| 356 |
+
negate: false;
|
| 357 |
+
}
|
| 358 |
+
/**
|
| 359 |
+
* The expression character class.
|
| 360 |
+
* E.g. `[a--b]`, `[a&&b]`,`[^a--b]`, `[^a&&b]`
|
| 361 |
+
*/
|
| 362 |
+
export interface ExpressionCharacterClass extends NodeBase {
|
| 363 |
+
type: "ExpressionCharacterClass";
|
| 364 |
+
parent:
|
| 365 |
+
| Alternative
|
| 366 |
+
| ClassIntersection
|
| 367 |
+
| ClassSubtraction
|
| 368 |
+
| Quantifier
|
| 369 |
+
| UnicodeSetsCharacterClass;
|
| 370 |
+
negate: boolean;
|
| 371 |
+
expression: ClassIntersection | ClassSubtraction;
|
| 372 |
+
}
|
| 373 |
+
export type ClassSetOperand =
|
| 374 |
+
| Character
|
| 375 |
+
| ClassStringDisjunction
|
| 376 |
+
| EscapeCharacterSet
|
| 377 |
+
| ExpressionCharacterClass
|
| 378 |
+
| UnicodePropertyCharacterSet
|
| 379 |
+
| UnicodeSetsCharacterClass;
|
| 380 |
+
/**
|
| 381 |
+
* The character class intersection.
|
| 382 |
+
* E.g. `a&&b`
|
| 383 |
+
*/
|
| 384 |
+
export interface ClassIntersection extends NodeBase {
|
| 385 |
+
type: "ClassIntersection";
|
| 386 |
+
parent: ClassIntersection | ExpressionCharacterClass;
|
| 387 |
+
left: ClassIntersection | ClassSetOperand;
|
| 388 |
+
right: ClassSetOperand;
|
| 389 |
+
}
|
| 390 |
+
/**
|
| 391 |
+
* The character class subtraction.
|
| 392 |
+
* E.g. `a--b`
|
| 393 |
+
*/
|
| 394 |
+
export interface ClassSubtraction extends NodeBase {
|
| 395 |
+
type: "ClassSubtraction";
|
| 396 |
+
parent: ClassSubtraction | ExpressionCharacterClass;
|
| 397 |
+
left: ClassSetOperand | ClassSubtraction;
|
| 398 |
+
right: ClassSetOperand;
|
| 399 |
+
}
|
| 400 |
+
/**
|
| 401 |
+
* The character class string disjunction.
|
| 402 |
+
* E.g. `\q{a|b}`
|
| 403 |
+
*/
|
| 404 |
+
export interface ClassStringDisjunction extends NodeBase {
|
| 405 |
+
type: "ClassStringDisjunction";
|
| 406 |
+
parent: ClassIntersection | ClassSubtraction | UnicodeSetsCharacterClass;
|
| 407 |
+
alternatives: StringAlternative[];
|
| 408 |
+
}
|
| 409 |
+
/** StringAlternative is only used for `\q{alt}`({@link ClassStringDisjunction}). */
|
| 410 |
+
export interface StringAlternative extends NodeBase {
|
| 411 |
+
type: "StringAlternative";
|
| 412 |
+
parent: ClassStringDisjunction;
|
| 413 |
+
elements: Character[];
|
| 414 |
+
}
|
| 415 |
+
/**
|
| 416 |
+
* The character.
|
| 417 |
+
* This includes escape sequences which mean a character.
|
| 418 |
+
* E.g. `a`, `あ`, `✿`, `\x65`, `\u0065`, `\u{65}`, `\/`
|
| 419 |
+
*/
|
| 420 |
+
export interface Character extends NodeBase {
|
| 421 |
+
type: "Character";
|
| 422 |
+
parent:
|
| 423 |
+
| Alternative
|
| 424 |
+
| CharacterClass
|
| 425 |
+
| CharacterClassRange
|
| 426 |
+
| ClassIntersection
|
| 427 |
+
| ClassSubtraction
|
| 428 |
+
| Quantifier
|
| 429 |
+
| StringAlternative;
|
| 430 |
+
value: number;
|
| 431 |
+
}
|
| 432 |
+
/**
|
| 433 |
+
* The backreference.
|
| 434 |
+
* E.g. `\1`, `\k<name>`
|
| 435 |
+
*/
|
| 436 |
+
export type Backreference = AmbiguousBackreference | UnambiguousBackreference;
|
| 437 |
+
interface BaseBackreference extends NodeBase {
|
| 438 |
+
type: "Backreference";
|
| 439 |
+
parent: Alternative | Quantifier;
|
| 440 |
+
ref: number | string;
|
| 441 |
+
ambiguous: boolean;
|
| 442 |
+
resolved: CapturingGroup | CapturingGroup[];
|
| 443 |
+
}
|
| 444 |
+
export interface AmbiguousBackreference extends BaseBackreference {
|
| 445 |
+
ref: string;
|
| 446 |
+
ambiguous: true;
|
| 447 |
+
resolved: CapturingGroup[];
|
| 448 |
+
}
|
| 449 |
+
export interface UnambiguousBackreference extends BaseBackreference {
|
| 450 |
+
ambiguous: false;
|
| 451 |
+
resolved: CapturingGroup;
|
| 452 |
+
}
|
| 453 |
+
/**
|
| 454 |
+
* The modifiers.
|
| 455 |
+
*/
|
| 456 |
+
export interface Modifiers extends NodeBase {
|
| 457 |
+
type: "Modifiers";
|
| 458 |
+
parent: Group;
|
| 459 |
+
/**
|
| 460 |
+
* The add modifier flags.
|
| 461 |
+
*/
|
| 462 |
+
add: ModifierFlags;
|
| 463 |
+
/**
|
| 464 |
+
* The remove modifier flags.
|
| 465 |
+
*
|
| 466 |
+
* `null` means no remove modifier flags. e.g. `(?ims:x)`
|
| 467 |
+
* The reason for `null` is that there is no position where the remove modifier flags appears. Must be behind the minus mark.
|
| 468 |
+
*/
|
| 469 |
+
remove: ModifierFlags | null;
|
| 470 |
+
}
|
| 471 |
+
/**
|
| 472 |
+
* The modifier flags.
|
| 473 |
+
*/
|
| 474 |
+
export interface ModifierFlags extends NodeBase {
|
| 475 |
+
type: "ModifierFlags";
|
| 476 |
+
parent: Modifiers;
|
| 477 |
+
dotAll: boolean;
|
| 478 |
+
ignoreCase: boolean;
|
| 479 |
+
multiline: boolean;
|
| 480 |
+
}
|
| 481 |
+
/**
|
| 482 |
+
* The flags.
|
| 483 |
+
*/
|
| 484 |
+
export interface Flags extends NodeBase {
|
| 485 |
+
type: "Flags";
|
| 486 |
+
parent: RegExpLiteral | null;
|
| 487 |
+
dotAll: boolean;
|
| 488 |
+
global: boolean;
|
| 489 |
+
hasIndices: boolean;
|
| 490 |
+
ignoreCase: boolean;
|
| 491 |
+
multiline: boolean;
|
| 492 |
+
sticky: boolean;
|
| 493 |
+
unicode: boolean;
|
| 494 |
+
unicodeSets: boolean;
|
| 495 |
+
}
|
| 496 |
+
export {};
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
declare module "@eslint-community/regexpp/parser" {
|
| 500 |
+
import type {
|
| 501 |
+
Flags,
|
| 502 |
+
RegExpLiteral,
|
| 503 |
+
Pattern,
|
| 504 |
+
} from "@eslint-community/regexpp/ast";
|
| 505 |
+
import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
|
| 506 |
+
export namespace RegExpParser {
|
| 507 |
+
/**
|
| 508 |
+
* The options for RegExpParser construction.
|
| 509 |
+
*/
|
| 510 |
+
interface Options {
|
| 511 |
+
/**
|
| 512 |
+
* The flag to disable Annex B syntax. Default is `false`.
|
| 513 |
+
*/
|
| 514 |
+
strict?: boolean;
|
| 515 |
+
/**
|
| 516 |
+
* ECMAScript version. Default is `2025`.
|
| 517 |
+
* - `2015` added `u` and `y` flags.
|
| 518 |
+
* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
|
| 519 |
+
* and Unicode Property Escape.
|
| 520 |
+
* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
|
| 521 |
+
* - `2022` added `d` flag.
|
| 522 |
+
* - `2023` added more valid Unicode Property Escapes.
|
| 523 |
+
* - `2024` added `v` flag.
|
| 524 |
+
* - `2025` added duplicate named capturing groups, modifiers.
|
| 525 |
+
*/
|
| 526 |
+
ecmaVersion?: EcmaVersion;
|
| 527 |
+
}
|
| 528 |
+
}
|
| 529 |
+
export class RegExpParser {
|
| 530 |
+
/**
|
| 531 |
+
* Initialize this parser.
|
| 532 |
+
* @param options The options of parser.
|
| 533 |
+
*/
|
| 534 |
+
constructor(options?: RegExpParser.Options);
|
| 535 |
+
/**
|
| 536 |
+
* Parse a regular expression literal. E.g. "/abc/g"
|
| 537 |
+
* @param source The source code to parse.
|
| 538 |
+
* @param start The start index in the source code.
|
| 539 |
+
* @param end The end index in the source code.
|
| 540 |
+
* @returns The AST of the given regular expression.
|
| 541 |
+
*/
|
| 542 |
+
parseLiteral(source: string, start?: number, end?: number): RegExpLiteral;
|
| 543 |
+
/**
|
| 544 |
+
* Parse a regular expression flags. E.g. "gim"
|
| 545 |
+
* @param source The source code to parse.
|
| 546 |
+
* @param start The start index in the source code.
|
| 547 |
+
* @param end The end index in the source code.
|
| 548 |
+
* @returns The AST of the given flags.
|
| 549 |
+
*/
|
| 550 |
+
parseFlags(source: string, start?: number, end?: number): Flags;
|
| 551 |
+
/**
|
| 552 |
+
* Parse a regular expression pattern. E.g. "abc"
|
| 553 |
+
* @param source The source code to parse.
|
| 554 |
+
* @param start The start index in the source code.
|
| 555 |
+
* @param end The end index in the source code.
|
| 556 |
+
* @param flags The flags.
|
| 557 |
+
* @returns The AST of the given pattern.
|
| 558 |
+
*/
|
| 559 |
+
parsePattern(
|
| 560 |
+
source: string,
|
| 561 |
+
start?: number,
|
| 562 |
+
end?: number,
|
| 563 |
+
flags?: {
|
| 564 |
+
unicode?: boolean;
|
| 565 |
+
unicodeSets?: boolean;
|
| 566 |
+
}
|
| 567 |
+
): Pattern;
|
| 568 |
+
/**
|
| 569 |
+
* @deprecated Backward compatibility
|
| 570 |
+
* Use object `flags` instead of boolean `uFlag`.
|
| 571 |
+
*
|
| 572 |
+
* @param source The source code to parse.
|
| 573 |
+
* @param start The start index in the source code.
|
| 574 |
+
* @param end The end index in the source code.
|
| 575 |
+
* @param uFlag The flag to set unicode mode.
|
| 576 |
+
* @returns The AST of the given pattern.
|
| 577 |
+
*/
|
| 578 |
+
parsePattern(
|
| 579 |
+
source: string,
|
| 580 |
+
start?: number,
|
| 581 |
+
end?: number,
|
| 582 |
+
uFlag?: boolean
|
| 583 |
+
): Pattern;
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
declare module "@eslint-community/regexpp/validator" {
|
| 588 |
+
import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
|
| 589 |
+
export type RegExpValidatorSourceContext = {
|
| 590 |
+
readonly source: string;
|
| 591 |
+
readonly start: number;
|
| 592 |
+
readonly end: number;
|
| 593 |
+
readonly kind: "flags" | "literal" | "pattern";
|
| 594 |
+
};
|
| 595 |
+
export namespace RegExpValidator {
|
| 596 |
+
/**
|
| 597 |
+
* The options for RegExpValidator construction.
|
| 598 |
+
*/
|
| 599 |
+
interface Options {
|
| 600 |
+
/**
|
| 601 |
+
* The flag to disable Annex B syntax. Default is `false`.
|
| 602 |
+
*/
|
| 603 |
+
strict?: boolean;
|
| 604 |
+
/**
|
| 605 |
+
* ECMAScript version. Default is `2025`.
|
| 606 |
+
* - `2015` added `u` and `y` flags.
|
| 607 |
+
* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
|
| 608 |
+
* and Unicode Property Escape.
|
| 609 |
+
* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
|
| 610 |
+
* - `2022` added `d` flag.
|
| 611 |
+
* - `2023` added more valid Unicode Property Escapes.
|
| 612 |
+
* - `2024` added `v` flag.
|
| 613 |
+
* - `2025` added duplicate named capturing groups, modifiers.
|
| 614 |
+
*/
|
| 615 |
+
ecmaVersion?: EcmaVersion;
|
| 616 |
+
/**
|
| 617 |
+
* A function that is called when the validator entered a RegExp literal.
|
| 618 |
+
* @param start The 0-based index of the first character.
|
| 619 |
+
*/
|
| 620 |
+
onLiteralEnter?: (start: number) => void;
|
| 621 |
+
/**
|
| 622 |
+
* A function that is called when the validator left a RegExp literal.
|
| 623 |
+
* @param start The 0-based index of the first character.
|
| 624 |
+
* @param end The next 0-based index of the last character.
|
| 625 |
+
*/
|
| 626 |
+
onLiteralLeave?: (start: number, end: number) => void;
|
| 627 |
+
/**
|
| 628 |
+
* A function that is called when the validator found flags.
|
| 629 |
+
* @param start The 0-based index of the first character.
|
| 630 |
+
* @param end The next 0-based index of the last character.
|
| 631 |
+
* @param flags.global `g` flag.
|
| 632 |
+
* @param flags.ignoreCase `i` flag.
|
| 633 |
+
* @param flags.multiline `m` flag.
|
| 634 |
+
* @param flags.unicode `u` flag.
|
| 635 |
+
* @param flags.sticky `y` flag.
|
| 636 |
+
* @param flags.dotAll `s` flag.
|
| 637 |
+
* @param flags.hasIndices `d` flag.
|
| 638 |
+
* @param flags.unicodeSets `v` flag.
|
| 639 |
+
*/
|
| 640 |
+
onRegExpFlags?: (
|
| 641 |
+
start: number,
|
| 642 |
+
end: number,
|
| 643 |
+
flags: {
|
| 644 |
+
global: boolean;
|
| 645 |
+
ignoreCase: boolean;
|
| 646 |
+
multiline: boolean;
|
| 647 |
+
unicode: boolean;
|
| 648 |
+
sticky: boolean;
|
| 649 |
+
dotAll: boolean;
|
| 650 |
+
hasIndices: boolean;
|
| 651 |
+
unicodeSets: boolean;
|
| 652 |
+
}
|
| 653 |
+
) => void;
|
| 654 |
+
/**
|
| 655 |
+
* A function that is called when the validator found flags.
|
| 656 |
+
* @param start The 0-based index of the first character.
|
| 657 |
+
* @param end The next 0-based index of the last character.
|
| 658 |
+
* @param global `g` flag.
|
| 659 |
+
* @param ignoreCase `i` flag.
|
| 660 |
+
* @param multiline `m` flag.
|
| 661 |
+
* @param unicode `u` flag.
|
| 662 |
+
* @param sticky `y` flag.
|
| 663 |
+
* @param dotAll `s` flag.
|
| 664 |
+
* @param hasIndices `d` flag.
|
| 665 |
+
*
|
| 666 |
+
* @deprecated Use `onRegExpFlags` instead.
|
| 667 |
+
*/
|
| 668 |
+
onFlags?: (
|
| 669 |
+
start: number,
|
| 670 |
+
end: number,
|
| 671 |
+
global: boolean,
|
| 672 |
+
ignoreCase: boolean,
|
| 673 |
+
multiline: boolean,
|
| 674 |
+
unicode: boolean,
|
| 675 |
+
sticky: boolean,
|
| 676 |
+
dotAll: boolean,
|
| 677 |
+
hasIndices: boolean
|
| 678 |
+
) => void;
|
| 679 |
+
/**
|
| 680 |
+
* A function that is called when the validator entered a pattern.
|
| 681 |
+
* @param start The 0-based index of the first character.
|
| 682 |
+
*/
|
| 683 |
+
onPatternEnter?: (start: number) => void;
|
| 684 |
+
/**
|
| 685 |
+
* A function that is called when the validator left a pattern.
|
| 686 |
+
* @param start The 0-based index of the first character.
|
| 687 |
+
* @param end The next 0-based index of the last character.
|
| 688 |
+
*/
|
| 689 |
+
onPatternLeave?: (start: number, end: number) => void;
|
| 690 |
+
/**
|
| 691 |
+
* A function that is called when the validator entered a disjunction.
|
| 692 |
+
* @param start The 0-based index of the first character.
|
| 693 |
+
*/
|
| 694 |
+
onDisjunctionEnter?: (start: number) => void;
|
| 695 |
+
/**
|
| 696 |
+
* A function that is called when the validator left a disjunction.
|
| 697 |
+
* @param start The 0-based index of the first character.
|
| 698 |
+
* @param end The next 0-based index of the last character.
|
| 699 |
+
*/
|
| 700 |
+
onDisjunctionLeave?: (start: number, end: number) => void;
|
| 701 |
+
/**
|
| 702 |
+
* A function that is called when the validator entered an alternative.
|
| 703 |
+
* @param start The 0-based index of the first character.
|
| 704 |
+
* @param index The 0-based index of alternatives in a disjunction.
|
| 705 |
+
*/
|
| 706 |
+
onAlternativeEnter?: (start: number, index: number) => void;
|
| 707 |
+
/**
|
| 708 |
+
* A function that is called when the validator left an alternative.
|
| 709 |
+
* @param start The 0-based index of the first character.
|
| 710 |
+
* @param end The next 0-based index of the last character.
|
| 711 |
+
* @param index The 0-based index of alternatives in a disjunction.
|
| 712 |
+
*/
|
| 713 |
+
onAlternativeLeave?: (start: number, end: number, index: number) => void;
|
| 714 |
+
/**
|
| 715 |
+
* A function that is called when the validator entered an uncapturing group.
|
| 716 |
+
* @param start The 0-based index of the first character.
|
| 717 |
+
*/
|
| 718 |
+
onGroupEnter?: (start: number) => void;
|
| 719 |
+
/**
|
| 720 |
+
* A function that is called when the validator left an uncapturing group.
|
| 721 |
+
* @param start The 0-based index of the first character.
|
| 722 |
+
* @param end The next 0-based index of the last character.
|
| 723 |
+
*/
|
| 724 |
+
onGroupLeave?: (start: number, end: number) => void;
|
| 725 |
+
/**
|
| 726 |
+
* A function that is called when the validator entered a modifiers.
|
| 727 |
+
* @param start The 0-based index of the first character.
|
| 728 |
+
*/
|
| 729 |
+
onModifiersEnter?: (start: number) => void;
|
| 730 |
+
/**
|
| 731 |
+
* A function that is called when the validator left a modifiers.
|
| 732 |
+
* @param start The 0-based index of the first character.
|
| 733 |
+
* @param end The next 0-based index of the last character.
|
| 734 |
+
*/
|
| 735 |
+
onModifiersLeave?: (start: number, end: number) => void;
|
| 736 |
+
/**
|
| 737 |
+
* A function that is called when the validator found an add modifiers.
|
| 738 |
+
* @param start The 0-based index of the first character.
|
| 739 |
+
* @param end The next 0-based index of the last character.
|
| 740 |
+
* @param flags flags.
|
| 741 |
+
* @param flags.ignoreCase `i` flag.
|
| 742 |
+
* @param flags.multiline `m` flag.
|
| 743 |
+
* @param flags.dotAll `s` flag.
|
| 744 |
+
*/
|
| 745 |
+
onAddModifiers?: (
|
| 746 |
+
start: number,
|
| 747 |
+
end: number,
|
| 748 |
+
flags: {
|
| 749 |
+
ignoreCase: boolean;
|
| 750 |
+
multiline: boolean;
|
| 751 |
+
dotAll: boolean;
|
| 752 |
+
}
|
| 753 |
+
) => void;
|
| 754 |
+
/**
|
| 755 |
+
* A function that is called when the validator found a remove modifiers.
|
| 756 |
+
* @param start The 0-based index of the first character.
|
| 757 |
+
* @param end The next 0-based index of the last character.
|
| 758 |
+
* @param flags flags.
|
| 759 |
+
* @param flags.ignoreCase `i` flag.
|
| 760 |
+
* @param flags.multiline `m` flag.
|
| 761 |
+
* @param flags.dotAll `s` flag.
|
| 762 |
+
*/
|
| 763 |
+
onRemoveModifiers?: (
|
| 764 |
+
start: number,
|
| 765 |
+
end: number,
|
| 766 |
+
flags: {
|
| 767 |
+
ignoreCase: boolean;
|
| 768 |
+
multiline: boolean;
|
| 769 |
+
dotAll: boolean;
|
| 770 |
+
}
|
| 771 |
+
) => void;
|
| 772 |
+
/**
|
| 773 |
+
* A function that is called when the validator entered a capturing group.
|
| 774 |
+
* @param start The 0-based index of the first character.
|
| 775 |
+
* @param name The group name.
|
| 776 |
+
*/
|
| 777 |
+
onCapturingGroupEnter?: (start: number, name: string | null) => void;
|
| 778 |
+
/**
|
| 779 |
+
* A function that is called when the validator left a capturing group.
|
| 780 |
+
* @param start The 0-based index of the first character.
|
| 781 |
+
* @param end The next 0-based index of the last character.
|
| 782 |
+
* @param name The group name.
|
| 783 |
+
*/
|
| 784 |
+
onCapturingGroupLeave?: (
|
| 785 |
+
start: number,
|
| 786 |
+
end: number,
|
| 787 |
+
name: string | null
|
| 788 |
+
) => void;
|
| 789 |
+
/**
|
| 790 |
+
* A function that is called when the validator found a quantifier.
|
| 791 |
+
* @param start The 0-based index of the first character.
|
| 792 |
+
* @param end The next 0-based index of the last character.
|
| 793 |
+
* @param min The minimum number of repeating.
|
| 794 |
+
* @param max The maximum number of repeating.
|
| 795 |
+
* @param greedy The flag to choose the longest matching.
|
| 796 |
+
*/
|
| 797 |
+
onQuantifier?: (
|
| 798 |
+
start: number,
|
| 799 |
+
end: number,
|
| 800 |
+
min: number,
|
| 801 |
+
max: number,
|
| 802 |
+
greedy: boolean
|
| 803 |
+
) => void;
|
| 804 |
+
/**
|
| 805 |
+
* A function that is called when the validator entered a lookahead/lookbehind assertion.
|
| 806 |
+
* @param start The 0-based index of the first character.
|
| 807 |
+
* @param kind The kind of the assertion.
|
| 808 |
+
* @param negate The flag which represents that the assertion is negative.
|
| 809 |
+
*/
|
| 810 |
+
onLookaroundAssertionEnter?: (
|
| 811 |
+
start: number,
|
| 812 |
+
kind: "lookahead" | "lookbehind",
|
| 813 |
+
negate: boolean
|
| 814 |
+
) => void;
|
| 815 |
+
/**
|
| 816 |
+
* A function that is called when the validator left a lookahead/lookbehind assertion.
|
| 817 |
+
* @param start The 0-based index of the first character.
|
| 818 |
+
* @param end The next 0-based index of the last character.
|
| 819 |
+
* @param kind The kind of the assertion.
|
| 820 |
+
* @param negate The flag which represents that the assertion is negative.
|
| 821 |
+
*/
|
| 822 |
+
onLookaroundAssertionLeave?: (
|
| 823 |
+
start: number,
|
| 824 |
+
end: number,
|
| 825 |
+
kind: "lookahead" | "lookbehind",
|
| 826 |
+
negate: boolean
|
| 827 |
+
) => void;
|
| 828 |
+
/**
|
| 829 |
+
* A function that is called when the validator found an edge boundary assertion.
|
| 830 |
+
* @param start The 0-based index of the first character.
|
| 831 |
+
* @param end The next 0-based index of the last character.
|
| 832 |
+
* @param kind The kind of the assertion.
|
| 833 |
+
*/
|
| 834 |
+
onEdgeAssertion?: (
|
| 835 |
+
start: number,
|
| 836 |
+
end: number,
|
| 837 |
+
kind: "end" | "start"
|
| 838 |
+
) => void;
|
| 839 |
+
/**
|
| 840 |
+
* A function that is called when the validator found a word boundary assertion.
|
| 841 |
+
* @param start The 0-based index of the first character.
|
| 842 |
+
* @param end The next 0-based index of the last character.
|
| 843 |
+
* @param kind The kind of the assertion.
|
| 844 |
+
* @param negate The flag which represents that the assertion is negative.
|
| 845 |
+
*/
|
| 846 |
+
onWordBoundaryAssertion?: (
|
| 847 |
+
start: number,
|
| 848 |
+
end: number,
|
| 849 |
+
kind: "word",
|
| 850 |
+
negate: boolean
|
| 851 |
+
) => void;
|
| 852 |
+
/**
|
| 853 |
+
* A function that is called when the validator found a dot.
|
| 854 |
+
* @param start The 0-based index of the first character.
|
| 855 |
+
* @param end The next 0-based index of the last character.
|
| 856 |
+
* @param kind The kind of the character set.
|
| 857 |
+
*/
|
| 858 |
+
onAnyCharacterSet?: (start: number, end: number, kind: "any") => void;
|
| 859 |
+
/**
|
| 860 |
+
* A function that is called when the validator found a character set escape.
|
| 861 |
+
* @param start The 0-based index of the first character.
|
| 862 |
+
* @param end The next 0-based index of the last character.
|
| 863 |
+
* @param kind The kind of the character set.
|
| 864 |
+
* @param negate The flag which represents that the character set is negative.
|
| 865 |
+
*/
|
| 866 |
+
onEscapeCharacterSet?: (
|
| 867 |
+
start: number,
|
| 868 |
+
end: number,
|
| 869 |
+
kind: "digit" | "space" | "word",
|
| 870 |
+
negate: boolean
|
| 871 |
+
) => void;
|
| 872 |
+
/**
|
| 873 |
+
* A function that is called when the validator found a Unicode proerty escape.
|
| 874 |
+
* @param start The 0-based index of the first character.
|
| 875 |
+
* @param end The next 0-based index of the last character.
|
| 876 |
+
* @param kind The kind of the character set.
|
| 877 |
+
* @param key The property name.
|
| 878 |
+
* @param value The property value.
|
| 879 |
+
* @param negate The flag which represents that the character set is negative.
|
| 880 |
+
* @param strings If true, the given property is property of strings.
|
| 881 |
+
*/
|
| 882 |
+
onUnicodePropertyCharacterSet?: (
|
| 883 |
+
start: number,
|
| 884 |
+
end: number,
|
| 885 |
+
kind: "property",
|
| 886 |
+
key: string,
|
| 887 |
+
value: string | null,
|
| 888 |
+
negate: boolean,
|
| 889 |
+
strings: boolean
|
| 890 |
+
) => void;
|
| 891 |
+
/**
|
| 892 |
+
* A function that is called when the validator found a character.
|
| 893 |
+
* @param start The 0-based index of the first character.
|
| 894 |
+
* @param end The next 0-based index of the last character.
|
| 895 |
+
* @param value The code point of the character.
|
| 896 |
+
*/
|
| 897 |
+
onCharacter?: (start: number, end: number, value: number) => void;
|
| 898 |
+
/**
|
| 899 |
+
* A function that is called when the validator found a backreference.
|
| 900 |
+
* @param start The 0-based index of the first character.
|
| 901 |
+
* @param end The next 0-based index of the last character.
|
| 902 |
+
* @param ref The key of the referred capturing group.
|
| 903 |
+
*/
|
| 904 |
+
onBackreference?: (
|
| 905 |
+
start: number,
|
| 906 |
+
end: number,
|
| 907 |
+
ref: number | string
|
| 908 |
+
) => void;
|
| 909 |
+
/**
|
| 910 |
+
* A function that is called when the validator entered a character class.
|
| 911 |
+
* @param start The 0-based index of the first character.
|
| 912 |
+
* @param negate The flag which represents that the character class is negative.
|
| 913 |
+
* @param unicodeSets `true` if unicodeSets mode.
|
| 914 |
+
*/
|
| 915 |
+
onCharacterClassEnter?: (
|
| 916 |
+
start: number,
|
| 917 |
+
negate: boolean,
|
| 918 |
+
unicodeSets: boolean
|
| 919 |
+
) => void;
|
| 920 |
+
/**
|
| 921 |
+
* A function that is called when the validator left a character class.
|
| 922 |
+
* @param start The 0-based index of the first character.
|
| 923 |
+
* @param end The next 0-based index of the last character.
|
| 924 |
+
* @param negate The flag which represents that the character class is negative.
|
| 925 |
+
*/
|
| 926 |
+
onCharacterClassLeave?: (
|
| 927 |
+
start: number,
|
| 928 |
+
end: number,
|
| 929 |
+
negate: boolean
|
| 930 |
+
) => void;
|
| 931 |
+
/**
|
| 932 |
+
* A function that is called when the validator found a character class range.
|
| 933 |
+
* @param start The 0-based index of the first character.
|
| 934 |
+
* @param end The next 0-based index of the last character.
|
| 935 |
+
* @param min The minimum code point of the range.
|
| 936 |
+
* @param max The maximum code point of the range.
|
| 937 |
+
*/
|
| 938 |
+
onCharacterClassRange?: (
|
| 939 |
+
start: number,
|
| 940 |
+
end: number,
|
| 941 |
+
min: number,
|
| 942 |
+
max: number
|
| 943 |
+
) => void;
|
| 944 |
+
/**
|
| 945 |
+
* A function that is called when the validator found a class intersection.
|
| 946 |
+
* @param start The 0-based index of the first character.
|
| 947 |
+
* @param end The next 0-based index of the last character.
|
| 948 |
+
*/
|
| 949 |
+
onClassIntersection?: (start: number, end: number) => void;
|
| 950 |
+
/**
|
| 951 |
+
* A function that is called when the validator found a class subtraction.
|
| 952 |
+
* @param start The 0-based index of the first character.
|
| 953 |
+
* @param end The next 0-based index of the last character.
|
| 954 |
+
*/
|
| 955 |
+
onClassSubtraction?: (start: number, end: number) => void;
|
| 956 |
+
/**
|
| 957 |
+
* A function that is called when the validator entered a class string disjunction.
|
| 958 |
+
* @param start The 0-based index of the first character.
|
| 959 |
+
*/
|
| 960 |
+
onClassStringDisjunctionEnter?: (start: number) => void;
|
| 961 |
+
/**
|
| 962 |
+
* A function that is called when the validator left a class string disjunction.
|
| 963 |
+
* @param start The 0-based index of the first character.
|
| 964 |
+
* @param end The next 0-based index of the last character.
|
| 965 |
+
*/
|
| 966 |
+
onClassStringDisjunctionLeave?: (start: number, end: number) => void;
|
| 967 |
+
/**
|
| 968 |
+
* A function that is called when the validator entered a string alternative.
|
| 969 |
+
* @param start The 0-based index of the first character.
|
| 970 |
+
* @param index The 0-based index of alternatives in a disjunction.
|
| 971 |
+
*/
|
| 972 |
+
onStringAlternativeEnter?: (start: number, index: number) => void;
|
| 973 |
+
/**
|
| 974 |
+
* A function that is called when the validator left a string alternative.
|
| 975 |
+
* @param start The 0-based index of the first character.
|
| 976 |
+
* @param end The next 0-based index of the last character.
|
| 977 |
+
* @param index The 0-based index of alternatives in a disjunction.
|
| 978 |
+
*/
|
| 979 |
+
onStringAlternativeLeave?: (
|
| 980 |
+
start: number,
|
| 981 |
+
end: number,
|
| 982 |
+
index: number
|
| 983 |
+
) => void;
|
| 984 |
+
}
|
| 985 |
+
}
|
| 986 |
+
/**
|
| 987 |
+
* The regular expression validator.
|
| 988 |
+
*/
|
| 989 |
+
export class RegExpValidator {
|
| 990 |
+
/**
|
| 991 |
+
* Initialize this validator.
|
| 992 |
+
* @param options The options of validator.
|
| 993 |
+
*/
|
| 994 |
+
constructor(options?: RegExpValidator.Options);
|
| 995 |
+
/**
|
| 996 |
+
* Validate a regular expression literal. E.g. "/abc/g"
|
| 997 |
+
* @param source The source code to validate.
|
| 998 |
+
* @param start The start index in the source code.
|
| 999 |
+
* @param end The end index in the source code.
|
| 1000 |
+
*/
|
| 1001 |
+
validateLiteral(source: string, start?: number, end?: number): void;
|
| 1002 |
+
/**
|
| 1003 |
+
* Validate a regular expression flags. E.g. "gim"
|
| 1004 |
+
* @param source The source code to validate.
|
| 1005 |
+
* @param start The start index in the source code.
|
| 1006 |
+
* @param end The end index in the source code.
|
| 1007 |
+
*/
|
| 1008 |
+
validateFlags(source: string, start?: number, end?: number): void;
|
| 1009 |
+
/**
|
| 1010 |
+
* Validate a regular expression pattern. E.g. "abc"
|
| 1011 |
+
* @param source The source code to validate.
|
| 1012 |
+
* @param start The start index in the source code.
|
| 1013 |
+
* @param end The end index in the source code.
|
| 1014 |
+
* @param flags The flags.
|
| 1015 |
+
*/
|
| 1016 |
+
validatePattern(
|
| 1017 |
+
source: string,
|
| 1018 |
+
start?: number,
|
| 1019 |
+
end?: number,
|
| 1020 |
+
flags?: {
|
| 1021 |
+
unicode?: boolean;
|
| 1022 |
+
unicodeSets?: boolean;
|
| 1023 |
+
}
|
| 1024 |
+
): void;
|
| 1025 |
+
/**
|
| 1026 |
+
* @deprecated Backward compatibility
|
| 1027 |
+
* Use object `flags` instead of boolean `uFlag`.
|
| 1028 |
+
* @param source The source code to validate.
|
| 1029 |
+
* @param start The start index in the source code.
|
| 1030 |
+
* @param end The end index in the source code.
|
| 1031 |
+
* @param uFlag The flag to set unicode mode.
|
| 1032 |
+
*/
|
| 1033 |
+
validatePattern(
|
| 1034 |
+
source: string,
|
| 1035 |
+
start?: number,
|
| 1036 |
+
end?: number,
|
| 1037 |
+
uFlag?: boolean
|
| 1038 |
+
): void;
|
| 1039 |
+
}
|
| 1040 |
+
}
|
| 1041 |
+
|
| 1042 |
+
declare module "@eslint-community/regexpp/visitor" {
|
| 1043 |
+
import type {
|
| 1044 |
+
Alternative,
|
| 1045 |
+
Assertion,
|
| 1046 |
+
Backreference,
|
| 1047 |
+
CapturingGroup,
|
| 1048 |
+
Character,
|
| 1049 |
+
CharacterClass,
|
| 1050 |
+
CharacterClassRange,
|
| 1051 |
+
CharacterSet,
|
| 1052 |
+
ClassIntersection,
|
| 1053 |
+
ClassStringDisjunction,
|
| 1054 |
+
ClassSubtraction,
|
| 1055 |
+
ExpressionCharacterClass,
|
| 1056 |
+
Flags,
|
| 1057 |
+
Group,
|
| 1058 |
+
ModifierFlags,
|
| 1059 |
+
Modifiers,
|
| 1060 |
+
Node,
|
| 1061 |
+
Pattern,
|
| 1062 |
+
Quantifier,
|
| 1063 |
+
RegExpLiteral,
|
| 1064 |
+
StringAlternative,
|
| 1065 |
+
} from "@eslint-community/regexpp/ast";
|
| 1066 |
+
/**
|
| 1067 |
+
* The visitor to walk on AST.
|
| 1068 |
+
*/
|
| 1069 |
+
export class RegExpVisitor {
|
| 1070 |
+
/**
|
| 1071 |
+
* Initialize this visitor.
|
| 1072 |
+
* @param handlers Callbacks for each node.
|
| 1073 |
+
*/
|
| 1074 |
+
constructor(handlers: RegExpVisitor.Handlers);
|
| 1075 |
+
/**
|
| 1076 |
+
* Visit a given node and descendant nodes.
|
| 1077 |
+
* @param node The root node to visit tree.
|
| 1078 |
+
*/
|
| 1079 |
+
visit(node: Node): void;
|
| 1080 |
+
}
|
| 1081 |
+
export namespace RegExpVisitor {
|
| 1082 |
+
interface Handlers {
|
| 1083 |
+
onAlternativeEnter?: (node: Alternative) => void;
|
| 1084 |
+
onAlternativeLeave?: (node: Alternative) => void;
|
| 1085 |
+
onAssertionEnter?: (node: Assertion) => void;
|
| 1086 |
+
onAssertionLeave?: (node: Assertion) => void;
|
| 1087 |
+
onBackreferenceEnter?: (node: Backreference) => void;
|
| 1088 |
+
onBackreferenceLeave?: (node: Backreference) => void;
|
| 1089 |
+
onCapturingGroupEnter?: (node: CapturingGroup) => void;
|
| 1090 |
+
onCapturingGroupLeave?: (node: CapturingGroup) => void;
|
| 1091 |
+
onCharacterEnter?: (node: Character) => void;
|
| 1092 |
+
onCharacterLeave?: (node: Character) => void;
|
| 1093 |
+
onCharacterClassEnter?: (node: CharacterClass) => void;
|
| 1094 |
+
onCharacterClassLeave?: (node: CharacterClass) => void;
|
| 1095 |
+
onCharacterClassRangeEnter?: (node: CharacterClassRange) => void;
|
| 1096 |
+
onCharacterClassRangeLeave?: (node: CharacterClassRange) => void;
|
| 1097 |
+
onCharacterSetEnter?: (node: CharacterSet) => void;
|
| 1098 |
+
onCharacterSetLeave?: (node: CharacterSet) => void;
|
| 1099 |
+
onClassIntersectionEnter?: (node: ClassIntersection) => void;
|
| 1100 |
+
onClassIntersectionLeave?: (node: ClassIntersection) => void;
|
| 1101 |
+
onClassStringDisjunctionEnter?: (node: ClassStringDisjunction) => void;
|
| 1102 |
+
onClassStringDisjunctionLeave?: (node: ClassStringDisjunction) => void;
|
| 1103 |
+
onClassSubtractionEnter?: (node: ClassSubtraction) => void;
|
| 1104 |
+
onClassSubtractionLeave?: (node: ClassSubtraction) => void;
|
| 1105 |
+
onExpressionCharacterClassEnter?: (
|
| 1106 |
+
node: ExpressionCharacterClass
|
| 1107 |
+
) => void;
|
| 1108 |
+
onExpressionCharacterClassLeave?: (
|
| 1109 |
+
node: ExpressionCharacterClass
|
| 1110 |
+
) => void;
|
| 1111 |
+
onFlagsEnter?: (node: Flags) => void;
|
| 1112 |
+
onFlagsLeave?: (node: Flags) => void;
|
| 1113 |
+
onGroupEnter?: (node: Group) => void;
|
| 1114 |
+
onGroupLeave?: (node: Group) => void;
|
| 1115 |
+
onModifierFlagsEnter?: (node: ModifierFlags) => void;
|
| 1116 |
+
onModifierFlagsLeave?: (node: ModifierFlags) => void;
|
| 1117 |
+
onModifiersEnter?: (node: Modifiers) => void;
|
| 1118 |
+
onModifiersLeave?: (node: Modifiers) => void;
|
| 1119 |
+
onPatternEnter?: (node: Pattern) => void;
|
| 1120 |
+
onPatternLeave?: (node: Pattern) => void;
|
| 1121 |
+
onQuantifierEnter?: (node: Quantifier) => void;
|
| 1122 |
+
onQuantifierLeave?: (node: Quantifier) => void;
|
| 1123 |
+
onRegExpLiteralEnter?: (node: RegExpLiteral) => void;
|
| 1124 |
+
onRegExpLiteralLeave?: (node: RegExpLiteral) => void;
|
| 1125 |
+
onStringAlternativeEnter?: (node: StringAlternative) => void;
|
| 1126 |
+
onStringAlternativeLeave?: (node: StringAlternative) => void;
|
| 1127 |
+
}
|
| 1128 |
+
}
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
declare module "@eslint-community/regexpp/regexp-syntax-error" {
|
| 1132 |
+
import type { RegExpValidatorSourceContext } from "@eslint-community/regexpp/validator";
|
| 1133 |
+
export class RegExpSyntaxError extends SyntaxError {
|
| 1134 |
+
index: number;
|
| 1135 |
+
constructor(message: string, index: number);
|
| 1136 |
+
}
|
| 1137 |
+
export function newRegExpSyntaxError(
|
| 1138 |
+
srcCtx: RegExpValidatorSourceContext,
|
| 1139 |
+
flags: {
|
| 1140 |
+
unicode: boolean;
|
| 1141 |
+
unicodeSets: boolean;
|
| 1142 |
+
},
|
| 1143 |
+
index: number,
|
| 1144 |
+
message: string
|
| 1145 |
+
): RegExpSyntaxError;
|
| 1146 |
+
}
|
| 1147 |
+
|
| 1148 |
+
declare module "@eslint-community/regexpp/ecma-versions" {
|
| 1149 |
+
export type EcmaVersion =
|
| 1150 |
+
| 5
|
| 1151 |
+
| 2015
|
| 1152 |
+
| 2016
|
| 1153 |
+
| 2017
|
| 1154 |
+
| 2018
|
| 1155 |
+
| 2019
|
| 1156 |
+
| 2020
|
| 1157 |
+
| 2021
|
| 1158 |
+
| 2022
|
| 1159 |
+
| 2023
|
| 1160 |
+
| 2024
|
| 1161 |
+
| 2025;
|
| 1162 |
+
export const latestEcmaVersion = 2025;
|
| 1163 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.mjs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/index.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@eslint-community/regexpp/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@eslint-community/regexpp",
|
| 3 |
+
"version": "4.12.1",
|
| 4 |
+
"description": "Regular expression parser for ECMAScript.",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"regexp",
|
| 7 |
+
"regular",
|
| 8 |
+
"expression",
|
| 9 |
+
"parser",
|
| 10 |
+
"validator",
|
| 11 |
+
"ast",
|
| 12 |
+
"abstract",
|
| 13 |
+
"syntax",
|
| 14 |
+
"tree",
|
| 15 |
+
"ecmascript",
|
| 16 |
+
"es2015",
|
| 17 |
+
"es2016",
|
| 18 |
+
"es2017",
|
| 19 |
+
"es2018",
|
| 20 |
+
"es2019",
|
| 21 |
+
"es2020",
|
| 22 |
+
"es2021",
|
| 23 |
+
"annexB"
|
| 24 |
+
],
|
| 25 |
+
"homepage": "https://github.com/eslint-community/regexpp#readme",
|
| 26 |
+
"bugs": {
|
| 27 |
+
"url": "https://github.com/eslint-community/regexpp/issues"
|
| 28 |
+
},
|
| 29 |
+
"repository": {
|
| 30 |
+
"type": "git",
|
| 31 |
+
"url": "https://github.com/eslint-community/regexpp"
|
| 32 |
+
},
|
| 33 |
+
"license": "MIT",
|
| 34 |
+
"author": "Toru Nagashima",
|
| 35 |
+
"exports": {
|
| 36 |
+
".": {
|
| 37 |
+
"types": "./index.d.ts",
|
| 38 |
+
"import": "./index.mjs",
|
| 39 |
+
"default": "./index.js"
|
| 40 |
+
},
|
| 41 |
+
"./package.json": "./package.json"
|
| 42 |
+
},
|
| 43 |
+
"main": "index",
|
| 44 |
+
"files": [
|
| 45 |
+
"index.*"
|
| 46 |
+
],
|
| 47 |
+
"scripts": {
|
| 48 |
+
"prebuild": "npm run -s clean",
|
| 49 |
+
"build": "run-s build:*",
|
| 50 |
+
"build:tsc": "tsc --module es2015",
|
| 51 |
+
"build:rollup": "rollup -c",
|
| 52 |
+
"build:dts": "npm run -s build:tsc -- --removeComments false && dts-bundle --name @eslint-community/regexpp --main .temp/index.d.ts --out ../index.d.ts && prettier --write index.d.ts",
|
| 53 |
+
"clean": "rimraf .temp index.*",
|
| 54 |
+
"lint": "eslint . --ext .ts",
|
| 55 |
+
"test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
|
| 56 |
+
"debug": "mocha --require ts-node/register/transpile-only \"test/*.ts\" --reporter dot --timeout 10000",
|
| 57 |
+
"update:test": "ts-node scripts/update-fixtures.ts",
|
| 58 |
+
"update:unicode": "run-s update:unicode:*",
|
| 59 |
+
"update:unicode:ids": "ts-node scripts/update-unicode-ids.ts",
|
| 60 |
+
"update:unicode:props": "ts-node scripts/update-unicode-properties.ts",
|
| 61 |
+
"update:test262:extract": "ts-node -T scripts/extract-test262.ts",
|
| 62 |
+
"preversion": "npm test && npm run -s build",
|
| 63 |
+
"postversion": "git push && git push --tags",
|
| 64 |
+
"prewatch": "npm run -s clean",
|
| 65 |
+
"watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions ts --watch --growl"
|
| 66 |
+
},
|
| 67 |
+
"dependencies": {},
|
| 68 |
+
"devDependencies": {
|
| 69 |
+
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
|
| 70 |
+
"@rollup/plugin-node-resolve": "^14.1.0",
|
| 71 |
+
"@types/eslint": "^8.44.3",
|
| 72 |
+
"@types/jsdom": "^16.2.15",
|
| 73 |
+
"@types/mocha": "^9.1.1",
|
| 74 |
+
"@types/node": "^12.20.55",
|
| 75 |
+
"dts-bundle": "^0.7.3",
|
| 76 |
+
"eslint": "^8.50.0",
|
| 77 |
+
"js-tokens": "^8.0.2",
|
| 78 |
+
"jsdom": "^19.0.0",
|
| 79 |
+
"mocha": "^9.2.2",
|
| 80 |
+
"npm-run-all2": "^6.2.2",
|
| 81 |
+
"nyc": "^14.1.1",
|
| 82 |
+
"rimraf": "^3.0.2",
|
| 83 |
+
"rollup": "^2.79.1",
|
| 84 |
+
"rollup-plugin-sourcemaps": "^0.6.3",
|
| 85 |
+
"ts-node": "^10.9.1",
|
| 86 |
+
"typescript": "~5.0.2"
|
| 87 |
+
},
|
| 88 |
+
"engines": {
|
| 89 |
+
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
| 90 |
+
}
|
| 91 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/createProjectService.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ProjectServiceOptions } from '@typescript-eslint/types';
|
| 2 |
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
| 3 |
+
/**
|
| 4 |
+
* Shortcut type to refer to TypeScript's server ProjectService.
|
| 5 |
+
*/
|
| 6 |
+
export type TypeScriptProjectService = ts.server.ProjectService;
|
| 7 |
+
/**
|
| 8 |
+
* A created Project Service instance, as well as metadata on its creation.
|
| 9 |
+
*/
|
| 10 |
+
export interface ProjectServiceAndMetadata {
|
| 11 |
+
/**
|
| 12 |
+
* Files allowed to be loaded from the default project, if any were specified.
|
| 13 |
+
*/
|
| 14 |
+
allowDefaultProject: string[] | undefined;
|
| 15 |
+
/**
|
| 16 |
+
* The performance.now() timestamp of the last reload of the project service.
|
| 17 |
+
*/
|
| 18 |
+
lastReloadTimestamp: number;
|
| 19 |
+
/**
|
| 20 |
+
* The maximum number of files that can be matched by the default project.
|
| 21 |
+
*/
|
| 22 |
+
maximumDefaultProjectFileMatchCount: number;
|
| 23 |
+
/**
|
| 24 |
+
* The created TypeScript Project Service instance.
|
| 25 |
+
*/
|
| 26 |
+
service: TypeScriptProjectService;
|
| 27 |
+
}
|
| 28 |
+
/**
|
| 29 |
+
* Settings to create a new Project Service instance with {@link createProjectService}.
|
| 30 |
+
*/
|
| 31 |
+
export interface CreateProjectServiceSettings {
|
| 32 |
+
/**
|
| 33 |
+
* Granular options to configure the project service.
|
| 34 |
+
*/
|
| 35 |
+
options?: ProjectServiceOptions;
|
| 36 |
+
/**
|
| 37 |
+
* How aggressively (and slowly) to parse JSDoc comments.
|
| 38 |
+
*/
|
| 39 |
+
jsDocParsingMode?: ts.JSDocParsingMode;
|
| 40 |
+
/**
|
| 41 |
+
* Root directory for the tsconfig.json file, if not the current directory.
|
| 42 |
+
*/
|
| 43 |
+
tsconfigRootDir?: string;
|
| 44 |
+
}
|
| 45 |
+
/**
|
| 46 |
+
* Creates a new Project Service instance, as well as metadata on its creation.
|
| 47 |
+
* @param settings Settings to create a new Project Service instance.
|
| 48 |
+
* @returns A new Project Service instance, as well as metadata on its creation.
|
| 49 |
+
* @example
|
| 50 |
+
* ```ts
|
| 51 |
+
* import { createProjectService } from '@typescript-eslint/project-service';
|
| 52 |
+
*
|
| 53 |
+
* const { service } = createProjectService();
|
| 54 |
+
*
|
| 55 |
+
* service.openClientFile('index.ts');
|
| 56 |
+
* ```
|
| 57 |
+
*/
|
| 58 |
+
export declare function createProjectService({ jsDocParsingMode, options: optionsRaw, tsconfigRootDir, }?: CreateProjectServiceSettings): ProjectServiceAndMetadata;
|
| 59 |
+
export { type ProjectServiceOptions } from '@typescript-eslint/types';
|
| 60 |
+
//# sourceMappingURL=createProjectService.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/createProjectService.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"createProjectService.d.ts","sourceRoot":"","sources":["../src/createProjectService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,KAAK,EAAE,MAAM,gCAAgC,CAAC;AA4B1D;;GAEG;AACH,MAAM,M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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.createProjectService = createProjectService;
|
| 7 |
+
const debug_1 = __importDefault(require("debug"));
|
| 8 |
+
const getParsedConfigFileFromTSServer_js_1 = require("./getParsedConfigFileFromTSServer.js");
|
| 9 |
+
const DEFAULT_PROJECT_MATCHED_FILES_THRESHOLD = 8;
|
| 10 |
+
const log = (0, debug_1.default)('typescript-eslint:project-service:createProjectService');
|
| 11 |
+
const logTsserverErr = (0, debug_1.default)('typescript-eslint:project-service:tsserver:err');
|
| 12 |
+
const logTsserverInfo = (0, debug_1.default)('typescript-eslint:project-service:tsserver:info');
|
| 13 |
+
const logTsserverPerf = (0, debug_1.default)('typescript-eslint:project-service:tsserver:perf');
|
| 14 |
+
const logTsserverEvent = (0, debug_1.default)('typescript-eslint:project-service:tsserver:event');
|
| 15 |
+
// For TypeScript APIs that expect a function to be passed in
|
| 16 |
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
| 17 |
+
const doNothing = () => { };
|
| 18 |
+
const createStubFileWatcher = () => ({
|
| 19 |
+
close: doNothing,
|
| 20 |
+
});
|
| 21 |
+
/**
|
| 22 |
+
* Creates a new Project Service instance, as well as metadata on its creation.
|
| 23 |
+
* @param settings Settings to create a new Project Service instance.
|
| 24 |
+
* @returns A new Project Service instance, as well as metadata on its creation.
|
| 25 |
+
* @example
|
| 26 |
+
* ```ts
|
| 27 |
+
* import { createProjectService } from '@typescript-eslint/project-service';
|
| 28 |
+
*
|
| 29 |
+
* const { service } = createProjectService();
|
| 30 |
+
*
|
| 31 |
+
* service.openClientFile('index.ts');
|
| 32 |
+
* ```
|
| 33 |
+
*/
|
| 34 |
+
function createProjectService({ jsDocParsingMode, options: optionsRaw = {}, tsconfigRootDir, } = {}) {
|
| 35 |
+
const options = {
|
| 36 |
+
defaultProject: 'tsconfig.json',
|
| 37 |
+
...optionsRaw,
|
| 38 |
+
};
|
| 39 |
+
// We import this lazily to avoid its cost for users who don't use the service
|
| 40 |
+
// TODO: Once we drop support for TS<5.3 we can import from "typescript" directly
|
| 41 |
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
| 42 |
+
const tsserver = require('typescript/lib/tsserverlibrary');
|
| 43 |
+
// TODO: see getWatchProgramsForProjects
|
| 44 |
+
// We don't watch the disk, we just refer to these when ESLint calls us
|
| 45 |
+
// there's a whole separate update pass in maybeInvalidateProgram at the bottom of getWatchProgramsForProjects
|
| 46 |
+
// (this "goes nuclear on TypeScript")
|
| 47 |
+
const system = {
|
| 48 |
+
...tsserver.sys,
|
| 49 |
+
clearImmediate,
|
| 50 |
+
clearTimeout,
|
| 51 |
+
setImmediate,
|
| 52 |
+
setTimeout,
|
| 53 |
+
watchDirectory: createStubFileWatcher,
|
| 54 |
+
watchFile: createStubFileWatcher,
|
| 55 |
+
// We stop loading any TypeScript plugins by default, to prevent them from attaching disk watchers
|
| 56 |
+
// See https://github.com/typescript-eslint/typescript-eslint/issues/9905
|
| 57 |
+
...(!options.loadTypeScriptPlugins && {
|
| 58 |
+
require: () => ({
|
| 59 |
+
error: {
|
| 60 |
+
message: 'TypeScript plugins are not required when using parserOptions.projectService.',
|
| 61 |
+
},
|
| 62 |
+
module: undefined,
|
| 63 |
+
}),
|
| 64 |
+
}),
|
| 65 |
+
};
|
| 66 |
+
const logger = {
|
| 67 |
+
close: doNothing,
|
| 68 |
+
endGroup: doNothing,
|
| 69 |
+
getLogFileName: () => undefined,
|
| 70 |
+
// The debug library doesn't use levels without creating a namespace for each.
|
| 71 |
+
// Log levels are not passed to the writer so we wouldn't be able to forward
|
| 72 |
+
// to a respective namespace. Supporting would require an additional flag for
|
| 73 |
+
// granular control. Defaulting to all levels for now.
|
| 74 |
+
hasLevel: () => true,
|
| 75 |
+
info(s) {
|
| 76 |
+
this.msg(s, tsserver.server.Msg.Info);
|
| 77 |
+
},
|
| 78 |
+
loggingEnabled: () =>
|
| 79 |
+
// if none of the debug namespaces are enabled, then don't enable logging in tsserver
|
| 80 |
+
logTsserverInfo.enabled ||
|
| 81 |
+
logTsserverErr.enabled ||
|
| 82 |
+
logTsserverPerf.enabled,
|
| 83 |
+
msg: (s, type) => {
|
| 84 |
+
switch (type) {
|
| 85 |
+
case tsserver.server.Msg.Err:
|
| 86 |
+
logTsserverErr(s);
|
| 87 |
+
break;
|
| 88 |
+
case tsserver.server.Msg.Perf:
|
| 89 |
+
logTsserverPerf(s);
|
| 90 |
+
break;
|
| 91 |
+
default:
|
| 92 |
+
logTsserverInfo(s);
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
perftrc(s) {
|
| 96 |
+
this.msg(s, tsserver.server.Msg.Perf);
|
| 97 |
+
},
|
| 98 |
+
startGroup: doNothing,
|
| 99 |
+
};
|
| 100 |
+
log('Creating Project Service with: %o', options);
|
| 101 |
+
const service = new tsserver.server.ProjectService({
|
| 102 |
+
cancellationToken: { isCancellationRequested: () => false },
|
| 103 |
+
eventHandler: logTsserverEvent.enabled
|
| 104 |
+
? (e) => {
|
| 105 |
+
logTsserverEvent(e);
|
| 106 |
+
}
|
| 107 |
+
: undefined,
|
| 108 |
+
host: system,
|
| 109 |
+
jsDocParsingMode,
|
| 110 |
+
logger,
|
| 111 |
+
session: undefined,
|
| 112 |
+
useInferredProjectPerProjectRoot: false,
|
| 113 |
+
useSingleInferredProject: false,
|
| 114 |
+
});
|
| 115 |
+
service.setHostConfiguration({
|
| 116 |
+
preferences: {
|
| 117 |
+
includePackageJsonAutoImports: 'off',
|
| 118 |
+
},
|
| 119 |
+
});
|
| 120 |
+
log('Enabling default project: %s', options.defaultProject);
|
| 121 |
+
const configFile = (0, getParsedConfigFileFromTSServer_js_1.getParsedConfigFileFromTSServer)(tsserver, options.defaultProject, !!optionsRaw.defaultProject, tsconfigRootDir);
|
| 122 |
+
if (configFile) {
|
| 123 |
+
service.setCompilerOptionsForInferredProjects(
|
| 124 |
+
// NOTE: The inferred projects API is not intended for source files when a tsconfig
|
| 125 |
+
// exists. There is no API that generates an InferredProjectCompilerOptions suggesting
|
| 126 |
+
// it is meant for hard coded options passed in. Hard asserting as a work around.
|
| 127 |
+
// See https://github.com/microsoft/TypeScript/blob/27bcd4cb5a98bce46c9cdd749752703ead021a4b/src/server/protocol.ts#L1904
|
| 128 |
+
configFile.options);
|
| 129 |
+
}
|
| 130 |
+
return {
|
| 131 |
+
allowDefaultProject: options.allowDefaultProject,
|
| 132 |
+
lastReloadTimestamp: performance.now(),
|
| 133 |
+
maximumDefaultProjectFileMatchCount: options.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING ??
|
| 134 |
+
DEFAULT_PROJECT_MATCHED_FILES_THRESHOLD,
|
| 135 |
+
service,
|
| 136 |
+
};
|
| 137 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
| 2 |
+
export declare function getParsedConfigFileFromTSServer(tsserver: typeof ts, defaultProject: string, throwOnFailure: boolean, tsconfigRootDir?: string): ts.ParsedCommandLine | undefined;
|
| 3 |
+
//# sourceMappingURL=getParsedConfigFileFromTSServer.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"getParsedConfigFileFromTSServer.d.ts","sourceRoot":"","sources":["../src/getParsedConfigFileFromTSServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAI1D,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,OAAO,EAAE,EACnB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,OAAO,EACvB,eAAe,CAAC,EAAE,MAAM,GACvB,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAYlC"}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/getParsedConfigFileFromTSServer.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.getParsedConfigFileFromTSServer = getParsedConfigFileFromTSServer;
|
| 4 |
+
const tsconfig_utils_1 = require("@typescript-eslint/tsconfig-utils");
|
| 5 |
+
function getParsedConfigFileFromTSServer(tsserver, defaultProject, throwOnFailure, tsconfigRootDir) {
|
| 6 |
+
try {
|
| 7 |
+
return (0, tsconfig_utils_1.getParsedConfigFile)(tsserver, defaultProject, tsconfigRootDir);
|
| 8 |
+
}
|
| 9 |
+
catch (error) {
|
| 10 |
+
if (throwOnFailure) {
|
| 11 |
+
throw new Error(`Could not read Project Service default project '${defaultProject}': ${error.message}`);
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
return undefined;
|
| 15 |
+
}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './createProjectService';
|
| 2 |
+
//# sourceMappingURL=index.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/project-service/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 14 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 15 |
+
};
|
| 16 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 17 |
+
__exportStar(require("./createProjectService"), exports);
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Lib, TSESTree } from '@typescript-eslint/types';
|
| 2 |
+
import type { Scope } from '../scope';
|
| 3 |
+
import type { ScopeManager } from '../ScopeManager';
|
| 4 |
+
import type { ReferenceImplicitGlobal } from './Reference';
|
| 5 |
+
import type { VisitorOptions } from './Visitor';
|
| 6 |
+
import { Visitor } from './Visitor';
|
| 7 |
+
export interface ReferencerOptions extends VisitorOptions {
|
| 8 |
+
jsxFragmentName: string | null;
|
| 9 |
+
jsxPragma: string | null;
|
| 10 |
+
lib: Lib[];
|
| 11 |
+
}
|
| 12 |
+
export declare class Referencer extends Visitor {
|
| 13 |
+
#private;
|
| 14 |
+
readonly scopeManager: ScopeManager;
|
| 15 |
+
constructor(options: ReferencerOptions, scopeManager: ScopeManager);
|
| 16 |
+
private populateGlobalsFromLib;
|
| 17 |
+
close(node: TSESTree.Node): void;
|
| 18 |
+
currentScope(): Scope;
|
| 19 |
+
currentScope(throwOnNull: true): Scope | null;
|
| 20 |
+
referencingDefaultValue(pattern: TSESTree.Identifier, assignments: (TSESTree.AssignmentExpression | TSESTree.AssignmentPattern)[], maybeImplicitGlobal: ReferenceImplicitGlobal | null, init: boolean): void;
|
| 21 |
+
/**
|
| 22 |
+
* Searches for a variable named "name" in the upper scopes and adds a pseudo-reference from itself to itself
|
| 23 |
+
*/
|
| 24 |
+
private referenceInSomeUpperScope;
|
| 25 |
+
private referenceJsxFragment;
|
| 26 |
+
private referenceJsxPragma;
|
| 27 |
+
protected visitClass(node: TSESTree.ClassDeclaration | TSESTree.ClassExpression): void;
|
| 28 |
+
protected visitForIn(node: TSESTree.ForInStatement | TSESTree.ForOfStatement): void;
|
| 29 |
+
protected visitFunction(node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.TSDeclareFunction | TSESTree.TSEmptyBodyFunctionExpression): void;
|
| 30 |
+
protected visitFunctionParameterTypeAnnotation(node: TSESTree.Parameter): void;
|
| 31 |
+
protected visitJSXElement(node: TSESTree.JSXClosingElement | TSESTree.JSXOpeningElement): void;
|
| 32 |
+
protected visitProperty(node: TSESTree.Property): void;
|
| 33 |
+
protected visitType(node: TSESTree.Node | null | undefined): void;
|
| 34 |
+
protected visitTypeAssertion(node: TSESTree.TSAsExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion): void;
|
| 35 |
+
protected ArrowFunctionExpression(node: TSESTree.ArrowFunctionExpression): void;
|
| 36 |
+
protected AssignmentExpression(node: TSESTree.AssignmentExpression): void;
|
| 37 |
+
protected BlockStatement(node: TSESTree.BlockStatement): void;
|
| 38 |
+
protected BreakStatement(): void;
|
| 39 |
+
protected CallExpression(node: TSESTree.CallExpression): void;
|
| 40 |
+
protected CatchClause(node: TSESTree.CatchClause): void;
|
| 41 |
+
protected ClassDeclaration(node: TSESTree.ClassDeclaration): void;
|
| 42 |
+
protected ClassExpression(node: TSESTree.ClassExpression): void;
|
| 43 |
+
protected ContinueStatement(): void;
|
| 44 |
+
protected ExportAllDeclaration(): void;
|
| 45 |
+
protected ExportDefaultDeclaration(node: TSESTree.ExportDefaultDeclaration): void;
|
| 46 |
+
protected ExportNamedDeclaration(node: TSESTree.ExportNamedDeclaration): void;
|
| 47 |
+
protected ForInStatement(node: TSESTree.ForInStatement): void;
|
| 48 |
+
protected ForOfStatement(node: TSESTree.ForOfStatement): void;
|
| 49 |
+
protected ForStatement(node: TSESTree.ForStatement): void;
|
| 50 |
+
protected FunctionDeclaration(node: TSESTree.FunctionDeclaration): void;
|
| 51 |
+
protected FunctionExpression(node: TSESTree.FunctionExpression): void;
|
| 52 |
+
protected Identifier(node: TSESTree.Identifier): void;
|
| 53 |
+
protected ImportAttribute(): void;
|
| 54 |
+
protected ImportDeclaration(node: TSESTree.ImportDeclaration): void;
|
| 55 |
+
protected JSXAttribute(node: TSESTree.JSXAttribute): void;
|
| 56 |
+
protected JSXClosingElement(node: TSESTree.JSXClosingElement): void;
|
| 57 |
+
protected JSXFragment(node: TSESTree.JSXFragment): void;
|
| 58 |
+
protected JSXIdentifier(node: TSESTree.JSXIdentifier): void;
|
| 59 |
+
protected JSXMemberExpression(node: TSESTree.JSXMemberExpression): void;
|
| 60 |
+
protected JSXOpeningElement(node: TSESTree.JSXOpeningElement): void;
|
| 61 |
+
protected LabeledStatement(node: TSESTree.LabeledStatement): void;
|
| 62 |
+
protected MemberExpression(node: TSESTree.MemberExpression): void;
|
| 63 |
+
protected MetaProperty(): void;
|
| 64 |
+
protected NewExpression(node: TSESTree.NewExpression): void;
|
| 65 |
+
protected PrivateIdentifier(): void;
|
| 66 |
+
protected Program(node: TSESTree.Program): void;
|
| 67 |
+
protected Property(node: TSESTree.Property): void;
|
| 68 |
+
protected SwitchStatement(node: TSESTree.SwitchStatement): void;
|
| 69 |
+
protected TaggedTemplateExpression(node: TSESTree.TaggedTemplateExpression): void;
|
| 70 |
+
protected TSAsExpression(node: TSESTree.TSAsExpression): void;
|
| 71 |
+
protected TSDeclareFunction(node: TSESTree.TSDeclareFunction): void;
|
| 72 |
+
protected TSEmptyBodyFunctionExpression(node: TSESTree.TSEmptyBodyFunctionExpression): void;
|
| 73 |
+
protected TSEnumDeclaration(node: TSESTree.TSEnumDeclaration): void;
|
| 74 |
+
protected TSExportAssignment(node: TSESTree.TSExportAssignment): void;
|
| 75 |
+
protected TSImportEqualsDeclaration(node: TSESTree.TSImportEqualsDeclaration): void;
|
| 76 |
+
protected TSInstantiationExpression(node: TSESTree.TSInstantiationExpression): void;
|
| 77 |
+
protected TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void;
|
| 78 |
+
protected TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void;
|
| 79 |
+
protected TSSatisfiesExpression(node: TSESTree.TSSatisfiesExpression): void;
|
| 80 |
+
protected TSTypeAliasDeclaration(node: TSESTree.TSTypeAliasDeclaration): void;
|
| 81 |
+
protected TSTypeAssertion(node: TSESTree.TSTypeAssertion): void;
|
| 82 |
+
protected UpdateExpression(node: TSESTree.UpdateExpression): void;
|
| 83 |
+
protected VariableDeclaration(node: TSESTree.VariableDeclaration): void;
|
| 84 |
+
protected WithStatement(node: TSESTree.WithStatement): void;
|
| 85 |
+
private visitExpressionTarget;
|
| 86 |
+
}
|
| 87 |
+
//# sourceMappingURL=Referencer.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/TypeVisitor.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TSESTree } from '@typescript-eslint/types';
|
| 2 |
+
import type { Referencer } from './Referencer';
|
| 3 |
+
import { Visitor } from './Visitor';
|
| 4 |
+
export declare class TypeVisitor extends Visitor {
|
| 5 |
+
#private;
|
| 6 |
+
constructor(referencer: Referencer);
|
| 7 |
+
static visit(referencer: Referencer, node: TSESTree.Node): void;
|
| 8 |
+
protected visitFunctionType(node: TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSFunctionType | TSESTree.TSMethodSignature): void;
|
| 9 |
+
protected visitPropertyKey(node: TSESTree.TSMethodSignature | TSESTree.TSPropertySignature): void;
|
| 10 |
+
protected Identifier(node: TSESTree.Identifier): void;
|
| 11 |
+
protected MemberExpression(node: TSESTree.MemberExpression): void;
|
| 12 |
+
protected TSCallSignatureDeclaration(node: TSESTree.TSCallSignatureDeclaration): void;
|
| 13 |
+
protected TSConditionalType(node: TSESTree.TSConditionalType): void;
|
| 14 |
+
protected TSConstructorType(node: TSESTree.TSConstructorType): void;
|
| 15 |
+
protected TSConstructSignatureDeclaration(node: TSESTree.TSConstructSignatureDeclaration): void;
|
| 16 |
+
protected TSFunctionType(node: TSESTree.TSFunctionType): void;
|
| 17 |
+
protected TSImportType(node: TSESTree.TSImportType): void;
|
| 18 |
+
protected TSIndexSignature(node: TSESTree.TSIndexSignature): void;
|
| 19 |
+
protected TSInferType(node: TSESTree.TSInferType): void;
|
| 20 |
+
protected TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void;
|
| 21 |
+
protected TSMappedType(node: TSESTree.TSMappedType): void;
|
| 22 |
+
protected TSMethodSignature(node: TSESTree.TSMethodSignature): void;
|
| 23 |
+
protected TSNamedTupleMember(node: TSESTree.TSNamedTupleMember): void;
|
| 24 |
+
protected TSPropertySignature(node: TSESTree.TSPropertySignature): void;
|
| 25 |
+
protected TSQualifiedName(node: TSESTree.TSQualifiedName): void;
|
| 26 |
+
protected TSTypeAliasDeclaration(node: TSESTree.TSTypeAliasDeclaration): void;
|
| 27 |
+
protected TSTypeParameter(node: TSESTree.TSTypeParameter): void;
|
| 28 |
+
protected TSTypePredicate(node: TSESTree.TSTypePredicate): void;
|
| 29 |
+
protected TSTypeAnnotation(node: TSESTree.TSTypeAnnotation): void;
|
| 30 |
+
protected TSTypeQuery(node: TSESTree.TSTypeQuery): void;
|
| 31 |
+
}
|
| 32 |
+
//# sourceMappingURL=TypeVisitor.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/Visitor.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TSESTree } from '@typescript-eslint/types';
|
| 2 |
+
import type { PatternVisitorCallback, PatternVisitorOptions } from './PatternVisitor';
|
| 3 |
+
import type { VisitorOptions } from './VisitorBase';
|
| 4 |
+
import { VisitorBase } from './VisitorBase';
|
| 5 |
+
interface VisitPatternOptions extends PatternVisitorOptions {
|
| 6 |
+
processRightHandNodes?: boolean;
|
| 7 |
+
}
|
| 8 |
+
export declare class Visitor extends VisitorBase {
|
| 9 |
+
#private;
|
| 10 |
+
constructor(optionsOrVisitor: Visitor | VisitorOptions);
|
| 11 |
+
protected visitPattern(node: TSESTree.Node, callback: PatternVisitorCallback, options?: VisitPatternOptions): void;
|
| 12 |
+
}
|
| 13 |
+
export { VisitorBase, type VisitorOptions } from './VisitorBase';
|
| 14 |
+
//# sourceMappingURL=Visitor.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/referencer/VisitorBase.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TSESTree } from '@typescript-eslint/types';
|
| 2 |
+
import type { VisitorKeys } from '@typescript-eslint/visitor-keys';
|
| 3 |
+
export interface VisitorOptions {
|
| 4 |
+
childVisitorKeys?: VisitorKeys | null;
|
| 5 |
+
visitChildrenEvenIfSelectorExists?: boolean;
|
| 6 |
+
}
|
| 7 |
+
export declare abstract class VisitorBase {
|
| 8 |
+
#private;
|
| 9 |
+
constructor(options: VisitorOptions);
|
| 10 |
+
/**
|
| 11 |
+
* Default method for visiting children.
|
| 12 |
+
* @param node the node whose children should be visited
|
| 13 |
+
* @param excludeArr a list of keys to not visit
|
| 14 |
+
*/
|
| 15 |
+
visitChildren<T extends TSESTree.Node>(node: T | null | undefined, excludeArr?: (keyof T)[]): void;
|
| 16 |
+
/**
|
| 17 |
+
* Dispatching node.
|
| 18 |
+
*/
|
| 19 |
+
visit(node: TSESTree.Node | null | undefined): void;
|
| 20 |
+
}
|
| 21 |
+
export type { VisitorKeys } from '@typescript-eslint/visitor-keys';
|
| 22 |
+
//# sourceMappingURL=VisitorBase.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { TSESTree } from '@typescript-eslint/types';
|
| 2 |
+
import { VariableBase } from './VariableBase';
|
| 3 |
+
/**
|
| 4 |
+
* ESLint defines global variables using the eslint-scope Variable class
|
| 5 |
+
* This is declared here for consumers to use
|
| 6 |
+
*/
|
| 7 |
+
export declare class ESLintScopeVariable extends VariableBase {
|
| 8 |
+
/**
|
| 9 |
+
* Written to by ESLint.
|
| 10 |
+
* If this key exists, this variable is a global variable added by ESLint.
|
| 11 |
+
* If this is `true`, this variable can be assigned arbitrary values.
|
| 12 |
+
* If this is `false`, this variable is readonly.
|
| 13 |
+
*/
|
| 14 |
+
writeable?: boolean;
|
| 15 |
+
/**
|
| 16 |
+
* Written to by ESLint.
|
| 17 |
+
* This property is undefined if there are no globals comment directives.
|
| 18 |
+
* The array of globals comment directives which defined this global variable in the source code file.
|
| 19 |
+
*/
|
| 20 |
+
eslintExplicitGlobal?: boolean;
|
| 21 |
+
/**
|
| 22 |
+
* Written to by ESLint.
|
| 23 |
+
* The configured value in config files. This can be different from `variable.writeable` if there are globals comment directives.
|
| 24 |
+
*/
|
| 25 |
+
eslintImplicitGlobalSetting?: 'readonly' | 'writable';
|
| 26 |
+
/**
|
| 27 |
+
* Written to by ESLint.
|
| 28 |
+
* If this key exists, it is a global variable added by ESLint.
|
| 29 |
+
* If `true`, this global variable was defined by a globals comment directive in the source code file.
|
| 30 |
+
*/
|
| 31 |
+
eslintExplicitGlobalComments?: TSESTree.Comment[];
|
| 32 |
+
}
|
| 33 |
+
//# sourceMappingURL=ESLintScopeVariable.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"ESLintScopeVariable.d.ts","sourceRoot":"","sources":["../../src/variable/ESLintScopeVariable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACnD;;;;;OAKG;IACI,SAAS,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACI,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAEtC;;;OAGG;IACI,2BAA2B,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7D;;;;OAIG;IACI,4BAA4B,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CAC1D"}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.ESLintScopeVariable = void 0;
|
| 4 |
+
const VariableBase_1 = require("./VariableBase");
|
| 5 |
+
/**
|
| 6 |
+
* ESLint defines global variables using the eslint-scope Variable class
|
| 7 |
+
* This is declared here for consumers to use
|
| 8 |
+
*/
|
| 9 |
+
class ESLintScopeVariable extends VariableBase_1.VariableBase {
|
| 10 |
+
/**
|
| 11 |
+
* Written to by ESLint.
|
| 12 |
+
* If this key exists, this variable is a global variable added by ESLint.
|
| 13 |
+
* If this is `true`, this variable can be assigned arbitrary values.
|
| 14 |
+
* If this is `false`, this variable is readonly.
|
| 15 |
+
*/
|
| 16 |
+
writeable; // note that this isn't a typo - ESlint uses this spelling here
|
| 17 |
+
/**
|
| 18 |
+
* Written to by ESLint.
|
| 19 |
+
* This property is undefined if there are no globals comment directives.
|
| 20 |
+
* The array of globals comment directives which defined this global variable in the source code file.
|
| 21 |
+
*/
|
| 22 |
+
eslintExplicitGlobal;
|
| 23 |
+
/**
|
| 24 |
+
* Written to by ESLint.
|
| 25 |
+
* The configured value in config files. This can be different from `variable.writeable` if there are globals comment directives.
|
| 26 |
+
*/
|
| 27 |
+
eslintImplicitGlobalSetting;
|
| 28 |
+
/**
|
| 29 |
+
* Written to by ESLint.
|
| 30 |
+
* If this key exists, it is a global variable added by ESLint.
|
| 31 |
+
* If `true`, this global variable was defined by a globals comment directive in the source code file.
|
| 32 |
+
*/
|
| 33 |
+
eslintExplicitGlobalComments;
|
| 34 |
+
}
|
| 35 |
+
exports.ESLintScopeVariable = ESLintScopeVariable;
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Scope } from '../scope';
|
| 2 |
+
import type { Variable } from './Variable';
|
| 3 |
+
import { ESLintScopeVariable } from './ESLintScopeVariable';
|
| 4 |
+
export interface ImplicitLibVariableOptions {
|
| 5 |
+
readonly eslintImplicitGlobalSetting?: ESLintScopeVariable['eslintImplicitGlobalSetting'];
|
| 6 |
+
readonly isTypeVariable?: boolean;
|
| 7 |
+
readonly isValueVariable?: boolean;
|
| 8 |
+
readonly writeable?: boolean;
|
| 9 |
+
}
|
| 10 |
+
export interface LibDefinition {
|
| 11 |
+
libs: readonly LibDefinition[];
|
| 12 |
+
variables: readonly [string, ImplicitLibVariableOptions][];
|
| 13 |
+
}
|
| 14 |
+
/**
|
| 15 |
+
* An variable implicitly defined by the TS Lib
|
| 16 |
+
*/
|
| 17 |
+
export declare class ImplicitLibVariable extends ESLintScopeVariable implements Variable {
|
| 18 |
+
/**
|
| 19 |
+
* `true` if the variable is valid in a type context, false otherwise
|
| 20 |
+
*/
|
| 21 |
+
readonly isTypeVariable: boolean;
|
| 22 |
+
/**
|
| 23 |
+
* `true` if the variable is valid in a value context, false otherwise
|
| 24 |
+
*/
|
| 25 |
+
readonly isValueVariable: boolean;
|
| 26 |
+
constructor(scope: Scope, name: string, { eslintImplicitGlobalSetting, isTypeVariable, isValueVariable, writeable, }: ImplicitLibVariableOptions);
|
| 27 |
+
}
|
| 28 |
+
//# sourceMappingURL=ImplicitLibVariable.d.ts.map
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"ImplicitLibVariable.d.ts","sourceRoot":"","sources":["../../src/variable/ImplicitLibVariable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;IAC1F,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,0BAA0B,CAAC,EAAE,CAAC;CAC5D;AAED;;GAEG;AACH,qBAAa,mBACX,SAAQ,mBACR,YAAW,QAAQ;IAEnB;;OAEG;IACH,SAAgB,cAAc,EAAE,OAAO,CAAC;IAExC;;OAEG;IACH,SAAgB,eAAe,EAAE,OAAO,CAAC;gBAGvC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,EACE,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,SAAS,GACV,EAAE,0BAA0B;CAShC"}
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.ImplicitLibVariable = void 0;
|
| 4 |
+
const ESLintScopeVariable_1 = require("./ESLintScopeVariable");
|
| 5 |
+
/**
|
| 6 |
+
* An variable implicitly defined by the TS Lib
|
| 7 |
+
*/
|
| 8 |
+
class ImplicitLibVariable extends ESLintScopeVariable_1.ESLintScopeVariable {
|
| 9 |
+
/**
|
| 10 |
+
* `true` if the variable is valid in a type context, false otherwise
|
| 11 |
+
*/
|
| 12 |
+
isTypeVariable;
|
| 13 |
+
/**
|
| 14 |
+
* `true` if the variable is valid in a value context, false otherwise
|
| 15 |
+
*/
|
| 16 |
+
isValueVariable;
|
| 17 |
+
constructor(scope, name, { eslintImplicitGlobalSetting, isTypeVariable, isValueVariable, writeable, }) {
|
| 18 |
+
super(name, scope);
|
| 19 |
+
this.isTypeVariable = isTypeVariable ?? false;
|
| 20 |
+
this.isValueVariable = isValueVariable ?? false;
|
| 21 |
+
this.writeable = writeable ?? false;
|
| 22 |
+
this.eslintImplicitGlobalSetting =
|
| 23 |
+
eslintImplicitGlobalSetting ?? 'readonly';
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
exports.ImplicitLibVariable = ImplicitLibVariable;
|
novas/novacore-zephyr/claude-code-router/ui/node_modules/@typescript-eslint/scope-manager/dist/variable/Variable.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { VariableBase } from './VariableBase';
|
| 2 |
+
/**
|
| 3 |
+
* A Variable represents a locally scoped identifier. These include arguments to functions.
|
| 4 |
+
*/
|
| 5 |
+
export declare class Variable extends VariableBase {
|
| 6 |
+
/**
|
| 7 |
+
* `true` if the variable is valid in a type context, false otherwise
|
| 8 |
+
* @public
|
| 9 |
+
*/
|
| 10 |
+
get isTypeVariable(): boolean;
|
| 11 |
+
/**
|
| 12 |
+
* `true` if the variable is valid in a value context, false otherwise
|
| 13 |
+
* @public
|
| 14 |
+
*/
|
| 15 |
+
get isValueVariable(): boolean;
|
| 16 |
+
}
|
| 17 |
+
//# sourceMappingURL=Variable.d.ts.map
|