@descent-vtt/spec-guard 0.2.0 → 0.4.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/CHANGELOG.md +150 -0
- package/README.md +262 -36
- package/dist/cli.d.ts +3 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -3
- package/dist/cli.js.map +1 -1
- package/dist/comments.d.ts +78 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +241 -0
- package/dist/comments.js.map +1 -0
- package/dist/engine.d.ts +62 -40
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +236 -186
- package/dist/engine.js.map +1 -1
- package/dist/glob.d.ts +34 -6
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +50 -28
- package/dist/glob.js.map +1 -1
- package/dist/imports.d.ts +94 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +492 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +24 -2
- package/dist/parser.js.map +1 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +67 -2
- package/dist/reporter.js.map +1 -1
- package/dist/runner.d.ts +23 -3
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +274 -73
- package/dist/runner.js.map +1 -1
- package/dist/scope.d.ts +108 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +115 -0
- package/dist/scope.js.map +1 -0
- package/dist/types.d.ts +47 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +1 -1
- package/package.json +2 -1
package/dist/imports.js
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-reference extraction for JavaScript and TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* This is deliberately a tokenizer and not a parser. It walks the source
|
|
5
|
+
* tracking whether it is in code, a comment, a string, a template literal or a
|
|
6
|
+
* regular expression, emits a flat token stream, and reads module references
|
|
7
|
+
* off that stream. It knows nothing about scopes, types or semantics.
|
|
8
|
+
*
|
|
9
|
+
* The reason it is a tokenizer rather than a regular expression is that a
|
|
10
|
+
* regular expression cannot tell these apart:
|
|
11
|
+
*
|
|
12
|
+
* // import { Client } from '../db'; a comment
|
|
13
|
+
* const doc = "import { Client } from '..'"; a string
|
|
14
|
+
*
|
|
15
|
+
* and the reason it is not a parser is that a parser for two languages is
|
|
16
|
+
* larger than this whole tool. See ADR-0005.
|
|
17
|
+
*
|
|
18
|
+
* The critical property is that it knows when it has failed. If the scan ends
|
|
19
|
+
* inside a string, template or comment, the token stream is not trustworthy and
|
|
20
|
+
* the file is reported as unanalysable rather than as having no imports.
|
|
21
|
+
*/
|
|
22
|
+
import { promises as fs } from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { toPosix } from './glob.js';
|
|
25
|
+
/** Extensions this analyser understands. Anything else is reported as skipped. */
|
|
26
|
+
export const ANALYSABLE_EXTENSIONS = new Set([
|
|
27
|
+
'.js',
|
|
28
|
+
'.mjs',
|
|
29
|
+
'.cjs',
|
|
30
|
+
'.jsx',
|
|
31
|
+
'.ts',
|
|
32
|
+
'.mts',
|
|
33
|
+
'.cts',
|
|
34
|
+
'.tsx',
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* Words after which a `/` begins a regular expression rather than a division.
|
|
38
|
+
* The remaining ambiguity is `)` and `}`, where this follows the usual
|
|
39
|
+
* heuristic; a wrong guess is caught by the end-state check rather than
|
|
40
|
+
* silently mis-scanning the rest of the file.
|
|
41
|
+
*/
|
|
42
|
+
const REGEX_AFTER_WORD = new Set([
|
|
43
|
+
'return',
|
|
44
|
+
'typeof',
|
|
45
|
+
'instanceof',
|
|
46
|
+
'in',
|
|
47
|
+
'of',
|
|
48
|
+
'new',
|
|
49
|
+
'delete',
|
|
50
|
+
'void',
|
|
51
|
+
'throw',
|
|
52
|
+
'case',
|
|
53
|
+
'do',
|
|
54
|
+
'else',
|
|
55
|
+
'yield',
|
|
56
|
+
'await',
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* `<` is deliberately absent: in JSX every closing tag is `</`, and reading that
|
|
60
|
+
* as the start of a regular expression loses the scan for the rest of the file.
|
|
61
|
+
* The cost is that `a < /re/.test(b)` is misread instead, which is a shape that
|
|
62
|
+
* does not occur in practice.
|
|
63
|
+
*/
|
|
64
|
+
const REGEX_AFTER_PUNCT = new Set([
|
|
65
|
+
'(',
|
|
66
|
+
',',
|
|
67
|
+
'=',
|
|
68
|
+
':',
|
|
69
|
+
'[',
|
|
70
|
+
'!',
|
|
71
|
+
'&',
|
|
72
|
+
'|',
|
|
73
|
+
'?',
|
|
74
|
+
'{',
|
|
75
|
+
'}',
|
|
76
|
+
';',
|
|
77
|
+
'+',
|
|
78
|
+
'-',
|
|
79
|
+
'*',
|
|
80
|
+
'/',
|
|
81
|
+
'%',
|
|
82
|
+
'^',
|
|
83
|
+
'~',
|
|
84
|
+
'>',
|
|
85
|
+
]);
|
|
86
|
+
function isIdentifierStart(char) {
|
|
87
|
+
// Deliberately not @ or #: they can start a decorator or a private field but
|
|
88
|
+
// cannot continue an identifier, so accepting them here would read a
|
|
89
|
+
// zero-length word and never advance. They are emitted as punctuation.
|
|
90
|
+
return /[A-Za-z_$]/.test(char);
|
|
91
|
+
}
|
|
92
|
+
function isIdentifierPart(char) {
|
|
93
|
+
return /[A-Za-z0-9_$]/.test(char);
|
|
94
|
+
}
|
|
95
|
+
/** Splits source into the flat token stream the extractor reads. */
|
|
96
|
+
export function tokenize(source) {
|
|
97
|
+
const tokens = [];
|
|
98
|
+
let index = 0;
|
|
99
|
+
let line = 1;
|
|
100
|
+
let lineStart = 0;
|
|
101
|
+
// Brace depth at each open `${`, so the matching `}` returns to the template.
|
|
102
|
+
const templateStack = [];
|
|
103
|
+
let braceDepth = 0;
|
|
104
|
+
let desynced = false;
|
|
105
|
+
const column = (at) => at - lineStart + 1;
|
|
106
|
+
const advanceLine = (at) => {
|
|
107
|
+
line += 1;
|
|
108
|
+
lineStart = at + 1;
|
|
109
|
+
};
|
|
110
|
+
const previous = () => tokens[tokens.length - 1];
|
|
111
|
+
const regexAllowed = () => {
|
|
112
|
+
const token = previous();
|
|
113
|
+
if (!token)
|
|
114
|
+
return true;
|
|
115
|
+
if (token.type === 'word')
|
|
116
|
+
return REGEX_AFTER_WORD.has(token.value);
|
|
117
|
+
if (token.type === 'punct')
|
|
118
|
+
return REGEX_AFTER_PUNCT.has(token.value);
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
/** Reads a quoted string. Returns null when it does not terminate. */
|
|
122
|
+
const readQuoted = (quote) => {
|
|
123
|
+
let value = '';
|
|
124
|
+
index += 1;
|
|
125
|
+
while (index < source.length) {
|
|
126
|
+
const char = source[index];
|
|
127
|
+
if (char === '\\') {
|
|
128
|
+
value += source[index + 1] ?? '';
|
|
129
|
+
index += 2;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (char === quote) {
|
|
133
|
+
index += 1;
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
if (char === '\n')
|
|
137
|
+
return null;
|
|
138
|
+
value += char;
|
|
139
|
+
index += 1;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
};
|
|
143
|
+
while (index < source.length) {
|
|
144
|
+
const char = source[index];
|
|
145
|
+
const next = source[index + 1];
|
|
146
|
+
if (char === '\n') {
|
|
147
|
+
advanceLine(index);
|
|
148
|
+
index += 1;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (/\s/.test(char)) {
|
|
152
|
+
index += 1;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (char === '/' && next === '/') {
|
|
156
|
+
while (index < source.length && source[index] !== '\n')
|
|
157
|
+
index += 1;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (char === '/' && next === '*') {
|
|
161
|
+
const end = source.indexOf('*/', index + 2);
|
|
162
|
+
if (end === -1) {
|
|
163
|
+
desynced = true;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
for (let scan = index; scan < end; scan++) {
|
|
167
|
+
if (source[scan] === '\n')
|
|
168
|
+
advanceLine(scan);
|
|
169
|
+
}
|
|
170
|
+
index = end + 2;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (char === '/' && regexAllowed()) {
|
|
174
|
+
const startLine = line;
|
|
175
|
+
const startColumn = column(index);
|
|
176
|
+
let scan = index + 1;
|
|
177
|
+
let inClass = false;
|
|
178
|
+
let closed = false;
|
|
179
|
+
while (scan < source.length) {
|
|
180
|
+
const inner = source[scan];
|
|
181
|
+
if (inner === '\\') {
|
|
182
|
+
scan += 2;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (inner === '\n')
|
|
186
|
+
break;
|
|
187
|
+
if (inner === '[')
|
|
188
|
+
inClass = true;
|
|
189
|
+
else if (inner === ']')
|
|
190
|
+
inClass = false;
|
|
191
|
+
else if (inner === '/' && !inClass) {
|
|
192
|
+
closed = true;
|
|
193
|
+
scan += 1;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
scan += 1;
|
|
197
|
+
}
|
|
198
|
+
if (!closed) {
|
|
199
|
+
desynced = true;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
while (scan < source.length && isIdentifierPart(source[scan]))
|
|
203
|
+
scan += 1;
|
|
204
|
+
tokens.push({ type: 'punct', value: 'regex', line: startLine, column: startColumn });
|
|
205
|
+
index = scan;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (char === "'" || char === '"') {
|
|
209
|
+
const startLine = line;
|
|
210
|
+
const startColumn = column(index);
|
|
211
|
+
const value = readQuoted(char);
|
|
212
|
+
if (value === null) {
|
|
213
|
+
desynced = true;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
tokens.push({ type: 'string', value, line: startLine, column: startColumn });
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (char === '`') {
|
|
220
|
+
const startLine = line;
|
|
221
|
+
const startColumn = column(index);
|
|
222
|
+
let value = '';
|
|
223
|
+
let substituted = false;
|
|
224
|
+
let scan = index + 1;
|
|
225
|
+
let closed = false;
|
|
226
|
+
while (scan < source.length) {
|
|
227
|
+
const inner = source[scan];
|
|
228
|
+
if (inner === '\\') {
|
|
229
|
+
value += source[scan + 1] ?? '';
|
|
230
|
+
scan += 2;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (inner === '`') {
|
|
234
|
+
closed = true;
|
|
235
|
+
scan += 1;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
if (inner === '$' && source[scan + 1] === '{') {
|
|
239
|
+
// Hand the substitution back to the main loop so its contents are
|
|
240
|
+
// tokenized as code; the matching brace returns here.
|
|
241
|
+
substituted = true;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (inner === '\n')
|
|
245
|
+
advanceLine(scan);
|
|
246
|
+
value += inner;
|
|
247
|
+
scan += 1;
|
|
248
|
+
}
|
|
249
|
+
if (substituted) {
|
|
250
|
+
templateStack.push(braceDepth);
|
|
251
|
+
braceDepth += 1;
|
|
252
|
+
tokens.push({ type: 'template', value: '', line: startLine, column: startColumn });
|
|
253
|
+
index = scan + 2;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (!closed) {
|
|
257
|
+
desynced = true;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
// A template with no substitutions is usable as a specifier.
|
|
261
|
+
tokens.push({ type: 'string', value, line: startLine, column: startColumn });
|
|
262
|
+
index = scan;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (char === '}' && templateStack.length > 0 && braceDepth === templateStack.at(-1) + 1) {
|
|
266
|
+
// Closing a `${`: resume scanning the template that opened it.
|
|
267
|
+
templateStack.pop();
|
|
268
|
+
braceDepth -= 1;
|
|
269
|
+
let scan = index + 1;
|
|
270
|
+
let closed = false;
|
|
271
|
+
while (scan < source.length) {
|
|
272
|
+
const inner = source[scan];
|
|
273
|
+
if (inner === '\\') {
|
|
274
|
+
scan += 2;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (inner === '`') {
|
|
278
|
+
closed = true;
|
|
279
|
+
scan += 1;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
if (inner === '$' && source[scan + 1] === '{') {
|
|
283
|
+
templateStack.push(braceDepth);
|
|
284
|
+
braceDepth += 1;
|
|
285
|
+
scan += 2;
|
|
286
|
+
closed = true;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
if (inner === '\n')
|
|
290
|
+
advanceLine(scan);
|
|
291
|
+
scan += 1;
|
|
292
|
+
}
|
|
293
|
+
if (!closed) {
|
|
294
|
+
desynced = true;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
index = scan;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (isIdentifierStart(char)) {
|
|
301
|
+
const startColumn = column(index);
|
|
302
|
+
let scan = index;
|
|
303
|
+
while (scan < source.length && isIdentifierPart(source[scan]))
|
|
304
|
+
scan += 1;
|
|
305
|
+
/* c8 ignore next -- belt and braces: a word must consume at least one character */
|
|
306
|
+
if (scan === index)
|
|
307
|
+
scan += 1;
|
|
308
|
+
tokens.push({ type: 'word', value: source.slice(index, scan), line, column: startColumn });
|
|
309
|
+
index = scan;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (char === '{')
|
|
313
|
+
braceDepth += 1;
|
|
314
|
+
if (char === '}')
|
|
315
|
+
braceDepth -= 1;
|
|
316
|
+
tokens.push({ type: 'punct', value: char, line, column: column(index) });
|
|
317
|
+
index += 1;
|
|
318
|
+
}
|
|
319
|
+
if (templateStack.length > 0)
|
|
320
|
+
desynced = true;
|
|
321
|
+
return { tokens, desynced };
|
|
322
|
+
}
|
|
323
|
+
/* ---------------------------------------------------------------- extractor */
|
|
324
|
+
/** How far past `import`/`export` to look for `from`, before giving up. */
|
|
325
|
+
const CLAUSE_LOOKAHEAD = 200;
|
|
326
|
+
/**
|
|
327
|
+
* Reads module references off a token stream.
|
|
328
|
+
*
|
|
329
|
+
* Recognised: `import ... from 'x'`, `import 'x'`, `import('x')`,
|
|
330
|
+
* `export ... from 'x'`, `export * from 'x'`, `require('x')`. Anything whose
|
|
331
|
+
* specifier is not a literal becomes a note instead of a reference.
|
|
332
|
+
*/
|
|
333
|
+
export function extractReferences(tokens, file) {
|
|
334
|
+
const references = [];
|
|
335
|
+
const notes = [];
|
|
336
|
+
const note = (kind, token, detail) => {
|
|
337
|
+
notes.push({ kind, file, line: token.line, column: token.column, detail });
|
|
338
|
+
};
|
|
339
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
340
|
+
const token = tokens[index];
|
|
341
|
+
if (token.type !== 'word')
|
|
342
|
+
continue;
|
|
343
|
+
const isImport = token.value === 'import';
|
|
344
|
+
const isExport = token.value === 'export';
|
|
345
|
+
const isRequire = token.value === 'require';
|
|
346
|
+
if (!isImport && !isExport && !isRequire)
|
|
347
|
+
continue;
|
|
348
|
+
// ADR-0005 Q3: a property access is not a module reference. `loader.require`
|
|
349
|
+
// and `obj.import` are ordinary method calls.
|
|
350
|
+
const preceding = tokens[index - 1];
|
|
351
|
+
if (preceding?.type === 'punct' && preceding.value === '.')
|
|
352
|
+
continue;
|
|
353
|
+
const after = tokens[index + 1];
|
|
354
|
+
if (!after)
|
|
355
|
+
continue;
|
|
356
|
+
// import.meta / import.something - not a module reference.
|
|
357
|
+
if (isImport && after.type === 'punct' && after.value === '.')
|
|
358
|
+
continue;
|
|
359
|
+
// Call form: import('x') and require('x').
|
|
360
|
+
if ((isImport || isRequire) && after.type === 'punct' && after.value === '(') {
|
|
361
|
+
const argument = tokens[index + 2];
|
|
362
|
+
const closing = tokens[index + 3];
|
|
363
|
+
if (argument?.type === 'string' &&
|
|
364
|
+
closing?.type === 'punct' &&
|
|
365
|
+
(closing.value === ')' || closing.value === ',')) {
|
|
366
|
+
references.push({
|
|
367
|
+
specifier: argument.value,
|
|
368
|
+
kind: isImport ? 'dynamic-import' : 'require',
|
|
369
|
+
typeOnly: false,
|
|
370
|
+
line: token.line,
|
|
371
|
+
column: token.column,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
const shape = argument?.type === 'word' ? argument.value : 'expression';
|
|
376
|
+
note('dynamic', token, `${token.value}(${shape})`);
|
|
377
|
+
}
|
|
378
|
+
index += 1;
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
// Bare side-effect import: import 'x'.
|
|
382
|
+
if (isImport && after.type === 'string') {
|
|
383
|
+
references.push({
|
|
384
|
+
specifier: after.value,
|
|
385
|
+
kind: 'import',
|
|
386
|
+
typeOnly: false,
|
|
387
|
+
line: token.line,
|
|
388
|
+
column: token.column,
|
|
389
|
+
});
|
|
390
|
+
index += 1;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (isRequire)
|
|
394
|
+
continue;
|
|
395
|
+
// Statement form: scan the clause for `from` followed by a literal.
|
|
396
|
+
// `import type { A } from 'x'` is type-only. `import type from 'x'` imports a
|
|
397
|
+
// default binding that happens to be called type, and is a value import.
|
|
398
|
+
const following = tokens[index + 2];
|
|
399
|
+
const typeOnly = after.type === 'word' &&
|
|
400
|
+
after.value === 'type' &&
|
|
401
|
+
following?.type !== 'string' &&
|
|
402
|
+
!(following?.type === 'word' && following.value === 'from');
|
|
403
|
+
const limit = Math.min(tokens.length, index + CLAUSE_LOOKAHEAD);
|
|
404
|
+
for (let scan = index + 1; scan < limit; scan++) {
|
|
405
|
+
const current = tokens[scan];
|
|
406
|
+
if (current.type === 'punct' && current.value === ';')
|
|
407
|
+
break;
|
|
408
|
+
if (current.type !== 'word' || current.value !== 'from')
|
|
409
|
+
continue;
|
|
410
|
+
const specifier = tokens[scan + 1];
|
|
411
|
+
if (specifier?.type === 'string') {
|
|
412
|
+
references.push({
|
|
413
|
+
specifier: specifier.value,
|
|
414
|
+
kind: isImport ? 'import' : 'export',
|
|
415
|
+
typeOnly,
|
|
416
|
+
line: token.line,
|
|
417
|
+
column: token.column,
|
|
418
|
+
});
|
|
419
|
+
index = scan + 1;
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return { references, notes };
|
|
425
|
+
}
|
|
426
|
+
/** Tokenizes and extracts, reporting a lost scan as an unreadable note. */
|
|
427
|
+
export function analyzeSource(source, file) {
|
|
428
|
+
const { tokens, desynced } = tokenize(source);
|
|
429
|
+
const result = extractReferences(tokens, file);
|
|
430
|
+
if (desynced) {
|
|
431
|
+
result.notes.push({
|
|
432
|
+
kind: 'unreadable',
|
|
433
|
+
file,
|
|
434
|
+
line: 1,
|
|
435
|
+
column: 1,
|
|
436
|
+
detail: 'the scan ended inside a string, template or comment, so its imports are not trustworthy',
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
/* ------------------------------------------------------------- normalisation */
|
|
442
|
+
/**
|
|
443
|
+
* Resolves a specifier to something matchable, using path arithmetic only.
|
|
444
|
+
*
|
|
445
|
+
* Relative specifiers become root-relative paths; everything else is left
|
|
446
|
+
* exactly as written. There is deliberately no filesystem access, no extension
|
|
447
|
+
* guessing and no tsconfig path mapping - see ADR-0005.
|
|
448
|
+
*/
|
|
449
|
+
export function resolveSpecifier(specifier, importingFile) {
|
|
450
|
+
if (!specifier.startsWith('./') && !specifier.startsWith('../'))
|
|
451
|
+
return specifier;
|
|
452
|
+
const directory = path.posix.dirname(toPosix(importingFile));
|
|
453
|
+
return path.posix.normalize(path.posix.join(directory, specifier));
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Per-run cache: parse once, query many.
|
|
457
|
+
*
|
|
458
|
+
* Several assertions in one document routinely point at the same directory, and
|
|
459
|
+
* tokenizing is the most expensive thing spec-guard does. Without this the cost
|
|
460
|
+
* would be the tree multiplied by the number of import assertions.
|
|
461
|
+
*/
|
|
462
|
+
export function createImportIndex() {
|
|
463
|
+
const cache = new Map();
|
|
464
|
+
return {
|
|
465
|
+
get size() {
|
|
466
|
+
return cache.size;
|
|
467
|
+
},
|
|
468
|
+
analyze(absolutePath, relativePath) {
|
|
469
|
+
let pending = cache.get(absolutePath);
|
|
470
|
+
if (!pending) {
|
|
471
|
+
pending = fs
|
|
472
|
+
.readFile(absolutePath, 'utf8')
|
|
473
|
+
.then((source) => analyzeSource(source, relativePath))
|
|
474
|
+
.catch((error) => ({
|
|
475
|
+
references: [],
|
|
476
|
+
notes: [
|
|
477
|
+
{
|
|
478
|
+
kind: 'unreadable',
|
|
479
|
+
file: relativePath,
|
|
480
|
+
line: 1,
|
|
481
|
+
column: 1,
|
|
482
|
+
detail: `could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
}));
|
|
486
|
+
cache.set(absolutePath, pending);
|
|
487
|
+
}
|
|
488
|
+
return pending;
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../src/imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IAChE,KAAK;IACL,MAAM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AI,EAAE,YAAY;4BAClB,IAAI,EAAE,YAAY;4BAClB,IAAI,EAAE,CAAC;4BACP,MAAM,EAAE,CAAC;4BACT,MAAM,EAAE,sBAAsB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;yBACvF;qBACF;iBACF,CAAC,CACH,CAAC;gBACJ,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,19 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { main, parseArgs, HELP, UsageError, EXIT_OK, EXIT_FAILED, EXIT_ERROR } from './cli.js';
|
|
15
15
|
export type { CliIO, CliOptions } from './cli.js';
|
|
16
|
-
export { buildJsRegExp, buildRipgrepArgs,
|
|
17
|
-
export type { BatchEngine, CachedEngine, Engine, EnginePreference, Enumeration, EnumerationBudget,
|
|
18
|
-
export { compareDirents, createGlobMatcher, defaultDirectoryReader, expandSpecPatterns, globBase, globToRegExp, isGlob, toPosix, walkFiles,
|
|
16
|
+
export { buildJsRegExp, buildRipgrepArgs, createCachedEngine, enumerateCandidates, escapeRegExp, findRipgrep, parseRipgrepErrors, isMissingBinary, javascriptEngine, resetRipgrepProbe, resolveEngine, runSearches, scanContent, sortLocations, MAX_FILE_SIZE, SMALL_TREE_BUDGET, } from './engine.js';
|
|
17
|
+
export type { BatchEngine, CachedEngine, Engine, EnginePreference, Enumeration, EnumerationBudget, SearchRequest, } from './engine.js';
|
|
18
|
+
export { compareDirents, createExcludeMatcher, createGlobMatcher, defaultDirectoryReader, expandSpecPatterns, globBase, globToRegExp, isGlob, toPosix, walkFiles, } from './glob.js';
|
|
19
19
|
export type { DirectoryReader, WalkedFile, WalkOptions } from './glob.js';
|
|
20
|
+
export { createScope, isBinary, mergeLedgers, tallyLedger, LedgerBuilder, DEFAULT_SCOPE, DEFAULT_SKIPPED_DIRECTORIES, MAX_LEDGER_ENTRIES, SCAN_EVERYTHING, UNCERTAIN_REASONS, } from './scope.js';
|
|
21
|
+
export type { ScopeLedger, ScopePolicy, SkippedPath, SkipReason } from './scope.js';
|
|
22
|
+
export { analyzeSource, createImportIndex, extractReferences, resolveSpecifier, tokenize, ANALYSABLE_EXTENSIONS, } from './imports.js';
|
|
23
|
+
export type { AnalysisNote, FileImports, ImportIndex, ModuleReference, ReferenceKind } from './imports.js';
|
|
20
24
|
export { maskCode, parseAttributes, parseDirectives } from './parser.js';
|
|
21
25
|
export type { ParseContext } from './parser.js';
|
|
22
26
|
export { executeAssertion, resolveDirective, runSpecGuard, DEFAULT_CONCURRENCY, DEFAULT_MAX_SNIPPETS, } from './runner.js';
|
|
23
27
|
export type { ResolveContext, RunOptions, RunResult } from './runner.js';
|
|
24
28
|
export { createPainter, formatJson, formatReport, shouldUseAscii, shouldUseColor } from './reporter.js';
|
|
25
29
|
export type { ReporterOptions } from './reporter.js';
|
|
26
|
-
export type { Assertion, AssertionResult, Bounds, Directive, DirectiveError, DirectiveKind, EngineName, MatchLocation, ParseResult, RunReport, RunSummary, SearchOptions, SearchResult, SourceLocation, } from './types.js';
|
|
30
|
+
export type { Assertion, AssertionResult, Bounds, Directive, DirectiveError, DirectiveKind, EngineName, ImportQuery, MatchLocation, ParseResult, RunReport, RunSummary, SearchOptions, SearchResult, SourceLocation, } from './types.js';
|
|
27
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CA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L,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3G,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACxG,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,YAAY,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,SAAS,EACT,cAAc,EACd,aAAa,EACb,UAAU,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export { main, parseArgs, HELP, UsageError, EXIT_OK, EXIT_FAILED, EXIT_ERROR } from './cli.js';
|
|
15
|
-
export { buildJsRegExp, buildRipgrepArgs,
|
|
16
|
-
export { compareDirents, createGlobMatcher, defaultDirectoryReader, expandSpecPatterns, globBase, globToRegExp, isGlob, toPosix, walkFiles,
|
|
15
|
+
export { buildJsRegExp, buildRipgrepArgs, createCachedEngine, enumerateCandidates, escapeRegExp, findRipgrep, parseRipgrepErrors, isMissingBinary, javascriptEngine, resetRipgrepProbe, resolveEngine, runSearches, scanContent, sortLocations, MAX_FILE_SIZE, SMALL_TREE_BUDGET, } from './engine.js';
|
|
16
|
+
export { compareDirents, createExcludeMatcher, createGlobMatcher, defaultDirectoryReader, expandSpecPatterns, globBase, globToRegExp, isGlob, toPosix, walkFiles, } from './glob.js';
|
|
17
|
+
export { createScope, isBinary, mergeLedgers, tallyLedger, LedgerBuilder, DEFAULT_SCOPE, DEFAULT_SKIPPED_DIRECTORIES, MAX_LEDGER_ENTRIES, SCAN_EVERYTHING, UNCERTAIN_REASONS, } from './scope.js';
|
|
18
|
+
export { analyzeSource, createImportIndex, extractReferences, resolveSpecifier, tokenize, ANALYSABLE_EXTENSIONS, } from './imports.js';
|
|
17
19
|
export { maskCode, parseAttributes, parseDirectives } from './parser.js';
|
|
18
20
|
export { executeAssertion, resolveDirective, runSpecGuard, DEFAULT_CONCURRENCY, DEFAULT_MAX_SNIPPETS, } from './runner.js';
|
|
19
21
|
export { createPainter, formatJson, formatReport, shouldUseAscii, shouldUseColor } from './reporter.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG/F,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG/F,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAWrB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,OAAO,EACP,SAAS,GACV,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAA4C,WAAW,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAA4C,WAAW,EAAkB,MAAM,YAAY,CAAC;AAgDxG,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAwD/C;AA0BD,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUrE;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,WAAW,CAkDlF"}
|
package/dist/parser.js
CHANGED
|
@@ -14,10 +14,28 @@
|
|
|
14
14
|
* error rather than silently skipped - a typo must never turn into a
|
|
15
15
|
* silently-passing invariant.
|
|
16
16
|
*/
|
|
17
|
-
const KINDS = new Set([
|
|
17
|
+
const KINDS = new Set([
|
|
18
|
+
'assert-absence',
|
|
19
|
+
'assert-count',
|
|
20
|
+
'assert-present',
|
|
21
|
+
'assert-import-absence',
|
|
22
|
+
'assert-import-count',
|
|
23
|
+
]);
|
|
18
24
|
/** Attributes each directive kind accepts. */
|
|
19
25
|
const ALLOWED_ATTRIBUTES = {
|
|
20
|
-
'assert-absence': new Set([
|
|
26
|
+
'assert-absence': new Set([
|
|
27
|
+
'target',
|
|
28
|
+
'symbol',
|
|
29
|
+
'expected',
|
|
30
|
+
'max',
|
|
31
|
+
'glob',
|
|
32
|
+
'exclude',
|
|
33
|
+
'comments',
|
|
34
|
+
'regex',
|
|
35
|
+
'word',
|
|
36
|
+
'ignore-case',
|
|
37
|
+
'reason',
|
|
38
|
+
]),
|
|
21
39
|
'assert-count': new Set([
|
|
22
40
|
'target',
|
|
23
41
|
'symbol',
|
|
@@ -25,12 +43,16 @@ const ALLOWED_ATTRIBUTES = {
|
|
|
25
43
|
'min',
|
|
26
44
|
'max',
|
|
27
45
|
'glob',
|
|
46
|
+
'exclude',
|
|
47
|
+
'comments',
|
|
28
48
|
'regex',
|
|
29
49
|
'word',
|
|
30
50
|
'ignore-case',
|
|
31
51
|
'reason',
|
|
32
52
|
]),
|
|
33
53
|
'assert-present': new Set(['file', 'reason']),
|
|
54
|
+
'assert-import-absence': new Set(['target', 'module', 'exclude', 'types', 'expected', 'max', 'reason']),
|
|
55
|
+
'assert-import-count': new Set(['target', 'module', 'exclude', 'types', 'expected', 'min', 'max', 'reason']),
|
|
34
56
|
};
|
|
35
57
|
const DIRECTIVE_RE = /<!--\s*@([a-zA-Z][\w-]*)([\s\S]*?)-->/g;
|
|
36
58
|
const ATTRIBUTE_RE = /([a-zA-Z][\w-]*)(?:\s*=\s*(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|([^\s"'=<>`]+)))?/g;
|