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/rules.js
CHANGED
|
@@ -39,7 +39,13 @@ async function loadRulesFrom(directory) {
|
|
|
39
39
|
const loaded = [];
|
|
40
40
|
for (const file of files) {
|
|
41
41
|
const absolute = path.join(resolved, file);
|
|
42
|
-
|
|
42
|
+
let module;
|
|
43
|
+
try {
|
|
44
|
+
module = (await import(__rewriteRelativeImportExtension(pathToFileURL(absolute).href)));
|
|
45
|
+
}
|
|
46
|
+
catch (thrown) {
|
|
47
|
+
throw new Error(`Could not load the rule "${absolute}": ${thrown instanceof Error ? thrown.message : String(thrown)}`);
|
|
48
|
+
}
|
|
43
49
|
loaded.push(extractRule(module, absolute));
|
|
44
50
|
}
|
|
45
51
|
return loaded;
|
|
@@ -77,20 +83,106 @@ export function getRuleSeverity(config) {
|
|
|
77
83
|
export function getRuleSettings(config) {
|
|
78
84
|
return Array.isArray(config) ? config[1] : undefined;
|
|
79
85
|
}
|
|
80
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Clears the state kept by rules that look for duplicates across files.
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Use `beginRun`, which does this and hands each rule a context
|
|
90
|
+
* of its own besides.
|
|
91
|
+
*/
|
|
81
92
|
export function resetRules(rules) {
|
|
82
93
|
for (const rule of rules.values()) {
|
|
83
94
|
rule.reset?.();
|
|
84
95
|
}
|
|
85
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* One rule's state for one run, made the first time the rule asks for it.
|
|
99
|
+
*
|
|
100
|
+
* Exported because testing a rule on its own means handing it one of these.
|
|
101
|
+
*/
|
|
102
|
+
export function newRunContext() {
|
|
103
|
+
let state;
|
|
104
|
+
let made = false;
|
|
105
|
+
return {
|
|
106
|
+
state(create) {
|
|
107
|
+
if (!made) {
|
|
108
|
+
state = create();
|
|
109
|
+
made = true;
|
|
110
|
+
}
|
|
111
|
+
return state;
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Starts a run, telling every enabled rule that one is beginning. */
|
|
116
|
+
export function beginRun(rules, configuration) {
|
|
117
|
+
// Rules written before contexts existed keep their state in the module and
|
|
118
|
+
// clear it here. Deprecated, but still honoured.
|
|
119
|
+
resetRules(rules);
|
|
120
|
+
const contexts = new Map();
|
|
121
|
+
const run = {
|
|
122
|
+
contextFor(ruleName) {
|
|
123
|
+
let context = contexts.get(ruleName);
|
|
124
|
+
if (context === undefined) {
|
|
125
|
+
context = newRunContext();
|
|
126
|
+
contexts.set(ruleName, context);
|
|
127
|
+
}
|
|
128
|
+
return context;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
for (const rule of rules.values()) {
|
|
132
|
+
const config = configuration[rule.name];
|
|
133
|
+
if (isRuleEnabled(config)) {
|
|
134
|
+
rule.onRunStart?.(getRuleSettings(config), run.contextFor(rule.name));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return run;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Ends a run, collecting what could only be worked out once every file had
|
|
141
|
+
* been seen.
|
|
142
|
+
*
|
|
143
|
+
* As while checking a file, a rule that throws costs you its own findings
|
|
144
|
+
* rather than everyone else's.
|
|
145
|
+
*/
|
|
146
|
+
export async function finishRun(rules, configuration, run) {
|
|
147
|
+
const findings = [];
|
|
148
|
+
for (const rule of rules.values()) {
|
|
149
|
+
const config = configuration[rule.name];
|
|
150
|
+
if (!isRuleEnabled(config) || rule.onRunEnd === undefined) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const severity = getRuleSeverity(config);
|
|
154
|
+
try {
|
|
155
|
+
const found = await rule.onRunEnd(getRuleSettings(config), run.contextFor(rule.name));
|
|
156
|
+
for (const finding of found) {
|
|
157
|
+
findings.push({ severity, ...finding });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (thrown) {
|
|
161
|
+
// No file to blame: what failed was the look back over all of them.
|
|
162
|
+
findings.push({
|
|
163
|
+
message: `Rule "${rule.name}" failed at the end of the run: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
164
|
+
rule: 'unexpected-error',
|
|
165
|
+
line: 0,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return findings;
|
|
170
|
+
}
|
|
86
171
|
/**
|
|
87
172
|
* Runs every enabled rule against one feature file.
|
|
88
173
|
*
|
|
89
174
|
* Rules are awaited one at a time. Most return an array outright, in which
|
|
90
175
|
* case awaiting costs nothing; a rule that needs to wait for something can
|
|
91
176
|
* return a promise instead.
|
|
177
|
+
*
|
|
178
|
+
* A rule that throws is reported as an `unexpected-error` finding naming it,
|
|
179
|
+
* and the remaining rules still run.
|
|
180
|
+
*
|
|
181
|
+
* `run` carries the state the rules keep between the files of one run. Left
|
|
182
|
+
* out, a run of this one file alone is started, which is what a caller
|
|
183
|
+
* checking a single file wants.
|
|
92
184
|
*/
|
|
93
|
-
export async function runEnabledRules(feature, file, configuration, rules) {
|
|
185
|
+
export async function runEnabledRules(feature, file, configuration, rules, run = beginRun(rules, configuration)) {
|
|
94
186
|
const errors = [];
|
|
95
187
|
for (const rule of rules.values()) {
|
|
96
188
|
const config = configuration[rule.name];
|
|
@@ -98,7 +190,23 @@ export async function runEnabledRules(feature, file, configuration, rules) {
|
|
|
98
190
|
continue;
|
|
99
191
|
}
|
|
100
192
|
const severity = getRuleSeverity(config);
|
|
101
|
-
|
|
193
|
+
let found;
|
|
194
|
+
try {
|
|
195
|
+
found = await rule.run(feature, file, getRuleSettings(config), run.contextFor(rule.name));
|
|
196
|
+
}
|
|
197
|
+
catch (thrown) {
|
|
198
|
+
// A rule that throws - one of your own from --rulesdir, or a built-in
|
|
199
|
+
// one meeting a file it did not expect - costs you that rule's findings
|
|
200
|
+
// for this file, not every other rule's. The failure is reported in
|
|
201
|
+
// their place so that it cannot pass unnoticed.
|
|
202
|
+
errors.push({
|
|
203
|
+
message: `Rule "${rule.name}" failed: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
204
|
+
rule: 'unexpected-error',
|
|
205
|
+
line: 0,
|
|
206
|
+
});
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
for (const error of found) {
|
|
102
210
|
// The configuration decides how loudly a rule reports, so a custom rule
|
|
103
211
|
// needs no say in it - but one that sets a severity itself is respected.
|
|
104
212
|
errors.push({ severity, ...error });
|
package/dist/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":";;;;;;;;AAAA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B,CAAC;QACvB,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CACpB,OAAO,EACP,IAAI,EACJ,eAAe,CAAC,MAAM,CAAC,EACvB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAC1B,CAAC;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,sEAAsE;YACtE,wEAAwE;YACxE,oEAAoE;YACpE,gDAAgD;YAChD,MAAM,CAAC,IAAI,CAAC;gBACV,OAAO,EAAE,SAAS,IAAI,CAAC,IAAI,aAAa,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACnG,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,CAAC;aACR,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;YAC1B,wEAAwE;YACxE,yEAAyE;YACzE,MAAM,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/stats/collect.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ParseResult } from '../gherkin/parse.ts';
|
|
2
2
|
import type { SimilarityOptions } from './similar.ts';
|
|
3
|
+
import type { Sequence } from '../util/stream.ts';
|
|
3
4
|
import type { Distribution, Statistics } from './types.ts';
|
|
4
5
|
export interface CollectOptions {
|
|
5
6
|
/** How alike two steps have to be to be reported as nearly the same. */
|
|
@@ -20,4 +21,11 @@ export declare function distribution(values: readonly number[]): Distribution;
|
|
|
20
21
|
* is worse than none of it, because the numbers would quietly be wrong.
|
|
21
22
|
*/
|
|
22
23
|
export declare function collectStatistics(parsed: readonly ParseResult[], options?: CollectOptions): Statistics;
|
|
24
|
+
/**
|
|
25
|
+
* The same count, over files arriving one at a time.
|
|
26
|
+
*
|
|
27
|
+
* Nothing here holds on to a parsed document once it has been counted, so a
|
|
28
|
+
* suite of any size costs the same as the report it produces.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collectStatisticsFrom(parsed: Sequence<ParseResult>, options?: CollectOptions): Promise<Statistics>;
|
|
23
31
|
//# sourceMappingURL=collect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/stats/collect.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAWrD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EAMZ,UAAU,EAGX,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAkBpE;
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/stats/collect.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAWrD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EACV,YAAY,EAMZ,UAAU,EAGX,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAkBpE;AAgRD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,GAAE,cAAmB,GAC3B,UAAU,CAMZ;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC7B,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAMrB"}
|
package/dist/stats/collect.js
CHANGED
|
@@ -40,7 +40,7 @@ function testCases(scenario) {
|
|
|
40
40
|
}
|
|
41
41
|
return scenario.examples.reduce((total, examples) => total + examples.tableBody.length, 0);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function tallyOne(counts, key) {
|
|
44
44
|
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
45
45
|
}
|
|
46
46
|
/** Most used first, and alphabetically within an equal count. */
|
|
@@ -122,17 +122,11 @@ function collectFile(feature, file, into) {
|
|
|
122
122
|
}
|
|
123
123
|
for (const { node } of taggedNodesOf(feature)) {
|
|
124
124
|
for (const tag of node.tags) {
|
|
125
|
-
|
|
125
|
+
tallyOne(into.tags, tag.name);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
* Counts a set of parsed feature files.
|
|
131
|
-
*
|
|
132
|
-
* Files the parser refused are listed rather than counted: half a broken file
|
|
133
|
-
* is worse than none of it, because the numbers would quietly be wrong.
|
|
134
|
-
*/
|
|
135
|
-
export function collectStatistics(parsed, options = {}) {
|
|
129
|
+
function newTally() {
|
|
136
130
|
const inventory = {
|
|
137
131
|
features: 0,
|
|
138
132
|
rules: 0,
|
|
@@ -145,35 +139,45 @@ export function collectStatistics(parsed, options = {}) {
|
|
|
145
139
|
dataTables: 0,
|
|
146
140
|
docStrings: 0,
|
|
147
141
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
142
|
+
return {
|
|
143
|
+
into: {
|
|
144
|
+
inventory,
|
|
145
|
+
steps: new Map(),
|
|
146
|
+
keywords: { given: 0, when: 0, then: 0, other: 0 },
|
|
147
|
+
stepWords: [],
|
|
148
|
+
stepsPerScenario: [],
|
|
149
|
+
scenarios: [],
|
|
150
|
+
tags: new Map(),
|
|
151
|
+
effective: 0,
|
|
152
|
+
untagged: 0,
|
|
153
|
+
},
|
|
154
|
+
unreadable: [],
|
|
155
|
+
languages: new Map(),
|
|
156
|
+
readable: 0,
|
|
157
|
+
total: 0,
|
|
158
158
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
readable += 1;
|
|
170
|
-
// An empty file parses without complaint and holds nothing to count.
|
|
171
|
-
if (result.feature === undefined) {
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
tally(languages, result.feature.language);
|
|
175
|
-
collectFile(result.feature, file, into);
|
|
159
|
+
}
|
|
160
|
+
/** Counts one file into the tally. */
|
|
161
|
+
function absorb(tally, result) {
|
|
162
|
+
tally.total += 1;
|
|
163
|
+
const file = result.file.relativePath;
|
|
164
|
+
const failure = result.errors[0];
|
|
165
|
+
if (failure !== undefined) {
|
|
166
|
+
tally.unreadable.push({ file, reason: failure.message, line: failure.line });
|
|
167
|
+
return;
|
|
176
168
|
}
|
|
169
|
+
tally.readable += 1;
|
|
170
|
+
// An empty file parses without complaint and holds nothing to count.
|
|
171
|
+
if (result.feature === undefined) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
tallyOne(tally.languages, result.feature.language);
|
|
175
|
+
collectFile(result.feature, file, tally.into);
|
|
176
|
+
}
|
|
177
|
+
/** Turns the running totals into the report. */
|
|
178
|
+
function summarise(tally, options) {
|
|
179
|
+
const { into, unreadable, languages } = tally;
|
|
180
|
+
const { inventory } = into;
|
|
177
181
|
const vocabulary = [...into.steps]
|
|
178
182
|
.map(([text, sighting]) => ({ text, ...sighting }))
|
|
179
183
|
.sort(byCountThenName((entry) => entry.text));
|
|
@@ -187,7 +191,7 @@ export function collectStatistics(parsed, options = {}) {
|
|
|
187
191
|
.map(([name, count]) => ({ name, count }))
|
|
188
192
|
.sort(byCountThenName((entry) => entry.name));
|
|
189
193
|
return {
|
|
190
|
-
files: { total:
|
|
194
|
+
files: { total: tally.total, parsed: tally.readable, unreadable },
|
|
191
195
|
inventory,
|
|
192
196
|
scenarios: {
|
|
193
197
|
effective: into.effective,
|
|
@@ -216,4 +220,30 @@ export function collectStatistics(parsed, options = {}) {
|
|
|
216
220
|
.sort((a, b) => b.files - a.files || (a.code < b.code ? -1 : 1)),
|
|
217
221
|
};
|
|
218
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Counts a set of parsed feature files.
|
|
225
|
+
*
|
|
226
|
+
* Files the parser refused are listed rather than counted: half a broken file
|
|
227
|
+
* is worse than none of it, because the numbers would quietly be wrong.
|
|
228
|
+
*/
|
|
229
|
+
export function collectStatistics(parsed, options = {}) {
|
|
230
|
+
const tally = newTally();
|
|
231
|
+
for (const result of parsed) {
|
|
232
|
+
absorb(tally, result);
|
|
233
|
+
}
|
|
234
|
+
return summarise(tally, options);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The same count, over files arriving one at a time.
|
|
238
|
+
*
|
|
239
|
+
* Nothing here holds on to a parsed document once it has been counted, so a
|
|
240
|
+
* suite of any size costs the same as the report it produces.
|
|
241
|
+
*/
|
|
242
|
+
export async function collectStatisticsFrom(parsed, options = {}) {
|
|
243
|
+
const tally = newTally();
|
|
244
|
+
for await (const result of parsed) {
|
|
245
|
+
absorb(tally, result);
|
|
246
|
+
}
|
|
247
|
+
return summarise(tally, options);
|
|
248
|
+
}
|
|
219
249
|
//# sourceMappingURL=collect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../src/stats/collect.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../src/stats/collect.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAoB9D;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC;IAChE,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAU,EAAE,CACxC,MAAM,CAAC,IAAI,CAAC,GAAG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E,CAAC;QAC5B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAA6B,EAC7B,OAAO,GAAmB,EAAE;IAE5B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/stats/command.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Diagnostics } from '../diagnostics.ts';
|
|
1
2
|
export declare function statsUsage(): string;
|
|
2
|
-
export declare function runStats(argv: readonly string[]): Promise<number>;
|
|
3
|
+
export declare function runStats(argv: readonly string[], diagnostics?: Diagnostics): Promise<number>;
|
|
3
4
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/stats/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/stats/command.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AASnD,wBAAgB,UAAU,IAAI,MAAM,CAmBnC;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,WAAW,GAAE,WAAoB,GAChC,OAAO,CAAC,MAAM,CAAC,CAmFjB"}
|
package/dist/stats/command.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { parseArgs } from 'node:util';
|
|
10
10
|
import { EXIT_OK, EXIT_USAGE } from '../exit-codes.js';
|
|
11
|
-
import { DEFAULT_IGNORE_FILE_NAME,
|
|
11
|
+
import { DEFAULT_IGNORE_FILE_NAME, findFeatureFileStream } from '../feature-finder.js';
|
|
12
12
|
import { isKnownLanguage } from '../gherkin/dialects.js';
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
13
|
+
import { readAndParseFiles } from '../gherkin/parse.js';
|
|
14
|
+
import { SILENT } from '../diagnostics.js';
|
|
15
|
+
import { collectStatisticsFrom } from './collect.js';
|
|
16
16
|
import { DEFAULT_STATS_FORMAT, DEFAULT_TOP, STATS_FORMATTERS, getStatsFormatter, } from './format/index.js';
|
|
17
17
|
export function statsUsage() {
|
|
18
18
|
return [
|
|
@@ -34,26 +34,7 @@ export function statsUsage() {
|
|
|
34
34
|
'rather than judging them. Use the linter itself to fail a build.',
|
|
35
35
|
].join('\n');
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
async function read(file, language) {
|
|
39
|
-
try {
|
|
40
|
-
return await readAndParseFile(file, language);
|
|
41
|
-
}
|
|
42
|
-
catch (thrown) {
|
|
43
|
-
return {
|
|
44
|
-
file: { relativePath: file, lines: [] },
|
|
45
|
-
feature: undefined,
|
|
46
|
-
errors: [
|
|
47
|
-
{
|
|
48
|
-
message: thrown instanceof Error ? thrown.message : String(thrown),
|
|
49
|
-
rule: 'unexpected-error',
|
|
50
|
-
line: 0,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export async function runStats(argv) {
|
|
37
|
+
export async function runStats(argv, diagnostics = SILENT) {
|
|
57
38
|
let parsed;
|
|
58
39
|
try {
|
|
59
40
|
parsed = parseArgs({
|
|
@@ -69,8 +50,11 @@ export async function runStats(argv) {
|
|
|
69
50
|
});
|
|
70
51
|
}
|
|
71
52
|
catch (thrown) {
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
diagnostics.report({
|
|
54
|
+
level: 'error',
|
|
55
|
+
message: thrown instanceof Error ? thrown.message : String(thrown),
|
|
56
|
+
});
|
|
57
|
+
diagnostics.report({ level: 'notice', message: statsUsage() });
|
|
74
58
|
return EXIT_USAGE;
|
|
75
59
|
}
|
|
76
60
|
const { values, positionals } = parsed;
|
|
@@ -80,33 +64,49 @@ export async function runStats(argv) {
|
|
|
80
64
|
}
|
|
81
65
|
const formatter = getStatsFormatter(values.format);
|
|
82
66
|
if (formatter === undefined) {
|
|
83
|
-
|
|
67
|
+
diagnostics.report({
|
|
68
|
+
level: 'error',
|
|
69
|
+
message: `Unsupported format "${values.format}". Use one of ${Object.keys(STATS_FORMATTERS).join(', ')}.`,
|
|
70
|
+
});
|
|
84
71
|
return EXIT_USAGE;
|
|
85
72
|
}
|
|
86
73
|
let top = DEFAULT_TOP;
|
|
87
74
|
if (values.top !== undefined) {
|
|
88
75
|
top = Number(values.top);
|
|
89
76
|
if (!Number.isInteger(top) || top < 1) {
|
|
90
|
-
|
|
77
|
+
diagnostics.report({
|
|
78
|
+
level: 'error',
|
|
79
|
+
message: `--top needs a whole number of at least 1, not "${values.top}".`,
|
|
80
|
+
});
|
|
91
81
|
return EXIT_USAGE;
|
|
92
82
|
}
|
|
93
83
|
}
|
|
94
84
|
const language = values.language;
|
|
95
85
|
if (language !== undefined && !isKnownLanguage(language)) {
|
|
96
|
-
|
|
86
|
+
diagnostics.report({
|
|
87
|
+
level: 'error',
|
|
88
|
+
message: `Unknown language "${language}". Use a Gherkin language code, such as "fr".`,
|
|
89
|
+
});
|
|
97
90
|
return EXIT_USAGE;
|
|
98
91
|
}
|
|
99
92
|
const ignore = values.ignore?.split(',').map((pattern) => pattern.trim());
|
|
100
|
-
const { files, invalidPatterns } =
|
|
93
|
+
const { files, invalidPatterns } = findFeatureFileStream(positionals, ignore);
|
|
101
94
|
if (invalidPatterns.length > 0) {
|
|
102
95
|
for (const pattern of invalidPatterns) {
|
|
103
|
-
|
|
96
|
+
diagnostics.report({
|
|
97
|
+
level: 'error',
|
|
98
|
+
message: `Invalid format of the feature file path/pattern: "${pattern}".`,
|
|
99
|
+
});
|
|
104
100
|
}
|
|
105
|
-
|
|
101
|
+
diagnostics.report({
|
|
102
|
+
level: 'detail',
|
|
103
|
+
message: 'To run the linter please specify an existing feature file, directory or glob.',
|
|
104
|
+
});
|
|
106
105
|
return EXIT_USAGE;
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
// Counted as they arrive, so a suite of any size costs what the report
|
|
108
|
+
// costs rather than what the suite does.
|
|
109
|
+
const statistics = await collectStatisticsFrom(readAndParseFiles(files, { language }));
|
|
110
110
|
console.log(formatter(statistics, { top }));
|
|
111
111
|
return EXIT_OK;
|
|
112
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/stats/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/stats/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,wBAAwB,EAAE,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,WA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ACjC,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzD,WAAW,CAAC,MAAM,CAAC;YACjB,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,qBAAqB,QAAQ,+CAA+C;SACtF,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAC,KAAK,EAAE,eAAe,EAAC,GAAG,qBAAqB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE5E,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;YACtC,WAAW,CAAC,MAAM,CAAC;gBACjB,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,qDAAqD,OAAO,IAAI;aAC1E,CAAC,CAAC;QACL,CAAC;QACD,WAAW,CAAC,MAAM,CAAC;YACjB,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,+EAA+E;SACzF,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,uEAAuE;IACvE,yCAAyC;IACzC,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,KAAK,EAAE,EAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;IAErF,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -50,6 +50,30 @@ export type Severity = 'error' | 'warning';
|
|
|
50
50
|
export type RuleConfig = RuleState | readonly [RuleState, unknown];
|
|
51
51
|
/** The parsed contents of a `.gurkencheckrc` file. */
|
|
52
52
|
export type Configuration = Record<string, RuleConfig>;
|
|
53
|
+
/**
|
|
54
|
+
* Somewhere for a rule to keep what it learns as a run goes on.
|
|
55
|
+
*
|
|
56
|
+
* A rule looking for duplicates has to remember what it has already seen.
|
|
57
|
+
* Keeping that in the module makes it process-global, so two runs at once - a
|
|
58
|
+
* language server checking two folders, a test suite running cases side by
|
|
59
|
+
* side - quietly corrupt each other's state. A context belongs to one rule in
|
|
60
|
+
* one run, so there is nothing shared and nothing to reset.
|
|
61
|
+
*/
|
|
62
|
+
export interface RunContext {
|
|
63
|
+
/** This rule's state for this run, made the first time it is asked for. */
|
|
64
|
+
state<T>(create: () => T): T;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A finding that could only be worked out once every file had been seen, so
|
|
68
|
+
* it has to say which file it is about.
|
|
69
|
+
*/
|
|
70
|
+
export interface RunFinding extends RuleError {
|
|
71
|
+
/**
|
|
72
|
+
* The file this is about, as it was given to the linter. Left out for a
|
|
73
|
+
* finding about the run as a whole rather than about any one file.
|
|
74
|
+
*/
|
|
75
|
+
filePath?: string;
|
|
76
|
+
}
|
|
53
77
|
/**
|
|
54
78
|
* A lint rule.
|
|
55
79
|
*
|
|
@@ -68,11 +92,31 @@ export interface LintRule {
|
|
|
68
92
|
/**
|
|
69
93
|
* Returns the violations found in this file. A rule that needs to wait for
|
|
70
94
|
* something - reading a file, asking a service - may return a promise.
|
|
95
|
+
*
|
|
96
|
+
* `context` is the same object for every file of a run, and a different one
|
|
97
|
+
* for every other run, so it is where anything remembered between files
|
|
98
|
+
* belongs.
|
|
99
|
+
*/
|
|
100
|
+
run(feature: Feature | undefined, file: FeatureFile, configuration: unknown, context: RunContext): RuleError[] | Promise<RuleError[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Called once before the first file, for a rule with something to set up.
|
|
103
|
+
* Rules that only accumulate as they go need nothing here: the context
|
|
104
|
+
* makes their state the first time they ask for it.
|
|
105
|
+
*/
|
|
106
|
+
onRunStart?(configuration: unknown, context: RunContext): void;
|
|
107
|
+
/**
|
|
108
|
+
* The findings that could only be worked out once every file had been seen,
|
|
109
|
+
* such as two files sharing a name. Called once after the last file, and
|
|
110
|
+
* only for a rule the configuration switched on.
|
|
71
111
|
*/
|
|
72
|
-
|
|
112
|
+
onRunEnd?(configuration: unknown, context: RunContext): RunFinding[] | Promise<RunFinding[]>;
|
|
73
113
|
/**
|
|
74
|
-
* Clears any state kept between files.
|
|
75
|
-
*
|
|
114
|
+
* Clears any state kept between files.
|
|
115
|
+
*
|
|
116
|
+
* @deprecated Keep state in the `RunContext` handed to `run` instead. State
|
|
117
|
+
* in the module is shared by every run in the process, so two at once tread
|
|
118
|
+
* on each other. Still called before each run, for rules written before
|
|
119
|
+
* contexts existed.
|
|
76
120
|
*/
|
|
77
121
|
reset?(): void;
|
|
78
122
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAEhD,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,+BAA+B;AAC/B,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;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,CAAC;CAChB;AAED,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
|
package/dist/util/glob.d.ts
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* slash-separated paths.
|
|
4
4
|
*/
|
|
5
5
|
export declare function globToRegExp(pattern: string): RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* The directory a pattern's search starts from - the leading run of literal
|
|
8
|
+
* segments, resolved against `cwd`. What you would watch to be told about
|
|
9
|
+
* anything the pattern could match.
|
|
10
|
+
*/
|
|
11
|
+
export declare function globRoot(pattern: string, cwd?: string): string;
|
|
6
12
|
export interface GlobOptions {
|
|
7
13
|
/** Directory that relative patterns and returned paths are relative to. */
|
|
8
14
|
cwd?: string;
|
|
@@ -17,4 +23,16 @@ export interface GlobOptions {
|
|
|
17
23
|
* forward slashes. Directories are never returned. Results are sorted.
|
|
18
24
|
*/
|
|
19
25
|
export declare function globSync(pattern: string, options?: GlobOptions): string[];
|
|
26
|
+
/**
|
|
27
|
+
* The same search, handing each match over as it is found.
|
|
28
|
+
*
|
|
29
|
+
* Collecting a whole tree before anything else starts is time in which
|
|
30
|
+
* nothing is read, parsed or checked. This hands each match over as it is
|
|
31
|
+
* reached, so the work after it starts on the first file rather than on the
|
|
32
|
+
* last.
|
|
33
|
+
*
|
|
34
|
+
* The order is the order `globSync` returns, without anything being collected
|
|
35
|
+
* to sort: `byPathOrder` is what makes the two agree.
|
|
36
|
+
*/
|
|
37
|
+
export declare function globStream(pattern: string, options?: GlobOptions): AsyncGenerator<string>;
|
|
20
38
|
//# sourceMappingURL=glob.d.ts.map
|