corsa-oxlint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ast_utils.d.ts +17 -0
- package/dist/ast_utils.js +21 -0
- package/dist/ast_utils.js.map +1 -0
- package/dist/checker.d.ts +11 -0
- package/dist/checker.js +80 -0
- package/dist/checker.js.map +1 -0
- package/dist/compat.d.ts +194 -0
- package/dist/compat.js +103 -0
- package/dist/compat.js.map +1 -0
- package/dist/context.d.ts +24 -0
- package/dist/context.js +134 -0
- package/dist/context.js.map +1 -0
- package/dist/eslint_utils.d.ts +19 -0
- package/dist/eslint_utils.js +48 -0
- package/dist/eslint_utils.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/json_schema.d.ts +11 -0
- package/dist/json_schema.js +17 -0
- package/dist/json_schema.js.map +1 -0
- package/dist/node_map.d.ts +18 -0
- package/dist/node_map.js +52 -0
- package/dist/node_map.js.map +1 -0
- package/dist/parser_services.d.ts +16 -0
- package/dist/parser_services.js +48 -0
- package/dist/parser_services.js.map +1 -0
- package/dist/plugin.d.ts +26 -0
- package/dist/plugin.js +83 -0
- package/dist/plugin.js.map +1 -0
- package/dist/registry.d.ts +12 -0
- package/dist/registry.js +35 -0
- package/dist/registry.js.map +1 -0
- package/dist/rule_tester.d.ts +37 -0
- package/dist/rule_tester.js +120 -0
- package/dist/rule_tester.js.map +1 -0
- package/dist/rules/ast.d.ts +16 -0
- package/dist/rules/ast.js +56 -0
- package/dist/rules/ast.js.map +1 -0
- package/dist/rules/await_thenable.d.ts +16 -0
- package/dist/rules/await_thenable.js +23 -0
- package/dist/rules/await_thenable.js.map +1 -0
- package/dist/rules/index.d.ts +473 -0
- package/dist/rules/index.js +120 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/no_array_delete.d.ts +16 -0
- package/dist/rules/no_array_delete.js +29 -0
- package/dist/rules/no_array_delete.js.map +1 -0
- package/dist/rules/no_base_to_string.d.ts +16 -0
- package/dist/rules/no_base_to_string.js +66 -0
- package/dist/rules/no_base_to_string.js.map +1 -0
- package/dist/rules/no_floating_promises.d.ts +16 -0
- package/dist/rules/no_floating_promises.js +42 -0
- package/dist/rules/no_floating_promises.js.map +1 -0
- package/dist/rules/no_for_in_array.d.ts +16 -0
- package/dist/rules/no_for_in_array.js +16 -0
- package/dist/rules/no_for_in_array.js.map +1 -0
- package/dist/rules/no_implied_eval.d.ts +16 -0
- package/dist/rules/no_implied_eval.js +35 -0
- package/dist/rules/no_implied_eval.js.map +1 -0
- package/dist/rules/no_mixed_enums.d.ts +16 -0
- package/dist/rules/no_mixed_enums.js +41 -0
- package/dist/rules/no_mixed_enums.js.map +1 -0
- package/dist/rules/no_unsafe_assignment.d.ts +16 -0
- package/dist/rules/no_unsafe_assignment.js +41 -0
- package/dist/rules/no_unsafe_assignment.js.map +1 -0
- package/dist/rules/no_unsafe_return.d.ts +16 -0
- package/dist/rules/no_unsafe_return.js +56 -0
- package/dist/rules/no_unsafe_return.js.map +1 -0
- package/dist/rules/no_unsafe_unary_minus.d.ts +16 -0
- package/dist/rules/no_unsafe_unary_minus.js +28 -0
- package/dist/rules/no_unsafe_unary_minus.js.map +1 -0
- package/dist/rules/only_throw_error.d.ts +16 -0
- package/dist/rules/only_throw_error.js +16 -0
- package/dist/rules/only_throw_error.js.map +1 -0
- package/dist/rules/prefer_find.d.ts +16 -0
- package/dist/rules/prefer_find.js +25 -0
- package/dist/rules/prefer_find.js.map +1 -0
- package/dist/rules/prefer_includes.d.ts +16 -0
- package/dist/rules/prefer_includes.js +21 -0
- package/dist/rules/prefer_includes.js.map +1 -0
- package/dist/rules/prefer_promise_reject_errors.d.ts +16 -0
- package/dist/rules/prefer_promise_reject_errors.js +52 -0
- package/dist/rules/prefer_promise_reject_errors.js.map +1 -0
- package/dist/rules/prefer_regexp_exec.d.ts +16 -0
- package/dist/rules/prefer_regexp_exec.js +20 -0
- package/dist/rules/prefer_regexp_exec.js.map +1 -0
- package/dist/rules/prefer_string_starts_ends_with.d.ts +16 -0
- package/dist/rules/prefer_string_starts_ends_with.js +53 -0
- package/dist/rules/prefer_string_starts_ends_with.js.map +1 -0
- package/dist/rules/require_array_sort_compare.d.ts +16 -0
- package/dist/rules/require_array_sort_compare.js +36 -0
- package/dist/rules/require_array_sort_compare.js.map +1 -0
- package/dist/rules/restrict_plus_operands.d.ts +16 -0
- package/dist/rules/restrict_plus_operands.js +62 -0
- package/dist/rules/restrict_plus_operands.js.map +1 -0
- package/dist/rules/rule_creator.d.ts +16 -0
- package/dist/rules/rule_creator.js +22 -0
- package/dist/rules/rule_creator.js.map +1 -0
- package/dist/rules/type_utils.d.ts +56 -0
- package/dist/rules/type_utils.js +102 -0
- package/dist/rules/type_utils.js.map +1 -0
- package/dist/rules/use_unknown_in_catch_callback_variable.d.ts +16 -0
- package/dist/rules/use_unknown_in_catch_callback_variable.js +19 -0
- package/dist/rules/use_unknown_in_catch_callback_variable.js.map +1 -0
- package/dist/session.d.ts +32 -0
- package/dist/session.js +179 -0
- package/dist/session.js.map +1 -0
- package/dist/ts_eslint.d.ts +22 -0
- package/dist/ts_eslint.js +30 -0
- package/dist/ts_eslint.js.map +1 -0
- package/dist/ts_estree.d.ts +2 -0
- package/dist/ts_estree.js +2 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.js +22 -0
- package/dist/utils.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ubugeeei and contributors
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# corsa-oxlint
|
|
2
|
+
|
|
3
|
+
`corsa-oxlint` is a self-hosted `typescript-eslint`-style framework for
|
|
4
|
+
building Oxlint JS plugins with real type information powered by `tsgo`.
|
|
5
|
+
|
|
6
|
+
> [!WARNING]
|
|
7
|
+
> This package is still an early WIP.
|
|
8
|
+
> The core direction is stable, but the API surface will keep moving while
|
|
9
|
+
> `typescript-go`, Oxlint's JS plugin APIs, and the surrounding benchmarks are
|
|
10
|
+
> still evolving.
|
|
11
|
+
|
|
12
|
+
## What It Does
|
|
13
|
+
|
|
14
|
+
- exposes `ESLintUtils.RuleCreator()` and `getParserServices()` backed by `tsgo`
|
|
15
|
+
- preserves the familiar subpath layout without depending on `@typescript-eslint`
|
|
16
|
+
- binds Rust-implemented hot paths into JS through `napi-rs`
|
|
17
|
+
- lets custom Oxlint rules query types and symbols from JS or TS
|
|
18
|
+
- ships a `RuleTester` wrapper that injects temp projects and type-aware config
|
|
19
|
+
- ships a growing TS-native ruleset under `corsa-oxlint/rules`
|
|
20
|
+
|
|
21
|
+
The design goal is simple: performance-critical pieces live in Rust, `napi-rs`
|
|
22
|
+
bridges them into Node, and end users still get to author custom plugins and
|
|
23
|
+
custom rules in plain JS/TS.
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
Oxlint does not expose arbitrary parser options at runtime, so
|
|
28
|
+
`corsa-oxlint` reads its type-aware settings from
|
|
29
|
+
`settings.typescriptOxlint`.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { ESLintUtils } from "corsa-oxlint";
|
|
33
|
+
|
|
34
|
+
const createRule = ESLintUtils.RuleCreator((name) => `https://example.com/rules/${name}`);
|
|
35
|
+
|
|
36
|
+
export const noStringPlusNumber = createRule({
|
|
37
|
+
name: "no-string-plus-number",
|
|
38
|
+
meta: {
|
|
39
|
+
type: "problem",
|
|
40
|
+
docs: {
|
|
41
|
+
description: "forbid string + number",
|
|
42
|
+
requiresTypeChecking: true,
|
|
43
|
+
},
|
|
44
|
+
messages: {
|
|
45
|
+
unexpected: "string plus number is forbidden",
|
|
46
|
+
},
|
|
47
|
+
schema: [],
|
|
48
|
+
},
|
|
49
|
+
defaultOptions: [],
|
|
50
|
+
create(context) {
|
|
51
|
+
const services = ESLintUtils.getParserServices(context);
|
|
52
|
+
const checker = services.program.getTypeChecker();
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
BinaryExpression(node) {
|
|
56
|
+
if (node.operator !== "+") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const left = checker.getTypeAtLocation(node.left);
|
|
60
|
+
const right = checker.getTypeAtLocation(node.right);
|
|
61
|
+
if (!left || !right) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const leftText = checker.typeToString(checker.getBaseTypeOfLiteralType(left) ?? left);
|
|
65
|
+
const rightText = checker.typeToString(checker.getBaseTypeOfLiteralType(right) ?? right);
|
|
66
|
+
if (leftText === "string" && rightText === "number") {
|
|
67
|
+
context.report({ node, messageId: "unexpected" });
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
export default [
|
|
77
|
+
{
|
|
78
|
+
settings: {
|
|
79
|
+
typescriptOxlint: {
|
|
80
|
+
parserOptions: {
|
|
81
|
+
project: ["./tsconfig.json"],
|
|
82
|
+
tsconfigRootDir: import.meta.dirname,
|
|
83
|
+
tsgo: {
|
|
84
|
+
executable: "./.cache/tsgo",
|
|
85
|
+
mode: "msgpack",
|
|
86
|
+
requestTimeoutMs: 30000,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Native Rules
|
|
96
|
+
|
|
97
|
+
`corsa-oxlint/rules` exports the TS-native rule set and plugin surface.
|
|
98
|
+
Rule parity is tracked against upstream `tsgolint/internal/rules`, but the
|
|
99
|
+
runtime implementation lives entirely in this package.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { typescriptOxlintPlugin } from "corsa-oxlint/rules";
|
|
103
|
+
|
|
104
|
+
export default [
|
|
105
|
+
{
|
|
106
|
+
plugins: {
|
|
107
|
+
typescript: typescriptOxlintPlugin,
|
|
108
|
+
},
|
|
109
|
+
rules: {
|
|
110
|
+
"typescript/no-floating-promises": "error",
|
|
111
|
+
"typescript/prefer-promise-reject-errors": "error",
|
|
112
|
+
"typescript/restrict-plus-operands": ["error", { allowNumberAndString: false }],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Current native coverage includes:
|
|
119
|
+
|
|
120
|
+
- `await-thenable`
|
|
121
|
+
- `no-array-delete`
|
|
122
|
+
- `no-base-to-string`
|
|
123
|
+
- `no-floating-promises`
|
|
124
|
+
- `no-for-in-array`
|
|
125
|
+
- `no-implied-eval`
|
|
126
|
+
- `no-mixed-enums`
|
|
127
|
+
- `no-unsafe-assignment`
|
|
128
|
+
- `no-unsafe-return`
|
|
129
|
+
- `no-unsafe-unary-minus`
|
|
130
|
+
- `only-throw-error`
|
|
131
|
+
- `prefer-find`
|
|
132
|
+
- `prefer-includes`
|
|
133
|
+
- `prefer-promise-reject-errors`
|
|
134
|
+
- `prefer-regexp-exec`
|
|
135
|
+
- `prefer-string-starts-ends-with`
|
|
136
|
+
- `require-array-sort-compare`
|
|
137
|
+
- `restrict-plus-operands`
|
|
138
|
+
- `use-unknown-in-catch-callback-variable`
|
|
139
|
+
|
|
140
|
+
The remaining upstream rules stay listed in `pendingNativeRuleNames`, and
|
|
141
|
+
`native_rules.test.ts` fails if implemented + pending drift away from the
|
|
142
|
+
tracked upstream rule list.
|
|
143
|
+
|
|
144
|
+
## Runtime Safety Controls
|
|
145
|
+
|
|
146
|
+
The underlying `@corsa-bind/napi` client now exposes a few production-oriented
|
|
147
|
+
runtime controls:
|
|
148
|
+
|
|
149
|
+
- `requestTimeoutMs`
|
|
150
|
+
- `shutdownTimeoutMs`
|
|
151
|
+
- `outboundCapacity`
|
|
152
|
+
- `allowUnstableUpstreamCalls`
|
|
153
|
+
|
|
154
|
+
Leaving `allowUnstableUpstreamCalls` unset keeps unstable upstream endpoints
|
|
155
|
+
such as `printNode` disabled by default.
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
vp install
|
|
161
|
+
vp run -w build_typescript_oxlint
|
|
162
|
+
vp fmt
|
|
163
|
+
vp lint
|
|
164
|
+
vp check
|
|
165
|
+
vp test run --config ./vite.config.ts src/bindings/nodejs/typescript_oxlint/ts/**/*.test.ts
|
|
166
|
+
vp test bench --config ./vite.config.ts bench/src/typescript_oxlint.bench.ts
|
|
167
|
+
vp test bench --config ./vite.config.ts bench/src/typescript_oxlint_rules.bench.ts
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Repository-level examples live under [`examples/`](../../examples/README.md),
|
|
171
|
+
including custom-rule, custom-plugin, and native-rules flat-config samples.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare namespace ast_utils_d_exports {
|
|
2
|
+
export { ASTUtils, isIdentifier, isNodeOfType };
|
|
3
|
+
}
|
|
4
|
+
declare function isNodeOfType(node: {
|
|
5
|
+
readonly type?: string;
|
|
6
|
+
} | null | undefined, type: string): boolean;
|
|
7
|
+
declare function isIdentifier(node: {
|
|
8
|
+
readonly type?: string;
|
|
9
|
+
readonly name?: string;
|
|
10
|
+
} | null | undefined, name?: string): boolean;
|
|
11
|
+
declare const ASTUtils: Readonly<{
|
|
12
|
+
isIdentifier: typeof isIdentifier;
|
|
13
|
+
isNodeOfType: typeof isNodeOfType;
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ASTUtils, ast_utils_d_exports, isIdentifier, isNodeOfType };
|
|
17
|
+
//# sourceMappingURL=ast_utils.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/ast_utils.ts
|
|
3
|
+
var ast_utils_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
ASTUtils: () => ASTUtils,
|
|
5
|
+
isIdentifier: () => isIdentifier,
|
|
6
|
+
isNodeOfType: () => isNodeOfType
|
|
7
|
+
});
|
|
8
|
+
function isNodeOfType(node, type) {
|
|
9
|
+
return node?.type === type;
|
|
10
|
+
}
|
|
11
|
+
function isIdentifier(node, name) {
|
|
12
|
+
return node?.type === "Identifier" && (name === void 0 || node.name === name);
|
|
13
|
+
}
|
|
14
|
+
const ASTUtils = Object.freeze({
|
|
15
|
+
isIdentifier,
|
|
16
|
+
isNodeOfType
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ASTUtils, ast_utils_exports, isIdentifier, isNodeOfType };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=ast_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast_utils.js","names":[],"sources":["../ts/ast_utils.ts"],"sourcesContent":["export function isNodeOfType(\n node: { readonly type?: string } | null | undefined,\n type: string,\n): boolean {\n return node?.type === type;\n}\n\nexport function isIdentifier(\n node: { readonly type?: string; readonly name?: string } | null | undefined,\n name?: string,\n): boolean {\n return node?.type === \"Identifier\" && (name === undefined || node.name === name);\n}\n\nexport const ASTUtils = Object.freeze({\n isIdentifier,\n isNodeOfType,\n});\n"],"mappings":";;;;;;;AAAA,SAAgB,aACd,MACA,MACS;AACT,QAAO,MAAM,SAAS;;AAGxB,SAAgB,aACd,MACA,MACS;AACT,QAAO,MAAM,SAAS,iBAAiB,SAAS,KAAA,KAAa,KAAK,SAAS;;AAG7E,MAAa,WAAW,OAAO,OAAO;CACpC;CACA;CACD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContextWithParserOptions, TsgoProgramShape, TsgoTypeCheckerShape } from "./types.js";
|
|
2
|
+
import { createNodeMaps } from "./node_map.js";
|
|
3
|
+
|
|
4
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/checker.d.ts
|
|
5
|
+
declare function createProgram(context: ContextWithParserOptions): TsgoProgramShape & {
|
|
6
|
+
readonly nodeMaps: ReturnType<typeof createNodeMaps>;
|
|
7
|
+
};
|
|
8
|
+
declare function createTypeChecker(context: ContextWithParserOptions): TsgoTypeCheckerShape;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createProgram, createTypeChecker };
|
|
11
|
+
//# sourceMappingURL=checker.d.ts.map
|
package/dist/checker.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createNodeMaps, toPosition } from "./node_map.js";
|
|
2
|
+
import { sessionForContext } from "./registry.js";
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/checker.ts
|
|
4
|
+
function createProgram(context) {
|
|
5
|
+
return {
|
|
6
|
+
nodeMaps: createNodeMaps(context),
|
|
7
|
+
getCompilerOptions() {
|
|
8
|
+
return sessionForContext(context).session.getCompilerOptions();
|
|
9
|
+
},
|
|
10
|
+
getCurrentDirectory() {
|
|
11
|
+
return sessionForContext(context).project.rootDir;
|
|
12
|
+
},
|
|
13
|
+
getRootFileNames() {
|
|
14
|
+
return sessionForContext(context).session.getRootFileNames();
|
|
15
|
+
},
|
|
16
|
+
getSourceFile(fileName = context.filename) {
|
|
17
|
+
return {
|
|
18
|
+
fileName,
|
|
19
|
+
text: context.sourceCode.text
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
getTypeChecker() {
|
|
23
|
+
return createTypeChecker(context);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createTypeChecker(context) {
|
|
28
|
+
return {
|
|
29
|
+
getTypeAtLocation(node) {
|
|
30
|
+
return sessionForContext(context).session.getTypeAtPosition(filenameFor(context, node), toPosition(node));
|
|
31
|
+
},
|
|
32
|
+
getContextualType(node) {
|
|
33
|
+
return this.getTypeAtLocation(node);
|
|
34
|
+
},
|
|
35
|
+
getSymbolAtLocation(node) {
|
|
36
|
+
return sessionForContext(context).session.getSymbolAtPosition(filenameFor(context, node), toPosition(node));
|
|
37
|
+
},
|
|
38
|
+
getTypeOfSymbol(symbol) {
|
|
39
|
+
return sessionForContext(context).session.getTypeOfSymbol(symbol);
|
|
40
|
+
},
|
|
41
|
+
getDeclaredTypeOfSymbol(symbol) {
|
|
42
|
+
return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);
|
|
43
|
+
},
|
|
44
|
+
getTypeOfSymbolAtLocation(symbol, node) {
|
|
45
|
+
return this.getTypeAtLocation(node) ?? this.getTypeOfSymbol(symbol);
|
|
46
|
+
},
|
|
47
|
+
typeToString(type, enclosingDeclaration, flags) {
|
|
48
|
+
return sessionForContext(context).session.typeToString(type, flags);
|
|
49
|
+
},
|
|
50
|
+
getBaseTypeOfLiteralType(type) {
|
|
51
|
+
return sessionForContext(context).session.getBaseTypeOfLiteralType(type);
|
|
52
|
+
},
|
|
53
|
+
getPropertiesOfType(type) {
|
|
54
|
+
return sessionForContext(context).session.getPropertiesOfType(type);
|
|
55
|
+
},
|
|
56
|
+
getSignaturesOfType(type, kind) {
|
|
57
|
+
return sessionForContext(context).session.getSignaturesOfType(type, kind);
|
|
58
|
+
},
|
|
59
|
+
getReturnTypeOfSignature(signature) {
|
|
60
|
+
return sessionForContext(context).session.getReturnTypeOfSignature(signature);
|
|
61
|
+
},
|
|
62
|
+
getTypePredicateOfSignature(signature) {
|
|
63
|
+
return sessionForContext(context).session.getTypePredicateOfSignature(signature);
|
|
64
|
+
},
|
|
65
|
+
getBaseTypes(type) {
|
|
66
|
+
return sessionForContext(context).session.getBaseTypes(type);
|
|
67
|
+
},
|
|
68
|
+
getTypeArguments(type) {
|
|
69
|
+
return sessionForContext(context).session.getTypeArguments(type);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function filenameFor(context, node) {
|
|
74
|
+
if ("fileName" in node) return node.fileName;
|
|
75
|
+
return context.filename;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { createProgram, createTypeChecker };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checker.js","names":[],"sources":["../ts/checker.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport { createNodeMaps, toPosition } from \"./node_map\";\nimport { sessionForContext } from \"./registry\";\nimport type {\n ContextWithParserOptions,\n TsgoNode,\n TsgoProgramShape,\n TsgoSignature,\n TsgoSymbol,\n TsgoType,\n TsgoTypeCheckerShape,\n} from \"./types\";\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): TsgoProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): TsgoTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n return sessionForContext(context).session.getTypeAtPosition(\n filenameFor(context, node),\n toPosition(node),\n );\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, node),\n toPosition(node),\n );\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return this.getTypeAtLocation(node) ?? this.getTypeOfSymbol(symbol);\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n };\n}\n\nfunction filenameFor(\n context: ContextWithParserOptions,\n node: Node | TsgoNode | TsgoType | TsgoSymbol | TsgoSignature,\n): string {\n if (\"fileName\" in node) {\n return node.fileName;\n }\n return context.filename;\n}\n"],"mappings":";;;AAcA,SAAgB,cACd,SAC6E;AAE7E,QAAO;EACL,UAFe,eAAe,QAAQ;EAGtC,qBAAqB;AACnB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBAAoB;;EAEhE,sBAAsB;AACpB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ;;EAE5C,mBAAmB;AACjB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,kBAAkB;;EAE9D,cAAc,WAAW,QAAQ,UAAU;AACzC,UAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;IAAM;;EAEpD,iBAAiB;AACf,UAAO,kBAAkB,QAAQ;;EAEpC;;AAGH,SAAgB,kBAAkB,SAAyD;AACzF,QAAO;EACL,kBAAkB,MAAM;AACtB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,kBACxC,YAAY,SAAS,KAAK,EAC1B,WAAW,KAAK,CACjB;;EAEH,kBAAkB,MAAM;AACtB,UAAO,KAAK,kBAAkB,KAAK;;EAErC,oBAAoB,MAAM;AACxB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBACxC,YAAY,SAAS,KAAK,EAC1B,WAAW,KAAK,CACjB;;EAEH,gBAAgB,QAAQ;AACtB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,gBAAgB,OAAO;;EAEnE,wBAAwB,QAAQ;AAC9B,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,wBAAwB,OAAO;;EAE3E,0BAA0B,QAAQ,MAAM;AACtC,UAAO,KAAK,kBAAkB,KAAK,IAAI,KAAK,gBAAgB,OAAO;;EAErE,aAAa,MAAM,sBAAsB,OAAO;AAE9C,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,aAAa,MAAM,MAAM;;EAErE,yBAAyB,MAAM;AAC7B,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,yBAAyB,KAAK;;EAE1E,oBAAoB,MAAM;AACxB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBAAoB,KAAK;;EAErE,oBAAoB,MAAM,MAAM;AAC9B,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBAAoB,MAAM,KAAK;;EAE3E,yBAAyB,WAAW;AAClC,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,yBAAyB,UAAU;;EAE/E,4BAA4B,WAAW;AACrC,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,4BAA4B,UAAU;;EAElF,aAAa,MAAM;AACjB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,aAAa,KAAK;;EAE9D,iBAAiB,MAAM;AACrB,UAAO,kBAAkB,QAAQ,CAAC,QAAQ,iBAAiB,KAAK;;EAEnE;;AAGH,SAAS,YACP,SACA,MACQ;AACR,KAAI,cAAc,KAChB,QAAO,KAAK;AAEd,QAAO,QAAQ"}
|
package/dist/compat.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/compat.d.ts
|
|
2
|
+
declare const AST_NODE_TYPES: Readonly<{
|
|
3
|
+
readonly ArrayExpression: "ArrayExpression";
|
|
4
|
+
readonly ArrowFunctionExpression: "ArrowFunctionExpression";
|
|
5
|
+
readonly AssignmentExpression: "AssignmentExpression";
|
|
6
|
+
readonly AwaitExpression: "AwaitExpression";
|
|
7
|
+
readonly BinaryExpression: "BinaryExpression";
|
|
8
|
+
readonly BlockStatement: "BlockStatement";
|
|
9
|
+
readonly CallExpression: "CallExpression";
|
|
10
|
+
readonly CatchClause: "CatchClause";
|
|
11
|
+
readonly ChainExpression: "ChainExpression";
|
|
12
|
+
readonly ConditionalExpression: "ConditionalExpression";
|
|
13
|
+
readonly ExpressionStatement: "ExpressionStatement";
|
|
14
|
+
readonly ForInStatement: "ForInStatement";
|
|
15
|
+
readonly ForOfStatement: "ForOfStatement";
|
|
16
|
+
readonly FunctionDeclaration: "FunctionDeclaration";
|
|
17
|
+
readonly FunctionExpression: "FunctionExpression";
|
|
18
|
+
readonly Identifier: "Identifier";
|
|
19
|
+
readonly IfStatement: "IfStatement";
|
|
20
|
+
readonly ImportDeclaration: "ImportDeclaration";
|
|
21
|
+
readonly Literal: "Literal";
|
|
22
|
+
readonly LogicalExpression: "LogicalExpression";
|
|
23
|
+
readonly MemberExpression: "MemberExpression";
|
|
24
|
+
readonly MethodDefinition: "MethodDefinition";
|
|
25
|
+
readonly NewExpression: "NewExpression";
|
|
26
|
+
readonly ObjectExpression: "ObjectExpression";
|
|
27
|
+
readonly Program: "Program";
|
|
28
|
+
readonly Property: "Property";
|
|
29
|
+
readonly ReturnStatement: "ReturnStatement";
|
|
30
|
+
readonly SequenceExpression: "SequenceExpression";
|
|
31
|
+
readonly SpreadElement: "SpreadElement";
|
|
32
|
+
readonly SwitchStatement: "SwitchStatement";
|
|
33
|
+
readonly TaggedTemplateExpression: "TaggedTemplateExpression";
|
|
34
|
+
readonly TemplateLiteral: "TemplateLiteral";
|
|
35
|
+
readonly ThrowStatement: "ThrowStatement";
|
|
36
|
+
readonly TryStatement: "TryStatement";
|
|
37
|
+
readonly UnaryExpression: "UnaryExpression";
|
|
38
|
+
readonly UpdateExpression: "UpdateExpression";
|
|
39
|
+
readonly VariableDeclaration: "VariableDeclaration";
|
|
40
|
+
readonly VariableDeclarator: "VariableDeclarator";
|
|
41
|
+
readonly TSAnyKeyword: "TSAnyKeyword";
|
|
42
|
+
readonly TSAsExpression: "TSAsExpression";
|
|
43
|
+
readonly TSBooleanKeyword: "TSBooleanKeyword";
|
|
44
|
+
readonly TSCallSignatureDeclaration: "TSCallSignatureDeclaration";
|
|
45
|
+
readonly TSConditionalType: "TSConditionalType";
|
|
46
|
+
readonly TSConstructSignatureDeclaration: "TSConstructSignatureDeclaration";
|
|
47
|
+
readonly TSDeclareFunction: "TSDeclareFunction";
|
|
48
|
+
readonly TSEnumDeclaration: "TSEnumDeclaration";
|
|
49
|
+
readonly TSExpressionWithTypeArguments: "TSExpressionWithTypeArguments";
|
|
50
|
+
readonly TSFunctionType: "TSFunctionType";
|
|
51
|
+
readonly TSImportType: "TSImportType";
|
|
52
|
+
readonly TSIndexedAccessType: "TSIndexedAccessType";
|
|
53
|
+
readonly TSInferType: "TSInferType";
|
|
54
|
+
readonly TSInterfaceDeclaration: "TSInterfaceDeclaration";
|
|
55
|
+
readonly TSLiteralType: "TSLiteralType";
|
|
56
|
+
readonly TSMappedType: "TSMappedType";
|
|
57
|
+
readonly TSMethodSignature: "TSMethodSignature";
|
|
58
|
+
readonly TSModuleDeclaration: "TSModuleDeclaration";
|
|
59
|
+
readonly TSNeverKeyword: "TSNeverKeyword";
|
|
60
|
+
readonly TSNullKeyword: "TSNullKeyword";
|
|
61
|
+
readonly TSNumberKeyword: "TSNumberKeyword";
|
|
62
|
+
readonly TSObjectKeyword: "TSObjectKeyword";
|
|
63
|
+
readonly TSPropertySignature: "TSPropertySignature";
|
|
64
|
+
readonly TSStringKeyword: "TSStringKeyword";
|
|
65
|
+
readonly TSThisType: "TSThisType";
|
|
66
|
+
readonly TSTupleType: "TSTupleType";
|
|
67
|
+
readonly TSTypeAliasDeclaration: "TSTypeAliasDeclaration";
|
|
68
|
+
readonly TSTypeAnnotation: "TSTypeAnnotation";
|
|
69
|
+
readonly TSTypeAssertion: "TSTypeAssertion";
|
|
70
|
+
readonly TSTypeLiteral: "TSTypeLiteral";
|
|
71
|
+
readonly TSTypeOperator: "TSTypeOperator";
|
|
72
|
+
readonly TSTypeParameter: "TSTypeParameter";
|
|
73
|
+
readonly TSTypeParameterDeclaration: "TSTypeParameterDeclaration";
|
|
74
|
+
readonly TSTypeParameterInstantiation: "TSTypeParameterInstantiation";
|
|
75
|
+
readonly TSTypePredicate: "TSTypePredicate";
|
|
76
|
+
readonly TSTypeReference: "TSTypeReference";
|
|
77
|
+
readonly TSUndefinedKeyword: "TSUndefinedKeyword";
|
|
78
|
+
readonly TSUnionType: "TSUnionType";
|
|
79
|
+
readonly TSUnknownKeyword: "TSUnknownKeyword";
|
|
80
|
+
readonly TSVoidKeyword: "TSVoidKeyword";
|
|
81
|
+
}>;
|
|
82
|
+
declare const AST_TOKEN_TYPES: Readonly<{
|
|
83
|
+
readonly Boolean: "Boolean";
|
|
84
|
+
readonly Identifier: "Identifier";
|
|
85
|
+
readonly JSXIdentifier: "JSXIdentifier";
|
|
86
|
+
readonly JSXText: "JSXText";
|
|
87
|
+
readonly Keyword: "Keyword";
|
|
88
|
+
readonly Null: "Null";
|
|
89
|
+
readonly Numeric: "Numeric";
|
|
90
|
+
readonly PrivateIdentifier: "PrivateIdentifier";
|
|
91
|
+
readonly Punctuator: "Punctuator";
|
|
92
|
+
readonly RegularExpression: "RegularExpression";
|
|
93
|
+
readonly String: "String";
|
|
94
|
+
readonly Template: "Template";
|
|
95
|
+
}>;
|
|
96
|
+
declare const TSESTree: Readonly<{
|
|
97
|
+
AST_NODE_TYPES: Readonly<{
|
|
98
|
+
readonly ArrayExpression: "ArrayExpression";
|
|
99
|
+
readonly ArrowFunctionExpression: "ArrowFunctionExpression";
|
|
100
|
+
readonly AssignmentExpression: "AssignmentExpression";
|
|
101
|
+
readonly AwaitExpression: "AwaitExpression";
|
|
102
|
+
readonly BinaryExpression: "BinaryExpression";
|
|
103
|
+
readonly BlockStatement: "BlockStatement";
|
|
104
|
+
readonly CallExpression: "CallExpression";
|
|
105
|
+
readonly CatchClause: "CatchClause";
|
|
106
|
+
readonly ChainExpression: "ChainExpression";
|
|
107
|
+
readonly ConditionalExpression: "ConditionalExpression";
|
|
108
|
+
readonly ExpressionStatement: "ExpressionStatement";
|
|
109
|
+
readonly ForInStatement: "ForInStatement";
|
|
110
|
+
readonly ForOfStatement: "ForOfStatement";
|
|
111
|
+
readonly FunctionDeclaration: "FunctionDeclaration";
|
|
112
|
+
readonly FunctionExpression: "FunctionExpression";
|
|
113
|
+
readonly Identifier: "Identifier";
|
|
114
|
+
readonly IfStatement: "IfStatement";
|
|
115
|
+
readonly ImportDeclaration: "ImportDeclaration";
|
|
116
|
+
readonly Literal: "Literal";
|
|
117
|
+
readonly LogicalExpression: "LogicalExpression";
|
|
118
|
+
readonly MemberExpression: "MemberExpression";
|
|
119
|
+
readonly MethodDefinition: "MethodDefinition";
|
|
120
|
+
readonly NewExpression: "NewExpression";
|
|
121
|
+
readonly ObjectExpression: "ObjectExpression";
|
|
122
|
+
readonly Program: "Program";
|
|
123
|
+
readonly Property: "Property";
|
|
124
|
+
readonly ReturnStatement: "ReturnStatement";
|
|
125
|
+
readonly SequenceExpression: "SequenceExpression";
|
|
126
|
+
readonly SpreadElement: "SpreadElement";
|
|
127
|
+
readonly SwitchStatement: "SwitchStatement";
|
|
128
|
+
readonly TaggedTemplateExpression: "TaggedTemplateExpression";
|
|
129
|
+
readonly TemplateLiteral: "TemplateLiteral";
|
|
130
|
+
readonly ThrowStatement: "ThrowStatement";
|
|
131
|
+
readonly TryStatement: "TryStatement";
|
|
132
|
+
readonly UnaryExpression: "UnaryExpression";
|
|
133
|
+
readonly UpdateExpression: "UpdateExpression";
|
|
134
|
+
readonly VariableDeclaration: "VariableDeclaration";
|
|
135
|
+
readonly VariableDeclarator: "VariableDeclarator";
|
|
136
|
+
readonly TSAnyKeyword: "TSAnyKeyword";
|
|
137
|
+
readonly TSAsExpression: "TSAsExpression";
|
|
138
|
+
readonly TSBooleanKeyword: "TSBooleanKeyword";
|
|
139
|
+
readonly TSCallSignatureDeclaration: "TSCallSignatureDeclaration";
|
|
140
|
+
readonly TSConditionalType: "TSConditionalType";
|
|
141
|
+
readonly TSConstructSignatureDeclaration: "TSConstructSignatureDeclaration";
|
|
142
|
+
readonly TSDeclareFunction: "TSDeclareFunction";
|
|
143
|
+
readonly TSEnumDeclaration: "TSEnumDeclaration";
|
|
144
|
+
readonly TSExpressionWithTypeArguments: "TSExpressionWithTypeArguments";
|
|
145
|
+
readonly TSFunctionType: "TSFunctionType";
|
|
146
|
+
readonly TSImportType: "TSImportType";
|
|
147
|
+
readonly TSIndexedAccessType: "TSIndexedAccessType";
|
|
148
|
+
readonly TSInferType: "TSInferType";
|
|
149
|
+
readonly TSInterfaceDeclaration: "TSInterfaceDeclaration";
|
|
150
|
+
readonly TSLiteralType: "TSLiteralType";
|
|
151
|
+
readonly TSMappedType: "TSMappedType";
|
|
152
|
+
readonly TSMethodSignature: "TSMethodSignature";
|
|
153
|
+
readonly TSModuleDeclaration: "TSModuleDeclaration";
|
|
154
|
+
readonly TSNeverKeyword: "TSNeverKeyword";
|
|
155
|
+
readonly TSNullKeyword: "TSNullKeyword";
|
|
156
|
+
readonly TSNumberKeyword: "TSNumberKeyword";
|
|
157
|
+
readonly TSObjectKeyword: "TSObjectKeyword";
|
|
158
|
+
readonly TSPropertySignature: "TSPropertySignature";
|
|
159
|
+
readonly TSStringKeyword: "TSStringKeyword";
|
|
160
|
+
readonly TSThisType: "TSThisType";
|
|
161
|
+
readonly TSTupleType: "TSTupleType";
|
|
162
|
+
readonly TSTypeAliasDeclaration: "TSTypeAliasDeclaration";
|
|
163
|
+
readonly TSTypeAnnotation: "TSTypeAnnotation";
|
|
164
|
+
readonly TSTypeAssertion: "TSTypeAssertion";
|
|
165
|
+
readonly TSTypeLiteral: "TSTypeLiteral";
|
|
166
|
+
readonly TSTypeOperator: "TSTypeOperator";
|
|
167
|
+
readonly TSTypeParameter: "TSTypeParameter";
|
|
168
|
+
readonly TSTypeParameterDeclaration: "TSTypeParameterDeclaration";
|
|
169
|
+
readonly TSTypeParameterInstantiation: "TSTypeParameterInstantiation";
|
|
170
|
+
readonly TSTypePredicate: "TSTypePredicate";
|
|
171
|
+
readonly TSTypeReference: "TSTypeReference";
|
|
172
|
+
readonly TSUndefinedKeyword: "TSUndefinedKeyword";
|
|
173
|
+
readonly TSUnionType: "TSUnionType";
|
|
174
|
+
readonly TSUnknownKeyword: "TSUnknownKeyword";
|
|
175
|
+
readonly TSVoidKeyword: "TSVoidKeyword";
|
|
176
|
+
}>;
|
|
177
|
+
AST_TOKEN_TYPES: Readonly<{
|
|
178
|
+
readonly Boolean: "Boolean";
|
|
179
|
+
readonly Identifier: "Identifier";
|
|
180
|
+
readonly JSXIdentifier: "JSXIdentifier";
|
|
181
|
+
readonly JSXText: "JSXText";
|
|
182
|
+
readonly Keyword: "Keyword";
|
|
183
|
+
readonly Null: "Null";
|
|
184
|
+
readonly Numeric: "Numeric";
|
|
185
|
+
readonly PrivateIdentifier: "PrivateIdentifier";
|
|
186
|
+
readonly Punctuator: "Punctuator";
|
|
187
|
+
readonly RegularExpression: "RegularExpression";
|
|
188
|
+
readonly String: "String";
|
|
189
|
+
readonly Template: "Template";
|
|
190
|
+
}>;
|
|
191
|
+
}>;
|
|
192
|
+
//#endregion
|
|
193
|
+
export { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree };
|
|
194
|
+
//# sourceMappingURL=compat.d.ts.map
|
package/dist/compat.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/compat.ts
|
|
2
|
+
const AST_NODE_TYPES = Object.freeze({
|
|
3
|
+
ArrayExpression: "ArrayExpression",
|
|
4
|
+
ArrowFunctionExpression: "ArrowFunctionExpression",
|
|
5
|
+
AssignmentExpression: "AssignmentExpression",
|
|
6
|
+
AwaitExpression: "AwaitExpression",
|
|
7
|
+
BinaryExpression: "BinaryExpression",
|
|
8
|
+
BlockStatement: "BlockStatement",
|
|
9
|
+
CallExpression: "CallExpression",
|
|
10
|
+
CatchClause: "CatchClause",
|
|
11
|
+
ChainExpression: "ChainExpression",
|
|
12
|
+
ConditionalExpression: "ConditionalExpression",
|
|
13
|
+
ExpressionStatement: "ExpressionStatement",
|
|
14
|
+
ForInStatement: "ForInStatement",
|
|
15
|
+
ForOfStatement: "ForOfStatement",
|
|
16
|
+
FunctionDeclaration: "FunctionDeclaration",
|
|
17
|
+
FunctionExpression: "FunctionExpression",
|
|
18
|
+
Identifier: "Identifier",
|
|
19
|
+
IfStatement: "IfStatement",
|
|
20
|
+
ImportDeclaration: "ImportDeclaration",
|
|
21
|
+
Literal: "Literal",
|
|
22
|
+
LogicalExpression: "LogicalExpression",
|
|
23
|
+
MemberExpression: "MemberExpression",
|
|
24
|
+
MethodDefinition: "MethodDefinition",
|
|
25
|
+
NewExpression: "NewExpression",
|
|
26
|
+
ObjectExpression: "ObjectExpression",
|
|
27
|
+
Program: "Program",
|
|
28
|
+
Property: "Property",
|
|
29
|
+
ReturnStatement: "ReturnStatement",
|
|
30
|
+
SequenceExpression: "SequenceExpression",
|
|
31
|
+
SpreadElement: "SpreadElement",
|
|
32
|
+
SwitchStatement: "SwitchStatement",
|
|
33
|
+
TaggedTemplateExpression: "TaggedTemplateExpression",
|
|
34
|
+
TemplateLiteral: "TemplateLiteral",
|
|
35
|
+
ThrowStatement: "ThrowStatement",
|
|
36
|
+
TryStatement: "TryStatement",
|
|
37
|
+
UnaryExpression: "UnaryExpression",
|
|
38
|
+
UpdateExpression: "UpdateExpression",
|
|
39
|
+
VariableDeclaration: "VariableDeclaration",
|
|
40
|
+
VariableDeclarator: "VariableDeclarator",
|
|
41
|
+
TSAnyKeyword: "TSAnyKeyword",
|
|
42
|
+
TSAsExpression: "TSAsExpression",
|
|
43
|
+
TSBooleanKeyword: "TSBooleanKeyword",
|
|
44
|
+
TSCallSignatureDeclaration: "TSCallSignatureDeclaration",
|
|
45
|
+
TSConditionalType: "TSConditionalType",
|
|
46
|
+
TSConstructSignatureDeclaration: "TSConstructSignatureDeclaration",
|
|
47
|
+
TSDeclareFunction: "TSDeclareFunction",
|
|
48
|
+
TSEnumDeclaration: "TSEnumDeclaration",
|
|
49
|
+
TSExpressionWithTypeArguments: "TSExpressionWithTypeArguments",
|
|
50
|
+
TSFunctionType: "TSFunctionType",
|
|
51
|
+
TSImportType: "TSImportType",
|
|
52
|
+
TSIndexedAccessType: "TSIndexedAccessType",
|
|
53
|
+
TSInferType: "TSInferType",
|
|
54
|
+
TSInterfaceDeclaration: "TSInterfaceDeclaration",
|
|
55
|
+
TSLiteralType: "TSLiteralType",
|
|
56
|
+
TSMappedType: "TSMappedType",
|
|
57
|
+
TSMethodSignature: "TSMethodSignature",
|
|
58
|
+
TSModuleDeclaration: "TSModuleDeclaration",
|
|
59
|
+
TSNeverKeyword: "TSNeverKeyword",
|
|
60
|
+
TSNullKeyword: "TSNullKeyword",
|
|
61
|
+
TSNumberKeyword: "TSNumberKeyword",
|
|
62
|
+
TSObjectKeyword: "TSObjectKeyword",
|
|
63
|
+
TSPropertySignature: "TSPropertySignature",
|
|
64
|
+
TSStringKeyword: "TSStringKeyword",
|
|
65
|
+
TSThisType: "TSThisType",
|
|
66
|
+
TSTupleType: "TSTupleType",
|
|
67
|
+
TSTypeAliasDeclaration: "TSTypeAliasDeclaration",
|
|
68
|
+
TSTypeAnnotation: "TSTypeAnnotation",
|
|
69
|
+
TSTypeAssertion: "TSTypeAssertion",
|
|
70
|
+
TSTypeLiteral: "TSTypeLiteral",
|
|
71
|
+
TSTypeOperator: "TSTypeOperator",
|
|
72
|
+
TSTypeParameter: "TSTypeParameter",
|
|
73
|
+
TSTypeParameterDeclaration: "TSTypeParameterDeclaration",
|
|
74
|
+
TSTypeParameterInstantiation: "TSTypeParameterInstantiation",
|
|
75
|
+
TSTypePredicate: "TSTypePredicate",
|
|
76
|
+
TSTypeReference: "TSTypeReference",
|
|
77
|
+
TSUndefinedKeyword: "TSUndefinedKeyword",
|
|
78
|
+
TSUnionType: "TSUnionType",
|
|
79
|
+
TSUnknownKeyword: "TSUnknownKeyword",
|
|
80
|
+
TSVoidKeyword: "TSVoidKeyword"
|
|
81
|
+
});
|
|
82
|
+
const AST_TOKEN_TYPES = Object.freeze({
|
|
83
|
+
Boolean: "Boolean",
|
|
84
|
+
Identifier: "Identifier",
|
|
85
|
+
JSXIdentifier: "JSXIdentifier",
|
|
86
|
+
JSXText: "JSXText",
|
|
87
|
+
Keyword: "Keyword",
|
|
88
|
+
Null: "Null",
|
|
89
|
+
Numeric: "Numeric",
|
|
90
|
+
PrivateIdentifier: "PrivateIdentifier",
|
|
91
|
+
Punctuator: "Punctuator",
|
|
92
|
+
RegularExpression: "RegularExpression",
|
|
93
|
+
String: "String",
|
|
94
|
+
Template: "Template"
|
|
95
|
+
});
|
|
96
|
+
const TSESTree = Object.freeze({
|
|
97
|
+
AST_NODE_TYPES,
|
|
98
|
+
AST_TOKEN_TYPES
|
|
99
|
+
});
|
|
100
|
+
//#endregion
|
|
101
|
+
export { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","names":[],"sources":["../ts/compat.ts"],"sourcesContent":["export const AST_NODE_TYPES = Object.freeze({\n ArrayExpression: \"ArrayExpression\",\n ArrowFunctionExpression: \"ArrowFunctionExpression\",\n AssignmentExpression: \"AssignmentExpression\",\n AwaitExpression: \"AwaitExpression\",\n BinaryExpression: \"BinaryExpression\",\n BlockStatement: \"BlockStatement\",\n CallExpression: \"CallExpression\",\n CatchClause: \"CatchClause\",\n ChainExpression: \"ChainExpression\",\n ConditionalExpression: \"ConditionalExpression\",\n ExpressionStatement: \"ExpressionStatement\",\n ForInStatement: \"ForInStatement\",\n ForOfStatement: \"ForOfStatement\",\n FunctionDeclaration: \"FunctionDeclaration\",\n FunctionExpression: \"FunctionExpression\",\n Identifier: \"Identifier\",\n IfStatement: \"IfStatement\",\n ImportDeclaration: \"ImportDeclaration\",\n Literal: \"Literal\",\n LogicalExpression: \"LogicalExpression\",\n MemberExpression: \"MemberExpression\",\n MethodDefinition: \"MethodDefinition\",\n NewExpression: \"NewExpression\",\n ObjectExpression: \"ObjectExpression\",\n Program: \"Program\",\n Property: \"Property\",\n ReturnStatement: \"ReturnStatement\",\n SequenceExpression: \"SequenceExpression\",\n SpreadElement: \"SpreadElement\",\n SwitchStatement: \"SwitchStatement\",\n TaggedTemplateExpression: \"TaggedTemplateExpression\",\n TemplateLiteral: \"TemplateLiteral\",\n ThrowStatement: \"ThrowStatement\",\n TryStatement: \"TryStatement\",\n UnaryExpression: \"UnaryExpression\",\n UpdateExpression: \"UpdateExpression\",\n VariableDeclaration: \"VariableDeclaration\",\n VariableDeclarator: \"VariableDeclarator\",\n TSAnyKeyword: \"TSAnyKeyword\",\n TSAsExpression: \"TSAsExpression\",\n TSBooleanKeyword: \"TSBooleanKeyword\",\n TSCallSignatureDeclaration: \"TSCallSignatureDeclaration\",\n TSConditionalType: \"TSConditionalType\",\n TSConstructSignatureDeclaration: \"TSConstructSignatureDeclaration\",\n TSDeclareFunction: \"TSDeclareFunction\",\n TSEnumDeclaration: \"TSEnumDeclaration\",\n TSExpressionWithTypeArguments: \"TSExpressionWithTypeArguments\",\n TSFunctionType: \"TSFunctionType\",\n TSImportType: \"TSImportType\",\n TSIndexedAccessType: \"TSIndexedAccessType\",\n TSInferType: \"TSInferType\",\n TSInterfaceDeclaration: \"TSInterfaceDeclaration\",\n TSLiteralType: \"TSLiteralType\",\n TSMappedType: \"TSMappedType\",\n TSMethodSignature: \"TSMethodSignature\",\n TSModuleDeclaration: \"TSModuleDeclaration\",\n TSNeverKeyword: \"TSNeverKeyword\",\n TSNullKeyword: \"TSNullKeyword\",\n TSNumberKeyword: \"TSNumberKeyword\",\n TSObjectKeyword: \"TSObjectKeyword\",\n TSPropertySignature: \"TSPropertySignature\",\n TSStringKeyword: \"TSStringKeyword\",\n TSThisType: \"TSThisType\",\n TSTupleType: \"TSTupleType\",\n TSTypeAliasDeclaration: \"TSTypeAliasDeclaration\",\n TSTypeAnnotation: \"TSTypeAnnotation\",\n TSTypeAssertion: \"TSTypeAssertion\",\n TSTypeLiteral: \"TSTypeLiteral\",\n TSTypeOperator: \"TSTypeOperator\",\n TSTypeParameter: \"TSTypeParameter\",\n TSTypeParameterDeclaration: \"TSTypeParameterDeclaration\",\n TSTypeParameterInstantiation: \"TSTypeParameterInstantiation\",\n TSTypePredicate: \"TSTypePredicate\",\n TSTypeReference: \"TSTypeReference\",\n TSUndefinedKeyword: \"TSUndefinedKeyword\",\n TSUnionType: \"TSUnionType\",\n TSUnknownKeyword: \"TSUnknownKeyword\",\n TSVoidKeyword: \"TSVoidKeyword\",\n} as const);\n\nexport const AST_TOKEN_TYPES = Object.freeze({\n Boolean: \"Boolean\",\n Identifier: \"Identifier\",\n JSXIdentifier: \"JSXIdentifier\",\n JSXText: \"JSXText\",\n Keyword: \"Keyword\",\n Null: \"Null\",\n Numeric: \"Numeric\",\n PrivateIdentifier: \"PrivateIdentifier\",\n Punctuator: \"Punctuator\",\n RegularExpression: \"RegularExpression\",\n String: \"String\",\n Template: \"Template\",\n} as const);\n\nexport const TSESTree = Object.freeze({\n AST_NODE_TYPES,\n AST_TOKEN_TYPES,\n});\n"],"mappings":";AAAA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,iBAAiB;CACjB,yBAAyB;CACzB,sBAAsB;CACtB,iBAAiB;CACjB,kBAAkB;CAClB,gBAAgB;CAChB,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,uBAAuB;CACvB,qBAAqB;CACrB,gBAAgB;CAChB,gBAAgB;CAChB,qBAAqB;CACrB,oBAAoB;CACpB,YAAY;CACZ,aAAa;CACb,mBAAmB;CACnB,SAAS;CACT,mBAAmB;CACnB,kBAAkB;CAClB,kBAAkB;CAClB,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,UAAU;CACV,iBAAiB;CACjB,oBAAoB;CACpB,eAAe;CACf,iBAAiB;CACjB,0BAA0B;CAC1B,iBAAiB;CACjB,gBAAgB;CAChB,cAAc;CACd,iBAAiB;CACjB,kBAAkB;CAClB,qBAAqB;CACrB,oBAAoB;CACpB,cAAc;CACd,gBAAgB;CAChB,kBAAkB;CAClB,4BAA4B;CAC5B,mBAAmB;CACnB,iCAAiC;CACjC,mBAAmB;CACnB,mBAAmB;CACnB,+BAA+B;CAC/B,gBAAgB;CAChB,cAAc;CACd,qBAAqB;CACrB,aAAa;CACb,wBAAwB;CACxB,eAAe;CACf,cAAc;CACd,mBAAmB;CACnB,qBAAqB;CACrB,gBAAgB;CAChB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,qBAAqB;CACrB,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,wBAAwB;CACxB,kBAAkB;CAClB,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,4BAA4B;CAC5B,8BAA8B;CAC9B,iBAAiB;CACjB,iBAAiB;CACjB,oBAAoB;CACpB,aAAa;CACb,kBAAkB;CAClB,eAAe;CAChB,CAAU;AAEX,MAAa,kBAAkB,OAAO,OAAO;CAC3C,SAAS;CACT,YAAY;CACZ,eAAe;CACf,SAAS;CACT,SAAS;CACT,MAAM;CACN,SAAS;CACT,mBAAmB;CACnB,YAAY;CACZ,mBAAmB;CACnB,QAAQ;CACR,UAAU;CACX,CAAU;AAEX,MAAa,WAAW,OAAO,OAAO;CACpC;CACA;CACD,CAAC"}
|