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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/rules/use_unknown_in_catch_callback_variable.d.ts
|
|
2
|
+
declare const useUnknownInCatchCallbackVariableRule: {
|
|
3
|
+
defaultOptions: never[];
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
requiresTypeChecking: boolean;
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
type: "problem";
|
|
10
|
+
schema: never[];
|
|
11
|
+
};
|
|
12
|
+
create: (context: any) => Record<string, (node: any) => void>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useUnknownInCatchCallbackVariableRule };
|
|
16
|
+
//# sourceMappingURL=use_unknown_in_catch_callback_variable.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { calleePropertyName, hasUnknownTypeAnnotation } from "./ast.js";
|
|
2
|
+
import { createNativeRule } from "./rule_creator.js";
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/rules/use_unknown_in_catch_callback_variable.ts
|
|
4
|
+
const useUnknownInCatchCallbackVariableRule = createNativeRule("use-unknown-in-catch-callback-variable", {
|
|
5
|
+
docs: { description: "Require Promise catch callback variables to use an explicit unknown annotation." },
|
|
6
|
+
messages: { unexpected: "Catch callback variables should be explicitly typed as unknown." }
|
|
7
|
+
}, (context) => ({ CallExpression(node) {
|
|
8
|
+
const propertyName = calleePropertyName(node);
|
|
9
|
+
const callback = propertyName === "catch" ? node.arguments[0] : propertyName === "then" ? node.arguments[1] : void 0;
|
|
10
|
+
const parameter = callback?.params?.[0];
|
|
11
|
+
if (callback?.type?.includes("Function") && parameter && !hasUnknownTypeAnnotation(parameter)) context.report({
|
|
12
|
+
node: parameter,
|
|
13
|
+
messageId: "unexpected"
|
|
14
|
+
});
|
|
15
|
+
} }));
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useUnknownInCatchCallbackVariableRule };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=use_unknown_in_catch_callback_variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_unknown_in_catch_callback_variable.js","names":[],"sources":["../../ts/rules/use_unknown_in_catch_callback_variable.ts"],"sourcesContent":["import { calleePropertyName, hasUnknownTypeAnnotation } from \"./ast\";\nimport { createNativeRule } from \"./rule_creator\";\n\nexport const useUnknownInCatchCallbackVariableRule = createNativeRule(\n \"use-unknown-in-catch-callback-variable\",\n {\n docs: {\n description:\n \"Require Promise catch callback variables to use an explicit unknown annotation.\",\n },\n messages: {\n unexpected: \"Catch callback variables should be explicitly typed as unknown.\",\n },\n },\n (context) => ({\n CallExpression(node: any) {\n const propertyName = calleePropertyName(node);\n const callback =\n propertyName === \"catch\"\n ? node.arguments[0]\n : propertyName === \"then\"\n ? node.arguments[1]\n : undefined;\n const parameter = callback?.params?.[0];\n if (\n callback?.type?.includes(\"Function\") &&\n parameter &&\n !hasUnknownTypeAnnotation(parameter)\n ) {\n context.report({ node: parameter, messageId: \"unexpected\" });\n }\n },\n }),\n);\n"],"mappings":";;;AAGA,MAAa,wCAAwC,iBACnD,0CACA;CACE,MAAM,EACJ,aACE,mFACH;CACD,UAAU,EACR,YAAY,mEACb;CACF,GACA,aAAa,EACZ,eAAe,MAAW;CACxB,MAAM,eAAe,mBAAmB,KAAK;CAC7C,MAAM,WACJ,iBAAiB,UACb,KAAK,UAAU,KACf,iBAAiB,SACf,KAAK,UAAU,KACf,KAAA;CACR,MAAM,YAAY,UAAU,SAAS;AACrC,KACE,UAAU,MAAM,SAAS,WAAW,IACpC,aACA,CAAC,yBAAyB,UAAU,CAEpC,SAAQ,OAAO;EAAE,MAAM;EAAW,WAAW;EAAc,CAAC;GAGjE,EACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ResolvedProjectConfig, ResolvedRuntimeOptions, TsgoSignature, TsgoSymbol, TsgoType, TsgoTypePredicate } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/session.d.ts
|
|
4
|
+
declare class TsgoProjectSession {
|
|
5
|
+
#private;
|
|
6
|
+
readonly project: ResolvedProjectConfig;
|
|
7
|
+
readonly runtime: ResolvedRuntimeOptions;
|
|
8
|
+
constructor(project: ResolvedProjectConfig, runtime: ResolvedRuntimeOptions);
|
|
9
|
+
close(): void;
|
|
10
|
+
getCompilerOptions(): unknown;
|
|
11
|
+
getRootFileNames(): readonly string[];
|
|
12
|
+
getTypeAtPosition(fileName: string, position: number): TsgoType | undefined;
|
|
13
|
+
getSymbolAtPosition(fileName: string, position: number): TsgoSymbol | undefined;
|
|
14
|
+
getTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined;
|
|
15
|
+
getDeclaredTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined;
|
|
16
|
+
typeToString(type: TsgoType, flags?: number): string;
|
|
17
|
+
getBaseTypeOfLiteralType(type: TsgoType): TsgoType | undefined;
|
|
18
|
+
getPropertiesOfType(type: TsgoType): readonly TsgoSymbol[];
|
|
19
|
+
getSignaturesOfType(type: TsgoType, kind: number): readonly TsgoSignature[];
|
|
20
|
+
getReturnTypeOfSignature(signature: TsgoSignature): TsgoType | undefined;
|
|
21
|
+
getTypePredicateOfSignature(signature: TsgoSignature): TsgoTypePredicate | undefined;
|
|
22
|
+
getBaseTypes(type: TsgoType): readonly TsgoType[];
|
|
23
|
+
getTypeArguments(type: TsgoType): readonly TsgoType[];
|
|
24
|
+
private client;
|
|
25
|
+
private config;
|
|
26
|
+
private fileState;
|
|
27
|
+
private refreshIfNeeded;
|
|
28
|
+
private projectId;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { TsgoProjectSession };
|
|
32
|
+
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { TsgoApiClient } from "@corsa-bind/napi";
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/session.ts
|
|
4
|
+
var TsgoProjectSession = class {
|
|
5
|
+
#client;
|
|
6
|
+
#config;
|
|
7
|
+
#snapshot;
|
|
8
|
+
#projects = [];
|
|
9
|
+
#files = /* @__PURE__ */ new Map();
|
|
10
|
+
#lastRefreshMs = 0;
|
|
11
|
+
constructor(project, runtime) {
|
|
12
|
+
this.project = project;
|
|
13
|
+
this.runtime = runtime;
|
|
14
|
+
}
|
|
15
|
+
close() {
|
|
16
|
+
if (this.#snapshot) {
|
|
17
|
+
this.#client?.releaseHandle(this.#snapshot);
|
|
18
|
+
this.#snapshot = void 0;
|
|
19
|
+
}
|
|
20
|
+
this.#client?.close();
|
|
21
|
+
this.#client = void 0;
|
|
22
|
+
this.#files.clear();
|
|
23
|
+
}
|
|
24
|
+
getCompilerOptions() {
|
|
25
|
+
return this.config().options;
|
|
26
|
+
}
|
|
27
|
+
getRootFileNames() {
|
|
28
|
+
return this.config().fileNames;
|
|
29
|
+
}
|
|
30
|
+
getTypeAtPosition(fileName, position) {
|
|
31
|
+
const state = this.fileState(fileName);
|
|
32
|
+
if (!state.typeByPosition.has(position)) state.typeByPosition.set(position, this.client().callJson("getTypeAtPosition", {
|
|
33
|
+
snapshot: this.#snapshot,
|
|
34
|
+
project: state.projectId,
|
|
35
|
+
file: fileName,
|
|
36
|
+
position
|
|
37
|
+
}));
|
|
38
|
+
return state.typeByPosition.get(position);
|
|
39
|
+
}
|
|
40
|
+
getSymbolAtPosition(fileName, position) {
|
|
41
|
+
const state = this.fileState(fileName);
|
|
42
|
+
if (!state.symbolByPosition.has(position)) state.symbolByPosition.set(position, this.client().callJson("getSymbolAtPosition", {
|
|
43
|
+
snapshot: this.#snapshot,
|
|
44
|
+
project: state.projectId,
|
|
45
|
+
file: fileName,
|
|
46
|
+
position
|
|
47
|
+
}));
|
|
48
|
+
return state.symbolByPosition.get(position);
|
|
49
|
+
}
|
|
50
|
+
getTypeOfSymbol(symbol) {
|
|
51
|
+
return this.client().callJson("getTypeOfSymbol", {
|
|
52
|
+
snapshot: this.#snapshot,
|
|
53
|
+
project: this.projectId(),
|
|
54
|
+
symbol: symbol.id
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getDeclaredTypeOfSymbol(symbol) {
|
|
58
|
+
return this.client().callJson("getDeclaredTypeOfSymbol", {
|
|
59
|
+
snapshot: this.#snapshot,
|
|
60
|
+
project: this.projectId(),
|
|
61
|
+
symbol: symbol.id
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
typeToString(type, flags) {
|
|
65
|
+
return this.client().typeToString(this.#snapshot, this.projectId(), type.id, void 0, flags);
|
|
66
|
+
}
|
|
67
|
+
getBaseTypeOfLiteralType(type) {
|
|
68
|
+
return this.client().callJson("getBaseTypeOfLiteralType", {
|
|
69
|
+
snapshot: this.#snapshot,
|
|
70
|
+
project: this.projectId(),
|
|
71
|
+
type: type.id
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getPropertiesOfType(type) {
|
|
75
|
+
return this.client().callJson("getPropertiesOfType", {
|
|
76
|
+
snapshot: this.#snapshot,
|
|
77
|
+
project: this.projectId(),
|
|
78
|
+
type: type.id
|
|
79
|
+
}) ?? [];
|
|
80
|
+
}
|
|
81
|
+
getSignaturesOfType(type, kind) {
|
|
82
|
+
return this.client().callJson("getSignaturesOfType", {
|
|
83
|
+
snapshot: this.#snapshot,
|
|
84
|
+
project: this.projectId(),
|
|
85
|
+
type: type.id,
|
|
86
|
+
kind
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getReturnTypeOfSignature(signature) {
|
|
90
|
+
return this.client().callJson("getReturnTypeOfSignature", {
|
|
91
|
+
snapshot: this.#snapshot,
|
|
92
|
+
project: this.projectId(),
|
|
93
|
+
signature: signature.id
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getTypePredicateOfSignature(signature) {
|
|
97
|
+
return this.client().callJson("getTypePredicateOfSignature", {
|
|
98
|
+
snapshot: this.#snapshot,
|
|
99
|
+
project: this.projectId(),
|
|
100
|
+
signature: signature.id
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getBaseTypes(type) {
|
|
104
|
+
return this.client().callJson("getBaseTypes", {
|
|
105
|
+
snapshot: this.#snapshot,
|
|
106
|
+
project: this.projectId(),
|
|
107
|
+
type: type.id
|
|
108
|
+
}) ?? [];
|
|
109
|
+
}
|
|
110
|
+
getTypeArguments(type) {
|
|
111
|
+
return this.client().callJson("getTypeArguments", {
|
|
112
|
+
snapshot: this.#snapshot,
|
|
113
|
+
project: this.projectId(),
|
|
114
|
+
type: type.id
|
|
115
|
+
}) ?? [];
|
|
116
|
+
}
|
|
117
|
+
client() {
|
|
118
|
+
if (!this.#client) {
|
|
119
|
+
this.#client = TsgoApiClient.spawn({
|
|
120
|
+
executable: this.runtime.executable,
|
|
121
|
+
cwd: this.runtime.cwd,
|
|
122
|
+
mode: this.runtime.mode
|
|
123
|
+
});
|
|
124
|
+
this.#client.initialize();
|
|
125
|
+
}
|
|
126
|
+
return this.#client;
|
|
127
|
+
}
|
|
128
|
+
config() {
|
|
129
|
+
if (!this.#config) this.#config = this.client().parseConfigFile(this.project.configPath);
|
|
130
|
+
const config = this.#config;
|
|
131
|
+
if (!config) throw new Error(`oxlint-plugin-typescript-go could not parse a tsgo config for ${this.project.configPath}`);
|
|
132
|
+
return config;
|
|
133
|
+
}
|
|
134
|
+
fileState(fileName) {
|
|
135
|
+
this.refreshIfNeeded(fileName);
|
|
136
|
+
const current = this.#files.get(fileName);
|
|
137
|
+
if (current) return current;
|
|
138
|
+
const project = this.client().callJson("getDefaultProjectForFile", {
|
|
139
|
+
snapshot: this.#snapshot,
|
|
140
|
+
file: fileName
|
|
141
|
+
});
|
|
142
|
+
const state = {
|
|
143
|
+
mtimeMs: statMtimeMs(fileName),
|
|
144
|
+
projectId: project?.id ?? this.projectId(),
|
|
145
|
+
typeByPosition: /* @__PURE__ */ new Map(),
|
|
146
|
+
symbolByPosition: /* @__PURE__ */ new Map()
|
|
147
|
+
};
|
|
148
|
+
this.#files.set(fileName, state);
|
|
149
|
+
return state;
|
|
150
|
+
}
|
|
151
|
+
refreshIfNeeded(fileName) {
|
|
152
|
+
const now = Date.now();
|
|
153
|
+
const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;
|
|
154
|
+
if (!(!this.#snapshot || statMtimeMs(fileName) !== this.#files.get(fileName)?.mtimeMs || expired)) return;
|
|
155
|
+
const previous = this.#snapshot;
|
|
156
|
+
const response = this.client().updateSnapshot(previous ? { fileChanges: { changed: [fileName] } } : { openProject: this.project.configPath });
|
|
157
|
+
this.#snapshot = response.snapshot;
|
|
158
|
+
this.#projects = response.projects;
|
|
159
|
+
this.#lastRefreshMs = now;
|
|
160
|
+
this.#files.clear();
|
|
161
|
+
if (previous && previous !== this.#snapshot) this.client().releaseHandle(previous);
|
|
162
|
+
}
|
|
163
|
+
projectId() {
|
|
164
|
+
const id = this.#projects[0]?.id;
|
|
165
|
+
if (!id) throw new Error(`oxlint-plugin-typescript-go could not resolve a tsgo project for ${this.project.filename}`);
|
|
166
|
+
return id;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function statMtimeMs(fileName) {
|
|
170
|
+
try {
|
|
171
|
+
return statSync(fileName).mtimeMs;
|
|
172
|
+
} catch {
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
export { TsgoProjectSession };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#files","#config","#lastRefreshMs","#projects"],"sources":["../ts/session.ts"],"sourcesContent":["import { statSync } from \"node:fs\";\n\nimport { type ProjectResponse, TsgoApiClient } from \"@corsa-bind/napi\";\n\nimport type { TsgoSignature, TsgoSymbol, TsgoType, TsgoTypePredicate } from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n projectId: string;\n typeByPosition: Map<number, TsgoType | undefined>;\n symbolByPosition: Map<number, TsgoSymbol | undefined>;\n};\n\nexport class TsgoProjectSession {\n #client?: TsgoApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #lastRefreshMs = 0;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.#client?.releaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.#client?.close();\n this.#client = undefined;\n this.#files.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.config().options;\n }\n\n getRootFileNames(): readonly string[] {\n return this.config().fileNames;\n }\n\n getTypeAtPosition(fileName: string, position: number): TsgoType | undefined {\n const state = this.fileState(fileName);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().callJson(\"getTypeAtPosition\", {\n snapshot: this.#snapshot,\n project: state.projectId,\n file: fileName,\n position,\n }),\n );\n }\n return state.typeByPosition.get(position);\n }\n\n getSymbolAtPosition(fileName: string, position: number): TsgoSymbol | undefined {\n const state = this.fileState(fileName);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().callJson(\"getSymbolAtPosition\", {\n snapshot: this.#snapshot,\n project: state.projectId,\n file: fileName,\n position,\n }),\n );\n }\n return state.symbolByPosition.get(position);\n }\n\n getTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined {\n return this.client().callJson(\"getTypeOfSymbol\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n symbol: symbol.id,\n });\n }\n\n getDeclaredTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined {\n return this.client().callJson(\"getDeclaredTypeOfSymbol\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n symbol: symbol.id,\n });\n }\n\n typeToString(type: TsgoType, flags?: number): string {\n return this.client().typeToString(this.#snapshot!, this.projectId(), type.id, undefined, flags);\n }\n\n getBaseTypeOfLiteralType(type: TsgoType): TsgoType | undefined {\n return this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n });\n }\n\n getPropertiesOfType(type: TsgoType): readonly TsgoSymbol[] {\n return (\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? []\n );\n }\n\n getSignaturesOfType(type: TsgoType, kind: number): readonly TsgoSignature[] {\n return this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n });\n }\n\n getReturnTypeOfSignature(signature: TsgoSignature): TsgoType | undefined {\n return this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n });\n }\n\n getTypePredicateOfSignature(signature: TsgoSignature): TsgoTypePredicate | undefined {\n return this.client().callJson(\"getTypePredicateOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n });\n }\n\n getBaseTypes(type: TsgoType): readonly TsgoType[] {\n return (\n this.client().callJson(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? []\n );\n }\n\n getTypeArguments(type: TsgoType): readonly TsgoType[] {\n return (\n this.client().callJson(\"getTypeArguments\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? []\n );\n }\n\n private client(): TsgoApiClient {\n if (!this.#client) {\n this.#client = TsgoApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(\n `oxlint-plugin-typescript-go could not parse a tsgo config for ${this.project.configPath}`,\n );\n }\n return config;\n }\n\n private fileState(fileName: string): FileCache {\n this.refreshIfNeeded(fileName);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: statMtimeMs(fileName),\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string): void {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const stale =\n !this.#snapshot || statMtimeMs(fileName) !== this.#files.get(fileName)?.mtimeMs || expired;\n if (!stale) {\n return;\n }\n const previous = this.#snapshot;\n const response = this.client().updateSnapshot(\n previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath },\n );\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n if (previous && previous !== this.#snapshot) {\n this.client().releaseHandle(previous);\n }\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `oxlint-plugin-typescript-go could not resolve a tsgo project for ${this.project.filename}`,\n );\n }\n return id;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare namespace ts_eslint_d_exports {
|
|
2
|
+
export { TSESLint, tseslint };
|
|
3
|
+
}
|
|
4
|
+
declare const TSESLint: Readonly<{}>;
|
|
5
|
+
declare const tseslint: Readonly<{
|
|
6
|
+
config(...configs: readonly unknown[]): unknown[];
|
|
7
|
+
configs: Readonly<{}>;
|
|
8
|
+
parser: Readonly<{
|
|
9
|
+
meta: {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
};
|
|
13
|
+
parseForESLint(): never;
|
|
14
|
+
}>;
|
|
15
|
+
plugin: Readonly<{
|
|
16
|
+
configs: Readonly<{}>;
|
|
17
|
+
rules: Readonly<{}>;
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { TSESLint, ts_eslint_d_exports, tseslint };
|
|
22
|
+
//# sourceMappingURL=ts_eslint.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/ts_eslint.ts
|
|
3
|
+
var ts_eslint_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
TSESLint: () => TSESLint,
|
|
5
|
+
tseslint: () => tseslint
|
|
6
|
+
});
|
|
7
|
+
const TSESLint = Object.freeze({});
|
|
8
|
+
const tseslint = Object.freeze({
|
|
9
|
+
config(...configs) {
|
|
10
|
+
return configs.flat();
|
|
11
|
+
},
|
|
12
|
+
configs: Object.freeze({}),
|
|
13
|
+
parser: Object.freeze({
|
|
14
|
+
meta: {
|
|
15
|
+
name: "oxlint-plugin-typescript-go/parser",
|
|
16
|
+
version: "0.1.0"
|
|
17
|
+
},
|
|
18
|
+
parseForESLint() {
|
|
19
|
+
throw new Error("oxlint-plugin-typescript-go relies on oxlint for parsing; use it as a JS plugin, not as an ESLint parser");
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
plugin: Object.freeze({
|
|
23
|
+
configs: Object.freeze({}),
|
|
24
|
+
rules: Object.freeze({})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { TSESLint, ts_eslint_exports, tseslint };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=ts_eslint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts_eslint.js","names":[],"sources":["../ts/ts_eslint.ts"],"sourcesContent":["export const TSESLint = Object.freeze({});\n\nexport const tseslint = Object.freeze({\n config(...configs: readonly unknown[]) {\n return configs.flat();\n },\n configs: Object.freeze({}),\n parser: Object.freeze({\n meta: {\n name: \"oxlint-plugin-typescript-go/parser\",\n version: \"0.1.0\",\n },\n parseForESLint() {\n throw new Error(\n \"oxlint-plugin-typescript-go relies on oxlint for parsing; use it as a JS plugin, not as an ESLint parser\",\n );\n },\n }),\n plugin: Object.freeze({\n configs: Object.freeze({}),\n rules: Object.freeze({}),\n }),\n});\n"],"mappings":";;;;;;AAAA,MAAa,WAAW,OAAO,OAAO,EAAE,CAAC;AAEzC,MAAa,WAAW,OAAO,OAAO;CACpC,OAAO,GAAG,SAA6B;AACrC,SAAO,QAAQ,MAAM;;CAEvB,SAAS,OAAO,OAAO,EAAE,CAAC;CAC1B,QAAQ,OAAO,OAAO;EACpB,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EACD,iBAAiB;AACf,SAAM,IAAI,MACR,2GACD;;EAEJ,CAAC;CACF,QAAQ,OAAO,OAAO;EACpB,SAAS,OAAO,OAAO,EAAE,CAAC;EAC1B,OAAO,OAAO,OAAO,EAAE,CAAC;EACzB,CAAC;CACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ApiMode, ConfigResponse, ProjectResponse, TypeResponse } from "@corsa-bind/napi";
|
|
2
|
+
import { Context, Node, SourceCode } from "@oxlint/plugins";
|
|
3
|
+
|
|
4
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/types.d.ts
|
|
5
|
+
interface TsgoRuntimeOptions {
|
|
6
|
+
executable?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
mode?: ApiMode;
|
|
9
|
+
requestTimeoutMs?: number;
|
|
10
|
+
shutdownTimeoutMs?: number;
|
|
11
|
+
outboundCapacity?: number;
|
|
12
|
+
allowUnstableUpstreamCalls?: boolean;
|
|
13
|
+
cacheLifetimeMs?: number;
|
|
14
|
+
}
|
|
15
|
+
interface ProjectServiceOptions {
|
|
16
|
+
allowDefaultProject?: string[];
|
|
17
|
+
defaultProject?: string;
|
|
18
|
+
}
|
|
19
|
+
interface TypeAwareParserOptions {
|
|
20
|
+
project?: string | string[];
|
|
21
|
+
projectService?: boolean | ProjectServiceOptions;
|
|
22
|
+
tsconfigRootDir?: string;
|
|
23
|
+
tsgo?: TsgoRuntimeOptions;
|
|
24
|
+
}
|
|
25
|
+
interface TypescriptOxlintSettings extends TypeAwareParserOptions {
|
|
26
|
+
parserOptions?: TypeAwareParserOptions;
|
|
27
|
+
}
|
|
28
|
+
interface ResolvedRuntimeOptions {
|
|
29
|
+
executable: string;
|
|
30
|
+
cwd: string;
|
|
31
|
+
mode: ApiMode;
|
|
32
|
+
cacheLifetimeMs: number;
|
|
33
|
+
}
|
|
34
|
+
interface ResolvedProjectConfig {
|
|
35
|
+
filename: string;
|
|
36
|
+
rootDir: string;
|
|
37
|
+
configPath: string;
|
|
38
|
+
runtime: ResolvedRuntimeOptions;
|
|
39
|
+
}
|
|
40
|
+
interface TsgoNode {
|
|
41
|
+
readonly fileName: string;
|
|
42
|
+
readonly pos: number;
|
|
43
|
+
readonly end: number;
|
|
44
|
+
readonly range: readonly [number, number];
|
|
45
|
+
}
|
|
46
|
+
interface TsgoSymbol {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly flags: number;
|
|
50
|
+
readonly checkFlags: number;
|
|
51
|
+
readonly declarations: readonly string[];
|
|
52
|
+
readonly valueDeclaration?: string;
|
|
53
|
+
}
|
|
54
|
+
interface TsgoSignature {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly flags: number;
|
|
57
|
+
readonly declaration?: string;
|
|
58
|
+
readonly typeParameters: readonly string[];
|
|
59
|
+
readonly parameters: readonly string[];
|
|
60
|
+
readonly thisParameter?: string;
|
|
61
|
+
readonly target?: string;
|
|
62
|
+
}
|
|
63
|
+
interface TsgoTypePredicate {
|
|
64
|
+
readonly kind: number;
|
|
65
|
+
readonly parameterIndex: number;
|
|
66
|
+
readonly parameterName?: string;
|
|
67
|
+
readonly type?: TsgoType;
|
|
68
|
+
}
|
|
69
|
+
interface TsgoType extends TypeResponse {
|
|
70
|
+
readonly __typescriptOxlintKind: "type";
|
|
71
|
+
}
|
|
72
|
+
interface TsgoProgramShape {
|
|
73
|
+
getCompilerOptions(): unknown;
|
|
74
|
+
getCurrentDirectory(): string;
|
|
75
|
+
getRootFileNames(): readonly string[];
|
|
76
|
+
getSourceFile(fileName?: string): {
|
|
77
|
+
readonly fileName: string;
|
|
78
|
+
readonly text: string;
|
|
79
|
+
};
|
|
80
|
+
getTypeChecker(): TsgoTypeCheckerShape;
|
|
81
|
+
}
|
|
82
|
+
interface TsgoTypeCheckerShape {
|
|
83
|
+
getTypeAtLocation(node: Node | TsgoNode): TsgoType | undefined;
|
|
84
|
+
getContextualType(node: Node | TsgoNode): TsgoType | undefined;
|
|
85
|
+
getSymbolAtLocation(node: Node | TsgoNode): TsgoSymbol | undefined;
|
|
86
|
+
getTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined;
|
|
87
|
+
getDeclaredTypeOfSymbol(symbol: TsgoSymbol): TsgoType | undefined;
|
|
88
|
+
getTypeOfSymbolAtLocation(symbol: TsgoSymbol, node: Node | TsgoNode): TsgoType | undefined;
|
|
89
|
+
typeToString(type: TsgoType, enclosingDeclaration?: Node | TsgoNode, flags?: number): string;
|
|
90
|
+
getBaseTypeOfLiteralType(type: TsgoType): TsgoType | undefined;
|
|
91
|
+
getPropertiesOfType(type: TsgoType): readonly TsgoSymbol[];
|
|
92
|
+
getSignaturesOfType(type: TsgoType, kind: number): readonly TsgoSignature[];
|
|
93
|
+
getReturnTypeOfSignature(signature: TsgoSignature): TsgoType | undefined;
|
|
94
|
+
getTypePredicateOfSignature(signature: TsgoSignature): TsgoTypePredicate | undefined;
|
|
95
|
+
getBaseTypes(type: TsgoType): readonly TsgoType[];
|
|
96
|
+
getTypeArguments(type: TsgoType): readonly TsgoType[];
|
|
97
|
+
}
|
|
98
|
+
interface ParserServices {
|
|
99
|
+
readonly program: TsgoProgramShape;
|
|
100
|
+
readonly esTreeNodeToTSNodeMap: {
|
|
101
|
+
get(node: Node): TsgoNode;
|
|
102
|
+
has(node: Node): boolean;
|
|
103
|
+
};
|
|
104
|
+
readonly tsNodeToESTreeNodeMap: {
|
|
105
|
+
get(node: TsgoNode): Node;
|
|
106
|
+
has(node: TsgoNode): boolean;
|
|
107
|
+
};
|
|
108
|
+
readonly hasFullTypeInformation: boolean;
|
|
109
|
+
getTypeAtLocation(node: Node): TsgoType | undefined;
|
|
110
|
+
getSymbolAtLocation(node: Node): TsgoSymbol | undefined;
|
|
111
|
+
}
|
|
112
|
+
type ParserServicesWithTypeInformation = ParserServices & {
|
|
113
|
+
readonly hasFullTypeInformation: true;
|
|
114
|
+
};
|
|
115
|
+
type ContextWithParserOptions = Context & {
|
|
116
|
+
readonly filename: string;
|
|
117
|
+
readonly cwd: string;
|
|
118
|
+
readonly sourceCode: SourceCode;
|
|
119
|
+
readonly parserOptions?: TypeAwareParserOptions;
|
|
120
|
+
readonly languageOptions?: {
|
|
121
|
+
readonly parserOptions?: TypeAwareParserOptions;
|
|
122
|
+
};
|
|
123
|
+
readonly settings?: {
|
|
124
|
+
readonly typescriptOxlint?: TypescriptOxlintSettings;
|
|
125
|
+
readonly [key: string]: unknown;
|
|
126
|
+
};
|
|
127
|
+
readonly parserServices?: ParserServices;
|
|
128
|
+
};
|
|
129
|
+
interface SessionProjectState {
|
|
130
|
+
readonly config: ConfigResponse;
|
|
131
|
+
readonly project: ProjectResponse;
|
|
132
|
+
readonly snapshot: string;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { ContextWithParserOptions, ParserServices, ParserServicesWithTypeInformation, type ProjectResponse, ProjectServiceOptions, ResolvedProjectConfig, ResolvedRuntimeOptions, SessionProjectState, TsgoNode, TsgoProgramShape, TsgoRuntimeOptions, TsgoSignature, TsgoSymbol, TsgoType, TsgoTypeCheckerShape, TsgoTypePredicate, TypeAwareParserOptions, TypescriptOxlintSettings };
|
|
136
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TypeTextKind, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
2
|
+
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/utils.d.ts
|
|
4
|
+
declare namespace utils_d_exports {
|
|
5
|
+
export { TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText };
|
|
6
|
+
}
|
|
7
|
+
declare const Utils: Readonly<{
|
|
8
|
+
classifyTypeText: typeof classifyTypeText;
|
|
9
|
+
splitTopLevelTypeText: typeof splitTopLevelTypeText;
|
|
10
|
+
splitTypeText: typeof splitTypeText;
|
|
11
|
+
isStringLikeTypeTexts: typeof isStringLikeTypeTexts;
|
|
12
|
+
isNumberLikeTypeTexts: typeof isNumberLikeTypeTexts;
|
|
13
|
+
isBigIntLikeTypeTexts: typeof isBigIntLikeTypeTexts;
|
|
14
|
+
isAnyLikeTypeTexts: typeof isAnyLikeTypeTexts;
|
|
15
|
+
isUnknownLikeTypeTexts: typeof isUnknownLikeTypeTexts;
|
|
16
|
+
isArrayLikeTypeTexts: typeof isArrayLikeTypeTexts;
|
|
17
|
+
isPromiseLikeTypeTexts: typeof isPromiseLikeTypeTexts;
|
|
18
|
+
isErrorLikeTypeTexts: typeof isErrorLikeTypeTexts;
|
|
19
|
+
}>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { type TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_d_exports };
|
|
22
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Utils as Utils$1, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
3
|
+
//#region src/bindings/nodejs/typescript_oxlint/ts/utils.ts
|
|
4
|
+
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Utils: () => Utils,
|
|
6
|
+
classifyTypeText: () => classifyTypeText,
|
|
7
|
+
isAnyLikeTypeTexts: () => isAnyLikeTypeTexts,
|
|
8
|
+
isArrayLikeTypeTexts: () => isArrayLikeTypeTexts,
|
|
9
|
+
isBigIntLikeTypeTexts: () => isBigIntLikeTypeTexts,
|
|
10
|
+
isErrorLikeTypeTexts: () => isErrorLikeTypeTexts,
|
|
11
|
+
isNumberLikeTypeTexts: () => isNumberLikeTypeTexts,
|
|
12
|
+
isPromiseLikeTypeTexts: () => isPromiseLikeTypeTexts,
|
|
13
|
+
isStringLikeTypeTexts: () => isStringLikeTypeTexts,
|
|
14
|
+
isUnknownLikeTypeTexts: () => isUnknownLikeTypeTexts,
|
|
15
|
+
splitTopLevelTypeText: () => splitTopLevelTypeText,
|
|
16
|
+
splitTypeText: () => splitTypeText
|
|
17
|
+
});
|
|
18
|
+
const Utils = Utils$1;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_exports };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["NodeUtils"],"sources":["../ts/utils.ts"],"sourcesContent":["import {\n Utils as NodeUtils,\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n} from \"@corsa-bind/napi\";\n\nexport type { TypeTextKind } from \"@corsa-bind/napi\";\n\nexport {\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n};\n\nexport const Utils = NodeUtils;\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAa,QAAQA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "corsa-oxlint",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "typescript-eslint-style Oxlint helpers powered by corsa and typescript-go",
|
|
5
|
+
"homepage": "https://github.com/ubugeeei/corsa-bind/tree/main/src/bindings/nodejs/typescript_oxlint",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/ubugeeei/corsa-bind/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ubugeeei/corsa-bind.git",
|
|
13
|
+
"directory": "src/bindings/nodejs/typescript_oxlint"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./ast-utils": {
|
|
28
|
+
"types": "./dist/ast_utils.d.ts",
|
|
29
|
+
"import": "./dist/ast_utils.js"
|
|
30
|
+
},
|
|
31
|
+
"./eslint-utils": {
|
|
32
|
+
"types": "./dist/eslint_utils.d.ts",
|
|
33
|
+
"import": "./dist/eslint_utils.js"
|
|
34
|
+
},
|
|
35
|
+
"./json-schema": {
|
|
36
|
+
"types": "./dist/json_schema.d.ts",
|
|
37
|
+
"import": "./dist/json_schema.js"
|
|
38
|
+
},
|
|
39
|
+
"./utils": {
|
|
40
|
+
"types": "./dist/utils.d.ts",
|
|
41
|
+
"import": "./dist/utils.js"
|
|
42
|
+
},
|
|
43
|
+
"./rule-tester": {
|
|
44
|
+
"types": "./dist/rule_tester.d.ts",
|
|
45
|
+
"import": "./dist/rule_tester.js"
|
|
46
|
+
},
|
|
47
|
+
"./rules": {
|
|
48
|
+
"types": "./dist/rules/index.d.ts",
|
|
49
|
+
"import": "./dist/rules/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./ts-eslint": {
|
|
52
|
+
"types": "./dist/ts_eslint.d.ts",
|
|
53
|
+
"import": "./dist/ts_eslint.js"
|
|
54
|
+
},
|
|
55
|
+
"./ts-estree": {
|
|
56
|
+
"types": "./dist/ts_estree.d.ts",
|
|
57
|
+
"import": "./dist/ts_estree.js"
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@oxlint/plugins": "1.57.0",
|
|
63
|
+
"oxlint": "1.57.0",
|
|
64
|
+
"@corsa-bind/napi": "0.1.0"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=22"
|
|
68
|
+
}
|
|
69
|
+
}
|