gurkencheck 0.0.7 → 0.0.9
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/README.md +19 -0
- package/dist/config-parser.d.ts.map +1 -1
- package/dist/config-parser.js +7 -1
- package/dist/config-parser.js.map +1 -1
- package/dist/diagnostics.d.ts +34 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +53 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/feature-finder.d.ts +38 -0
- package/dist/feature-finder.d.ts.map +1 -1
- package/dist/feature-finder.js +86 -8
- package/dist/feature-finder.js.map +1 -1
- package/dist/formatters/index.d.ts +44 -4
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +52 -15
- package/dist/formatters/index.js.map +1 -1
- package/dist/formatters/stylish.d.ts +3 -0
- package/dist/formatters/stylish.d.ts.map +1 -1
- package/dist/formatters/stylish.js +32 -1
- package/dist/formatters/stylish.js.map +1 -1
- package/dist/formatters/tap.d.ts +14 -0
- package/dist/formatters/tap.d.ts.map +1 -1
- package/dist/formatters/tap.js +22 -7
- package/dist/formatters/tap.js.map +1 -1
- package/dist/gherkin/parse.d.ts +42 -1
- package/dist/gherkin/parse.d.ts.map +1 -1
- package/dist/gherkin/parse.js +68 -3
- package/dist/gherkin/parse.js.map +1 -1
- package/dist/index.d.ts +18 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/linter.d.ts +31 -3
- package/dist/linter.d.ts.map +1 -1
- package/dist/linter.js +82 -15
- package/dist/linter.js.map +1 -1
- package/dist/logger.d.ts +2 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -0
- package/dist/logger.js.map +1 -1
- package/dist/main.d.ts +9 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +147 -26
- package/dist/main.js.map +1 -1
- package/dist/rules/no-dupe-feature-names.d.ts.map +1 -1
- package/dist/rules/no-dupe-feature-names.js +26 -13
- package/dist/rules/no-dupe-feature-names.js.map +1 -1
- package/dist/rules/no-dupe-file-names.d.ts.map +1 -1
- package/dist/rules/no-dupe-file-names.js +32 -17
- package/dist/rules/no-dupe-file-names.js.map +1 -1
- package/dist/rules/no-dupe-scenario-names.d.ts.map +1 -1
- package/dist/rules/no-dupe-scenario-names.js +34 -22
- package/dist/rules/no-dupe-scenario-names.js.map +1 -1
- package/dist/rules.d.ts +41 -3
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +112 -4
- package/dist/rules.js.map +1 -1
- package/dist/stats/collect.d.ts +8 -0
- package/dist/stats/collect.d.ts.map +1 -1
- package/dist/stats/collect.js +67 -37
- package/dist/stats/collect.js.map +1 -1
- package/dist/stats/command.d.ts +2 -1
- package/dist/stats/command.d.ts.map +1 -1
- package/dist/stats/command.js +34 -34
- package/dist/stats/command.js.map +1 -1
- package/dist/types.d.ts +47 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/util/glob.d.ts +18 -0
- package/dist/util/glob.d.ts.map +1 -1
- package/dist/util/glob.js +126 -22
- package/dist/util/glob.js.map +1 -1
- package/dist/util/stream.d.ts +31 -0
- package/dist/util/stream.d.ts.map +1 -0
- package/dist/util/stream.js +67 -0
- package/dist/util/stream.js.map +1 -0
- package/dist/watch.d.ts +36 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +203 -0
- package/dist/watch.js.map +1 -0
- package/package.json +1 -1
package/dist/formatters/tap.d.ts
CHANGED
|
@@ -5,8 +5,22 @@
|
|
|
5
5
|
* at, which is what TAP consumers expect. Findings are carried in the YAML
|
|
6
6
|
* diagnostic block. A file is `not ok` only when it holds something that
|
|
7
7
|
* fails the run, so a file with warnings alone passes but still says why.
|
|
8
|
+
*
|
|
9
|
+
* Written as the results arrive. A harness seeing `ok 1` while file two is
|
|
10
|
+
* still being checked is the whole point of TAP, and holding the stream back
|
|
11
|
+
* to print it in one go gives that up for nothing. The plan comes last
|
|
12
|
+
* instead of first, because the count is only known then - TAP 13 allows it
|
|
13
|
+
* at either end for exactly this reason.
|
|
8
14
|
*/
|
|
15
|
+
import type { FormatterRun } from './index.ts';
|
|
9
16
|
import type { FileResult } from '../types.ts';
|
|
17
|
+
/**
|
|
18
|
+
* A TAP stream, written a test point at a time.
|
|
19
|
+
*
|
|
20
|
+
* A new one per run, so its counter belongs to that run and two at once
|
|
21
|
+
* cannot number each other's test points.
|
|
22
|
+
*/
|
|
23
|
+
export declare function startRun(): FormatterRun;
|
|
10
24
|
/** Renders the results as a TAP 13 stream. */
|
|
11
25
|
export declare function format(results: readonly FileResult[]): string;
|
|
12
26
|
/** Writes the TAP stream to stdout. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../src/formatters/tap.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../src/formatters/tap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAC,UAAU,EAAY,MAAM,aAAa,CAAC;AAqCvD;;;;;GAKG;AACH,wBAAgB,QAAQ,IAAI,YAAY,CAYvC;AAED,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAK7D;AAED,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAEjE"}
|
package/dist/formatters/tap.js
CHANGED
|
@@ -28,15 +28,30 @@ function diagnostics(result) {
|
|
|
28
28
|
lines.push(' ...');
|
|
29
29
|
return lines;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A TAP stream, written a test point at a time.
|
|
33
|
+
*
|
|
34
|
+
* A new one per run, so its counter belongs to that run and two at once
|
|
35
|
+
* cannot number each other's test points.
|
|
36
|
+
*/
|
|
37
|
+
export function startRun() {
|
|
38
|
+
let count = 0;
|
|
39
|
+
return {
|
|
40
|
+
start: () => 'TAP version 13\n',
|
|
41
|
+
file(result) {
|
|
42
|
+
count++;
|
|
43
|
+
const status = fails(result) ? 'not ok' : 'ok';
|
|
44
|
+
return [`${status} ${count} - ${result.filePath}`, ...diagnostics(result), ''].join('\n');
|
|
45
|
+
},
|
|
46
|
+
end: () => `1..${count}\n`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
31
49
|
/** Renders the results as a TAP 13 stream. */
|
|
32
50
|
export function format(results) {
|
|
33
|
-
const
|
|
34
|
-
results.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
lines.push(...diagnostics(result));
|
|
38
|
-
});
|
|
39
|
-
return lines.join('\n');
|
|
51
|
+
const run = startRun();
|
|
52
|
+
const text = [run.start?.() ?? '', ...results.map((result) => run.file(result)), run.end?.() ?? ''];
|
|
53
|
+
// The caller prints this with console.log, which adds the last line break.
|
|
54
|
+
return text.join('').replace(/\n$/u, '');
|
|
40
55
|
}
|
|
41
56
|
/** Writes the TAP stream to stdout. */
|
|
42
57
|
export function printResults(results) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../src/formatters/tap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../src/formatters/tap.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC;AACnC,CAAC;AAED,SAAS,KAAK,CAAC,MAAkB;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CA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M,IAAI,KAAK,MAAM,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5F,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,KAAK,IAAI;KAC3B,CAAC;AACJ,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,MAAM,CAAC,OAA8B;IACnD,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACpG,2EAA2E;IAC3E,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,YAAY,CAAC,OAA8B;IACzD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/gherkin/parse.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Feature } from '@cucumber/messages';
|
|
2
|
+
import type { Sequence } from '../util/stream.ts';
|
|
2
3
|
import type { FeatureFile, RuleError } from '../types.ts';
|
|
3
4
|
/**
|
|
4
5
|
* Rules the parser enforces on every file. They cannot be turned off, but
|
|
@@ -27,6 +28,46 @@ export declare function toLines(source: string): string[];
|
|
|
27
28
|
* language.
|
|
28
29
|
*/
|
|
29
30
|
export declare function parseFeature(relativePath: string, source: string, defaultLanguage?: string): ParseResult;
|
|
30
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Reads a feature file from disk and parses it.
|
|
33
|
+
*
|
|
34
|
+
* A file that cannot be read at all - missing, unreadable, deleted between
|
|
35
|
+
* being found and being opened - comes back as a result carrying the reason,
|
|
36
|
+
* exactly as a file the parser rejected does. Nothing here throws: one
|
|
37
|
+
* unreadable file among a thousand should cost you that file's findings, not
|
|
38
|
+
* every other file's as well.
|
|
39
|
+
*
|
|
40
|
+
* That promise is what lets `readAndParseFiles` hold started reads in a
|
|
41
|
+
* window. A promise that rejected before anything awaited it would be an
|
|
42
|
+
* unhandled rejection, and take the process with it.
|
|
43
|
+
*/
|
|
31
44
|
export declare function readAndParseFile(relativePath: string, defaultLanguage?: string): Promise<ParseResult>;
|
|
45
|
+
/**
|
|
46
|
+
* How many files are read ahead of the one being handed over.
|
|
47
|
+
*
|
|
48
|
+
* Enough to keep the disk busy while a file is checked, few enough that the
|
|
49
|
+
* memory held is a property of this number rather than of the size of the
|
|
50
|
+
* suite. Reading every file at once - which is what a `Promise.all` over the
|
|
51
|
+
* whole list does - holds the entire suite's source and syntax trees at once,
|
|
52
|
+
* and opens a file descriptor per file while it is at it.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DEFAULT_READ_AHEAD = 16;
|
|
55
|
+
export interface ReadOptions {
|
|
56
|
+
/** The dialect for files carrying no `# language:` header of their own. */
|
|
57
|
+
language?: string;
|
|
58
|
+
/** How many files to keep reading ahead of the one handed over. */
|
|
59
|
+
readAhead?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Reads and parses feature files, handing each one over in turn.
|
|
63
|
+
*
|
|
64
|
+
* The files may be an array or something finding them as it goes, so a walk
|
|
65
|
+
* of a directory tree can feed this without being collected first.
|
|
66
|
+
*
|
|
67
|
+
* Files are read ahead of being handed over, so the next one is on its way
|
|
68
|
+
* while this one is being used, but only so many at a time. Results come in
|
|
69
|
+
* the order the files were given whatever order they finish reading in, which
|
|
70
|
+
* is what the rules looking across files need.
|
|
71
|
+
*/
|
|
72
|
+
export declare function readAndParseFiles(files: Sequence<string>, options?: ReadOptions): AsyncGenerator<ParseResult>;
|
|
32
73
|
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/gherkin/parse.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/gherkin/parse.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAGhD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,eAAe,YAC1B,wBAAwB,EACxB,sBAAsB,EACtB,+BAA+B,EAC/B,6BAA6B,EAC7B,oBAAoB,CACZ,CAAC;AAEX,sDAAsD;AACtD,eAAO,MAAM,YAAY,uKAAoD,CAAC;AAE9E,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,mFAAmF;IACnF,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,gFAAgF;IAChF,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAmMD,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,eAAe,GAAE,MAAyB,GACzC,WAAW,CA8Cb;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,OAAO,GAAE,WAAgB,GACxB,cAAc,CAAC,WAAW,CAAC,CAI7B"}
|
package/dist/gherkin/parse.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin';
|
|
12
12
|
import { IdGenerator } from '@cucumber/messages';
|
|
13
13
|
import { readFile } from 'node:fs/promises';
|
|
14
|
+
import { mapWithWindow } from '../util/stream.js';
|
|
14
15
|
import { DEFAULT_LANGUAGE, detectLanguage, getDialect } from './dialects.js';
|
|
15
16
|
/**
|
|
16
17
|
* Rules the parser enforces on every file. They cannot be turned off, but
|
|
@@ -228,9 +229,73 @@ export function parseFeature(relativePath, source, defaultLanguage = DEFAULT_LAN
|
|
|
228
229
|
}
|
|
229
230
|
return { file, feature: undefined, errors };
|
|
230
231
|
}
|
|
231
|
-
/**
|
|
232
|
+
/** A file that could not be turned into a feature, and why. */
|
|
233
|
+
function unreadable(relativePath, lines, thrown) {
|
|
234
|
+
return {
|
|
235
|
+
file: { relativePath, lines },
|
|
236
|
+
feature: undefined,
|
|
237
|
+
errors: [
|
|
238
|
+
{
|
|
239
|
+
message: thrown instanceof Error ? thrown.message : String(thrown),
|
|
240
|
+
rule: 'unexpected-error',
|
|
241
|
+
line: 0,
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Reads a feature file from disk and parses it.
|
|
248
|
+
*
|
|
249
|
+
* A file that cannot be read at all - missing, unreadable, deleted between
|
|
250
|
+
* being found and being opened - comes back as a result carrying the reason,
|
|
251
|
+
* exactly as a file the parser rejected does. Nothing here throws: one
|
|
252
|
+
* unreadable file among a thousand should cost you that file's findings, not
|
|
253
|
+
* every other file's as well.
|
|
254
|
+
*
|
|
255
|
+
* That promise is what lets `readAndParseFiles` hold started reads in a
|
|
256
|
+
* window. A promise that rejected before anything awaited it would be an
|
|
257
|
+
* unhandled rejection, and take the process with it.
|
|
258
|
+
*/
|
|
232
259
|
export async function readAndParseFile(relativePath, defaultLanguage) {
|
|
233
|
-
|
|
234
|
-
|
|
260
|
+
let source;
|
|
261
|
+
try {
|
|
262
|
+
source = await readFile(relativePath, 'utf8');
|
|
263
|
+
}
|
|
264
|
+
catch (thrown) {
|
|
265
|
+
return unreadable(relativePath, [], thrown);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return parseFeature(relativePath, source, defaultLanguage);
|
|
269
|
+
}
|
|
270
|
+
catch (thrown) {
|
|
271
|
+
// parseFeature turns the parser's complaints into findings rather than
|
|
272
|
+
// throwing, so getting here means gurkencheck itself went wrong. Even
|
|
273
|
+
// then, one file is one file.
|
|
274
|
+
return unreadable(relativePath, toLines(source), thrown);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* How many files are read ahead of the one being handed over.
|
|
279
|
+
*
|
|
280
|
+
* Enough to keep the disk busy while a file is checked, few enough that the
|
|
281
|
+
* memory held is a property of this number rather than of the size of the
|
|
282
|
+
* suite. Reading every file at once - which is what a `Promise.all` over the
|
|
283
|
+
* whole list does - holds the entire suite's source and syntax trees at once,
|
|
284
|
+
* and opens a file descriptor per file while it is at it.
|
|
285
|
+
*/
|
|
286
|
+
export const DEFAULT_READ_AHEAD = 16;
|
|
287
|
+
/**
|
|
288
|
+
* Reads and parses feature files, handing each one over in turn.
|
|
289
|
+
*
|
|
290
|
+
* The files may be an array or something finding them as it goes, so a walk
|
|
291
|
+
* of a directory tree can feed this without being collected first.
|
|
292
|
+
*
|
|
293
|
+
* Files are read ahead of being handed over, so the next one is on its way
|
|
294
|
+
* while this one is being used, but only so many at a time. Results come in
|
|
295
|
+
* the order the files were given whatever order they finish reading in, which
|
|
296
|
+
* is what the rules looking across files need.
|
|
297
|
+
*/
|
|
298
|
+
export function readAndParseFiles(files, options = {}) {
|
|
299
|
+
return mapWithWindow(files, options.readAhead ?? DEFAULT_READ_AHEAD, (file) => readAndParseFile(file, options.language));
|
|
235
300
|
}
|
|
236
301
|
//# sourceMappingURL=parse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/gherkin/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,UAAU,EAAE,0BAA0B,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/gherkin/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,UAAU,EAAE,0BAA0B,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,wBAAwB;IACxB,sBAAsB;IACtB,+BAA+B;IAC/B,6BAA6B;IAC7B,oBAAoB;CACZ,CAAC;AAEX,sDAAsD;AACtD,MAAM,CAAC,MAAM,Y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AC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,uEAAuE;QACvE,sEAAsE;QACtE,8BAA8B;QAC9B,OAAO,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AASrC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAuB,EACvB,OAAO,GAAgB,EAAE;IAEzB,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,IAAI,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC5E,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,27 +16,35 @@ export { DEFAULT_CONFIG_FILE_NAME, readConfiguration } from './config-parser.ts'
|
|
|
16
16
|
export type { ConfigurationResult } from './config-parser.ts';
|
|
17
17
|
export { verifyConfiguration } from './config-verifier.ts';
|
|
18
18
|
export { PRESETS, RECOMMENDED } from './presets.ts';
|
|
19
|
-
export { DEFAULT_IGNORE_FILE_NAME, DEFAULT_IGNORED_PATTERNS, findFeatureFiles, readIgnorePatterns, } from './feature-finder.ts';
|
|
20
|
-
export type { FeatureSearch } from './feature-finder.ts';
|
|
21
|
-
export { DEFAULT_FORMAT, FORMATTERS, getFormatter, loadFormatter } from './formatters/index.ts';
|
|
22
|
-
export type { Formatter } from './formatters/index.ts';
|
|
19
|
+
export { DEFAULT_IGNORE_FILE_NAME, DEFAULT_IGNORED_PATTERNS, featureRoots, findFeatureFileStream, findFeatureFiles, readIgnorePatterns, } from './feature-finder.ts';
|
|
20
|
+
export type { FeatureFileStream, FeatureSearch } from './feature-finder.ts';
|
|
21
|
+
export { DEFAULT_FORMAT, FORMATTERS, STREAMING_FORMATTERS, getFormatter, getStreamingFormatter, loadFormatter, loadStreamingFormatter, } from './formatters/index.ts';
|
|
22
|
+
export type { Formatter, FormatterRun, StreamingFormatter } from './formatters/index.ts';
|
|
23
23
|
export { toJson } from './formatters/json.ts';
|
|
24
24
|
export { toSarif } from './formatters/sarif.ts';
|
|
25
25
|
export { version } from './version.ts';
|
|
26
26
|
export type { JsonMessage, JsonResult } from './formatters/json.ts';
|
|
27
|
-
export { ALWAYS_ON_RULES, PARSER_RULES, parseFeature, readAndParseFile } from './gherkin/parse.ts';
|
|
28
|
-
export type { ParseResult } from './gherkin/parse.ts';
|
|
27
|
+
export { ALWAYS_ON_RULES, DEFAULT_READ_AHEAD, PARSER_RULES, parseFeature, readAndParseFile, readAndParseFiles, } from './gherkin/parse.ts';
|
|
28
|
+
export type { ParseResult, ReadOptions } from './gherkin/parse.ts';
|
|
29
29
|
export { getNeutralKeyword, getNodeType } from './gherkin/keywords.ts';
|
|
30
30
|
export { DEFAULT_LANGUAGE, detectLanguage, getDialect, isKnownLanguage } from './gherkin/dialects.ts';
|
|
31
31
|
export { backgroundsOf, rulesOf, scenariosOf, stepContainersOf } from './gherkin/traverse.ts';
|
|
32
32
|
export { EXIT_LINT_ERRORS, EXIT_OK, EXIT_USAGE } from './exit-codes.ts';
|
|
33
|
-
export {
|
|
33
|
+
export { SILENT, TO_STDERR, collectDiagnostics } from './diagnostics.ts';
|
|
34
|
+
export type { CollectedDiagnostics, Diagnostic, DiagnosticLevel, Diagnostics, } from './diagnostics.ts';
|
|
35
|
+
export { DEFAULT_SETTLE_MS, isInteresting, watch } from './watch.ts';
|
|
36
|
+
export type { WatchOptions } from './watch.ts';
|
|
37
|
+
export { mapWithWindow } from './util/stream.ts';
|
|
38
|
+
export type { Sequence } from './util/stream.ts';
|
|
39
|
+
export { globRoot, globStream, globSync } from './util/glob.ts';
|
|
40
|
+
export { countBySeverity, hasErrors, lint, lintStream } from './linter.ts';
|
|
34
41
|
export type { LintOptions } from './linter.ts';
|
|
35
42
|
export { readSuppressions } from './suppressions.ts';
|
|
36
43
|
export type { Suppressions } from './suppressions.ts';
|
|
37
|
-
export { getRuleSettings, getRuleSeverity, isRuleEnabled, loadRules, resetRules, runEnabledRules, } from './rules.ts';
|
|
44
|
+
export { beginRun, finishRun, getRuleSettings, getRuleSeverity, isRuleEnabled, loadRules, newRunContext, resetRules, runEnabledRules, } from './rules.ts';
|
|
45
|
+
export type { Run } from './rules.ts';
|
|
38
46
|
export { BUILT_IN_RULES } from './rules/index.ts';
|
|
39
|
-
export { collectStatistics, distribution } from './stats/collect.ts';
|
|
47
|
+
export { collectStatistics, collectStatisticsFrom, distribution } from './stats/collect.ts';
|
|
40
48
|
export type { CollectOptions } from './stats/collect.ts';
|
|
41
49
|
export { DEFAULT_SIMILARITY, boundedEditDistance, groupSimilar } from './stats/similar.ts';
|
|
42
50
|
export type { SimilarityOptions } from './stats/similar.ts';
|
|
@@ -45,5 +53,5 @@ export { DEFAULT_STATS_FORMAT, DEFAULT_TOP, STATS_FORMATTERS, getStatsFormatter,
|
|
|
45
53
|
export type { StatsFormatOptions, StatsFormatter } from './stats/format/index.ts';
|
|
46
54
|
export { runStats, statsUsage } from './stats/command.ts';
|
|
47
55
|
export type { Distribution, Inventory, KeywordMix, LanguageEntry, ScenarioRef, ScenarioStats, SimilarGroup, Statistics, StepEntry, StepStats, TagEntry, TagStats, UnreadableFile, } from './stats/types.ts';
|
|
48
|
-
export type { Configuration, FeatureFile, FileResult, LintRule, RuleConfig, RuleError, RuleRegistry, RuleState, Severity, } from './types.ts';
|
|
56
|
+
export type { Configuration, FeatureFile, FileResult, LintRule, RuleConfig, RuleError, RuleRegistry, RuleState, RunContext, RunFinding, Severity, } from './types.ts';
|
|
49
57
|
//# 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;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAC,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAC,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAC,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAA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YAAY,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,21 +15,25 @@
|
|
|
15
15
|
export { DEFAULT_CONFIG_FILE_NAME, readConfiguration } from './config-parser.js';
|
|
16
16
|
export { verifyConfiguration } from './config-verifier.js';
|
|
17
17
|
export { PRESETS, RECOMMENDED } from './presets.js';
|
|
18
|
-
export { DEFAULT_IGNORE_FILE_NAME, DEFAULT_IGNORED_PATTERNS, findFeatureFiles, readIgnorePatterns, } from './feature-finder.js';
|
|
19
|
-
export { DEFAULT_FORMAT, FORMATTERS, getFormatter, loadFormatter } from './formatters/index.js';
|
|
18
|
+
export { DEFAULT_IGNORE_FILE_NAME, DEFAULT_IGNORED_PATTERNS, featureRoots, findFeatureFileStream, findFeatureFiles, readIgnorePatterns, } from './feature-finder.js';
|
|
19
|
+
export { DEFAULT_FORMAT, FORMATTERS, STREAMING_FORMATTERS, getFormatter, getStreamingFormatter, loadFormatter, loadStreamingFormatter, } from './formatters/index.js';
|
|
20
20
|
export { toJson } from './formatters/json.js';
|
|
21
21
|
export { toSarif } from './formatters/sarif.js';
|
|
22
22
|
export { version } from './version.js';
|
|
23
|
-
export { ALWAYS_ON_RULES, PARSER_RULES, parseFeature, readAndParseFile } from './gherkin/parse.js';
|
|
23
|
+
export { ALWAYS_ON_RULES, DEFAULT_READ_AHEAD, PARSER_RULES, parseFeature, readAndParseFile, readAndParseFiles, } from './gherkin/parse.js';
|
|
24
24
|
export { getNeutralKeyword, getNodeType } from './gherkin/keywords.js';
|
|
25
25
|
export { DEFAULT_LANGUAGE, detectLanguage, getDialect, isKnownLanguage } from './gherkin/dialects.js';
|
|
26
26
|
export { backgroundsOf, rulesOf, scenariosOf, stepContainersOf } from './gherkin/traverse.js';
|
|
27
27
|
export { EXIT_LINT_ERRORS, EXIT_OK, EXIT_USAGE } from './exit-codes.js';
|
|
28
|
-
export {
|
|
28
|
+
export { SILENT, TO_STDERR, collectDiagnostics } from './diagnostics.js';
|
|
29
|
+
export { DEFAULT_SETTLE_MS, isInteresting, watch } from './watch.js';
|
|
30
|
+
export { mapWithWindow } from './util/stream.js';
|
|
31
|
+
export { globRoot, globStream, globSync } from './util/glob.js';
|
|
32
|
+
export { countBySeverity, hasErrors, lint, lintStream } from './linter.js';
|
|
29
33
|
export { readSuppressions } from './suppressions.js';
|
|
30
|
-
export { getRuleSettings, getRuleSeverity, isRuleEnabled, loadRules, resetRules, runEnabledRules, } from './rules.js';
|
|
34
|
+
export { beginRun, finishRun, getRuleSettings, getRuleSeverity, isRuleEnabled, loadRules, newRunContext, resetRules, runEnabledRules, } from './rules.js';
|
|
31
35
|
export { BUILT_IN_RULES } from './rules/index.js';
|
|
32
|
-
export { collectStatistics, distribution } from './stats/collect.js';
|
|
36
|
+
export { collectStatistics, collectStatisticsFrom, distribution } from './stats/collect.js';
|
|
33
37
|
export { DEFAULT_SIMILARITY, boundedEditDistance, groupSimilar } from './stats/similar.js';
|
|
34
38
|
export { NUMBER_MARKER, PLACEHOLDER_MARKER, STRING_MARKER, countWords, normaliseStepText, } from './stats/normalise.js';
|
|
35
39
|
export { DEFAULT_STATS_FORMAT, DEFAULT_TOP, STATS_FORMATTERS, getStatsFormatter, toJson as statisticsToJson, toMarkdown, toText, } from './stats/format/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAC,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAClD,O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C,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAOvE,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,EACT,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,IAAI,gBAAgB,EAC1B,UAAU,EACV,MAAM,GACP,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC"}
|
package/dist/linter.d.ts
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
1
|
import type { Configuration, FileResult, RuleRegistry } from './types.ts';
|
|
2
|
+
import type { Sequence } from './util/stream.ts';
|
|
2
3
|
export interface LintOptions {
|
|
3
4
|
/**
|
|
4
5
|
* The dialect to read a file in when it carries no `# language:` header,
|
|
5
6
|
* for projects written entirely in one language.
|
|
6
7
|
*/
|
|
7
8
|
language?: string;
|
|
9
|
+
/**
|
|
10
|
+
* How many files to read ahead of the one being checked. Left out, a
|
|
11
|
+
* sensible default is used; there is rarely a reason to set it.
|
|
12
|
+
*/
|
|
13
|
+
readAhead?: number;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
10
|
-
* Lints every file
|
|
16
|
+
* Lints every file, handing back each result as soon as it is final.
|
|
11
17
|
*
|
|
12
18
|
* Files are read concurrently but checked one after another, because rules
|
|
13
|
-
* that look for duplicates across files need a predictable order.
|
|
19
|
+
* that look for duplicates across files need a predictable order. Results
|
|
20
|
+
* come in the order the files were given.
|
|
21
|
+
*
|
|
22
|
+
* A rule that reports across files - two files sharing a name - cannot know
|
|
23
|
+
* what it has found until every file has been seen, so switching one on holds
|
|
24
|
+
* every result back until the end. That is the honest cost of the question it
|
|
25
|
+
* answers, not something to work around: a result handed over early would
|
|
26
|
+
* have to be taken back. With no such rule on, each result arrives as its
|
|
27
|
+
* file is checked.
|
|
28
|
+
*
|
|
29
|
+
* Files are read ahead of being checked, a bounded number at a time, so the
|
|
30
|
+
* next one is on its way while this one is being checked without the whole
|
|
31
|
+
* suite being held in memory at once.
|
|
32
|
+
*
|
|
33
|
+
* Stopping early - `break` in a `for await` - stops the reading as well as
|
|
34
|
+
* the checking, rather than running on to the last file.
|
|
35
|
+
*/
|
|
36
|
+
export declare function lintStream(files: Sequence<string>, configuration: Configuration, rules: RuleRegistry, options?: LintOptions): AsyncGenerator<FileResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Lints every file and returns one result per file, in the order given.
|
|
39
|
+
*
|
|
40
|
+
* The whole run at once. For results as they are ready - a progress line, an
|
|
41
|
+
* editor, stopping at the first error - use `lintStream`.
|
|
14
42
|
*/
|
|
15
|
-
export declare function lint(files:
|
|
43
|
+
export declare function lint(files: Sequence<string>, configuration: Configuration, rules: RuleRegistry, options?: LintOptions): Promise<FileResult[]>;
|
|
16
44
|
/** True when any file has a finding serious enough to fail the run. */
|
|
17
45
|
export declare function hasErrors(results: readonly FileResult[]): boolean;
|
|
18
46
|
/** How many findings there are of each severity. */
|
package/dist/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,aAAa,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAExE,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAK/C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAYD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAuB,UAAU,CAC/B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,WAAgB,GACxB,cAAc,CAAC,UAAU,CAAC,CAuD5B;AAED;;;;;GAKG;AACH,wBAAsB,IAAI,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC,CAMvB;AAED,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAIjE;AAED,oDAAoD;AACpD,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAaA"}
|
package/dist/linter.js
CHANGED
|
@@ -2,35 +2,102 @@
|
|
|
2
2
|
* Running the rules over a set of feature files.
|
|
3
3
|
*/
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { readAndParseFiles } from './gherkin/parse.js';
|
|
6
|
+
import { beginRun, finishRun, isRuleEnabled, runEnabledRules } from './rules.js';
|
|
7
7
|
import { readSuppressions } from './suppressions.js';
|
|
8
8
|
import { sortBy } from './util/collections.js';
|
|
9
|
+
/** Stands in for a file whose directives were never read, and hides nothing. */
|
|
10
|
+
const EMPTY_SUPPRESSIONS = { isEmpty: true, isSuppressed: () => false };
|
|
11
|
+
/** True when a rule that only reports once every file has been seen is on. */
|
|
12
|
+
function reportsAcrossFiles(rules, configuration) {
|
|
13
|
+
for (const rule of rules.values()) {
|
|
14
|
+
if (rule.onRunEnd !== undefined && isRuleEnabled(configuration[rule.name])) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
9
20
|
/**
|
|
10
|
-
* Lints every file
|
|
21
|
+
* Lints every file, handing back each result as soon as it is final.
|
|
11
22
|
*
|
|
12
23
|
* Files are read concurrently but checked one after another, because rules
|
|
13
|
-
* that look for duplicates across files need a predictable order.
|
|
24
|
+
* that look for duplicates across files need a predictable order. Results
|
|
25
|
+
* come in the order the files were given.
|
|
26
|
+
*
|
|
27
|
+
* A rule that reports across files - two files sharing a name - cannot know
|
|
28
|
+
* what it has found until every file has been seen, so switching one on holds
|
|
29
|
+
* every result back until the end. That is the honest cost of the question it
|
|
30
|
+
* answers, not something to work around: a result handed over early would
|
|
31
|
+
* have to be taken back. With no such rule on, each result arrives as its
|
|
32
|
+
* file is checked.
|
|
33
|
+
*
|
|
34
|
+
* Files are read ahead of being checked, a bounded number at a time, so the
|
|
35
|
+
* next one is on its way while this one is being checked without the whole
|
|
36
|
+
* suite being held in memory at once.
|
|
37
|
+
*
|
|
38
|
+
* Stopping early - `break` in a `for await` - stops the reading as well as
|
|
39
|
+
* the checking, rather than running on to the last file.
|
|
14
40
|
*/
|
|
15
|
-
export async function
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
41
|
+
export async function* lintStream(files, configuration, rules, options = {}) {
|
|
42
|
+
const run = beginRun(rules, configuration);
|
|
43
|
+
const held = reportsAcrossFiles(rules, configuration);
|
|
44
|
+
const waiting = [];
|
|
45
|
+
/** Where to put a finding that names a file, and what may hide it there. */
|
|
46
|
+
const byPath = new Map();
|
|
47
|
+
for await (const result of readAndParseFiles(files, {
|
|
48
|
+
language: options.language,
|
|
49
|
+
readAhead: options.readAhead,
|
|
50
|
+
})) {
|
|
20
51
|
// Parse errors are not suppressible: the file could not be read, so
|
|
21
52
|
// hiding the message would leave nothing in its place.
|
|
22
53
|
let errors = result.errors;
|
|
54
|
+
let suppressions = EMPTY_SUPPRESSIONS;
|
|
23
55
|
if (errors.length === 0) {
|
|
24
|
-
errors = await runEnabledRules(result.feature, result.file, configuration, rules);
|
|
25
|
-
|
|
56
|
+
errors = await runEnabledRules(result.feature, result.file, configuration, rules, run);
|
|
57
|
+
suppressions = readSuppressions(result.file.lines);
|
|
26
58
|
if (!suppressions.isEmpty) {
|
|
27
59
|
errors = errors.filter((error) => !suppressions.isSuppressed(error));
|
|
28
60
|
}
|
|
29
61
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
62
|
+
const fileResult = { filePath: path.resolve(result.file.relativePath), errors };
|
|
63
|
+
byPath.set(result.file.relativePath, { result: fileResult, suppressions });
|
|
64
|
+
if (held) {
|
|
65
|
+
waiting.push(fileResult);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
fileResult.errors = sortBy(fileResult.errors, (error) => error.line);
|
|
69
|
+
yield fileResult;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// What only the whole run could show: two files sharing a name, and the
|
|
73
|
+
// like. A finding naming no file is about the run itself - a rule that
|
|
74
|
+
// failed looking back over it - and goes against the first file so that it
|
|
75
|
+
// is seen at all.
|
|
76
|
+
for (const { filePath, ...error } of await finishRun(rules, configuration, run)) {
|
|
77
|
+
const target = filePath === undefined ? undefined : byPath.get(filePath);
|
|
78
|
+
if (target === undefined) {
|
|
79
|
+
waiting[0]?.errors.push(error);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (!target.suppressions.isSuppressed(error)) {
|
|
83
|
+
target.result.errors.push(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const result of waiting) {
|
|
87
|
+
result.errors = sortBy(result.errors, (error) => error.line);
|
|
88
|
+
yield result;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Lints every file and returns one result per file, in the order given.
|
|
93
|
+
*
|
|
94
|
+
* The whole run at once. For results as they are ready - a progress line, an
|
|
95
|
+
* editor, stopping at the first error - use `lintStream`.
|
|
96
|
+
*/
|
|
97
|
+
export async function lint(files, configuration, rules, options = {}) {
|
|
98
|
+
const results = [];
|
|
99
|
+
for await (const result of lintStream(files, configuration, rules, options)) {
|
|
100
|
+
results.push(result);
|
|
34
101
|
}
|
|
35
102
|
return results;
|
|
36
103
|
}
|
package/dist/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,aAA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KAAK,OAAO,CAAC,CACvE,CAAC;AACJ,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,eAAe,CAAC,OAA8B;IAI5D,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC9C,QAAQ,EAAE,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,CAAC;AAC5B,CAAC"}
|
package/dist/logger.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
export declare function error(message: string): void;
|
|
7
7
|
/** Writes a bold red message to stderr. */
|
|
8
8
|
export declare function boldError(message: string): void;
|
|
9
|
+
/** Writes a message to stderr without colouring it. */
|
|
10
|
+
export declare function note(message: string): void;
|
|
9
11
|
/** Text decorations used by the stylish formatter. */
|
|
10
12
|
export declare const style: {
|
|
11
13
|
gray: (text: string) => string;
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,sCAAsC;AACtC,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,sDAAsD;AACtD,eAAO,MAAM,KAAK;IAChB,IAAI,SAAS,MAAM,KAAG,MAAM;IAC5B,SAAS,SAAS,MAAM,KAAG,MAAM;IACjC,gFAAgF;IAChF,QAAQ,aAAa,MAAM,QAAQ,MAAM,KAAG,MAAM;CAEnD,CAAC"}
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,sCAAsC;AACtC,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,uDAAuD;AACvD,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,sDAAsD;AACtD,eAAO,MAAM,KAAK;IAChB,IAAI,SAAS,MAAM,KAAG,MAAM;IAC5B,SAAS,SAAS,MAAM,KAAG,MAAM;IACjC,gFAAgF;IAChF,QAAQ,aAAa,MAAM,QAAQ,MAAM,KAAG,MAAM;CAEnD,CAAC"}
|
package/dist/logger.js
CHANGED
|
@@ -18,6 +18,10 @@ export function error(message) {
|
|
|
18
18
|
export function boldError(message) {
|
|
19
19
|
console.error(paint(`${ESC}31m${ESC}1m`, message));
|
|
20
20
|
}
|
|
21
|
+
/** Writes a message to stderr without colouring it. */
|
|
22
|
+
export function note(message) {
|
|
23
|
+
console.error(message);
|
|
24
|
+
}
|
|
21
25
|
/** Text decorations used by the stylish formatter. */
|
|
22
26
|
export const style = {
|
|
23
27
|
gray: (text) => paint(`${ESC}38;5;243m`, text),
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;AAEzB,SAAS,QAAQ;IACf,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAA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