@rslint/core 0.3.0 → 0.3.1
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/dist/browser.d.ts +39 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +147 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +128 -0
- package/dist/config-loader.d.ts +14 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +107 -0
- package/dist/configs/import.d.ts +6 -0
- package/dist/configs/import.d.ts.map +1 -0
- package/dist/configs/import.js +7 -0
- package/dist/configs/index.d.ts +12 -0
- package/dist/configs/index.d.ts.map +1 -0
- package/dist/configs/index.js +16 -0
- package/dist/configs/javascript.d.ts +6 -0
- package/dist/configs/javascript.d.ts.map +1 -0
- package/dist/configs/javascript.js +73 -0
- package/dist/configs/react.d.ts +6 -0
- package/dist/configs/react.d.ts.map +1 -0
- package/dist/configs/react.js +31 -0
- package/dist/configs/typescript.d.ts +8 -0
- package/dist/configs/typescript.d.ts.map +1 -0
- package/dist/configs/typescript.js +112 -0
- package/dist/define-config.d.ts +21 -0
- package/dist/define-config.d.ts.map +1 -0
- package/dist/define-config.js +6 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/node.d.ts +31 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +116 -0
- package/dist/service.d.ts +30 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +71 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.d.ts +342 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +112 -0
- package/package.json +8 -8
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for rslint IPC protocol across all environments
|
|
3
|
+
*/
|
|
4
|
+
export interface Position {
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Range {
|
|
9
|
+
start: Position;
|
|
10
|
+
end: Position;
|
|
11
|
+
}
|
|
12
|
+
export interface Diagnostic {
|
|
13
|
+
ruleName: string;
|
|
14
|
+
message: string;
|
|
15
|
+
messageId: string;
|
|
16
|
+
filePath: string;
|
|
17
|
+
range: Range;
|
|
18
|
+
severity?: string;
|
|
19
|
+
suggestions: any[];
|
|
20
|
+
}
|
|
21
|
+
export interface LintResponse {
|
|
22
|
+
diagnostics: Diagnostic[];
|
|
23
|
+
errorCount: number;
|
|
24
|
+
fileCount: number;
|
|
25
|
+
ruleCount: number;
|
|
26
|
+
duration: string;
|
|
27
|
+
encodedSourceFiles?: Record<string, string>; // Binary encoded source files as base64-encoded strings
|
|
28
|
+
}
|
|
29
|
+
export interface LintOptions {
|
|
30
|
+
files?: string[];
|
|
31
|
+
config?: string; // Path to rslint.json config file
|
|
32
|
+
workingDirectory?: string;
|
|
33
|
+
ruleOptions?: Record<string, string>;
|
|
34
|
+
fileContents?: Record<string, string>; // Map of file paths to their contents for VFS
|
|
35
|
+
languageOptions?: LanguageOptions; // Override languageOptions from config file
|
|
36
|
+
includeEncodedSourceFiles?: boolean; // Whether to include encoded source files in response
|
|
37
|
+
}
|
|
38
|
+
export interface LanguageOptions {
|
|
39
|
+
parserOptions?: ParserOptions;
|
|
40
|
+
}
|
|
41
|
+
export interface ParserOptions {
|
|
42
|
+
projectService?: boolean;
|
|
43
|
+
project?: string[] | string;
|
|
44
|
+
}
|
|
45
|
+
export interface ApplyFixesRequest {
|
|
46
|
+
fileContent: string; // Current content of the file
|
|
47
|
+
diagnostics: Diagnostic[]; // Diagnostics with fixes to apply
|
|
48
|
+
}
|
|
49
|
+
export interface ApplyFixesResponse {
|
|
50
|
+
fixedContent: string[]; // The content after applying fixes (array of intermediate versions)
|
|
51
|
+
wasFixed: boolean; // Whether any fixes were actually applied
|
|
52
|
+
appliedCount: number; // Number of fixes that were applied
|
|
53
|
+
unappliedCount: number; // Number of fixes that couldn't be applied
|
|
54
|
+
}
|
|
55
|
+
export interface RSlintOptions {
|
|
56
|
+
rslintPath?: string;
|
|
57
|
+
workingDirectory?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface PendingMessage {
|
|
60
|
+
resolve: (data: any) => void;
|
|
61
|
+
reject: (error: Error) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface IpcMessage {
|
|
64
|
+
id: number;
|
|
65
|
+
kind: string;
|
|
66
|
+
data: any;
|
|
67
|
+
}
|
|
68
|
+
// Service interface that all implementations must follow
|
|
69
|
+
export interface RslintServiceInterface {
|
|
70
|
+
sendMessage(kind: string, data: any): Promise<any>;
|
|
71
|
+
terminate(): void;
|
|
72
|
+
}
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// AST Info Types - Used by Playground to display detailed AST information
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Request for AST info at a specific position
|
|
78
|
+
*/
|
|
79
|
+
export interface GetAstInfoRequest {
|
|
80
|
+
fileContent: string;
|
|
81
|
+
position: number;
|
|
82
|
+
end?: number; // End position (optional, for exact node matching)
|
|
83
|
+
kind?: number; // Optional: filter by node kind (when multiple nodes at same position)
|
|
84
|
+
depth?: number; // Max recursion depth (default: 2)
|
|
85
|
+
fileName?: string; // Target file to query (empty for user file, external path like lib.d.ts for external file)
|
|
86
|
+
compilerOptions?: Record<string, unknown>; // TypeScript compilerOptions (same format as tsconfig.json)
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Response containing detailed AST information
|
|
90
|
+
*/
|
|
91
|
+
export interface GetAstInfoResponse {
|
|
92
|
+
node?: NodeInfo;
|
|
93
|
+
type?: TypeInfo;
|
|
94
|
+
symbol?: SymbolInfo;
|
|
95
|
+
signature?: SignatureInfo;
|
|
96
|
+
flow?: FlowInfo;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* NodeList metadata (Pos, End, HasTrailingComma)
|
|
100
|
+
*/
|
|
101
|
+
export interface NodeListMeta {
|
|
102
|
+
pos: number;
|
|
103
|
+
end: number;
|
|
104
|
+
hasTrailingComma: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Detailed information about an AST node
|
|
108
|
+
*/
|
|
109
|
+
export interface NodeInfo {
|
|
110
|
+
id?: number;
|
|
111
|
+
kind: number;
|
|
112
|
+
kindName: string;
|
|
113
|
+
pos: number;
|
|
114
|
+
end: number;
|
|
115
|
+
flags: number;
|
|
116
|
+
flagNames?: string[];
|
|
117
|
+
text?: string;
|
|
118
|
+
fileName?: string; // External file path (only set for nodes from lib.d.ts etc.)
|
|
119
|
+
// Common node properties (shallow - only kind/pos/end for nested nodes)
|
|
120
|
+
parent?: NodeInfo;
|
|
121
|
+
name?: NodeInfo;
|
|
122
|
+
expression?: NodeInfo;
|
|
123
|
+
left?: NodeInfo;
|
|
124
|
+
right?: NodeInfo;
|
|
125
|
+
operatorToken?: NodeInfo;
|
|
126
|
+
operand?: NodeInfo;
|
|
127
|
+
condition?: NodeInfo;
|
|
128
|
+
whenTrue?: NodeInfo;
|
|
129
|
+
whenFalse?: NodeInfo;
|
|
130
|
+
thenStatement?: NodeInfo;
|
|
131
|
+
elseStatement?: NodeInfo;
|
|
132
|
+
body?: NodeInfo;
|
|
133
|
+
initializer?: NodeInfo;
|
|
134
|
+
type?: NodeInfo;
|
|
135
|
+
// Additional node properties for class/interface/function declarations
|
|
136
|
+
members?: NodeInfo[];
|
|
137
|
+
heritageClauses?: NodeInfo[];
|
|
138
|
+
typeParameters?: NodeInfo[];
|
|
139
|
+
parameters?: NodeInfo[];
|
|
140
|
+
modifiers?: NodeInfo[];
|
|
141
|
+
arguments?: NodeInfo[];
|
|
142
|
+
statements?: NodeInfo[];
|
|
143
|
+
properties?: NodeInfo[];
|
|
144
|
+
elements?: NodeInfo[];
|
|
145
|
+
// Variable/Declaration properties
|
|
146
|
+
declarationList?: NodeInfo;
|
|
147
|
+
declarations?: NodeInfo[];
|
|
148
|
+
// Import/Export properties
|
|
149
|
+
importClause?: NodeInfo;
|
|
150
|
+
moduleSpecifier?: NodeInfo;
|
|
151
|
+
namedBindings?: NodeInfo;
|
|
152
|
+
exportClause?: NodeInfo;
|
|
153
|
+
// Loop/Control flow properties
|
|
154
|
+
incrementor?: NodeInfo;
|
|
155
|
+
statement?: NodeInfo;
|
|
156
|
+
// Switch statement properties
|
|
157
|
+
caseBlock?: NodeInfo;
|
|
158
|
+
clauses?: NodeInfo[];
|
|
159
|
+
// Try/Catch properties
|
|
160
|
+
tryBlock?: NodeInfo;
|
|
161
|
+
catchClause?: NodeInfo;
|
|
162
|
+
finallyBlock?: NodeInfo;
|
|
163
|
+
variableDeclaration?: NodeInfo;
|
|
164
|
+
block?: NodeInfo;
|
|
165
|
+
// Property access properties
|
|
166
|
+
argumentExpression?: NodeInfo;
|
|
167
|
+
// Shorthand property assignment properties
|
|
168
|
+
equalsToken?: NodeInfo;
|
|
169
|
+
objectAssignmentInitializer?: NodeInfo;
|
|
170
|
+
// Template literal properties
|
|
171
|
+
head?: NodeInfo;
|
|
172
|
+
templateSpans?: NodeInfo[];
|
|
173
|
+
literal?: NodeInfo;
|
|
174
|
+
tag?: NodeInfo;
|
|
175
|
+
template?: NodeInfo;
|
|
176
|
+
// Token properties (for optional/rest/generator/arrow/etc.)
|
|
177
|
+
questionToken?: NodeInfo;
|
|
178
|
+
dotDotDotToken?: NodeInfo;
|
|
179
|
+
exclamationToken?: NodeInfo;
|
|
180
|
+
asteriskToken?: NodeInfo;
|
|
181
|
+
equalsGreaterThanToken?: NodeInfo;
|
|
182
|
+
questionDotToken?: NodeInfo;
|
|
183
|
+
// Type-related node properties
|
|
184
|
+
typeArguments?: NodeInfo[];
|
|
185
|
+
constraint?: NodeInfo;
|
|
186
|
+
defaultType?: NodeInfo;
|
|
187
|
+
// Locals - symbols declared in this node's scope
|
|
188
|
+
locals?: SymbolInfo[];
|
|
189
|
+
// SourceFile-specific properties
|
|
190
|
+
endOfFileToken?: NodeInfo;
|
|
191
|
+
imports?: NodeInfo[];
|
|
192
|
+
isDeclarationFile?: boolean;
|
|
193
|
+
scriptKind?: number; // 1=JS, 2=JSX, 3=TS, 4=TSX, 5=External, 6=JSON, 7=Deferred
|
|
194
|
+
identifierCount?: number;
|
|
195
|
+
symbolCount?: number;
|
|
196
|
+
nodeCount?: number;
|
|
197
|
+
// List metadata for array properties (Pos, End, HasTrailingComma)
|
|
198
|
+
// Key is the property name e.g. "Parameters", "Arguments", "Members"
|
|
199
|
+
listMetas?: Record<string, NodeListMeta>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Detailed information about a TypeScript type
|
|
203
|
+
*/
|
|
204
|
+
export interface TypeInfo {
|
|
205
|
+
id?: number;
|
|
206
|
+
flags: number;
|
|
207
|
+
flagNames?: string[];
|
|
208
|
+
objectFlags?: number;
|
|
209
|
+
objectFlagNames?: string[];
|
|
210
|
+
intrinsicName?: string;
|
|
211
|
+
typeString: string;
|
|
212
|
+
pos?: number; // Position for on-demand fetching
|
|
213
|
+
fileName?: string; // External file path (only set for types from lib.d.ts etc.)
|
|
214
|
+
// Literal type properties (only present for literal types)
|
|
215
|
+
value?: unknown; // Literal value (string, number, bigint, boolean)
|
|
216
|
+
freshType?: TypeInfo; // Fresh literal type (shallow)
|
|
217
|
+
regularType?: TypeInfo; // Regular literal type (shallow)
|
|
218
|
+
// Nested objects
|
|
219
|
+
symbol?: SymbolInfo;
|
|
220
|
+
aliasSymbol?: SymbolInfo;
|
|
221
|
+
typeArguments?: TypeInfo[];
|
|
222
|
+
baseTypes?: TypeInfo[];
|
|
223
|
+
properties?: SymbolInfo[];
|
|
224
|
+
callSignatures?: SignatureInfo[];
|
|
225
|
+
constructSignatures?: SignatureInfo[];
|
|
226
|
+
indexInfos?: IndexInfo[];
|
|
227
|
+
types?: TypeInfo[]; // Union/Intersection type members
|
|
228
|
+
constraint?: TypeInfo;
|
|
229
|
+
default?: TypeInfo;
|
|
230
|
+
target?: TypeInfo; // Target type for type references
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Index signature information
|
|
234
|
+
*/
|
|
235
|
+
export interface IndexInfo {
|
|
236
|
+
keyType: TypeInfo;
|
|
237
|
+
valueType: TypeInfo;
|
|
238
|
+
isReadonly: boolean;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Detailed information about a TypeScript symbol
|
|
242
|
+
*/
|
|
243
|
+
export interface SymbolInfo {
|
|
244
|
+
id?: number;
|
|
245
|
+
name: string;
|
|
246
|
+
escapedName?: string;
|
|
247
|
+
flags: number;
|
|
248
|
+
flagNames?: string[];
|
|
249
|
+
checkFlags?: number;
|
|
250
|
+
checkFlagNames?: string[];
|
|
251
|
+
pos?: number;
|
|
252
|
+
fileName?: string; // External file path (only set for symbols from lib.d.ts etc.)
|
|
253
|
+
declarations?: NodeInfo[];
|
|
254
|
+
valueDeclaration?: NodeInfo;
|
|
255
|
+
members?: SymbolInfo[];
|
|
256
|
+
exports?: SymbolInfo[];
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Detailed information about a function/method signature
|
|
260
|
+
*/
|
|
261
|
+
export interface SignatureInfo {
|
|
262
|
+
flags: number;
|
|
263
|
+
flagNames?: string[];
|
|
264
|
+
minArgumentCount: number;
|
|
265
|
+
pos?: number; // Position for on-demand fetching
|
|
266
|
+
fileName?: string; // External file path (only set for signatures from lib.d.ts etc.)
|
|
267
|
+
// Parameters and thisParameter use Symbol data (shallow)
|
|
268
|
+
parameters?: SymbolInfo[];
|
|
269
|
+
thisParameter?: SymbolInfo;
|
|
270
|
+
// Type parameters, return type, and type predicate use Type data (shallow)
|
|
271
|
+
typeParameters?: TypeInfo[];
|
|
272
|
+
returnType?: TypeInfo;
|
|
273
|
+
typePredicate?: TypePredicateInfo;
|
|
274
|
+
declaration?: NodeInfo; // Source declaration (shallow, supports lazy loading)
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Function parameter information (deprecated - use SymbolInfo instead)
|
|
278
|
+
*/
|
|
279
|
+
export interface ParameterInfo {
|
|
280
|
+
name: string;
|
|
281
|
+
type?: TypeInfo;
|
|
282
|
+
optional: boolean;
|
|
283
|
+
rest: boolean;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Generic type parameter information
|
|
287
|
+
*/
|
|
288
|
+
export interface TypeParamInfo {
|
|
289
|
+
name: string;
|
|
290
|
+
constraint?: TypeInfo;
|
|
291
|
+
default?: TypeInfo;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Type predicate information for type guards
|
|
295
|
+
*/
|
|
296
|
+
export interface TypePredicateInfo {
|
|
297
|
+
kind: number;
|
|
298
|
+
kindName: string;
|
|
299
|
+
parameterName?: string;
|
|
300
|
+
parameterIndex?: number;
|
|
301
|
+
type?: TypeInfo;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Control flow analysis information
|
|
305
|
+
*/
|
|
306
|
+
export interface FlowInfo {
|
|
307
|
+
flags: number;
|
|
308
|
+
flagNames?: string[];
|
|
309
|
+
nodeKind?: number;
|
|
310
|
+
nodeKindName?: string;
|
|
311
|
+
nodePos?: number;
|
|
312
|
+
nodeEnd?: number;
|
|
313
|
+
antecedent?: FlowInfo;
|
|
314
|
+
antecedents?: FlowInfo[];
|
|
315
|
+
graph?: FlowGraph; // Complete flow graph (only on top-level)
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Flow graph for visualization
|
|
319
|
+
*/
|
|
320
|
+
export interface FlowGraph {
|
|
321
|
+
nodes: FlowGraphNode[];
|
|
322
|
+
edges: FlowEdge[];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Node in the flow graph
|
|
326
|
+
*/
|
|
327
|
+
export interface FlowGraphNode {
|
|
328
|
+
id: number;
|
|
329
|
+
flags: number;
|
|
330
|
+
flagNames?: string[];
|
|
331
|
+
nodePos?: number;
|
|
332
|
+
nodeEnd?: number;
|
|
333
|
+
nodeKindName?: string;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Edge in the flow graph (from antecedent to current)
|
|
337
|
+
*/
|
|
338
|
+
export interface FlowEdge {
|
|
339
|
+
from: number; // Antecedent node ID
|
|
340
|
+
to: number; // Current node ID
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,GAAG,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,wDAAwD;CACtG;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,k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AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC,CAAC,qBAAqB;IACnC,EAAE,EAAE,MAAM,CAAC,CAAC,kBAAkB;CAC/B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":""}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
2
|
+
// Global state for the worker
|
|
3
|
+
let rslintProcess = null;
|
|
4
|
+
let nextMessageId = 1;
|
|
5
|
+
let pendingMessages = new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the rslint process (could be WASM or other browser-compatible implementation)
|
|
8
|
+
*/
|
|
9
|
+
async function initializeRslint() {
|
|
10
|
+
try {
|
|
11
|
+
// In a real implementation, this would load the rslint WASM module
|
|
12
|
+
// or initialize a browser-compatible version of rslint
|
|
13
|
+
// For now, we'll simulate the initialization
|
|
14
|
+
// Example: Load WASM module
|
|
15
|
+
// const rslintWasm = await import('./rslint.wasm');
|
|
16
|
+
// rslintProcess = await rslintWasm.default();
|
|
17
|
+
console.log('Rslint worker initialized');
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Failed to initialize rslint:', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Send a message to the rslint process
|
|
26
|
+
*/
|
|
27
|
+
async function sendToRslint(kind, data) {
|
|
28
|
+
if (!rslintProcess) {
|
|
29
|
+
throw new Error('Rslint process not initialized');
|
|
30
|
+
}
|
|
31
|
+
// In a real implementation, this would call the appropriate method on the rslint process
|
|
32
|
+
// For now, we'll simulate the response
|
|
33
|
+
switch (kind) {
|
|
34
|
+
case 'handshake':
|
|
35
|
+
return { version: '1.0.0', status: 'ok' };
|
|
36
|
+
case 'lint':
|
|
37
|
+
// Simulate linting response
|
|
38
|
+
return {
|
|
39
|
+
diagnostics: [],
|
|
40
|
+
errorCount: 0,
|
|
41
|
+
fileCount: data.files?.length || 0,
|
|
42
|
+
ruleCount: 0,
|
|
43
|
+
duration: '0ms',
|
|
44
|
+
};
|
|
45
|
+
case 'applyFixes':
|
|
46
|
+
// Simulate apply fixes response
|
|
47
|
+
return {
|
|
48
|
+
fixedContent: [data.fileContent],
|
|
49
|
+
wasFixed: false,
|
|
50
|
+
appliedCount: 0,
|
|
51
|
+
unappliedCount: data.diagnostics?.length || 0,
|
|
52
|
+
};
|
|
53
|
+
case 'exit':
|
|
54
|
+
rslintProcess = null;
|
|
55
|
+
return { status: 'ok' };
|
|
56
|
+
default:
|
|
57
|
+
throw new Error(`Unknown message kind: ${kind}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle messages from the main thread
|
|
62
|
+
*/
|
|
63
|
+
async function handleMessage(event) {
|
|
64
|
+
const { id, kind, data } = event.data;
|
|
65
|
+
try {
|
|
66
|
+
// Ensure rslint is initialized
|
|
67
|
+
if (!rslintProcess && kind !== 'exit') {
|
|
68
|
+
await initializeRslint();
|
|
69
|
+
}
|
|
70
|
+
// Send message to rslint and get response
|
|
71
|
+
const response = await sendToRslint(kind, data);
|
|
72
|
+
// Send response back to main thread
|
|
73
|
+
self.postMessage({
|
|
74
|
+
id,
|
|
75
|
+
kind: 'response',
|
|
76
|
+
data: response,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// Send error back to main thread
|
|
81
|
+
self.postMessage({
|
|
82
|
+
id,
|
|
83
|
+
kind: 'error',
|
|
84
|
+
data: {
|
|
85
|
+
message: error instanceof Error ? error.message : String(error),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Handle worker errors
|
|
92
|
+
*/
|
|
93
|
+
function handleError(error) {
|
|
94
|
+
console.error('Worker error:', error);
|
|
95
|
+
// Send error to main thread for all pending messages
|
|
96
|
+
for (const [id, pending] of pendingMessages) {
|
|
97
|
+
self.postMessage({
|
|
98
|
+
id,
|
|
99
|
+
kind: 'error',
|
|
100
|
+
data: {
|
|
101
|
+
message: `Worker error: ${error.message}`,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
pendingMessages.clear();
|
|
106
|
+
}
|
|
107
|
+
// Set up event listeners
|
|
108
|
+
self.addEventListener('message', handleMessage);
|
|
109
|
+
self.addEventListener('error', handleError);
|
|
110
|
+
// Initialize the worker
|
|
111
|
+
console.log('Rslint worker started');
|
|
112
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslint/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"@typescript/source": "./src/index.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/node": "24.0.14",
|
|
52
52
|
"typescript": "5.9.3",
|
|
53
53
|
"@typescript/native-preview": "7.0.0-dev.20250904.1",
|
|
54
|
-
"@rslint/api": "0.3.
|
|
54
|
+
"@rslint/api": "0.3.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"jiti": "^2.0.0"
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|
|
65
|
-
"@rslint/
|
|
66
|
-
"@rslint/darwin-x64": "0.3.
|
|
67
|
-
"@rslint/linux-x64": "0.3.
|
|
68
|
-
"@rslint/win32-
|
|
69
|
-
"@rslint/
|
|
70
|
-
"@rslint/
|
|
65
|
+
"@rslint/linux-arm64": "0.3.1",
|
|
66
|
+
"@rslint/darwin-x64": "0.3.1",
|
|
67
|
+
"@rslint/linux-x64": "0.3.1",
|
|
68
|
+
"@rslint/win32-x64": "0.3.1",
|
|
69
|
+
"@rslint/win32-arm64": "0.3.1",
|
|
70
|
+
"@rslint/darwin-arm64": "0.3.1"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build:bin": "go build -v -o bin/ ../../cmd/rslint",
|