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/README.md
CHANGED
|
@@ -73,6 +73,7 @@ gurkencheck [options] <feature-files>
|
|
|
73
73
|
-i, --ignore <globs> comma separated globs to skip, overriding .gurkencheckignore
|
|
74
74
|
-r, --rulesdir <dir> directory of custom rules; may be given more than once
|
|
75
75
|
-l, --language <code> dialect for files with no "# language:" header
|
|
76
|
+
-w, --watch keep running, checking again whenever a file changes
|
|
76
77
|
-h, --help show this message
|
|
77
78
|
-v, --version show the version number
|
|
78
79
|
|
|
@@ -211,6 +212,24 @@ npx gurkencheck stats features --format json > stats.json
|
|
|
211
212
|
|
|
212
213
|
`--format md` writes the same report as Markdown tables, for pasting into a pull request.
|
|
213
214
|
|
|
215
|
+
## Watching for changes
|
|
216
|
+
|
|
217
|
+
`--watch` checks once, then again whenever a feature file or your configuration
|
|
218
|
+
changes, until you stop it with Ctrl-C.
|
|
219
|
+
|
|
220
|
+
```sh
|
|
221
|
+
npx gurkencheck --watch features
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Every pass is a whole run rather than an update of the last one. Rules that look
|
|
225
|
+
across files — two files sharing a name, a scenario name used twice — have to see
|
|
226
|
+
every file to know what they have found, so there is little to reuse between
|
|
227
|
+
passes, and keeping every parsed file in memory between keystrokes costs more
|
|
228
|
+
than reading them again.
|
|
229
|
+
|
|
230
|
+
Directories are watched rather than the files found at startup, so a feature file
|
|
231
|
+
created after it started is picked up too. `node_modules` and `.git` are skipped.
|
|
232
|
+
|
|
214
233
|
## Reporting to GitHub code scanning
|
|
215
234
|
|
|
216
235
|
`--format sarif` writes a SARIF 2.1.0 log, which GitHub reads directly:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-parser.d.ts","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAG5D,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAQzD,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAC3B;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GAC3E;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"config-parser.d.ts","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAG5D,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAQzD,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAC3B;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GAC3E;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC;AAoIpD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAqD9B"}
|
package/dist/config-parser.js
CHANGED
|
@@ -88,7 +88,13 @@ async function loadExtended(specifier, fromFile) {
|
|
|
88
88
|
if (resolved.endsWith('.json')) {
|
|
89
89
|
return { configuration: parseFile(resolved), source: resolved };
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
let module;
|
|
92
|
+
try {
|
|
93
|
+
module = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolved).href)));
|
|
94
|
+
}
|
|
95
|
+
catch (thrown) {
|
|
96
|
+
throw new ConfigurationError(`Could not load "${specifier}", extended from "${fromFile}": ${thrown instanceof Error ? thrown.message : String(thrown)}`);
|
|
97
|
+
}
|
|
92
98
|
const exported = module['default'] ?? module;
|
|
93
99
|
if (!isConfigurationObject(exported)) {
|
|
94
100
|
throw new ConfigurationError(`"${specifier}" does not export a configuration object.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-parser.js","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":";;;;;;;;AAAA;;GAEG;AACH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AE,UAAU,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAC,CAAC,EAAC,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a diagnostic is meant to read.
|
|
3
|
+
*
|
|
4
|
+
* `detail` is a line belonging with the error above it, which is why it is
|
|
5
|
+
* here rather than being left to the caller to indent.
|
|
6
|
+
*/
|
|
7
|
+
export type DiagnosticLevel = 'error' | 'detail' | 'notice';
|
|
8
|
+
export interface Diagnostic {
|
|
9
|
+
level: DiagnosticLevel;
|
|
10
|
+
message: string;
|
|
11
|
+
/** Lines listed under the message, such as what is wrong with a config. */
|
|
12
|
+
details?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** Where diagnostics go. */
|
|
15
|
+
export interface Diagnostics {
|
|
16
|
+
report(diagnostic: Diagnostic): void;
|
|
17
|
+
}
|
|
18
|
+
/** Says nothing at all. What the library does unless it is told otherwise. */
|
|
19
|
+
export declare const SILENT: Diagnostics;
|
|
20
|
+
export interface CollectedDiagnostics extends Diagnostics {
|
|
21
|
+
/** Everything reported so far, in order. */
|
|
22
|
+
readonly reported: readonly Diagnostic[];
|
|
23
|
+
}
|
|
24
|
+
/** Keeps what it is told, for a test or for something showing it later. */
|
|
25
|
+
export declare function collectDiagnostics(): CollectedDiagnostics;
|
|
26
|
+
/**
|
|
27
|
+
* Writes to stderr, the way the command line always has.
|
|
28
|
+
*
|
|
29
|
+
* Findings go to stdout so they can be redirected or piped; anything about
|
|
30
|
+
* the run itself goes to stderr, so piping the one does not swallow the
|
|
31
|
+
* other.
|
|
32
|
+
*/
|
|
33
|
+
export declare const TO_STDERR: Diagnostics;
|
|
34
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,4BAA4B;AAC5B,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;CACtC;AAED,8EAA8E;AAC9E,eAAO,MAAM,MAAM,EAAE,WAEpB,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CAC1C;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,IAAI,oBAAoB,CAQzD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,WAavB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saying something to whoever is running gurkencheck, without deciding where
|
|
3
|
+
* it goes.
|
|
4
|
+
*
|
|
5
|
+
* The README promises that nothing in the library writes to the console. That
|
|
6
|
+
* was true only by convention - no library entry point happened to call the
|
|
7
|
+
* logger - and not quite true even then, since `runStats` is exported and
|
|
8
|
+
* wrote straight to stderr. Reporting through here instead makes it hold by
|
|
9
|
+
* construction: the library says what happened, and the command line is what
|
|
10
|
+
* decides that goes to stderr in red.
|
|
11
|
+
*
|
|
12
|
+
* This is for things said *about* a run. What a run produces - the findings,
|
|
13
|
+
* the statistics - is the formatter's business and goes to stdout.
|
|
14
|
+
*/
|
|
15
|
+
import * as logger from './logger.js';
|
|
16
|
+
/** Says nothing at all. What the library does unless it is told otherwise. */
|
|
17
|
+
export const SILENT = {
|
|
18
|
+
report: () => undefined,
|
|
19
|
+
};
|
|
20
|
+
/** Keeps what it is told, for a test or for something showing it later. */
|
|
21
|
+
export function collectDiagnostics() {
|
|
22
|
+
const reported = [];
|
|
23
|
+
return {
|
|
24
|
+
reported,
|
|
25
|
+
report(diagnostic) {
|
|
26
|
+
reported.push(diagnostic);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Writes to stderr, the way the command line always has.
|
|
32
|
+
*
|
|
33
|
+
* Findings go to stdout so they can be redirected or piped; anything about
|
|
34
|
+
* the run itself goes to stderr, so piping the one does not swallow the
|
|
35
|
+
* other.
|
|
36
|
+
*/
|
|
37
|
+
export const TO_STDERR = {
|
|
38
|
+
report({ level, message, details }) {
|
|
39
|
+
if (level === 'error') {
|
|
40
|
+
logger.boldError(message);
|
|
41
|
+
}
|
|
42
|
+
else if (level === 'detail') {
|
|
43
|
+
logger.error(message);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
logger.note(message);
|
|
47
|
+
}
|
|
48
|
+
for (const detail of details ?? []) {
|
|
49
|
+
logger.error(`- ${detail}`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAsBtC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAgB;IACjC,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS;CACxB,CAAC;AAOF,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB;IAChC,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,OAAO;QACL,QAAQ;QACR,MAAM,CAAC,UAAsB;YAC3B,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgB;IACpC,MAAM,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAa;QAC1C,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;YACtB,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;aAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;YACnC,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/feature-finder.d.ts
CHANGED
|
@@ -8,6 +8,20 @@ export interface FeatureSearch {
|
|
|
8
8
|
/** Arguments that were neither a feature file, a directory nor a glob. */
|
|
9
9
|
invalidPatterns: string[];
|
|
10
10
|
}
|
|
11
|
+
export interface FeatureFileStream {
|
|
12
|
+
/**
|
|
13
|
+
* Matching feature files, found as the walk reaches them, in the order
|
|
14
|
+
* `findFeatureFiles` returns them in.
|
|
15
|
+
*/
|
|
16
|
+
files: AsyncGenerator<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Arguments that were neither a feature file, a directory nor a glob.
|
|
19
|
+
*
|
|
20
|
+
* Known before anything is walked, so a caller can give up on a bad
|
|
21
|
+
* argument without having searched for the good ones.
|
|
22
|
+
*/
|
|
23
|
+
invalidPatterns: string[];
|
|
24
|
+
}
|
|
11
25
|
/** Reads the ignore file, one glob pattern per line, ignoring blank lines. */
|
|
12
26
|
export declare function readIgnorePatterns(ignoreArgument: readonly string[] | undefined, ignoreFileName?: string): string[];
|
|
13
27
|
/**
|
|
@@ -15,4 +29,28 @@ export declare function readIgnorePatterns(ignoreArgument: readonly string[] | u
|
|
|
15
29
|
* working directory is searched recursively.
|
|
16
30
|
*/
|
|
17
31
|
export declare function findFeatureFiles(patterns: readonly string[], ignoreArgument?: readonly string[]): FeatureSearch;
|
|
32
|
+
/**
|
|
33
|
+
* The same search, handing each file over as it is found.
|
|
34
|
+
*
|
|
35
|
+
* Walking a large tree to the end before anything else starts is time in
|
|
36
|
+
* which nothing is read, parsed or checked. Handing files over as they turn
|
|
37
|
+
* up lets the rest of the work begin on the first one.
|
|
38
|
+
*
|
|
39
|
+
* Only a run given more than one pattern remembers what it has already
|
|
40
|
+
* handed over: one walk cannot reach the same file twice, and remembering is
|
|
41
|
+
* what a stream is trying to avoid.
|
|
42
|
+
*/
|
|
43
|
+
export declare function findFeatureFileStream(patterns: readonly string[], ignoreArgument?: readonly string[]): FeatureFileStream;
|
|
44
|
+
/**
|
|
45
|
+
* The directories a set of patterns could draw feature files from.
|
|
46
|
+
*
|
|
47
|
+
* What to watch, in other words. A directory rather than the files
|
|
48
|
+
* themselves, so that a file created after the run started is noticed too -
|
|
49
|
+
* watching only what was found would never hear about anything new.
|
|
50
|
+
*
|
|
51
|
+
* A directory inside another one in the list is dropped: a recursive watch on
|
|
52
|
+
* the parent already covers it, and two watches over one place would report
|
|
53
|
+
* every change twice.
|
|
54
|
+
*/
|
|
55
|
+
export declare function featureRoots(patterns: readonly string[]): string[];
|
|
18
56
|
//# sourceMappingURL=feature-finder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-finder.d.ts","sourceRoot":"","sources":["../src/feature-finder.ts"],"names":[],"mappings":"AASA,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,UAAsB,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,0EAA0E;IAC1E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
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { uniq } from './util/collections.js';
|
|
8
|
-
import { globSync } from './util/glob.js';
|
|
8
|
+
import { globRoot, globStream, globSync } from './util/glob.js';
|
|
9
9
|
/** The ignore file looked for when `--ignore` is not given. */
|
|
10
10
|
export const DEFAULT_IGNORE_FILE_NAME = '.gurkencheckignore';
|
|
11
11
|
/** Never worth linting, and expensive to walk into. */
|
|
@@ -39,14 +39,21 @@ export function readIgnorePatterns(ignoreArgument, ignoreFileName = DEFAULT_IGNO
|
|
|
39
39
|
if (ignoreArgument !== undefined && ignoreArgument.length > 0) {
|
|
40
40
|
return [...ignoreArgument];
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
let contents;
|
|
43
|
+
try {
|
|
44
|
+
contents = fs.readFileSync(ignoreFileName, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// No ignore file, or one that cannot be read: fall back to the defaults
|
|
48
|
+
// rather than stopping the run, so that node_modules stays skipped either
|
|
49
|
+
// way. Reading it outright rather than checking that it exists first also
|
|
50
|
+
// closes the gap between the two, in which it can be moved or removed.
|
|
51
|
+
return [...DEFAULT_IGNORED_PATTERNS];
|
|
48
52
|
}
|
|
49
|
-
return
|
|
53
|
+
return contents
|
|
54
|
+
.split(/\r\n|\r|\n/)
|
|
55
|
+
.map((line) => line.trim())
|
|
56
|
+
.filter((line) => line !== '' && !line.startsWith('#'));
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* Finds the feature files named by the given patterns. With no patterns, the
|
|
@@ -67,4 +74,75 @@ export function findFeatureFiles(patterns, ignoreArgument) {
|
|
|
67
74
|
}
|
|
68
75
|
return { files: uniq(files), invalidPatterns };
|
|
69
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The same search, handing each file over as it is found.
|
|
79
|
+
*
|
|
80
|
+
* Walking a large tree to the end before anything else starts is time in
|
|
81
|
+
* which nothing is read, parsed or checked. Handing files over as they turn
|
|
82
|
+
* up lets the rest of the work begin on the first one.
|
|
83
|
+
*
|
|
84
|
+
* Only a run given more than one pattern remembers what it has already
|
|
85
|
+
* handed over: one walk cannot reach the same file twice, and remembering is
|
|
86
|
+
* what a stream is trying to avoid.
|
|
87
|
+
*/
|
|
88
|
+
export function findFeatureFileStream(patterns, ignoreArgument) {
|
|
89
|
+
const searched = patterns.length > 0 ? patterns : ['.'];
|
|
90
|
+
const ignore = readIgnorePatterns(ignoreArgument);
|
|
91
|
+
const globs = [];
|
|
92
|
+
const invalidPatterns = [];
|
|
93
|
+
for (const pattern of searched) {
|
|
94
|
+
const featureGlob = toFeatureGlob(pattern);
|
|
95
|
+
if (featureGlob === undefined) {
|
|
96
|
+
invalidPatterns.push(pattern);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
globs.push(featureGlob);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function* files() {
|
|
103
|
+
const seen = globs.length > 1 ? new Set() : undefined;
|
|
104
|
+
for (const featureGlob of globs) {
|
|
105
|
+
for await (const file of globStream(featureGlob, { ignore })) {
|
|
106
|
+
if (seen !== undefined) {
|
|
107
|
+
if (seen.has(file))
|
|
108
|
+
continue;
|
|
109
|
+
seen.add(file);
|
|
110
|
+
}
|
|
111
|
+
yield file;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { files: files(), invalidPatterns };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The directories a set of patterns could draw feature files from.
|
|
119
|
+
*
|
|
120
|
+
* What to watch, in other words. A directory rather than the files
|
|
121
|
+
* themselves, so that a file created after the run started is noticed too -
|
|
122
|
+
* watching only what was found would never hear about anything new.
|
|
123
|
+
*
|
|
124
|
+
* A directory inside another one in the list is dropped: a recursive watch on
|
|
125
|
+
* the parent already covers it, and two watches over one place would report
|
|
126
|
+
* every change twice.
|
|
127
|
+
*/
|
|
128
|
+
export function featureRoots(patterns) {
|
|
129
|
+
const searched = patterns.length > 0 ? patterns : ['.'];
|
|
130
|
+
const roots = new Set();
|
|
131
|
+
for (const pattern of searched) {
|
|
132
|
+
const featureGlob = toFeatureGlob(pattern);
|
|
133
|
+
if (featureGlob !== undefined) {
|
|
134
|
+
roots.add(globRoot(featureGlob));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Shorter paths sort first, so a parent is always seen before its children.
|
|
138
|
+
const sorted = [...roots].sort();
|
|
139
|
+
const kept = [];
|
|
140
|
+
for (const root of sorted) {
|
|
141
|
+
const covered = kept.some((parent) => root === parent || root.startsWith(`${parent}${path.sep}`));
|
|
142
|
+
if (!covered) {
|
|
143
|
+
kept.push(root);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return kept;
|
|
147
|
+
}
|
|
70
148
|
//# sourceMappingURL=feature-finder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-finder.js","sourceRoot":"","sources":["../src/feature-finder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"feature-finder.js","sourceRoot":"","sources":["../src/feature-finder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG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EAAU,CAAC;IAEhC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CACvB,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CACvE,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -9,15 +9,55 @@ export type Formatter = (results: readonly FileResult[]) => void | string | Prom
|
|
|
9
9
|
/** The formats accepted by `--format` without having to be loaded. */
|
|
10
10
|
export declare const FORMATTERS: Record<string, Formatter>;
|
|
11
11
|
export declare const DEFAULT_FORMAT = "stylish";
|
|
12
|
+
/**
|
|
13
|
+
* A formatter writing as the results arrive, rather than once they are all
|
|
14
|
+
* in.
|
|
15
|
+
*
|
|
16
|
+
* Text comes back written verbatim, line breaks included, so a formatter says
|
|
17
|
+
* exactly what goes on the stream. `start` and `end` are optional: a format
|
|
18
|
+
* with no preamble and no trailer needs neither.
|
|
19
|
+
*/
|
|
20
|
+
export interface FormatterRun {
|
|
21
|
+
/** Written before the first result. */
|
|
22
|
+
start?(): string;
|
|
23
|
+
/** Written for one file, as soon as that file is done. */
|
|
24
|
+
file(result: FileResult): string;
|
|
25
|
+
/** Written after the last result. */
|
|
26
|
+
end?(): string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Starts one run of a streaming formatter.
|
|
30
|
+
*
|
|
31
|
+
* A factory rather than an object, so counters and the like belong to a run
|
|
32
|
+
* and two at once cannot tread on each other.
|
|
33
|
+
*/
|
|
34
|
+
export type StreamingFormatter = () => FormatterRun;
|
|
35
|
+
/**
|
|
36
|
+
* The formats that can be written as the run goes on.
|
|
37
|
+
*
|
|
38
|
+
* Not every format can. json, sarif and junit are each a single document with
|
|
39
|
+
* a root element and counts over the whole run, so there is nothing to write
|
|
40
|
+
* until the run is over; they stay as they are rather than being bent into a
|
|
41
|
+
* shape that does not suit them.
|
|
42
|
+
*/
|
|
43
|
+
export declare const STREAMING_FORMATTERS: Record<string, StreamingFormatter>;
|
|
44
|
+
/** The streaming formatter for a format name, when that format has one. */
|
|
45
|
+
export declare function getStreamingFormatter(format: string | undefined): StreamingFormatter | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The streaming formatter for a name, a path or a package, when there is one.
|
|
48
|
+
*
|
|
49
|
+
* A formatter of your own joins in by exporting `startRun`, a function
|
|
50
|
+
* returning `{start?, file, end?}`. Without one it is used as it always was,
|
|
51
|
+
* with the whole run at once.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadStreamingFormatter(format: string | undefined, cwd?: string): Promise<StreamingFormatter | undefined>;
|
|
12
54
|
/** The formatter for a built-in format name, or `undefined` for anything else. */
|
|
13
55
|
export declare function getFormatter(format: string | undefined): Formatter | undefined;
|
|
14
56
|
/**
|
|
15
57
|
* The formatter for a format name, a path, or a package.
|
|
16
58
|
*
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
19
|
-
* path means what it looks like. The module may export the formatter as its
|
|
20
|
-
* default export, as `printResults`, or be the function itself.
|
|
59
|
+
* The module may export the formatter as its default export, as
|
|
60
|
+
* `printResults`, or be the function itself.
|
|
21
61
|
*/
|
|
22
62
|
export declare function loadFormatter(format: string | undefined, cwd?: string): Promise<Formatter>;
|
|
23
63
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,OAAO,EAAE,SAAS,UAAU,EAAE,KAC3B,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;AAE5C,sEAAsE;AACtE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAQhD,CAAC;AAEF,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAE9E;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,OAAO,EAAE,SAAS,UAAU,EAAE,KAC3B,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;AAE5C,sEAAsE;AACtE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAQhD,CAAC;AAEF,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,KAAK,CAAC,IAAI,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IACjC,qCAAqC;IACrC,GAAG,CAAC,IAAI,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAGnE,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CASzC;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAE9E;AAwCD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,SAAS,CAAC,CAiBpB"}
|
package/dist/formatters/index.js
CHANGED
|
@@ -15,8 +15,8 @@ import { pathToFileURL } from 'node:url';
|
|
|
15
15
|
import { printResults as json } from './json.js';
|
|
16
16
|
import { printResults as junit } from './junit.js';
|
|
17
17
|
import { printResults as sarif } from './sarif.js';
|
|
18
|
-
import { printResults as stylish } from './stylish.js';
|
|
19
|
-
import { printResults as tap } from './tap.js';
|
|
18
|
+
import { printResults as stylish, startRun as streamStylish } from './stylish.js';
|
|
19
|
+
import { printResults as tap, startRun as streamTap } from './tap.js';
|
|
20
20
|
/** The formats accepted by `--format` without having to be loaded. */
|
|
21
21
|
export const FORMATTERS = {
|
|
22
22
|
stylish,
|
|
@@ -28,6 +28,38 @@ export const FORMATTERS = {
|
|
|
28
28
|
xunit: junit,
|
|
29
29
|
};
|
|
30
30
|
export const DEFAULT_FORMAT = 'stylish';
|
|
31
|
+
/**
|
|
32
|
+
* The formats that can be written as the run goes on.
|
|
33
|
+
*
|
|
34
|
+
* Not every format can. json, sarif and junit are each a single document with
|
|
35
|
+
* a root element and counts over the whole run, so there is nothing to write
|
|
36
|
+
* until the run is over; they stay as they are rather than being bent into a
|
|
37
|
+
* shape that does not suit them.
|
|
38
|
+
*/
|
|
39
|
+
export const STREAMING_FORMATTERS = {
|
|
40
|
+
stylish: streamStylish,
|
|
41
|
+
tap: streamTap,
|
|
42
|
+
};
|
|
43
|
+
/** The streaming formatter for a format name, when that format has one. */
|
|
44
|
+
export function getStreamingFormatter(format) {
|
|
45
|
+
return STREAMING_FORMATTERS[format ?? DEFAULT_FORMAT];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The streaming formatter for a name, a path or a package, when there is one.
|
|
49
|
+
*
|
|
50
|
+
* A formatter of your own joins in by exporting `startRun`, a function
|
|
51
|
+
* returning `{start?, file, end?}`. Without one it is used as it always was,
|
|
52
|
+
* with the whole run at once.
|
|
53
|
+
*/
|
|
54
|
+
export async function loadStreamingFormatter(format, cwd = process.cwd()) {
|
|
55
|
+
const builtIn = getStreamingFormatter(format);
|
|
56
|
+
if (builtIn !== undefined || getFormatter(format) !== undefined) {
|
|
57
|
+
return builtIn;
|
|
58
|
+
}
|
|
59
|
+
const module = await loadFormatterModule(format, cwd);
|
|
60
|
+
const startRun = module['startRun'];
|
|
61
|
+
return typeof startRun === 'function' ? startRun : undefined;
|
|
62
|
+
}
|
|
31
63
|
/** The formatter for a built-in format name, or `undefined` for anything else. */
|
|
32
64
|
export function getFormatter(format) {
|
|
33
65
|
return FORMATTERS[format ?? DEFAULT_FORMAT];
|
|
@@ -36,19 +68,11 @@ function asFormatter(candidate) {
|
|
|
36
68
|
return typeof candidate === 'function' ? candidate : undefined;
|
|
37
69
|
}
|
|
38
70
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Anything that is not a built-in name is loaded as a module, resolved from
|
|
71
|
+
* Loads the module behind a format that is not a built-in name, resolved from
|
|
42
72
|
* `cwd` so that a formatter installed in the project is found and a relative
|
|
43
|
-
* path means what it looks like.
|
|
44
|
-
* default export, as `printResults`, or be the function itself.
|
|
73
|
+
* path means what it looks like.
|
|
45
74
|
*/
|
|
46
|
-
|
|
47
|
-
const builtIn = getFormatter(format);
|
|
48
|
-
if (builtIn !== undefined) {
|
|
49
|
-
return builtIn;
|
|
50
|
-
}
|
|
51
|
-
const specifier = format;
|
|
75
|
+
async function loadFormatterModule(specifier, cwd) {
|
|
52
76
|
const from = path.join(path.resolve(cwd), 'noop.js');
|
|
53
77
|
let resolved;
|
|
54
78
|
if (specifier.startsWith('.') || path.isAbsolute(specifier)) {
|
|
@@ -63,13 +87,26 @@ export async function loadFormatter(format, cwd = process.cwd()) {
|
|
|
63
87
|
'or the path to a formatter of your own.');
|
|
64
88
|
}
|
|
65
89
|
}
|
|
66
|
-
let module;
|
|
67
90
|
try {
|
|
68
|
-
|
|
91
|
+
return (await import(__rewriteRelativeImportExtension(pathToFileURL(resolved).href)));
|
|
69
92
|
}
|
|
70
93
|
catch (thrown) {
|
|
71
94
|
throw new Error(`Could not load the formatter "${specifier}": ${thrown instanceof Error ? thrown.message : String(thrown)}`);
|
|
72
95
|
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The formatter for a format name, a path, or a package.
|
|
99
|
+
*
|
|
100
|
+
* The module may export the formatter as its default export, as
|
|
101
|
+
* `printResults`, or be the function itself.
|
|
102
|
+
*/
|
|
103
|
+
export async function loadFormatter(format, cwd = process.cwd()) {
|
|
104
|
+
const builtIn = getFormatter(format);
|
|
105
|
+
if (builtIn !== undefined) {
|
|
106
|
+
return builtIn;
|
|
107
|
+
}
|
|
108
|
+
const specifier = format;
|
|
109
|
+
const module = await loadFormatterModule(specifier, cwd);
|
|
73
110
|
const formatter = asFormatter(module['default']) ?? asFormatter(module['printResults']) ?? asFormatter(module);
|
|
74
111
|
if (formatter === undefined) {
|
|
75
112
|
throw new Error(`"${specifier}" does not export a formatter. A formatter module exports a function taking the results.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":";;;;;;;;AAAA;;GAEG;AACH,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,YAAY,IAAI,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAC,YAAY,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,YAAY,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,YAAY,IAAI,OAAO,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":";;;;;;;;AAAA;;GAEG;AACH,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,YAAY,IAAI,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAC,YAAY,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,YAAY,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,YAAY,IAAI,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,YAAY,IAAI,GAAG,EAAE,QAAQ,IAAI,SAAS,EAAC,MAAM,UAAU,CAAC;AAYpE,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAA8B;IACnD,OAAO;IACP,I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M,SAAS,GAAG,MAAO,CAAC;IAC1B,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAEzD,MAAM,SAAS,GACb,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/F,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,IAAI,SAAS,0FAA0F,CACxG,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { FormatterRun } from './index.ts';
|
|
1
2
|
import type { FileResult } from '../types.ts';
|
|
3
|
+
/** Blocks written as each file is done rather than at the end of the run. */
|
|
4
|
+
export declare function startRun(): FormatterRun;
|
|
2
5
|
/**
|
|
3
6
|
* Human readable output, one block per file with findings.
|
|
4
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylish.d.ts","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAY,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"stylish.d.ts","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAC,UAAU,EAAY,MAAM,aAAa,CAAC;AAqFvD,6EAA6E;AAC7E,wBAAgB,QAAQ,IAAI,YAAY,CAKvC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAiBjE"}
|
|
@@ -42,6 +42,37 @@ function messageColumnWidth(result, lineWidth, consoleWidth) {
|
|
|
42
42
|
return Math.max(widest, error.message.length);
|
|
43
43
|
}, 0);
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* One file's block, or nothing when the file is clean.
|
|
47
|
+
*
|
|
48
|
+
* The columns are lined up within a file rather than across the whole run, so
|
|
49
|
+
* a block only ever needed that one file's findings - which means it can be
|
|
50
|
+
* written the moment the file is done, with the output byte for byte what it
|
|
51
|
+
* always was.
|
|
52
|
+
*/
|
|
53
|
+
function block(result, consoleWidth) {
|
|
54
|
+
if (result.errors.length === 0) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
const lineWidth = widestLineNumber(result);
|
|
58
|
+
const messageWidth = messageColumnWidth(result, lineWidth, consoleWidth);
|
|
59
|
+
const lines = [
|
|
60
|
+
style.underline(result.filePath),
|
|
61
|
+
...result.errors.map((error) => formatError(error, lineWidth, messageWidth, true)),
|
|
62
|
+
];
|
|
63
|
+
// A blank line between blocks, as printing '\n' with console.log gave.
|
|
64
|
+
return `${lines.join('\n')}\n\n\n`;
|
|
65
|
+
}
|
|
66
|
+
function widthOfConsole() {
|
|
67
|
+
return process.stdout.isTTY ? process.stdout.columns : Infinity;
|
|
68
|
+
}
|
|
69
|
+
/** Blocks written as each file is done rather than at the end of the run. */
|
|
70
|
+
export function startRun() {
|
|
71
|
+
const consoleWidth = widthOfConsole();
|
|
72
|
+
return {
|
|
73
|
+
file: (result) => block(result, consoleWidth),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
45
76
|
/**
|
|
46
77
|
* Human readable output, one block per file with findings.
|
|
47
78
|
*
|
|
@@ -49,7 +80,7 @@ function messageColumnWidth(result, lineWidth, consoleWidth) {
|
|
|
49
80
|
* stops the linter running is written to stderr instead.
|
|
50
81
|
*/
|
|
51
82
|
export function printResults(results) {
|
|
52
|
-
const consoleWidth =
|
|
83
|
+
const consoleWidth = widthOfConsole();
|
|
53
84
|
for (const result of results) {
|
|
54
85
|
if (result.errors.length === 0) {
|
|
55
86
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAInC,kEAAkE;AAClE,SAAS,QAAQ,CAAC,KAAgB;IAChC,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;AAC3F,CAAC;AAED,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,KAAgB,EAChB,SAAiB,EACjB,YAAoB,EACpB,QAAiB;IAEjB,MAAM,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,GAAG,GAAG,MAAM,CAAC;IACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/C,oEAAoE;IACpE,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,CACL,MAAM;QACN,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACpC,GAAG;QACH,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnE,GAAG;QACH,KAAK,CAAC,OAAO,C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