@rslint/core 0.3.0 → 0.3.2-canary.1774331097
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 +120 -0
- package/dist/config-loader.d.ts +14 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +94 -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 +113 -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/utils/args.d.ts +18 -0
- package/dist/utils/args.d.ts.map +1 -0
- package/dist/utils/args.js +76 -0
- package/dist/utils/config-discovery.d.ts +27 -0
- package/dist/utils/config-discovery.d.ts.map +1 -0
- package/dist/utils/config-discovery.js +131 -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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AAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,0CAA0C;CAC9D;AAED;;GAEG;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 {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function isJSConfigFile(filePath: string): boolean;
|
|
2
|
+
export declare function parseArgs(argv: string[]): {
|
|
3
|
+
raw: string[];
|
|
4
|
+
config: string;
|
|
5
|
+
init: boolean;
|
|
6
|
+
rest: string[];
|
|
7
|
+
positionals: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Classify positional args into files and directories.
|
|
11
|
+
* Resolves symlinks so paths are consistent with process.cwd() and
|
|
12
|
+
* TypeScript's SourceFile.FileName() which both return real paths.
|
|
13
|
+
*/
|
|
14
|
+
export declare function classifyArgs(positionals: string[], cwd: string): {
|
|
15
|
+
files: string[];
|
|
16
|
+
dirs: string[];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/utils/args.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE;;;;;;EAyCvC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EAAE,EACrB,GAAG,EAAE,MAAM,GACV;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAkBrC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parseArgs as nodeParseArgs } from 'node:util';
|
|
4
|
+
export function isJSConfigFile(filePath) {
|
|
5
|
+
return /\.(ts|mts|js|mjs)$/.test(filePath);
|
|
6
|
+
}
|
|
7
|
+
export function parseArgs(argv) {
|
|
8
|
+
const { values, tokens } = nodeParseArgs({
|
|
9
|
+
args: argv,
|
|
10
|
+
strict: false,
|
|
11
|
+
tokens: true,
|
|
12
|
+
options: {
|
|
13
|
+
config: { type: 'string' },
|
|
14
|
+
init: { type: 'boolean' },
|
|
15
|
+
// Register known Go string-valued flags so their values are not
|
|
16
|
+
// mistaken for positional file/dir arguments.
|
|
17
|
+
format: { type: 'string' },
|
|
18
|
+
'max-warnings': { type: 'string' },
|
|
19
|
+
trace: { type: 'string' },
|
|
20
|
+
cpuprof: { type: 'string' },
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
// Collect args that are not --config or --init for pass-through to Go.
|
|
24
|
+
// positionals collects only true file/dir arguments.
|
|
25
|
+
const rest = [];
|
|
26
|
+
const positionals = [];
|
|
27
|
+
for (const token of tokens) {
|
|
28
|
+
if (token.kind === 'option') {
|
|
29
|
+
if (token.name === 'config' || token.name === 'init')
|
|
30
|
+
continue;
|
|
31
|
+
rest.push(token.rawName);
|
|
32
|
+
if (token.value != null)
|
|
33
|
+
rest.push(token.value);
|
|
34
|
+
}
|
|
35
|
+
else if (token.kind === 'option-terminator') {
|
|
36
|
+
rest.push('--');
|
|
37
|
+
}
|
|
38
|
+
else if (token.kind === 'positional') {
|
|
39
|
+
rest.push(token.value);
|
|
40
|
+
positionals.push(token.value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
raw: argv,
|
|
45
|
+
config: values.config ?? null,
|
|
46
|
+
init: values.init ?? false,
|
|
47
|
+
rest,
|
|
48
|
+
positionals,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Classify positional args into files and directories.
|
|
53
|
+
* Resolves symlinks so paths are consistent with process.cwd() and
|
|
54
|
+
* TypeScript's SourceFile.FileName() which both return real paths.
|
|
55
|
+
*/
|
|
56
|
+
export function classifyArgs(positionals, cwd) {
|
|
57
|
+
const files = [];
|
|
58
|
+
const dirs = [];
|
|
59
|
+
for (const arg of positionals) {
|
|
60
|
+
const resolved = path.resolve(cwd, arg);
|
|
61
|
+
try {
|
|
62
|
+
const real = fs.realpathSync(resolved);
|
|
63
|
+
if (fs.statSync(real).isDirectory()) {
|
|
64
|
+
dirs.push(real);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
files.push(real);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Non-existent path: treat as file (Go will handle the error)
|
|
72
|
+
files.push(resolved);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { files, dirs };
|
|
76
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const JS_CONFIG_FILES: string[];
|
|
2
|
+
export declare function findJSConfig(cwd: string): string | null;
|
|
3
|
+
/**
|
|
4
|
+
* Walk upward from startDir to the filesystem root, returning the first
|
|
5
|
+
* rslint JS/TS config file found. Returns null if none is found.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findJSConfigUp(startDir: string): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Recursively scan a directory for all rslint JS/TS config files.
|
|
10
|
+
* Skips node_modules and .git directories (aligned with ESLint defaults).
|
|
11
|
+
* Uses native fs.globSync when available (Node 22+, C++ impl), falls back
|
|
12
|
+
* to hand-written recursive walk.
|
|
13
|
+
*/
|
|
14
|
+
export declare function findJSConfigsInDir(startDir: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Discover JS/TS config files for the given targets.
|
|
17
|
+
*
|
|
18
|
+
* For file arguments, config is searched upward from each file's directory,
|
|
19
|
+
* so different files can find different configs (monorepo multi-config).
|
|
20
|
+
*
|
|
21
|
+
* For no-args and directory arguments, config is searched upward from the
|
|
22
|
+
* starting point AND nested configs within the scope are scanned. This
|
|
23
|
+
* ensures sub-package configs in a monorepo are discovered when linting
|
|
24
|
+
* from the root.
|
|
25
|
+
*/
|
|
26
|
+
export declare function discoverConfigs(files: string[], dirs: string[], cwd: string, explicitConfig: string | null): Map<string, string>;
|
|
27
|
+
//# sourceMappingURL=config-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-discovery.d.ts","sourceRoot":"","sources":["../../src/utils/config-discovery.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,UAK3B,CAAC;AAIF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAkC7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAqDrB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export const JS_CONFIG_FILES = [
|
|
4
|
+
'rslint.config.js',
|
|
5
|
+
'rslint.config.mjs',
|
|
6
|
+
'rslint.config.ts',
|
|
7
|
+
'rslint.config.mts',
|
|
8
|
+
];
|
|
9
|
+
const SCAN_EXCLUDE_DIRS = new Set(['node_modules', '.git']);
|
|
10
|
+
export function findJSConfig(cwd) {
|
|
11
|
+
for (const name of JS_CONFIG_FILES) {
|
|
12
|
+
const p = path.join(cwd, name);
|
|
13
|
+
if (fs.existsSync(p))
|
|
14
|
+
return p;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Walk upward from startDir to the filesystem root, returning the first
|
|
20
|
+
* rslint JS/TS config file found. Returns null if none is found.
|
|
21
|
+
*/
|
|
22
|
+
export function findJSConfigUp(startDir) {
|
|
23
|
+
let dir = path.resolve(startDir);
|
|
24
|
+
while (true) {
|
|
25
|
+
const found = findJSConfig(dir);
|
|
26
|
+
if (found)
|
|
27
|
+
return found;
|
|
28
|
+
const parent = path.dirname(dir);
|
|
29
|
+
if (parent === dir)
|
|
30
|
+
return null;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Recursively scan a directory for all rslint JS/TS config files.
|
|
36
|
+
* Skips node_modules and .git directories (aligned with ESLint defaults).
|
|
37
|
+
* Uses native fs.globSync when available (Node 22+, C++ impl), falls back
|
|
38
|
+
* to hand-written recursive walk.
|
|
39
|
+
*/
|
|
40
|
+
export function findJSConfigsInDir(startDir) {
|
|
41
|
+
const resolved = path.resolve(startDir);
|
|
42
|
+
// Node 22+ native globSync (C++ implementation, faster)
|
|
43
|
+
if (typeof fs.globSync === 'function') {
|
|
44
|
+
const pattern = '**/rslint.config.{js,mjs,ts,mts}';
|
|
45
|
+
return fs
|
|
46
|
+
.globSync(pattern, {
|
|
47
|
+
cwd: resolved,
|
|
48
|
+
exclude: (f) => SCAN_EXCLUDE_DIRS.has(path.basename(f)),
|
|
49
|
+
})
|
|
50
|
+
.map((p) => path.join(resolved, p));
|
|
51
|
+
}
|
|
52
|
+
// Fallback: recursive walk
|
|
53
|
+
const configs = [];
|
|
54
|
+
const walk = (dir) => {
|
|
55
|
+
let entries;
|
|
56
|
+
try {
|
|
57
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (entry.isDirectory()) {
|
|
64
|
+
if (SCAN_EXCLUDE_DIRS.has(entry.name))
|
|
65
|
+
continue;
|
|
66
|
+
walk(path.join(dir, entry.name));
|
|
67
|
+
}
|
|
68
|
+
else if (JS_CONFIG_FILES.includes(entry.name)) {
|
|
69
|
+
configs.push(path.join(dir, entry.name));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
walk(resolved);
|
|
74
|
+
return configs;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Discover JS/TS config files for the given targets.
|
|
78
|
+
*
|
|
79
|
+
* For file arguments, config is searched upward from each file's directory,
|
|
80
|
+
* so different files can find different configs (monorepo multi-config).
|
|
81
|
+
*
|
|
82
|
+
* For no-args and directory arguments, config is searched upward from the
|
|
83
|
+
* starting point AND nested configs within the scope are scanned. This
|
|
84
|
+
* ensures sub-package configs in a monorepo are discovered when linting
|
|
85
|
+
* from the root.
|
|
86
|
+
*/
|
|
87
|
+
export function discoverConfigs(files, dirs, cwd, explicitConfig) {
|
|
88
|
+
// Map: configPath -> configDirectory
|
|
89
|
+
const configs = new Map();
|
|
90
|
+
const addConfig = (configPath) => {
|
|
91
|
+
if (!configs.has(configPath)) {
|
|
92
|
+
configs.set(configPath, path.dirname(configPath));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
if (explicitConfig) {
|
|
96
|
+
const resolved = path.resolve(cwd, explicitConfig);
|
|
97
|
+
addConfig(resolved);
|
|
98
|
+
return configs;
|
|
99
|
+
}
|
|
100
|
+
// Collect unique start directories for upward config search
|
|
101
|
+
const startDirs = new Set();
|
|
102
|
+
// Collect directories to scan for nested configs
|
|
103
|
+
const scanDirs = [];
|
|
104
|
+
if (files.length === 0 && dirs.length === 0) {
|
|
105
|
+
startDirs.add(cwd);
|
|
106
|
+
scanDirs.push(cwd);
|
|
107
|
+
}
|
|
108
|
+
// Deduplicate file directories before searching
|
|
109
|
+
for (const file of files) {
|
|
110
|
+
startDirs.add(path.dirname(file));
|
|
111
|
+
}
|
|
112
|
+
for (const dir of dirs) {
|
|
113
|
+
startDirs.add(dir);
|
|
114
|
+
scanDirs.push(dir);
|
|
115
|
+
}
|
|
116
|
+
// Upward traversal: find nearest config for each start directory
|
|
117
|
+
for (const startDir of startDirs) {
|
|
118
|
+
const configPath = findJSConfigUp(startDir);
|
|
119
|
+
if (configPath) {
|
|
120
|
+
addConfig(configPath);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Scan for nested configs within the target scope (no-args and dir-args).
|
|
124
|
+
// Broken configs are tolerated by runWithJSConfigs (skipped with warning).
|
|
125
|
+
for (const dir of scanDirs) {
|
|
126
|
+
for (const configPath of findJSConfigsInDir(dir)) {
|
|
127
|
+
addConfig(configPath);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return configs;
|
|
131
|
+
}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":""}
|