@hailstails/hone 0.0.0-stage → 0.1.0-pre.2
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/ADOPTING.md +314 -0
- package/LICENSE +17 -0
- package/MIGRATING.md +238 -0
- package/README.md +216 -2
- package/THIRD-PARTY-NOTICES.md +354 -0
- package/chunks/chunk-233U4FBA.js +42 -0
- package/chunks/chunk-7ZJZZBSS.js +14909 -0
- package/chunks/chunk-HBY4ZWSP.js +79 -0
- package/chunks/chunk-HJA4CX7C.js +24 -0
- package/chunks/chunk-NZLE2WMY.js +35 -0
- package/chunks/chunk-QWA6OVLC.js +11 -0
- package/chunks/chunk-TRCB27ET.js +202 -0
- package/core/check/tool-command.js +2305 -0
- package/docs/adding-a-discipline-or-mechanism.md +195 -0
- package/docs/why-chain-contract.md +78 -0
- package/mechanisms/audit/CD-1/any-cast.js +81 -0
- package/mechanisms/audit/CD-1/piece.json +13 -0
- package/mechanisms/audit/CD-10/piece.json +13 -0
- package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
- package/mechanisms/audit/CD-14/class-syntax.js +70 -0
- package/mechanisms/audit/CD-14/piece.json +13 -0
- package/mechanisms/audit/CD-15/loops.js +40 -0
- package/mechanisms/audit/CD-15/piece.json +13 -0
- package/mechanisms/audit/CD-17/clock-sources.js +29 -0
- package/mechanisms/audit/CD-17/piece.json +13 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
- package/mechanisms/audit/CD-19/piece.json +13 -0
- package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
- package/mechanisms/audit/CD-2/piece.json +13 -0
- package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
- package/mechanisms/audit/CD-23/piece.json +13 -0
- package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
- package/mechanisms/audit/CD-25/piece.json +13 -0
- package/mechanisms/audit/CD-26/module-mocking.js +51 -0
- package/mechanisms/audit/CD-26/piece.json +13 -0
- package/mechanisms/audit/CD-27/piece.json +13 -0
- package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
- package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
- package/mechanisms/audit/CD-3/piece.json +49 -0
- package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
- package/mechanisms/audit/CD-43/piece.json +13 -0
- package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
- package/mechanisms/audit/CD-44/piece.json +13 -0
- package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
- package/mechanisms/audit/CD-47/piece.json +13 -0
- package/mechanisms/audit/CD-5/comments-directives.js +73 -0
- package/mechanisms/audit/CD-5/piece.json +13 -0
- package/mechanisms/audit/CD-6/identifier-names.js +132 -0
- package/mechanisms/audit/CD-6/piece.json +13 -0
- package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
- package/mechanisms/audit/CD-7/piece.json +13 -0
- package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
- package/mechanisms/audit/CD-7a/piece.json +13 -0
- package/mechanisms/audit/CD-8/piece.json +13 -0
- package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
- package/mechanisms/audit/runner/README.md +38 -0
- package/mechanisms/audit/runner/runner.js +546 -0
- package/mechanisms/eslint/CD-1/README.md +12 -0
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
- package/mechanisms/eslint/CD-1/piece.json +23 -0
- package/mechanisms/eslint/CD-10/README.md +9 -0
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
- package/mechanisms/eslint/CD-10/piece.json +15 -0
- package/mechanisms/eslint/CD-14/README.md +11 -0
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
- package/mechanisms/eslint/CD-14/piece.json +31 -0
- package/mechanisms/eslint/CD-27/README.md +12 -0
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
- package/mechanisms/eslint/CD-27/piece.json +23 -0
- package/mechanisms/eslint/CD-40/README.md +7 -0
- package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-40/piece.json +21 -0
- package/mechanisms/eslint/CD-41/README.md +12 -0
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
- package/mechanisms/eslint/CD-41/piece.json +23 -0
- package/mechanisms/eslint/CD-42/README.md +9 -0
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
- package/mechanisms/eslint/CD-42/piece.json +15 -0
- package/mechanisms/eslint/CD-44/README.md +7 -0
- package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-44/piece.json +20 -0
- package/mechanisms/eslint/CD-6/README.md +9 -0
- package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-6/piece.json +217 -0
- package/mechanisms/eslint/CD-7/README.md +9 -0
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
- package/mechanisms/eslint/CD-7/piece.json +15 -0
- package/mechanisms/eslint/runner/README.md +43 -0
- package/mechanisms/eslint/runner/runner.js +4248 -0
- package/methods/README.md +18 -0
- package/methods/lenses/clean-architecture.md +167 -0
- package/methods/lenses/decomposition.md +159 -0
- package/methods/lenses/defended-on-intent.md +178 -0
- package/methods/lenses/di-discipline.md +156 -0
- package/methods/lenses/errors-as-data.md +88 -0
- package/methods/lenses/function-first.md +193 -0
- package/methods/lenses/naming.md +127 -0
- package/methods/lenses/test-discipline.md +166 -0
- package/methods/lenses/type-soundness.md +135 -0
- package/methods/lenses/zod-boundary.md +158 -0
- package/package.json +65 -4
- package/rules/CD-1/README.md +43 -0
- package/rules/CD-1/discipline.json +185 -0
- package/rules/CD-10/README.md +55 -0
- package/rules/CD-10/discipline.json +133 -0
- package/rules/CD-11/README.md +19 -0
- package/rules/CD-11/discipline.json +12 -0
- package/rules/CD-12/README.md +19 -0
- package/rules/CD-12/discipline.json +12 -0
- package/rules/CD-13/README.md +19 -0
- package/rules/CD-13/discipline.json +12 -0
- package/rules/CD-14/README.md +54 -0
- package/rules/CD-14/discipline.json +173 -0
- package/rules/CD-15/README.md +48 -0
- package/rules/CD-15/discipline.json +73 -0
- package/rules/CD-16/README.md +17 -0
- package/rules/CD-17/README.md +42 -0
- package/rules/CD-17/discipline.json +51 -0
- package/rules/CD-18/README.md +19 -0
- package/rules/CD-18/discipline.json +12 -0
- package/rules/CD-19/README.md +45 -0
- package/rules/CD-19/discipline.json +65 -0
- package/rules/CD-2/README.md +43 -0
- package/rules/CD-2/discipline.json +65 -0
- package/rules/CD-20/README.md +17 -0
- package/rules/CD-21/README.md +19 -0
- package/rules/CD-21/discipline.json +12 -0
- package/rules/CD-22/README.md +19 -0
- package/rules/CD-22/discipline.json +12 -0
- package/rules/CD-23/README.md +41 -0
- package/rules/CD-23/discipline.json +57 -0
- package/rules/CD-24/README.md +17 -0
- package/rules/CD-25/README.md +43 -0
- package/rules/CD-25/discipline.json +57 -0
- package/rules/CD-26/README.md +42 -0
- package/rules/CD-26/discipline.json +57 -0
- package/rules/CD-27/README.md +51 -0
- package/rules/CD-27/discipline.json +233 -0
- package/rules/CD-28/README.md +19 -0
- package/rules/CD-28/discipline.json +12 -0
- package/rules/CD-29/README.md +19 -0
- package/rules/CD-29/discipline.json +12 -0
- package/rules/CD-3/README.md +48 -0
- package/rules/CD-3/discipline.json +363 -0
- package/rules/CD-30/README.md +19 -0
- package/rules/CD-30/discipline.json +12 -0
- package/rules/CD-31/README.md +19 -0
- package/rules/CD-31/discipline.json +12 -0
- package/rules/CD-32/README.md +19 -0
- package/rules/CD-32/discipline.json +12 -0
- package/rules/CD-33/README.md +19 -0
- package/rules/CD-33/discipline.json +12 -0
- package/rules/CD-34/README.md +19 -0
- package/rules/CD-34/discipline.json +12 -0
- package/rules/CD-39/README.md +19 -0
- package/rules/CD-39/discipline.json +12 -0
- package/rules/CD-4/README.md +19 -0
- package/rules/CD-4/discipline.json +12 -0
- package/rules/CD-40/README.md +45 -0
- package/rules/CD-40/discipline.json +58 -0
- package/rules/CD-41/README.md +60 -0
- package/rules/CD-41/discipline.json +124 -0
- package/rules/CD-42/README.md +53 -0
- package/rules/CD-42/discipline.json +61 -0
- package/rules/CD-43/README.md +43 -0
- package/rules/CD-43/discipline.json +65 -0
- package/rules/CD-44/README.md +54 -0
- package/rules/CD-44/discipline.json +111 -0
- package/rules/CD-45/README.md +19 -0
- package/rules/CD-45/discipline.json +12 -0
- package/rules/CD-46/README.md +13 -0
- package/rules/CD-47/README.md +47 -0
- package/rules/CD-47/discipline.json +57 -0
- package/rules/CD-5/README.md +46 -0
- package/rules/CD-5/discipline.json +65 -0
- package/rules/CD-6/README.md +57 -0
- package/rules/CD-6/discipline.json +165 -0
- package/rules/CD-7/README.md +52 -0
- package/rules/CD-7/discipline.json +142 -0
- package/rules/CD-7a/README.md +44 -0
- package/rules/CD-7a/discipline.json +57 -0
- package/rules/CD-8/README.md +48 -0
- package/rules/CD-8/discipline.json +57 -0
- package/rules/CD-9/README.md +19 -0
- package/rules/CD-9/discipline.json +12 -0
- package/rules/README.md +52 -0
|
@@ -0,0 +1,4248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TOOL_IDENTITY,
|
|
3
|
+
eslintConfigLookupSchema,
|
|
4
|
+
parsedJson
|
|
5
|
+
} from "../../../chunks/chunk-TRCB27ET.js";
|
|
6
|
+
import {
|
|
7
|
+
createDefaultPackageLocationPort,
|
|
8
|
+
installRootOfRunnerEntry,
|
|
9
|
+
toolchainBoundEmbeddedRunner
|
|
10
|
+
} from "../../../chunks/chunk-233U4FBA.js";
|
|
11
|
+
import {
|
|
12
|
+
absolutePathSchema,
|
|
13
|
+
clauseAddressText,
|
|
14
|
+
createDefaultFileTextPort,
|
|
15
|
+
createDefaultModuleLoaderPort,
|
|
16
|
+
createDefaultPathPort,
|
|
17
|
+
external_exports,
|
|
18
|
+
installFormOf,
|
|
19
|
+
isRepoPathText,
|
|
20
|
+
loadedPeer,
|
|
21
|
+
moduleExtensionOf,
|
|
22
|
+
moduleFileForm,
|
|
23
|
+
repoPathSchema,
|
|
24
|
+
sameClauseAddress,
|
|
25
|
+
versionSupport
|
|
26
|
+
} from "../../../chunks/chunk-7ZJZZBSS.js";
|
|
27
|
+
import {
|
|
28
|
+
__commonJS,
|
|
29
|
+
__toESM
|
|
30
|
+
} from "../../../chunks/chunk-NZLE2WMY.js";
|
|
31
|
+
|
|
32
|
+
// node_modules/prelude-ls/lib/Func.js
|
|
33
|
+
var require_Func = __commonJS({
|
|
34
|
+
"node_modules/prelude-ls/lib/Func.js"(exports, module) {
|
|
35
|
+
var apply;
|
|
36
|
+
var curry;
|
|
37
|
+
var flip;
|
|
38
|
+
var fix;
|
|
39
|
+
var over;
|
|
40
|
+
var memoize;
|
|
41
|
+
var toString$ = {}.toString;
|
|
42
|
+
apply = curry$(function(f, list) {
|
|
43
|
+
return f.apply(null, list);
|
|
44
|
+
});
|
|
45
|
+
curry = function(f) {
|
|
46
|
+
return curry$(f);
|
|
47
|
+
};
|
|
48
|
+
flip = curry$(function(f, x, y) {
|
|
49
|
+
return f(y, x);
|
|
50
|
+
});
|
|
51
|
+
fix = function(f) {
|
|
52
|
+
return /* @__PURE__ */ (function(g) {
|
|
53
|
+
return function() {
|
|
54
|
+
return f(g(g)).apply(null, arguments);
|
|
55
|
+
};
|
|
56
|
+
})(function(g) {
|
|
57
|
+
return function() {
|
|
58
|
+
return f(g(g)).apply(null, arguments);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
over = curry$(function(f, g, x, y) {
|
|
63
|
+
return f(g(x), g(y));
|
|
64
|
+
});
|
|
65
|
+
memoize = function(f) {
|
|
66
|
+
var memo;
|
|
67
|
+
memo = {};
|
|
68
|
+
return function() {
|
|
69
|
+
var args, res$, i$, to$, key, arg;
|
|
70
|
+
res$ = [];
|
|
71
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
72
|
+
res$.push(arguments[i$]);
|
|
73
|
+
}
|
|
74
|
+
args = res$;
|
|
75
|
+
key = (function() {
|
|
76
|
+
var i$2, ref$, len$, results$ = [];
|
|
77
|
+
for (i$2 = 0, len$ = (ref$ = args).length; i$2 < len$; ++i$2) {
|
|
78
|
+
arg = ref$[i$2];
|
|
79
|
+
results$.push(arg + toString$.call(arg).slice(8, -1));
|
|
80
|
+
}
|
|
81
|
+
return results$;
|
|
82
|
+
})().join("");
|
|
83
|
+
return memo[key] = key in memo ? memo[key] : f.apply(null, args);
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
module.exports = {
|
|
87
|
+
curry,
|
|
88
|
+
flip,
|
|
89
|
+
fix,
|
|
90
|
+
apply,
|
|
91
|
+
over,
|
|
92
|
+
memoize
|
|
93
|
+
};
|
|
94
|
+
function curry$(f, bound) {
|
|
95
|
+
var context, _curry = function(args) {
|
|
96
|
+
return f.length > 1 ? function() {
|
|
97
|
+
var params = args ? args.concat() : [];
|
|
98
|
+
context = bound ? context || this : this;
|
|
99
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
100
|
+
} : f;
|
|
101
|
+
};
|
|
102
|
+
return _curry();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// node_modules/prelude-ls/lib/List.js
|
|
108
|
+
var require_List = __commonJS({
|
|
109
|
+
"node_modules/prelude-ls/lib/List.js"(exports, module) {
|
|
110
|
+
var each;
|
|
111
|
+
var map;
|
|
112
|
+
var compact;
|
|
113
|
+
var filter;
|
|
114
|
+
var reject;
|
|
115
|
+
var remove;
|
|
116
|
+
var partition;
|
|
117
|
+
var find;
|
|
118
|
+
var head;
|
|
119
|
+
var first;
|
|
120
|
+
var tail;
|
|
121
|
+
var last;
|
|
122
|
+
var initial;
|
|
123
|
+
var empty;
|
|
124
|
+
var reverse;
|
|
125
|
+
var unique;
|
|
126
|
+
var uniqueBy;
|
|
127
|
+
var fold;
|
|
128
|
+
var foldl;
|
|
129
|
+
var fold1;
|
|
130
|
+
var foldl1;
|
|
131
|
+
var foldr;
|
|
132
|
+
var foldr1;
|
|
133
|
+
var unfoldr;
|
|
134
|
+
var concat;
|
|
135
|
+
var concatMap;
|
|
136
|
+
var flatten;
|
|
137
|
+
var difference;
|
|
138
|
+
var intersection;
|
|
139
|
+
var union;
|
|
140
|
+
var countBy;
|
|
141
|
+
var groupBy;
|
|
142
|
+
var andList;
|
|
143
|
+
var orList;
|
|
144
|
+
var any;
|
|
145
|
+
var all;
|
|
146
|
+
var sort;
|
|
147
|
+
var sortWith;
|
|
148
|
+
var sortBy;
|
|
149
|
+
var sum;
|
|
150
|
+
var product;
|
|
151
|
+
var mean;
|
|
152
|
+
var average;
|
|
153
|
+
var maximum;
|
|
154
|
+
var minimum;
|
|
155
|
+
var maximumBy;
|
|
156
|
+
var minimumBy;
|
|
157
|
+
var scan;
|
|
158
|
+
var scanl;
|
|
159
|
+
var scan1;
|
|
160
|
+
var scanl1;
|
|
161
|
+
var scanr;
|
|
162
|
+
var scanr1;
|
|
163
|
+
var slice;
|
|
164
|
+
var take;
|
|
165
|
+
var drop;
|
|
166
|
+
var splitAt;
|
|
167
|
+
var takeWhile;
|
|
168
|
+
var dropWhile;
|
|
169
|
+
var span;
|
|
170
|
+
var breakList;
|
|
171
|
+
var zip;
|
|
172
|
+
var zipWith;
|
|
173
|
+
var zipAll;
|
|
174
|
+
var zipAllWith;
|
|
175
|
+
var at;
|
|
176
|
+
var elemIndex;
|
|
177
|
+
var elemIndices;
|
|
178
|
+
var findIndex;
|
|
179
|
+
var findIndices;
|
|
180
|
+
var toString$ = {}.toString;
|
|
181
|
+
each = curry$(function(f, xs) {
|
|
182
|
+
var i$, len$, x;
|
|
183
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
184
|
+
x = xs[i$];
|
|
185
|
+
f(x);
|
|
186
|
+
}
|
|
187
|
+
return xs;
|
|
188
|
+
});
|
|
189
|
+
map = curry$(function(f, xs) {
|
|
190
|
+
var i$, len$, x, results$ = [];
|
|
191
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
192
|
+
x = xs[i$];
|
|
193
|
+
results$.push(f(x));
|
|
194
|
+
}
|
|
195
|
+
return results$;
|
|
196
|
+
});
|
|
197
|
+
compact = function(xs) {
|
|
198
|
+
var i$, len$, x, results$ = [];
|
|
199
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
200
|
+
x = xs[i$];
|
|
201
|
+
if (x) {
|
|
202
|
+
results$.push(x);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return results$;
|
|
206
|
+
};
|
|
207
|
+
filter = curry$(function(f, xs) {
|
|
208
|
+
var i$, len$, x, results$ = [];
|
|
209
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
210
|
+
x = xs[i$];
|
|
211
|
+
if (f(x)) {
|
|
212
|
+
results$.push(x);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return results$;
|
|
216
|
+
});
|
|
217
|
+
reject = curry$(function(f, xs) {
|
|
218
|
+
var i$, len$, x, results$ = [];
|
|
219
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
220
|
+
x = xs[i$];
|
|
221
|
+
if (!f(x)) {
|
|
222
|
+
results$.push(x);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return results$;
|
|
226
|
+
});
|
|
227
|
+
remove = curry$(function(el, xs) {
|
|
228
|
+
var i, x$;
|
|
229
|
+
i = elemIndex(el, xs);
|
|
230
|
+
x$ = xs.slice();
|
|
231
|
+
if (i != null) {
|
|
232
|
+
x$.splice(i, 1);
|
|
233
|
+
}
|
|
234
|
+
return x$;
|
|
235
|
+
});
|
|
236
|
+
partition = curry$(function(f, xs) {
|
|
237
|
+
var passed, failed, i$, len$, x;
|
|
238
|
+
passed = [];
|
|
239
|
+
failed = [];
|
|
240
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
241
|
+
x = xs[i$];
|
|
242
|
+
(f(x) ? passed : failed).push(x);
|
|
243
|
+
}
|
|
244
|
+
return [passed, failed];
|
|
245
|
+
});
|
|
246
|
+
find = curry$(function(f, xs) {
|
|
247
|
+
var i$, len$, x;
|
|
248
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
249
|
+
x = xs[i$];
|
|
250
|
+
if (f(x)) {
|
|
251
|
+
return x;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
head = first = function(xs) {
|
|
256
|
+
return xs[0];
|
|
257
|
+
};
|
|
258
|
+
tail = function(xs) {
|
|
259
|
+
if (!xs.length) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
return xs.slice(1);
|
|
263
|
+
};
|
|
264
|
+
last = function(xs) {
|
|
265
|
+
return xs[xs.length - 1];
|
|
266
|
+
};
|
|
267
|
+
initial = function(xs) {
|
|
268
|
+
if (!xs.length) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
return xs.slice(0, -1);
|
|
272
|
+
};
|
|
273
|
+
empty = function(xs) {
|
|
274
|
+
return !xs.length;
|
|
275
|
+
};
|
|
276
|
+
reverse = function(xs) {
|
|
277
|
+
return xs.concat().reverse();
|
|
278
|
+
};
|
|
279
|
+
unique = function(xs) {
|
|
280
|
+
var result, i$, len$, x;
|
|
281
|
+
result = [];
|
|
282
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
283
|
+
x = xs[i$];
|
|
284
|
+
if (!in$(x, result)) {
|
|
285
|
+
result.push(x);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return result;
|
|
289
|
+
};
|
|
290
|
+
uniqueBy = curry$(function(f, xs) {
|
|
291
|
+
var seen, i$, len$, x, val, results$ = [];
|
|
292
|
+
seen = [];
|
|
293
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
294
|
+
x = xs[i$];
|
|
295
|
+
val = f(x);
|
|
296
|
+
if (in$(val, seen)) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
seen.push(val);
|
|
300
|
+
results$.push(x);
|
|
301
|
+
}
|
|
302
|
+
return results$;
|
|
303
|
+
});
|
|
304
|
+
fold = foldl = curry$(function(f, memo, xs) {
|
|
305
|
+
var i$, len$, x;
|
|
306
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
307
|
+
x = xs[i$];
|
|
308
|
+
memo = f(memo, x);
|
|
309
|
+
}
|
|
310
|
+
return memo;
|
|
311
|
+
});
|
|
312
|
+
fold1 = foldl1 = curry$(function(f, xs) {
|
|
313
|
+
return fold(f, xs[0], xs.slice(1));
|
|
314
|
+
});
|
|
315
|
+
foldr = curry$(function(f, memo, xs) {
|
|
316
|
+
var i$, x;
|
|
317
|
+
for (i$ = xs.length - 1; i$ >= 0; --i$) {
|
|
318
|
+
x = xs[i$];
|
|
319
|
+
memo = f(x, memo);
|
|
320
|
+
}
|
|
321
|
+
return memo;
|
|
322
|
+
});
|
|
323
|
+
foldr1 = curry$(function(f, xs) {
|
|
324
|
+
return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
|
|
325
|
+
});
|
|
326
|
+
unfoldr = curry$(function(f, b) {
|
|
327
|
+
var result, x, that;
|
|
328
|
+
result = [];
|
|
329
|
+
x = b;
|
|
330
|
+
while ((that = f(x)) != null) {
|
|
331
|
+
result.push(that[0]);
|
|
332
|
+
x = that[1];
|
|
333
|
+
}
|
|
334
|
+
return result;
|
|
335
|
+
});
|
|
336
|
+
concat = function(xss) {
|
|
337
|
+
return [].concat.apply([], xss);
|
|
338
|
+
};
|
|
339
|
+
concatMap = curry$(function(f, xs) {
|
|
340
|
+
var x;
|
|
341
|
+
return [].concat.apply([], (function() {
|
|
342
|
+
var i$, ref$, len$, results$ = [];
|
|
343
|
+
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
|
|
344
|
+
x = ref$[i$];
|
|
345
|
+
results$.push(f(x));
|
|
346
|
+
}
|
|
347
|
+
return results$;
|
|
348
|
+
})());
|
|
349
|
+
});
|
|
350
|
+
flatten = function(xs) {
|
|
351
|
+
var x;
|
|
352
|
+
return [].concat.apply([], (function() {
|
|
353
|
+
var i$, ref$, len$, results$ = [];
|
|
354
|
+
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
|
|
355
|
+
x = ref$[i$];
|
|
356
|
+
if (toString$.call(x).slice(8, -1) === "Array") {
|
|
357
|
+
results$.push(flatten(x));
|
|
358
|
+
} else {
|
|
359
|
+
results$.push(x);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return results$;
|
|
363
|
+
})());
|
|
364
|
+
};
|
|
365
|
+
difference = function(xs) {
|
|
366
|
+
var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
|
|
367
|
+
res$ = [];
|
|
368
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
369
|
+
res$.push(arguments[i$]);
|
|
370
|
+
}
|
|
371
|
+
yss = res$;
|
|
372
|
+
results = [];
|
|
373
|
+
outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
374
|
+
x = xs[i$];
|
|
375
|
+
for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
|
|
376
|
+
ys = yss[j$];
|
|
377
|
+
if (in$(x, ys)) {
|
|
378
|
+
continue outer;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
results.push(x);
|
|
382
|
+
}
|
|
383
|
+
return results;
|
|
384
|
+
};
|
|
385
|
+
intersection = function(xs) {
|
|
386
|
+
var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
|
|
387
|
+
res$ = [];
|
|
388
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
389
|
+
res$.push(arguments[i$]);
|
|
390
|
+
}
|
|
391
|
+
yss = res$;
|
|
392
|
+
results = [];
|
|
393
|
+
outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
394
|
+
x = xs[i$];
|
|
395
|
+
for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
|
|
396
|
+
ys = yss[j$];
|
|
397
|
+
if (!in$(x, ys)) {
|
|
398
|
+
continue outer;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
results.push(x);
|
|
402
|
+
}
|
|
403
|
+
return results;
|
|
404
|
+
};
|
|
405
|
+
union = function() {
|
|
406
|
+
var xss, res$, i$, to$, results, len$, xs, j$, len1$, x;
|
|
407
|
+
res$ = [];
|
|
408
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
409
|
+
res$.push(arguments[i$]);
|
|
410
|
+
}
|
|
411
|
+
xss = res$;
|
|
412
|
+
results = [];
|
|
413
|
+
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
|
|
414
|
+
xs = xss[i$];
|
|
415
|
+
for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
|
|
416
|
+
x = xs[j$];
|
|
417
|
+
if (!in$(x, results)) {
|
|
418
|
+
results.push(x);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return results;
|
|
423
|
+
};
|
|
424
|
+
countBy = curry$(function(f, xs) {
|
|
425
|
+
var results, i$, len$, x, key;
|
|
426
|
+
results = {};
|
|
427
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
428
|
+
x = xs[i$];
|
|
429
|
+
key = f(x);
|
|
430
|
+
if (key in results) {
|
|
431
|
+
results[key] += 1;
|
|
432
|
+
} else {
|
|
433
|
+
results[key] = 1;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return results;
|
|
437
|
+
});
|
|
438
|
+
groupBy = curry$(function(f, xs) {
|
|
439
|
+
var results, i$, len$, x, key;
|
|
440
|
+
results = {};
|
|
441
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
442
|
+
x = xs[i$];
|
|
443
|
+
key = f(x);
|
|
444
|
+
if (key in results) {
|
|
445
|
+
results[key].push(x);
|
|
446
|
+
} else {
|
|
447
|
+
results[key] = [x];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return results;
|
|
451
|
+
});
|
|
452
|
+
andList = function(xs) {
|
|
453
|
+
var i$, len$, x;
|
|
454
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
455
|
+
x = xs[i$];
|
|
456
|
+
if (!x) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
};
|
|
462
|
+
orList = function(xs) {
|
|
463
|
+
var i$, len$, x;
|
|
464
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
465
|
+
x = xs[i$];
|
|
466
|
+
if (x) {
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return false;
|
|
471
|
+
};
|
|
472
|
+
any = curry$(function(f, xs) {
|
|
473
|
+
var i$, len$, x;
|
|
474
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
475
|
+
x = xs[i$];
|
|
476
|
+
if (f(x)) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return false;
|
|
481
|
+
});
|
|
482
|
+
all = curry$(function(f, xs) {
|
|
483
|
+
var i$, len$, x;
|
|
484
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
485
|
+
x = xs[i$];
|
|
486
|
+
if (!f(x)) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return true;
|
|
491
|
+
});
|
|
492
|
+
sort = function(xs) {
|
|
493
|
+
return xs.concat().sort(function(x, y) {
|
|
494
|
+
if (x > y) {
|
|
495
|
+
return 1;
|
|
496
|
+
} else if (x < y) {
|
|
497
|
+
return -1;
|
|
498
|
+
} else {
|
|
499
|
+
return 0;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
sortWith = curry$(function(f, xs) {
|
|
504
|
+
return xs.concat().sort(f);
|
|
505
|
+
});
|
|
506
|
+
sortBy = curry$(function(f, xs) {
|
|
507
|
+
return xs.concat().sort(function(x, y) {
|
|
508
|
+
if (f(x) > f(y)) {
|
|
509
|
+
return 1;
|
|
510
|
+
} else if (f(x) < f(y)) {
|
|
511
|
+
return -1;
|
|
512
|
+
} else {
|
|
513
|
+
return 0;
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
sum = function(xs) {
|
|
518
|
+
var result, i$, len$, x;
|
|
519
|
+
result = 0;
|
|
520
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
521
|
+
x = xs[i$];
|
|
522
|
+
result += x;
|
|
523
|
+
}
|
|
524
|
+
return result;
|
|
525
|
+
};
|
|
526
|
+
product = function(xs) {
|
|
527
|
+
var result, i$, len$, x;
|
|
528
|
+
result = 1;
|
|
529
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
530
|
+
x = xs[i$];
|
|
531
|
+
result *= x;
|
|
532
|
+
}
|
|
533
|
+
return result;
|
|
534
|
+
};
|
|
535
|
+
mean = average = function(xs) {
|
|
536
|
+
var sum2, i$, len$, x;
|
|
537
|
+
sum2 = 0;
|
|
538
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
539
|
+
x = xs[i$];
|
|
540
|
+
sum2 += x;
|
|
541
|
+
}
|
|
542
|
+
return sum2 / xs.length;
|
|
543
|
+
};
|
|
544
|
+
maximum = function(xs) {
|
|
545
|
+
var max, i$, ref$, len$, x;
|
|
546
|
+
max = xs[0];
|
|
547
|
+
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
|
|
548
|
+
x = ref$[i$];
|
|
549
|
+
if (x > max) {
|
|
550
|
+
max = x;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return max;
|
|
554
|
+
};
|
|
555
|
+
minimum = function(xs) {
|
|
556
|
+
var min, i$, ref$, len$, x;
|
|
557
|
+
min = xs[0];
|
|
558
|
+
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
|
|
559
|
+
x = ref$[i$];
|
|
560
|
+
if (x < min) {
|
|
561
|
+
min = x;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return min;
|
|
565
|
+
};
|
|
566
|
+
maximumBy = curry$(function(f, xs) {
|
|
567
|
+
var max, i$, ref$, len$, x;
|
|
568
|
+
max = xs[0];
|
|
569
|
+
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
|
|
570
|
+
x = ref$[i$];
|
|
571
|
+
if (f(x) > f(max)) {
|
|
572
|
+
max = x;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return max;
|
|
576
|
+
});
|
|
577
|
+
minimumBy = curry$(function(f, xs) {
|
|
578
|
+
var min, i$, ref$, len$, x;
|
|
579
|
+
min = xs[0];
|
|
580
|
+
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
|
|
581
|
+
x = ref$[i$];
|
|
582
|
+
if (f(x) < f(min)) {
|
|
583
|
+
min = x;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return min;
|
|
587
|
+
});
|
|
588
|
+
scan = scanl = curry$(function(f, memo, xs) {
|
|
589
|
+
var last2, x;
|
|
590
|
+
last2 = memo;
|
|
591
|
+
return [memo].concat((function() {
|
|
592
|
+
var i$, ref$, len$, results$ = [];
|
|
593
|
+
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
|
|
594
|
+
x = ref$[i$];
|
|
595
|
+
results$.push(last2 = f(last2, x));
|
|
596
|
+
}
|
|
597
|
+
return results$;
|
|
598
|
+
})());
|
|
599
|
+
});
|
|
600
|
+
scan1 = scanl1 = curry$(function(f, xs) {
|
|
601
|
+
if (!xs.length) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
return scan(f, xs[0], xs.slice(1));
|
|
605
|
+
});
|
|
606
|
+
scanr = curry$(function(f, memo, xs) {
|
|
607
|
+
xs = xs.concat().reverse();
|
|
608
|
+
return scan(f, memo, xs).reverse();
|
|
609
|
+
});
|
|
610
|
+
scanr1 = curry$(function(f, xs) {
|
|
611
|
+
if (!xs.length) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
xs = xs.concat().reverse();
|
|
615
|
+
return scan(f, xs[0], xs.slice(1)).reverse();
|
|
616
|
+
});
|
|
617
|
+
slice = curry$(function(x, y, xs) {
|
|
618
|
+
return xs.slice(x, y);
|
|
619
|
+
});
|
|
620
|
+
take = curry$(function(n, xs) {
|
|
621
|
+
if (n <= 0) {
|
|
622
|
+
return xs.slice(0, 0);
|
|
623
|
+
} else {
|
|
624
|
+
return xs.slice(0, n);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
drop = curry$(function(n, xs) {
|
|
628
|
+
if (n <= 0) {
|
|
629
|
+
return xs;
|
|
630
|
+
} else {
|
|
631
|
+
return xs.slice(n);
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
splitAt = curry$(function(n, xs) {
|
|
635
|
+
return [take(n, xs), drop(n, xs)];
|
|
636
|
+
});
|
|
637
|
+
takeWhile = curry$(function(p, xs) {
|
|
638
|
+
var len, i;
|
|
639
|
+
len = xs.length;
|
|
640
|
+
if (!len) {
|
|
641
|
+
return xs;
|
|
642
|
+
}
|
|
643
|
+
i = 0;
|
|
644
|
+
while (i < len && p(xs[i])) {
|
|
645
|
+
i += 1;
|
|
646
|
+
}
|
|
647
|
+
return xs.slice(0, i);
|
|
648
|
+
});
|
|
649
|
+
dropWhile = curry$(function(p, xs) {
|
|
650
|
+
var len, i;
|
|
651
|
+
len = xs.length;
|
|
652
|
+
if (!len) {
|
|
653
|
+
return xs;
|
|
654
|
+
}
|
|
655
|
+
i = 0;
|
|
656
|
+
while (i < len && p(xs[i])) {
|
|
657
|
+
i += 1;
|
|
658
|
+
}
|
|
659
|
+
return xs.slice(i);
|
|
660
|
+
});
|
|
661
|
+
span = curry$(function(p, xs) {
|
|
662
|
+
return [takeWhile(p, xs), dropWhile(p, xs)];
|
|
663
|
+
});
|
|
664
|
+
breakList = curry$(function(p, xs) {
|
|
665
|
+
return span(compose$(p, not$), xs);
|
|
666
|
+
});
|
|
667
|
+
zip = curry$(function(xs, ys) {
|
|
668
|
+
var result, len, i$, len$, i, x;
|
|
669
|
+
result = [];
|
|
670
|
+
len = ys.length;
|
|
671
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
672
|
+
i = i$;
|
|
673
|
+
x = xs[i$];
|
|
674
|
+
if (i === len) {
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
result.push([x, ys[i]]);
|
|
678
|
+
}
|
|
679
|
+
return result;
|
|
680
|
+
});
|
|
681
|
+
zipWith = curry$(function(f, xs, ys) {
|
|
682
|
+
var result, len, i$, len$, i, x;
|
|
683
|
+
result = [];
|
|
684
|
+
len = ys.length;
|
|
685
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
686
|
+
i = i$;
|
|
687
|
+
x = xs[i$];
|
|
688
|
+
if (i === len) {
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
result.push(f(x, ys[i]));
|
|
692
|
+
}
|
|
693
|
+
return result;
|
|
694
|
+
});
|
|
695
|
+
zipAll = function() {
|
|
696
|
+
var xss, res$, i$, to$, minLength, len$, xs, ref$, i, lresult$, j$, results$ = [];
|
|
697
|
+
res$ = [];
|
|
698
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
699
|
+
res$.push(arguments[i$]);
|
|
700
|
+
}
|
|
701
|
+
xss = res$;
|
|
702
|
+
minLength = void 0;
|
|
703
|
+
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
|
|
704
|
+
xs = xss[i$];
|
|
705
|
+
minLength <= (ref$ = xs.length) || (minLength = ref$);
|
|
706
|
+
}
|
|
707
|
+
for (i$ = 0; i$ < minLength; ++i$) {
|
|
708
|
+
i = i$;
|
|
709
|
+
lresult$ = [];
|
|
710
|
+
for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
|
|
711
|
+
xs = xss[j$];
|
|
712
|
+
lresult$.push(xs[i]);
|
|
713
|
+
}
|
|
714
|
+
results$.push(lresult$);
|
|
715
|
+
}
|
|
716
|
+
return results$;
|
|
717
|
+
};
|
|
718
|
+
zipAllWith = function(f) {
|
|
719
|
+
var xss, res$, i$, to$, minLength, len$, xs, ref$, i, results$ = [];
|
|
720
|
+
res$ = [];
|
|
721
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
722
|
+
res$.push(arguments[i$]);
|
|
723
|
+
}
|
|
724
|
+
xss = res$;
|
|
725
|
+
minLength = void 0;
|
|
726
|
+
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
|
|
727
|
+
xs = xss[i$];
|
|
728
|
+
minLength <= (ref$ = xs.length) || (minLength = ref$);
|
|
729
|
+
}
|
|
730
|
+
for (i$ = 0; i$ < minLength; ++i$) {
|
|
731
|
+
i = i$;
|
|
732
|
+
results$.push(f.apply(null, fn$()));
|
|
733
|
+
}
|
|
734
|
+
return results$;
|
|
735
|
+
function fn$() {
|
|
736
|
+
var i$2, ref$2, len$2, results$2 = [];
|
|
737
|
+
for (i$2 = 0, len$2 = (ref$2 = xss).length; i$2 < len$2; ++i$2) {
|
|
738
|
+
xs = ref$2[i$2];
|
|
739
|
+
results$2.push(xs[i]);
|
|
740
|
+
}
|
|
741
|
+
return results$2;
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
at = curry$(function(n, xs) {
|
|
745
|
+
if (n < 0) {
|
|
746
|
+
return xs[xs.length + n];
|
|
747
|
+
} else {
|
|
748
|
+
return xs[n];
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
elemIndex = curry$(function(el, xs) {
|
|
752
|
+
var i$, len$, i, x;
|
|
753
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
754
|
+
i = i$;
|
|
755
|
+
x = xs[i$];
|
|
756
|
+
if (x === el) {
|
|
757
|
+
return i;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
elemIndices = curry$(function(el, xs) {
|
|
762
|
+
var i$, len$, i, x, results$ = [];
|
|
763
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
764
|
+
i = i$;
|
|
765
|
+
x = xs[i$];
|
|
766
|
+
if (x === el) {
|
|
767
|
+
results$.push(i);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return results$;
|
|
771
|
+
});
|
|
772
|
+
findIndex = curry$(function(f, xs) {
|
|
773
|
+
var i$, len$, i, x;
|
|
774
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
775
|
+
i = i$;
|
|
776
|
+
x = xs[i$];
|
|
777
|
+
if (f(x)) {
|
|
778
|
+
return i;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
findIndices = curry$(function(f, xs) {
|
|
783
|
+
var i$, len$, i, x, results$ = [];
|
|
784
|
+
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
|
|
785
|
+
i = i$;
|
|
786
|
+
x = xs[i$];
|
|
787
|
+
if (f(x)) {
|
|
788
|
+
results$.push(i);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return results$;
|
|
792
|
+
});
|
|
793
|
+
module.exports = {
|
|
794
|
+
each,
|
|
795
|
+
map,
|
|
796
|
+
filter,
|
|
797
|
+
compact,
|
|
798
|
+
reject,
|
|
799
|
+
remove,
|
|
800
|
+
partition,
|
|
801
|
+
find,
|
|
802
|
+
head,
|
|
803
|
+
first,
|
|
804
|
+
tail,
|
|
805
|
+
last,
|
|
806
|
+
initial,
|
|
807
|
+
empty,
|
|
808
|
+
reverse,
|
|
809
|
+
difference,
|
|
810
|
+
intersection,
|
|
811
|
+
union,
|
|
812
|
+
countBy,
|
|
813
|
+
groupBy,
|
|
814
|
+
fold,
|
|
815
|
+
fold1,
|
|
816
|
+
foldl,
|
|
817
|
+
foldl1,
|
|
818
|
+
foldr,
|
|
819
|
+
foldr1,
|
|
820
|
+
unfoldr,
|
|
821
|
+
andList,
|
|
822
|
+
orList,
|
|
823
|
+
any,
|
|
824
|
+
all,
|
|
825
|
+
unique,
|
|
826
|
+
uniqueBy,
|
|
827
|
+
sort,
|
|
828
|
+
sortWith,
|
|
829
|
+
sortBy,
|
|
830
|
+
sum,
|
|
831
|
+
product,
|
|
832
|
+
mean,
|
|
833
|
+
average,
|
|
834
|
+
concat,
|
|
835
|
+
concatMap,
|
|
836
|
+
flatten,
|
|
837
|
+
maximum,
|
|
838
|
+
minimum,
|
|
839
|
+
maximumBy,
|
|
840
|
+
minimumBy,
|
|
841
|
+
scan,
|
|
842
|
+
scan1,
|
|
843
|
+
scanl,
|
|
844
|
+
scanl1,
|
|
845
|
+
scanr,
|
|
846
|
+
scanr1,
|
|
847
|
+
slice,
|
|
848
|
+
take,
|
|
849
|
+
drop,
|
|
850
|
+
splitAt,
|
|
851
|
+
takeWhile,
|
|
852
|
+
dropWhile,
|
|
853
|
+
span,
|
|
854
|
+
breakList,
|
|
855
|
+
zip,
|
|
856
|
+
zipWith,
|
|
857
|
+
zipAll,
|
|
858
|
+
zipAllWith,
|
|
859
|
+
at,
|
|
860
|
+
elemIndex,
|
|
861
|
+
elemIndices,
|
|
862
|
+
findIndex,
|
|
863
|
+
findIndices
|
|
864
|
+
};
|
|
865
|
+
function curry$(f, bound) {
|
|
866
|
+
var context, _curry = function(args) {
|
|
867
|
+
return f.length > 1 ? function() {
|
|
868
|
+
var params = args ? args.concat() : [];
|
|
869
|
+
context = bound ? context || this : this;
|
|
870
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
871
|
+
} : f;
|
|
872
|
+
};
|
|
873
|
+
return _curry();
|
|
874
|
+
}
|
|
875
|
+
function in$(x, xs) {
|
|
876
|
+
var i = -1, l = xs.length >>> 0;
|
|
877
|
+
while (++i < l) if (x === xs[i]) return true;
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
function compose$() {
|
|
881
|
+
var functions = arguments;
|
|
882
|
+
return function() {
|
|
883
|
+
var i, result;
|
|
884
|
+
result = functions[0].apply(this, arguments);
|
|
885
|
+
for (i = 1; i < functions.length; ++i) {
|
|
886
|
+
result = functions[i](result);
|
|
887
|
+
}
|
|
888
|
+
return result;
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function not$(x) {
|
|
892
|
+
return !x;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
// node_modules/prelude-ls/lib/Obj.js
|
|
898
|
+
var require_Obj = __commonJS({
|
|
899
|
+
"node_modules/prelude-ls/lib/Obj.js"(exports, module) {
|
|
900
|
+
var values;
|
|
901
|
+
var keys;
|
|
902
|
+
var pairsToObj;
|
|
903
|
+
var objToPairs;
|
|
904
|
+
var listsToObj;
|
|
905
|
+
var objToLists;
|
|
906
|
+
var empty;
|
|
907
|
+
var each;
|
|
908
|
+
var map;
|
|
909
|
+
var compact;
|
|
910
|
+
var filter;
|
|
911
|
+
var reject;
|
|
912
|
+
var partition;
|
|
913
|
+
var find;
|
|
914
|
+
values = function(object) {
|
|
915
|
+
var i$, x, results$ = [];
|
|
916
|
+
for (i$ in object) {
|
|
917
|
+
x = object[i$];
|
|
918
|
+
results$.push(x);
|
|
919
|
+
}
|
|
920
|
+
return results$;
|
|
921
|
+
};
|
|
922
|
+
keys = function(object) {
|
|
923
|
+
var x, results$ = [];
|
|
924
|
+
for (x in object) {
|
|
925
|
+
results$.push(x);
|
|
926
|
+
}
|
|
927
|
+
return results$;
|
|
928
|
+
};
|
|
929
|
+
pairsToObj = function(object) {
|
|
930
|
+
var i$, len$, x, resultObj$ = {};
|
|
931
|
+
for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
|
|
932
|
+
x = object[i$];
|
|
933
|
+
resultObj$[x[0]] = x[1];
|
|
934
|
+
}
|
|
935
|
+
return resultObj$;
|
|
936
|
+
};
|
|
937
|
+
objToPairs = function(object) {
|
|
938
|
+
var key, value, results$ = [];
|
|
939
|
+
for (key in object) {
|
|
940
|
+
value = object[key];
|
|
941
|
+
results$.push([key, value]);
|
|
942
|
+
}
|
|
943
|
+
return results$;
|
|
944
|
+
};
|
|
945
|
+
listsToObj = curry$(function(keys2, values2) {
|
|
946
|
+
var i$, len$, i, key, resultObj$ = {};
|
|
947
|
+
for (i$ = 0, len$ = keys2.length; i$ < len$; ++i$) {
|
|
948
|
+
i = i$;
|
|
949
|
+
key = keys2[i$];
|
|
950
|
+
resultObj$[key] = values2[i];
|
|
951
|
+
}
|
|
952
|
+
return resultObj$;
|
|
953
|
+
});
|
|
954
|
+
objToLists = function(object) {
|
|
955
|
+
var keys2, values2, key, value;
|
|
956
|
+
keys2 = [];
|
|
957
|
+
values2 = [];
|
|
958
|
+
for (key in object) {
|
|
959
|
+
value = object[key];
|
|
960
|
+
keys2.push(key);
|
|
961
|
+
values2.push(value);
|
|
962
|
+
}
|
|
963
|
+
return [keys2, values2];
|
|
964
|
+
};
|
|
965
|
+
empty = function(object) {
|
|
966
|
+
var x;
|
|
967
|
+
for (x in object) {
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
970
|
+
return true;
|
|
971
|
+
};
|
|
972
|
+
each = curry$(function(f, object) {
|
|
973
|
+
var i$, x;
|
|
974
|
+
for (i$ in object) {
|
|
975
|
+
x = object[i$];
|
|
976
|
+
f(x);
|
|
977
|
+
}
|
|
978
|
+
return object;
|
|
979
|
+
});
|
|
980
|
+
map = curry$(function(f, object) {
|
|
981
|
+
var k, x, resultObj$ = {};
|
|
982
|
+
for (k in object) {
|
|
983
|
+
x = object[k];
|
|
984
|
+
resultObj$[k] = f(x);
|
|
985
|
+
}
|
|
986
|
+
return resultObj$;
|
|
987
|
+
});
|
|
988
|
+
compact = function(object) {
|
|
989
|
+
var k, x, resultObj$ = {};
|
|
990
|
+
for (k in object) {
|
|
991
|
+
x = object[k];
|
|
992
|
+
if (x) {
|
|
993
|
+
resultObj$[k] = x;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return resultObj$;
|
|
997
|
+
};
|
|
998
|
+
filter = curry$(function(f, object) {
|
|
999
|
+
var k, x, resultObj$ = {};
|
|
1000
|
+
for (k in object) {
|
|
1001
|
+
x = object[k];
|
|
1002
|
+
if (f(x)) {
|
|
1003
|
+
resultObj$[k] = x;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return resultObj$;
|
|
1007
|
+
});
|
|
1008
|
+
reject = curry$(function(f, object) {
|
|
1009
|
+
var k, x, resultObj$ = {};
|
|
1010
|
+
for (k in object) {
|
|
1011
|
+
x = object[k];
|
|
1012
|
+
if (!f(x)) {
|
|
1013
|
+
resultObj$[k] = x;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return resultObj$;
|
|
1017
|
+
});
|
|
1018
|
+
partition = curry$(function(f, object) {
|
|
1019
|
+
var passed, failed, k, x;
|
|
1020
|
+
passed = {};
|
|
1021
|
+
failed = {};
|
|
1022
|
+
for (k in object) {
|
|
1023
|
+
x = object[k];
|
|
1024
|
+
(f(x) ? passed : failed)[k] = x;
|
|
1025
|
+
}
|
|
1026
|
+
return [passed, failed];
|
|
1027
|
+
});
|
|
1028
|
+
find = curry$(function(f, object) {
|
|
1029
|
+
var i$, x;
|
|
1030
|
+
for (i$ in object) {
|
|
1031
|
+
x = object[i$];
|
|
1032
|
+
if (f(x)) {
|
|
1033
|
+
return x;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
module.exports = {
|
|
1038
|
+
values,
|
|
1039
|
+
keys,
|
|
1040
|
+
pairsToObj,
|
|
1041
|
+
objToPairs,
|
|
1042
|
+
listsToObj,
|
|
1043
|
+
objToLists,
|
|
1044
|
+
empty,
|
|
1045
|
+
each,
|
|
1046
|
+
map,
|
|
1047
|
+
filter,
|
|
1048
|
+
compact,
|
|
1049
|
+
reject,
|
|
1050
|
+
partition,
|
|
1051
|
+
find
|
|
1052
|
+
};
|
|
1053
|
+
function curry$(f, bound) {
|
|
1054
|
+
var context, _curry = function(args) {
|
|
1055
|
+
return f.length > 1 ? function() {
|
|
1056
|
+
var params = args ? args.concat() : [];
|
|
1057
|
+
context = bound ? context || this : this;
|
|
1058
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
1059
|
+
} : f;
|
|
1060
|
+
};
|
|
1061
|
+
return _curry();
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
// node_modules/prelude-ls/lib/Str.js
|
|
1067
|
+
var require_Str = __commonJS({
|
|
1068
|
+
"node_modules/prelude-ls/lib/Str.js"(exports, module) {
|
|
1069
|
+
var split;
|
|
1070
|
+
var join;
|
|
1071
|
+
var lines;
|
|
1072
|
+
var unlines;
|
|
1073
|
+
var words;
|
|
1074
|
+
var unwords;
|
|
1075
|
+
var chars;
|
|
1076
|
+
var unchars;
|
|
1077
|
+
var reverse;
|
|
1078
|
+
var repeat;
|
|
1079
|
+
var capitalize;
|
|
1080
|
+
var camelize;
|
|
1081
|
+
var dasherize;
|
|
1082
|
+
split = curry$(function(sep, str) {
|
|
1083
|
+
return str.split(sep);
|
|
1084
|
+
});
|
|
1085
|
+
join = curry$(function(sep, xs) {
|
|
1086
|
+
return xs.join(sep);
|
|
1087
|
+
});
|
|
1088
|
+
lines = function(str) {
|
|
1089
|
+
if (!str.length) {
|
|
1090
|
+
return [];
|
|
1091
|
+
}
|
|
1092
|
+
return str.split("\n");
|
|
1093
|
+
};
|
|
1094
|
+
unlines = function(it) {
|
|
1095
|
+
return it.join("\n");
|
|
1096
|
+
};
|
|
1097
|
+
words = function(str) {
|
|
1098
|
+
if (!str.length) {
|
|
1099
|
+
return [];
|
|
1100
|
+
}
|
|
1101
|
+
return str.split(/[ ]+/);
|
|
1102
|
+
};
|
|
1103
|
+
unwords = function(it) {
|
|
1104
|
+
return it.join(" ");
|
|
1105
|
+
};
|
|
1106
|
+
chars = function(it) {
|
|
1107
|
+
return it.split("");
|
|
1108
|
+
};
|
|
1109
|
+
unchars = function(it) {
|
|
1110
|
+
return it.join("");
|
|
1111
|
+
};
|
|
1112
|
+
reverse = function(str) {
|
|
1113
|
+
return str.split("").reverse().join("");
|
|
1114
|
+
};
|
|
1115
|
+
repeat = curry$(function(n, str) {
|
|
1116
|
+
var result, i$;
|
|
1117
|
+
result = "";
|
|
1118
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
1119
|
+
result += str;
|
|
1120
|
+
}
|
|
1121
|
+
return result;
|
|
1122
|
+
});
|
|
1123
|
+
capitalize = function(str) {
|
|
1124
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1125
|
+
};
|
|
1126
|
+
camelize = function(it) {
|
|
1127
|
+
return it.replace(/[-_]+(.)?/g, function(arg$, c) {
|
|
1128
|
+
return (c != null ? c : "").toUpperCase();
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
dasherize = function(str) {
|
|
1132
|
+
return str.replace(/([^-A-Z])([A-Z]+)/g, function(arg$, lower, upper) {
|
|
1133
|
+
return lower + "-" + (upper.length > 1 ? upper : upper.toLowerCase());
|
|
1134
|
+
}).replace(/^([A-Z]+)/, function(arg$, upper) {
|
|
1135
|
+
if (upper.length > 1) {
|
|
1136
|
+
return upper + "-";
|
|
1137
|
+
} else {
|
|
1138
|
+
return upper.toLowerCase();
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
};
|
|
1142
|
+
module.exports = {
|
|
1143
|
+
split,
|
|
1144
|
+
join,
|
|
1145
|
+
lines,
|
|
1146
|
+
unlines,
|
|
1147
|
+
words,
|
|
1148
|
+
unwords,
|
|
1149
|
+
chars,
|
|
1150
|
+
unchars,
|
|
1151
|
+
reverse,
|
|
1152
|
+
repeat,
|
|
1153
|
+
capitalize,
|
|
1154
|
+
camelize,
|
|
1155
|
+
dasherize
|
|
1156
|
+
};
|
|
1157
|
+
function curry$(f, bound) {
|
|
1158
|
+
var context, _curry = function(args) {
|
|
1159
|
+
return f.length > 1 ? function() {
|
|
1160
|
+
var params = args ? args.concat() : [];
|
|
1161
|
+
context = bound ? context || this : this;
|
|
1162
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
1163
|
+
} : f;
|
|
1164
|
+
};
|
|
1165
|
+
return _curry();
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
// node_modules/prelude-ls/lib/Num.js
|
|
1171
|
+
var require_Num = __commonJS({
|
|
1172
|
+
"node_modules/prelude-ls/lib/Num.js"(exports, module) {
|
|
1173
|
+
var max;
|
|
1174
|
+
var min;
|
|
1175
|
+
var negate;
|
|
1176
|
+
var abs;
|
|
1177
|
+
var signum;
|
|
1178
|
+
var quot;
|
|
1179
|
+
var rem;
|
|
1180
|
+
var div;
|
|
1181
|
+
var mod;
|
|
1182
|
+
var recip;
|
|
1183
|
+
var pi;
|
|
1184
|
+
var tau;
|
|
1185
|
+
var exp;
|
|
1186
|
+
var sqrt;
|
|
1187
|
+
var ln;
|
|
1188
|
+
var pow;
|
|
1189
|
+
var sin;
|
|
1190
|
+
var tan;
|
|
1191
|
+
var cos;
|
|
1192
|
+
var asin;
|
|
1193
|
+
var acos;
|
|
1194
|
+
var atan;
|
|
1195
|
+
var atan2;
|
|
1196
|
+
var truncate;
|
|
1197
|
+
var round;
|
|
1198
|
+
var ceiling;
|
|
1199
|
+
var floor;
|
|
1200
|
+
var isItNaN;
|
|
1201
|
+
var even;
|
|
1202
|
+
var odd;
|
|
1203
|
+
var gcd;
|
|
1204
|
+
var lcm;
|
|
1205
|
+
max = curry$(function(x$, y$) {
|
|
1206
|
+
return x$ > y$ ? x$ : y$;
|
|
1207
|
+
});
|
|
1208
|
+
min = curry$(function(x$, y$) {
|
|
1209
|
+
return x$ < y$ ? x$ : y$;
|
|
1210
|
+
});
|
|
1211
|
+
negate = function(x) {
|
|
1212
|
+
return -x;
|
|
1213
|
+
};
|
|
1214
|
+
abs = Math.abs;
|
|
1215
|
+
signum = function(x) {
|
|
1216
|
+
if (x < 0) {
|
|
1217
|
+
return -1;
|
|
1218
|
+
} else if (x > 0) {
|
|
1219
|
+
return 1;
|
|
1220
|
+
} else {
|
|
1221
|
+
return 0;
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
quot = curry$(function(x, y) {
|
|
1225
|
+
return ~~(x / y);
|
|
1226
|
+
});
|
|
1227
|
+
rem = curry$(function(x$, y$) {
|
|
1228
|
+
return x$ % y$;
|
|
1229
|
+
});
|
|
1230
|
+
div = curry$(function(x, y) {
|
|
1231
|
+
return Math.floor(x / y);
|
|
1232
|
+
});
|
|
1233
|
+
mod = curry$(function(x$, y$) {
|
|
1234
|
+
var ref$;
|
|
1235
|
+
return (x$ % (ref$ = y$) + ref$) % ref$;
|
|
1236
|
+
});
|
|
1237
|
+
recip = (function(it) {
|
|
1238
|
+
return 1 / it;
|
|
1239
|
+
});
|
|
1240
|
+
pi = Math.PI;
|
|
1241
|
+
tau = pi * 2;
|
|
1242
|
+
exp = Math.exp;
|
|
1243
|
+
sqrt = Math.sqrt;
|
|
1244
|
+
ln = Math.log;
|
|
1245
|
+
pow = curry$(function(x$, y$) {
|
|
1246
|
+
return Math.pow(x$, y$);
|
|
1247
|
+
});
|
|
1248
|
+
sin = Math.sin;
|
|
1249
|
+
tan = Math.tan;
|
|
1250
|
+
cos = Math.cos;
|
|
1251
|
+
asin = Math.asin;
|
|
1252
|
+
acos = Math.acos;
|
|
1253
|
+
atan = Math.atan;
|
|
1254
|
+
atan2 = curry$(function(x, y) {
|
|
1255
|
+
return Math.atan2(x, y);
|
|
1256
|
+
});
|
|
1257
|
+
truncate = function(x) {
|
|
1258
|
+
return ~~x;
|
|
1259
|
+
};
|
|
1260
|
+
round = Math.round;
|
|
1261
|
+
ceiling = Math.ceil;
|
|
1262
|
+
floor = Math.floor;
|
|
1263
|
+
isItNaN = function(x) {
|
|
1264
|
+
return x !== x;
|
|
1265
|
+
};
|
|
1266
|
+
even = function(x) {
|
|
1267
|
+
return x % 2 === 0;
|
|
1268
|
+
};
|
|
1269
|
+
odd = function(x) {
|
|
1270
|
+
return x % 2 !== 0;
|
|
1271
|
+
};
|
|
1272
|
+
gcd = curry$(function(x, y) {
|
|
1273
|
+
var z;
|
|
1274
|
+
x = Math.abs(x);
|
|
1275
|
+
y = Math.abs(y);
|
|
1276
|
+
while (y !== 0) {
|
|
1277
|
+
z = x % y;
|
|
1278
|
+
x = y;
|
|
1279
|
+
y = z;
|
|
1280
|
+
}
|
|
1281
|
+
return x;
|
|
1282
|
+
});
|
|
1283
|
+
lcm = curry$(function(x, y) {
|
|
1284
|
+
return Math.abs(Math.floor(x / gcd(x, y) * y));
|
|
1285
|
+
});
|
|
1286
|
+
module.exports = {
|
|
1287
|
+
max,
|
|
1288
|
+
min,
|
|
1289
|
+
negate,
|
|
1290
|
+
abs,
|
|
1291
|
+
signum,
|
|
1292
|
+
quot,
|
|
1293
|
+
rem,
|
|
1294
|
+
div,
|
|
1295
|
+
mod,
|
|
1296
|
+
recip,
|
|
1297
|
+
pi,
|
|
1298
|
+
tau,
|
|
1299
|
+
exp,
|
|
1300
|
+
sqrt,
|
|
1301
|
+
ln,
|
|
1302
|
+
pow,
|
|
1303
|
+
sin,
|
|
1304
|
+
tan,
|
|
1305
|
+
cos,
|
|
1306
|
+
acos,
|
|
1307
|
+
asin,
|
|
1308
|
+
atan,
|
|
1309
|
+
atan2,
|
|
1310
|
+
truncate,
|
|
1311
|
+
round,
|
|
1312
|
+
ceiling,
|
|
1313
|
+
floor,
|
|
1314
|
+
isItNaN,
|
|
1315
|
+
even,
|
|
1316
|
+
odd,
|
|
1317
|
+
gcd,
|
|
1318
|
+
lcm
|
|
1319
|
+
};
|
|
1320
|
+
function curry$(f, bound) {
|
|
1321
|
+
var context, _curry = function(args) {
|
|
1322
|
+
return f.length > 1 ? function() {
|
|
1323
|
+
var params = args ? args.concat() : [];
|
|
1324
|
+
context = bound ? context || this : this;
|
|
1325
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
1326
|
+
} : f;
|
|
1327
|
+
};
|
|
1328
|
+
return _curry();
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
// node_modules/prelude-ls/lib/index.js
|
|
1334
|
+
var require_lib = __commonJS({
|
|
1335
|
+
"node_modules/prelude-ls/lib/index.js"(exports, module) {
|
|
1336
|
+
var Func;
|
|
1337
|
+
var List;
|
|
1338
|
+
var Obj;
|
|
1339
|
+
var Str;
|
|
1340
|
+
var Num;
|
|
1341
|
+
var id;
|
|
1342
|
+
var isType;
|
|
1343
|
+
var replicate;
|
|
1344
|
+
var prelude;
|
|
1345
|
+
var toString$ = {}.toString;
|
|
1346
|
+
Func = require_Func();
|
|
1347
|
+
List = require_List();
|
|
1348
|
+
Obj = require_Obj();
|
|
1349
|
+
Str = require_Str();
|
|
1350
|
+
Num = require_Num();
|
|
1351
|
+
id = function(x) {
|
|
1352
|
+
return x;
|
|
1353
|
+
};
|
|
1354
|
+
isType = curry$(function(type, x) {
|
|
1355
|
+
return toString$.call(x).slice(8, -1) === type;
|
|
1356
|
+
});
|
|
1357
|
+
replicate = curry$(function(n, x) {
|
|
1358
|
+
var i$, results$ = [];
|
|
1359
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
1360
|
+
results$.push(x);
|
|
1361
|
+
}
|
|
1362
|
+
return results$;
|
|
1363
|
+
});
|
|
1364
|
+
Str.empty = List.empty;
|
|
1365
|
+
Str.slice = List.slice;
|
|
1366
|
+
Str.take = List.take;
|
|
1367
|
+
Str.drop = List.drop;
|
|
1368
|
+
Str.splitAt = List.splitAt;
|
|
1369
|
+
Str.takeWhile = List.takeWhile;
|
|
1370
|
+
Str.dropWhile = List.dropWhile;
|
|
1371
|
+
Str.span = List.span;
|
|
1372
|
+
Str.breakStr = List.breakList;
|
|
1373
|
+
prelude = {
|
|
1374
|
+
Func,
|
|
1375
|
+
List,
|
|
1376
|
+
Obj,
|
|
1377
|
+
Str,
|
|
1378
|
+
Num,
|
|
1379
|
+
id,
|
|
1380
|
+
isType,
|
|
1381
|
+
replicate
|
|
1382
|
+
};
|
|
1383
|
+
prelude.each = List.each;
|
|
1384
|
+
prelude.map = List.map;
|
|
1385
|
+
prelude.filter = List.filter;
|
|
1386
|
+
prelude.compact = List.compact;
|
|
1387
|
+
prelude.reject = List.reject;
|
|
1388
|
+
prelude.partition = List.partition;
|
|
1389
|
+
prelude.find = List.find;
|
|
1390
|
+
prelude.head = List.head;
|
|
1391
|
+
prelude.first = List.first;
|
|
1392
|
+
prelude.tail = List.tail;
|
|
1393
|
+
prelude.last = List.last;
|
|
1394
|
+
prelude.initial = List.initial;
|
|
1395
|
+
prelude.empty = List.empty;
|
|
1396
|
+
prelude.reverse = List.reverse;
|
|
1397
|
+
prelude.difference = List.difference;
|
|
1398
|
+
prelude.intersection = List.intersection;
|
|
1399
|
+
prelude.union = List.union;
|
|
1400
|
+
prelude.countBy = List.countBy;
|
|
1401
|
+
prelude.groupBy = List.groupBy;
|
|
1402
|
+
prelude.fold = List.fold;
|
|
1403
|
+
prelude.foldl = List.foldl;
|
|
1404
|
+
prelude.fold1 = List.fold1;
|
|
1405
|
+
prelude.foldl1 = List.foldl1;
|
|
1406
|
+
prelude.foldr = List.foldr;
|
|
1407
|
+
prelude.foldr1 = List.foldr1;
|
|
1408
|
+
prelude.unfoldr = List.unfoldr;
|
|
1409
|
+
prelude.andList = List.andList;
|
|
1410
|
+
prelude.orList = List.orList;
|
|
1411
|
+
prelude.any = List.any;
|
|
1412
|
+
prelude.all = List.all;
|
|
1413
|
+
prelude.unique = List.unique;
|
|
1414
|
+
prelude.uniqueBy = List.uniqueBy;
|
|
1415
|
+
prelude.sort = List.sort;
|
|
1416
|
+
prelude.sortWith = List.sortWith;
|
|
1417
|
+
prelude.sortBy = List.sortBy;
|
|
1418
|
+
prelude.sum = List.sum;
|
|
1419
|
+
prelude.product = List.product;
|
|
1420
|
+
prelude.mean = List.mean;
|
|
1421
|
+
prelude.average = List.average;
|
|
1422
|
+
prelude.concat = List.concat;
|
|
1423
|
+
prelude.concatMap = List.concatMap;
|
|
1424
|
+
prelude.flatten = List.flatten;
|
|
1425
|
+
prelude.maximum = List.maximum;
|
|
1426
|
+
prelude.minimum = List.minimum;
|
|
1427
|
+
prelude.maximumBy = List.maximumBy;
|
|
1428
|
+
prelude.minimumBy = List.minimumBy;
|
|
1429
|
+
prelude.scan = List.scan;
|
|
1430
|
+
prelude.scanl = List.scanl;
|
|
1431
|
+
prelude.scan1 = List.scan1;
|
|
1432
|
+
prelude.scanl1 = List.scanl1;
|
|
1433
|
+
prelude.scanr = List.scanr;
|
|
1434
|
+
prelude.scanr1 = List.scanr1;
|
|
1435
|
+
prelude.slice = List.slice;
|
|
1436
|
+
prelude.take = List.take;
|
|
1437
|
+
prelude.drop = List.drop;
|
|
1438
|
+
prelude.splitAt = List.splitAt;
|
|
1439
|
+
prelude.takeWhile = List.takeWhile;
|
|
1440
|
+
prelude.dropWhile = List.dropWhile;
|
|
1441
|
+
prelude.span = List.span;
|
|
1442
|
+
prelude.breakList = List.breakList;
|
|
1443
|
+
prelude.zip = List.zip;
|
|
1444
|
+
prelude.zipWith = List.zipWith;
|
|
1445
|
+
prelude.zipAll = List.zipAll;
|
|
1446
|
+
prelude.zipAllWith = List.zipAllWith;
|
|
1447
|
+
prelude.at = List.at;
|
|
1448
|
+
prelude.elemIndex = List.elemIndex;
|
|
1449
|
+
prelude.elemIndices = List.elemIndices;
|
|
1450
|
+
prelude.findIndex = List.findIndex;
|
|
1451
|
+
prelude.findIndices = List.findIndices;
|
|
1452
|
+
prelude.apply = Func.apply;
|
|
1453
|
+
prelude.curry = Func.curry;
|
|
1454
|
+
prelude.flip = Func.flip;
|
|
1455
|
+
prelude.fix = Func.fix;
|
|
1456
|
+
prelude.over = Func.over;
|
|
1457
|
+
prelude.split = Str.split;
|
|
1458
|
+
prelude.join = Str.join;
|
|
1459
|
+
prelude.lines = Str.lines;
|
|
1460
|
+
prelude.unlines = Str.unlines;
|
|
1461
|
+
prelude.words = Str.words;
|
|
1462
|
+
prelude.unwords = Str.unwords;
|
|
1463
|
+
prelude.chars = Str.chars;
|
|
1464
|
+
prelude.unchars = Str.unchars;
|
|
1465
|
+
prelude.repeat = Str.repeat;
|
|
1466
|
+
prelude.capitalize = Str.capitalize;
|
|
1467
|
+
prelude.camelize = Str.camelize;
|
|
1468
|
+
prelude.dasherize = Str.dasherize;
|
|
1469
|
+
prelude.values = Obj.values;
|
|
1470
|
+
prelude.keys = Obj.keys;
|
|
1471
|
+
prelude.pairsToObj = Obj.pairsToObj;
|
|
1472
|
+
prelude.objToPairs = Obj.objToPairs;
|
|
1473
|
+
prelude.listsToObj = Obj.listsToObj;
|
|
1474
|
+
prelude.objToLists = Obj.objToLists;
|
|
1475
|
+
prelude.max = Num.max;
|
|
1476
|
+
prelude.min = Num.min;
|
|
1477
|
+
prelude.negate = Num.negate;
|
|
1478
|
+
prelude.abs = Num.abs;
|
|
1479
|
+
prelude.signum = Num.signum;
|
|
1480
|
+
prelude.quot = Num.quot;
|
|
1481
|
+
prelude.rem = Num.rem;
|
|
1482
|
+
prelude.div = Num.div;
|
|
1483
|
+
prelude.mod = Num.mod;
|
|
1484
|
+
prelude.recip = Num.recip;
|
|
1485
|
+
prelude.pi = Num.pi;
|
|
1486
|
+
prelude.tau = Num.tau;
|
|
1487
|
+
prelude.exp = Num.exp;
|
|
1488
|
+
prelude.sqrt = Num.sqrt;
|
|
1489
|
+
prelude.ln = Num.ln;
|
|
1490
|
+
prelude.pow = Num.pow;
|
|
1491
|
+
prelude.sin = Num.sin;
|
|
1492
|
+
prelude.tan = Num.tan;
|
|
1493
|
+
prelude.cos = Num.cos;
|
|
1494
|
+
prelude.acos = Num.acos;
|
|
1495
|
+
prelude.asin = Num.asin;
|
|
1496
|
+
prelude.atan = Num.atan;
|
|
1497
|
+
prelude.atan2 = Num.atan2;
|
|
1498
|
+
prelude.truncate = Num.truncate;
|
|
1499
|
+
prelude.round = Num.round;
|
|
1500
|
+
prelude.ceiling = Num.ceiling;
|
|
1501
|
+
prelude.floor = Num.floor;
|
|
1502
|
+
prelude.isItNaN = Num.isItNaN;
|
|
1503
|
+
prelude.even = Num.even;
|
|
1504
|
+
prelude.odd = Num.odd;
|
|
1505
|
+
prelude.gcd = Num.gcd;
|
|
1506
|
+
prelude.lcm = Num.lcm;
|
|
1507
|
+
prelude.VERSION = "1.2.1";
|
|
1508
|
+
module.exports = prelude;
|
|
1509
|
+
function curry$(f, bound) {
|
|
1510
|
+
var context, _curry = function(args) {
|
|
1511
|
+
return f.length > 1 ? function() {
|
|
1512
|
+
var params = args ? args.concat() : [];
|
|
1513
|
+
context = bound ? context || this : this;
|
|
1514
|
+
return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
|
|
1515
|
+
} : f;
|
|
1516
|
+
};
|
|
1517
|
+
return _curry();
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
// node_modules/levn/lib/parse-string.js
|
|
1523
|
+
var require_parse_string = __commonJS({
|
|
1524
|
+
"node_modules/levn/lib/parse-string.js"(exports, module) {
|
|
1525
|
+
(function() {
|
|
1526
|
+
var reject, special, tokenRegex;
|
|
1527
|
+
reject = require_lib().reject;
|
|
1528
|
+
function consumeOp(tokens, op) {
|
|
1529
|
+
if (tokens[0] === op) {
|
|
1530
|
+
return tokens.shift();
|
|
1531
|
+
} else {
|
|
1532
|
+
throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + ".");
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
function maybeConsumeOp(tokens, op) {
|
|
1536
|
+
if (tokens[0] === op) {
|
|
1537
|
+
return tokens.shift();
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function consumeList(tokens, arg$, hasDelimiters) {
|
|
1541
|
+
var open, close, result, untilTest;
|
|
1542
|
+
open = arg$[0], close = arg$[1];
|
|
1543
|
+
if (hasDelimiters) {
|
|
1544
|
+
consumeOp(tokens, open);
|
|
1545
|
+
}
|
|
1546
|
+
result = [];
|
|
1547
|
+
untilTest = "," + (hasDelimiters ? close : "");
|
|
1548
|
+
while (tokens.length && (hasDelimiters && tokens[0] !== close)) {
|
|
1549
|
+
result.push(consumeElement(tokens, untilTest));
|
|
1550
|
+
maybeConsumeOp(tokens, ",");
|
|
1551
|
+
}
|
|
1552
|
+
if (hasDelimiters) {
|
|
1553
|
+
consumeOp(tokens, close);
|
|
1554
|
+
}
|
|
1555
|
+
return result;
|
|
1556
|
+
}
|
|
1557
|
+
function consumeArray(tokens, hasDelimiters) {
|
|
1558
|
+
return consumeList(tokens, ["[", "]"], hasDelimiters);
|
|
1559
|
+
}
|
|
1560
|
+
function consumeTuple(tokens, hasDelimiters) {
|
|
1561
|
+
return consumeList(tokens, ["(", ")"], hasDelimiters);
|
|
1562
|
+
}
|
|
1563
|
+
function consumeFields(tokens, hasDelimiters) {
|
|
1564
|
+
var result, untilTest, key;
|
|
1565
|
+
if (hasDelimiters) {
|
|
1566
|
+
consumeOp(tokens, "{");
|
|
1567
|
+
}
|
|
1568
|
+
result = {};
|
|
1569
|
+
untilTest = "," + (hasDelimiters ? "}" : "");
|
|
1570
|
+
while (tokens.length && (!hasDelimiters || tokens[0] !== "}")) {
|
|
1571
|
+
key = consumeValue(tokens, ":");
|
|
1572
|
+
consumeOp(tokens, ":");
|
|
1573
|
+
result[key] = consumeElement(tokens, untilTest);
|
|
1574
|
+
maybeConsumeOp(tokens, ",");
|
|
1575
|
+
}
|
|
1576
|
+
if (hasDelimiters) {
|
|
1577
|
+
consumeOp(tokens, "}");
|
|
1578
|
+
}
|
|
1579
|
+
return result;
|
|
1580
|
+
}
|
|
1581
|
+
function consumeValue(tokens, untilTest) {
|
|
1582
|
+
var out;
|
|
1583
|
+
untilTest == null && (untilTest = "");
|
|
1584
|
+
out = "";
|
|
1585
|
+
while (tokens.length && -1 === untilTest.indexOf(tokens[0])) {
|
|
1586
|
+
out += tokens.shift();
|
|
1587
|
+
}
|
|
1588
|
+
return out;
|
|
1589
|
+
}
|
|
1590
|
+
function consumeElement(tokens, untilTest) {
|
|
1591
|
+
switch (tokens[0]) {
|
|
1592
|
+
case "[":
|
|
1593
|
+
return consumeArray(tokens, true);
|
|
1594
|
+
case "(":
|
|
1595
|
+
return consumeTuple(tokens, true);
|
|
1596
|
+
case "{":
|
|
1597
|
+
return consumeFields(tokens, true);
|
|
1598
|
+
default:
|
|
1599
|
+
return consumeValue(tokens, untilTest);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
function consumeTopLevel(tokens, types, options) {
|
|
1603
|
+
var ref$, type, structure, origTokens, result, finalResult, x$, y$;
|
|
1604
|
+
ref$ = types[0], type = ref$.type, structure = ref$.structure;
|
|
1605
|
+
origTokens = tokens.concat();
|
|
1606
|
+
if (!options.explicit && types.length === 1 && (!type && structure || (type === "Array" || type === "Object"))) {
|
|
1607
|
+
result = structure === "array" || type === "Array" ? consumeArray(tokens, tokens[0] === "[") : structure === "tuple" ? consumeTuple(tokens, tokens[0] === "(") : consumeFields(tokens, tokens[0] === "{");
|
|
1608
|
+
finalResult = tokens.length ? consumeElement(structure === "array" || type === "Array" ? (x$ = origTokens, x$.unshift("["), x$.push("]"), x$) : (y$ = origTokens, y$.unshift("("), y$.push(")"), y$)) : result;
|
|
1609
|
+
} else {
|
|
1610
|
+
finalResult = consumeElement(tokens);
|
|
1611
|
+
}
|
|
1612
|
+
return finalResult;
|
|
1613
|
+
}
|
|
1614
|
+
special = /\[\]\(\)}{:,/.source;
|
|
1615
|
+
tokenRegex = RegExp(`("(?:\\\\"|[^"])*")|('(?:\\\\'|[^'])*')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([` + special + "])|([^\\s" + special + "](?:\\s*[^\\s" + special + "]+)*)|\\s*");
|
|
1616
|
+
module.exports = function(types, string, options) {
|
|
1617
|
+
var tokens, node;
|
|
1618
|
+
options == null && (options = {});
|
|
1619
|
+
if (!options.explicit && types.length === 1 && types[0].type === "String") {
|
|
1620
|
+
return string;
|
|
1621
|
+
}
|
|
1622
|
+
tokens = reject(not$, string.split(tokenRegex));
|
|
1623
|
+
node = consumeTopLevel(tokens, types, options);
|
|
1624
|
+
if (!node) {
|
|
1625
|
+
throw new Error("Error parsing '" + string + "'.");
|
|
1626
|
+
}
|
|
1627
|
+
return node;
|
|
1628
|
+
};
|
|
1629
|
+
function not$(x) {
|
|
1630
|
+
return !x;
|
|
1631
|
+
}
|
|
1632
|
+
}).call(exports);
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1636
|
+
// node_modules/type-check/lib/parse-type.js
|
|
1637
|
+
var require_parse_type = __commonJS({
|
|
1638
|
+
"node_modules/type-check/lib/parse-type.js"(exports, module) {
|
|
1639
|
+
(function() {
|
|
1640
|
+
var identifierRegex, tokenRegex;
|
|
1641
|
+
identifierRegex = /[\$\w]+/;
|
|
1642
|
+
function peek(tokens) {
|
|
1643
|
+
var token;
|
|
1644
|
+
token = tokens[0];
|
|
1645
|
+
if (token == null) {
|
|
1646
|
+
throw new Error("Unexpected end of input.");
|
|
1647
|
+
}
|
|
1648
|
+
return token;
|
|
1649
|
+
}
|
|
1650
|
+
function consumeIdent(tokens) {
|
|
1651
|
+
var token;
|
|
1652
|
+
token = peek(tokens);
|
|
1653
|
+
if (!identifierRegex.test(token)) {
|
|
1654
|
+
throw new Error("Expected text, got '" + token + "' instead.");
|
|
1655
|
+
}
|
|
1656
|
+
return tokens.shift();
|
|
1657
|
+
}
|
|
1658
|
+
function consumeOp(tokens, op) {
|
|
1659
|
+
var token;
|
|
1660
|
+
token = peek(tokens);
|
|
1661
|
+
if (token !== op) {
|
|
1662
|
+
throw new Error("Expected '" + op + "', got '" + token + "' instead.");
|
|
1663
|
+
}
|
|
1664
|
+
return tokens.shift();
|
|
1665
|
+
}
|
|
1666
|
+
function maybeConsumeOp(tokens, op) {
|
|
1667
|
+
var token;
|
|
1668
|
+
token = tokens[0];
|
|
1669
|
+
if (token === op) {
|
|
1670
|
+
return tokens.shift();
|
|
1671
|
+
} else {
|
|
1672
|
+
return null;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function consumeArray(tokens) {
|
|
1676
|
+
var types;
|
|
1677
|
+
consumeOp(tokens, "[");
|
|
1678
|
+
if (peek(tokens) === "]") {
|
|
1679
|
+
throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
|
|
1680
|
+
}
|
|
1681
|
+
types = consumeTypes(tokens);
|
|
1682
|
+
consumeOp(tokens, "]");
|
|
1683
|
+
return {
|
|
1684
|
+
structure: "array",
|
|
1685
|
+
of: types
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
function consumeTuple(tokens) {
|
|
1689
|
+
var components;
|
|
1690
|
+
components = [];
|
|
1691
|
+
consumeOp(tokens, "(");
|
|
1692
|
+
if (peek(tokens) === ")") {
|
|
1693
|
+
throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
|
|
1694
|
+
}
|
|
1695
|
+
for (; ; ) {
|
|
1696
|
+
components.push(consumeTypes(tokens));
|
|
1697
|
+
maybeConsumeOp(tokens, ",");
|
|
1698
|
+
if (")" === peek(tokens)) {
|
|
1699
|
+
break;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
consumeOp(tokens, ")");
|
|
1703
|
+
return {
|
|
1704
|
+
structure: "tuple",
|
|
1705
|
+
of: components
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
function consumeFields(tokens) {
|
|
1709
|
+
var fields, subset, ref$, key, types;
|
|
1710
|
+
fields = {};
|
|
1711
|
+
consumeOp(tokens, "{");
|
|
1712
|
+
subset = false;
|
|
1713
|
+
for (; ; ) {
|
|
1714
|
+
if (maybeConsumeOp(tokens, "...")) {
|
|
1715
|
+
subset = true;
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
|
|
1719
|
+
fields[key] = types;
|
|
1720
|
+
maybeConsumeOp(tokens, ",");
|
|
1721
|
+
if ("}" === peek(tokens)) {
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
consumeOp(tokens, "}");
|
|
1726
|
+
return {
|
|
1727
|
+
structure: "fields",
|
|
1728
|
+
of: fields,
|
|
1729
|
+
subset
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function consumeField(tokens) {
|
|
1733
|
+
var key, types;
|
|
1734
|
+
key = consumeIdent(tokens);
|
|
1735
|
+
consumeOp(tokens, ":");
|
|
1736
|
+
types = consumeTypes(tokens);
|
|
1737
|
+
return [key, types];
|
|
1738
|
+
}
|
|
1739
|
+
function maybeConsumeStructure(tokens) {
|
|
1740
|
+
switch (tokens[0]) {
|
|
1741
|
+
case "[":
|
|
1742
|
+
return consumeArray(tokens);
|
|
1743
|
+
case "(":
|
|
1744
|
+
return consumeTuple(tokens);
|
|
1745
|
+
case "{":
|
|
1746
|
+
return consumeFields(tokens);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
function consumeType(tokens) {
|
|
1750
|
+
var token, wildcard, type, structure;
|
|
1751
|
+
token = peek(tokens);
|
|
1752
|
+
wildcard = token === "*";
|
|
1753
|
+
if (wildcard || identifierRegex.test(token)) {
|
|
1754
|
+
type = wildcard ? consumeOp(tokens, "*") : consumeIdent(tokens);
|
|
1755
|
+
structure = maybeConsumeStructure(tokens);
|
|
1756
|
+
if (structure) {
|
|
1757
|
+
return structure.type = type, structure;
|
|
1758
|
+
} else {
|
|
1759
|
+
return {
|
|
1760
|
+
type
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
} else {
|
|
1764
|
+
structure = maybeConsumeStructure(tokens);
|
|
1765
|
+
if (!structure) {
|
|
1766
|
+
throw new Error("Unexpected character: " + token);
|
|
1767
|
+
}
|
|
1768
|
+
return structure;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
function consumeTypes(tokens) {
|
|
1772
|
+
var lookahead, types, typesSoFar, typeObj, type, structure;
|
|
1773
|
+
if ("::" === peek(tokens)) {
|
|
1774
|
+
throw new Error("No comment before comment separator '::' found.");
|
|
1775
|
+
}
|
|
1776
|
+
lookahead = tokens[1];
|
|
1777
|
+
if (lookahead != null && lookahead === "::") {
|
|
1778
|
+
tokens.shift();
|
|
1779
|
+
tokens.shift();
|
|
1780
|
+
}
|
|
1781
|
+
types = [];
|
|
1782
|
+
typesSoFar = {};
|
|
1783
|
+
if ("Maybe" === peek(tokens)) {
|
|
1784
|
+
tokens.shift();
|
|
1785
|
+
types = [
|
|
1786
|
+
{
|
|
1787
|
+
type: "Undefined"
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
type: "Null"
|
|
1791
|
+
}
|
|
1792
|
+
];
|
|
1793
|
+
typesSoFar = {
|
|
1794
|
+
Undefined: true,
|
|
1795
|
+
Null: true
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
for (; ; ) {
|
|
1799
|
+
typeObj = consumeType(tokens), type = typeObj.type, structure = typeObj.structure;
|
|
1800
|
+
if (!typesSoFar[type]) {
|
|
1801
|
+
types.push(typeObj);
|
|
1802
|
+
}
|
|
1803
|
+
if (structure == null) {
|
|
1804
|
+
typesSoFar[type] = true;
|
|
1805
|
+
}
|
|
1806
|
+
if (!maybeConsumeOp(tokens, "|")) {
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return types;
|
|
1811
|
+
}
|
|
1812
|
+
tokenRegex = RegExp("\\.\\.\\.|::|->|" + identifierRegex.source + "|\\S", "g");
|
|
1813
|
+
module.exports = function(input) {
|
|
1814
|
+
var tokens, e;
|
|
1815
|
+
if (!input.length) {
|
|
1816
|
+
throw new Error("No type specified.");
|
|
1817
|
+
}
|
|
1818
|
+
tokens = input.match(tokenRegex) || [];
|
|
1819
|
+
if (in$("->", tokens)) {
|
|
1820
|
+
throw new Error("Function types are not supported. To validate that something is a function, you may use 'Function'.");
|
|
1821
|
+
}
|
|
1822
|
+
try {
|
|
1823
|
+
return consumeTypes(tokens);
|
|
1824
|
+
} catch (e$) {
|
|
1825
|
+
e = e$;
|
|
1826
|
+
throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
function in$(x, xs) {
|
|
1830
|
+
var i = -1, l = xs.length >>> 0;
|
|
1831
|
+
while (++i < l) if (x === xs[i]) return true;
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
}).call(exports);
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
|
|
1838
|
+
// node_modules/type-check/lib/check.js
|
|
1839
|
+
var require_check = __commonJS({
|
|
1840
|
+
"node_modules/type-check/lib/check.js"(exports, module) {
|
|
1841
|
+
(function() {
|
|
1842
|
+
var ref$, any, all, isItNaN, types, defaultType, toString$ = {}.toString;
|
|
1843
|
+
ref$ = require_lib(), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
|
|
1844
|
+
types = {
|
|
1845
|
+
Number: {
|
|
1846
|
+
typeOf: "Number",
|
|
1847
|
+
validate: function(it) {
|
|
1848
|
+
return !isItNaN(it);
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
NaN: {
|
|
1852
|
+
typeOf: "Number",
|
|
1853
|
+
validate: isItNaN
|
|
1854
|
+
},
|
|
1855
|
+
Int: {
|
|
1856
|
+
typeOf: "Number",
|
|
1857
|
+
validate: function(it) {
|
|
1858
|
+
return !isItNaN(it) && it % 1 === 0;
|
|
1859
|
+
}
|
|
1860
|
+
},
|
|
1861
|
+
Float: {
|
|
1862
|
+
typeOf: "Number",
|
|
1863
|
+
validate: function(it) {
|
|
1864
|
+
return !isItNaN(it);
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
Date: {
|
|
1868
|
+
typeOf: "Date",
|
|
1869
|
+
validate: function(it) {
|
|
1870
|
+
return !isItNaN(it.getTime());
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
defaultType = {
|
|
1875
|
+
array: "Array",
|
|
1876
|
+
tuple: "Array"
|
|
1877
|
+
};
|
|
1878
|
+
function checkArray(input, type, options) {
|
|
1879
|
+
return all(function(it) {
|
|
1880
|
+
return checkMultiple(it, type.of, options);
|
|
1881
|
+
}, input);
|
|
1882
|
+
}
|
|
1883
|
+
function checkTuple(input, type, options) {
|
|
1884
|
+
var i, i$, ref$2, len$, types2;
|
|
1885
|
+
i = 0;
|
|
1886
|
+
for (i$ = 0, len$ = (ref$2 = type.of).length; i$ < len$; ++i$) {
|
|
1887
|
+
types2 = ref$2[i$];
|
|
1888
|
+
if (!checkMultiple(input[i], types2, options)) {
|
|
1889
|
+
return false;
|
|
1890
|
+
}
|
|
1891
|
+
i++;
|
|
1892
|
+
}
|
|
1893
|
+
return input.length <= i;
|
|
1894
|
+
}
|
|
1895
|
+
function checkFields(input, type, options) {
|
|
1896
|
+
var inputKeys, numInputKeys, k, numOfKeys, key, ref$2, types2;
|
|
1897
|
+
inputKeys = {};
|
|
1898
|
+
numInputKeys = 0;
|
|
1899
|
+
for (k in input) {
|
|
1900
|
+
inputKeys[k] = true;
|
|
1901
|
+
numInputKeys++;
|
|
1902
|
+
}
|
|
1903
|
+
numOfKeys = 0;
|
|
1904
|
+
for (key in ref$2 = type.of) {
|
|
1905
|
+
types2 = ref$2[key];
|
|
1906
|
+
if (!checkMultiple(input[key], types2, options)) {
|
|
1907
|
+
return false;
|
|
1908
|
+
}
|
|
1909
|
+
if (inputKeys[key]) {
|
|
1910
|
+
numOfKeys++;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
return type.subset || numInputKeys === numOfKeys;
|
|
1914
|
+
}
|
|
1915
|
+
function checkStructure(input, type, options) {
|
|
1916
|
+
if (!(input instanceof Object)) {
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
switch (type.structure) {
|
|
1920
|
+
case "fields":
|
|
1921
|
+
return checkFields(input, type, options);
|
|
1922
|
+
case "array":
|
|
1923
|
+
return checkArray(input, type, options);
|
|
1924
|
+
case "tuple":
|
|
1925
|
+
return checkTuple(input, type, options);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function check(input, typeObj, options) {
|
|
1929
|
+
var type, structure, setting, that;
|
|
1930
|
+
type = typeObj.type, structure = typeObj.structure;
|
|
1931
|
+
if (type) {
|
|
1932
|
+
if (type === "*") {
|
|
1933
|
+
return true;
|
|
1934
|
+
}
|
|
1935
|
+
setting = options.customTypes[type] || types[type];
|
|
1936
|
+
if (setting) {
|
|
1937
|
+
return (setting.typeOf === void 0 || setting.typeOf === toString$.call(input).slice(8, -1)) && setting.validate(input);
|
|
1938
|
+
} else {
|
|
1939
|
+
return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj, options));
|
|
1940
|
+
}
|
|
1941
|
+
} else if (structure) {
|
|
1942
|
+
if (that = defaultType[structure]) {
|
|
1943
|
+
if (that !== toString$.call(input).slice(8, -1)) {
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return checkStructure(input, typeObj, options);
|
|
1948
|
+
} else {
|
|
1949
|
+
throw new Error("No type defined. Input: " + input + ".");
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
function checkMultiple(input, types2, options) {
|
|
1953
|
+
if (toString$.call(types2).slice(8, -1) !== "Array") {
|
|
1954
|
+
throw new Error("Types must be in an array. Input: " + input + ".");
|
|
1955
|
+
}
|
|
1956
|
+
return any(function(it) {
|
|
1957
|
+
return check(input, it, options);
|
|
1958
|
+
}, types2);
|
|
1959
|
+
}
|
|
1960
|
+
module.exports = function(parsedType, input, options) {
|
|
1961
|
+
options == null && (options = {});
|
|
1962
|
+
if (options.customTypes == null) {
|
|
1963
|
+
options.customTypes = {};
|
|
1964
|
+
}
|
|
1965
|
+
return checkMultiple(input, parsedType, options);
|
|
1966
|
+
};
|
|
1967
|
+
}).call(exports);
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
|
|
1971
|
+
// node_modules/type-check/lib/index.js
|
|
1972
|
+
var require_lib2 = __commonJS({
|
|
1973
|
+
"node_modules/type-check/lib/index.js"(exports, module) {
|
|
1974
|
+
(function() {
|
|
1975
|
+
var VERSION, parseType, parsedTypeCheck, typeCheck;
|
|
1976
|
+
VERSION = "0.4.0";
|
|
1977
|
+
parseType = require_parse_type();
|
|
1978
|
+
parsedTypeCheck = require_check();
|
|
1979
|
+
typeCheck = function(type, input, options) {
|
|
1980
|
+
return parsedTypeCheck(parseType(type), input, options);
|
|
1981
|
+
};
|
|
1982
|
+
module.exports = {
|
|
1983
|
+
VERSION,
|
|
1984
|
+
typeCheck,
|
|
1985
|
+
parsedTypeCheck,
|
|
1986
|
+
parseType
|
|
1987
|
+
};
|
|
1988
|
+
}).call(exports);
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1991
|
+
|
|
1992
|
+
// node_modules/levn/lib/cast.js
|
|
1993
|
+
var require_cast = __commonJS({
|
|
1994
|
+
"node_modules/levn/lib/cast.js"(exports, module) {
|
|
1995
|
+
(function() {
|
|
1996
|
+
var parsedTypeCheck, types, toString$ = {}.toString;
|
|
1997
|
+
parsedTypeCheck = require_lib2().parsedTypeCheck;
|
|
1998
|
+
types = {
|
|
1999
|
+
"*": function(value, options) {
|
|
2000
|
+
switch (toString$.call(value).slice(8, -1)) {
|
|
2001
|
+
case "Array":
|
|
2002
|
+
return typeCast(value, {
|
|
2003
|
+
type: "Array"
|
|
2004
|
+
}, options);
|
|
2005
|
+
case "Object":
|
|
2006
|
+
return typeCast(value, {
|
|
2007
|
+
type: "Object"
|
|
2008
|
+
}, options);
|
|
2009
|
+
default:
|
|
2010
|
+
return {
|
|
2011
|
+
type: "Just",
|
|
2012
|
+
value: typesCast(value, [
|
|
2013
|
+
{
|
|
2014
|
+
type: "Undefined"
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
type: "Null"
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
type: "NaN"
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
type: "Boolean"
|
|
2024
|
+
},
|
|
2025
|
+
{
|
|
2026
|
+
type: "Number"
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
type: "Date"
|
|
2030
|
+
},
|
|
2031
|
+
{
|
|
2032
|
+
type: "RegExp"
|
|
2033
|
+
},
|
|
2034
|
+
{
|
|
2035
|
+
type: "Array"
|
|
2036
|
+
},
|
|
2037
|
+
{
|
|
2038
|
+
type: "Object"
|
|
2039
|
+
},
|
|
2040
|
+
{
|
|
2041
|
+
type: "String"
|
|
2042
|
+
}
|
|
2043
|
+
], (options.explicit = true, options))
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
Undefined: function(it) {
|
|
2048
|
+
if (it === "undefined" || it === void 0) {
|
|
2049
|
+
return {
|
|
2050
|
+
type: "Just",
|
|
2051
|
+
value: void 0
|
|
2052
|
+
};
|
|
2053
|
+
} else {
|
|
2054
|
+
return {
|
|
2055
|
+
type: "Nothing"
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
Null: function(it) {
|
|
2060
|
+
if (it === "null") {
|
|
2061
|
+
return {
|
|
2062
|
+
type: "Just",
|
|
2063
|
+
value: null
|
|
2064
|
+
};
|
|
2065
|
+
} else {
|
|
2066
|
+
return {
|
|
2067
|
+
type: "Nothing"
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
},
|
|
2071
|
+
NaN: function(it) {
|
|
2072
|
+
if (it === "NaN") {
|
|
2073
|
+
return {
|
|
2074
|
+
type: "Just",
|
|
2075
|
+
value: NaN
|
|
2076
|
+
};
|
|
2077
|
+
} else {
|
|
2078
|
+
return {
|
|
2079
|
+
type: "Nothing"
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
},
|
|
2083
|
+
Boolean: function(it) {
|
|
2084
|
+
if (it === "true") {
|
|
2085
|
+
return {
|
|
2086
|
+
type: "Just",
|
|
2087
|
+
value: true
|
|
2088
|
+
};
|
|
2089
|
+
} else if (it === "false") {
|
|
2090
|
+
return {
|
|
2091
|
+
type: "Just",
|
|
2092
|
+
value: false
|
|
2093
|
+
};
|
|
2094
|
+
} else {
|
|
2095
|
+
return {
|
|
2096
|
+
type: "Nothing"
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
},
|
|
2100
|
+
Number: function(it) {
|
|
2101
|
+
return {
|
|
2102
|
+
type: "Just",
|
|
2103
|
+
value: +it
|
|
2104
|
+
};
|
|
2105
|
+
},
|
|
2106
|
+
Int: function(it) {
|
|
2107
|
+
return {
|
|
2108
|
+
type: "Just",
|
|
2109
|
+
value: +it
|
|
2110
|
+
};
|
|
2111
|
+
},
|
|
2112
|
+
Float: function(it) {
|
|
2113
|
+
return {
|
|
2114
|
+
type: "Just",
|
|
2115
|
+
value: +it
|
|
2116
|
+
};
|
|
2117
|
+
},
|
|
2118
|
+
Date: function(value, options) {
|
|
2119
|
+
var that;
|
|
2120
|
+
if (that = /^\#([\s\S]*)\#$/.exec(value)) {
|
|
2121
|
+
return {
|
|
2122
|
+
type: "Just",
|
|
2123
|
+
value: new Date(+that[1] || that[1])
|
|
2124
|
+
};
|
|
2125
|
+
} else if (options.explicit) {
|
|
2126
|
+
return {
|
|
2127
|
+
type: "Nothing"
|
|
2128
|
+
};
|
|
2129
|
+
} else {
|
|
2130
|
+
return {
|
|
2131
|
+
type: "Just",
|
|
2132
|
+
value: new Date(+value || value)
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
RegExp: function(value, options) {
|
|
2137
|
+
var that;
|
|
2138
|
+
if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
|
|
2139
|
+
return {
|
|
2140
|
+
type: "Just",
|
|
2141
|
+
value: new RegExp(that[1], that[2])
|
|
2142
|
+
};
|
|
2143
|
+
} else if (options.explicit) {
|
|
2144
|
+
return {
|
|
2145
|
+
type: "Nothing"
|
|
2146
|
+
};
|
|
2147
|
+
} else {
|
|
2148
|
+
return {
|
|
2149
|
+
type: "Just",
|
|
2150
|
+
value: new RegExp(value)
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
},
|
|
2154
|
+
Array: function(value, options) {
|
|
2155
|
+
return castArray(value, {
|
|
2156
|
+
of: [{
|
|
2157
|
+
type: "*"
|
|
2158
|
+
}]
|
|
2159
|
+
}, options);
|
|
2160
|
+
},
|
|
2161
|
+
Object: function(value, options) {
|
|
2162
|
+
return castFields(value, {
|
|
2163
|
+
of: {}
|
|
2164
|
+
}, options);
|
|
2165
|
+
},
|
|
2166
|
+
String: function(it) {
|
|
2167
|
+
var replace, that;
|
|
2168
|
+
if (toString$.call(it).slice(8, -1) !== "String") {
|
|
2169
|
+
return {
|
|
2170
|
+
type: "Nothing"
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
replace = function(value, quote) {
|
|
2174
|
+
return value.replace(/\\([^u]|u[0-9a-fA-F]{4})/g, function(all, escaped) {
|
|
2175
|
+
switch (escaped[0]) {
|
|
2176
|
+
case quote:
|
|
2177
|
+
return quote;
|
|
2178
|
+
case "\\":
|
|
2179
|
+
return "\\";
|
|
2180
|
+
case "b":
|
|
2181
|
+
return "\b";
|
|
2182
|
+
case "f":
|
|
2183
|
+
return "\f";
|
|
2184
|
+
case "n":
|
|
2185
|
+
return "\n";
|
|
2186
|
+
case "r":
|
|
2187
|
+
return "\r";
|
|
2188
|
+
case "t":
|
|
2189
|
+
return " ";
|
|
2190
|
+
case "u":
|
|
2191
|
+
return JSON.parse('"' + all + '"');
|
|
2192
|
+
default:
|
|
2193
|
+
return escaped;
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
};
|
|
2197
|
+
if (that = it.match(/^'([\s\S]*)'$/)) {
|
|
2198
|
+
return {
|
|
2199
|
+
type: "Just",
|
|
2200
|
+
value: replace(that[1], "'")
|
|
2201
|
+
};
|
|
2202
|
+
} else if (that = it.match(/^"([\s\S]*)"$/)) {
|
|
2203
|
+
return {
|
|
2204
|
+
type: "Just",
|
|
2205
|
+
value: replace(that[1], '"')
|
|
2206
|
+
};
|
|
2207
|
+
} else {
|
|
2208
|
+
return {
|
|
2209
|
+
type: "Just",
|
|
2210
|
+
value: it
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
function castArray(node, type, options) {
|
|
2216
|
+
var typeOf, element;
|
|
2217
|
+
if (toString$.call(node).slice(8, -1) !== "Array") {
|
|
2218
|
+
return {
|
|
2219
|
+
type: "Nothing"
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
typeOf = type.of;
|
|
2223
|
+
return {
|
|
2224
|
+
type: "Just",
|
|
2225
|
+
value: (function() {
|
|
2226
|
+
var i$, ref$, len$, results$ = [];
|
|
2227
|
+
for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
|
|
2228
|
+
element = ref$[i$];
|
|
2229
|
+
results$.push(typesCast(element, typeOf, options));
|
|
2230
|
+
}
|
|
2231
|
+
return results$;
|
|
2232
|
+
})()
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2235
|
+
function castTuple(node, type, options) {
|
|
2236
|
+
var result, i, i$, ref$, len$, types2, cast;
|
|
2237
|
+
if (toString$.call(node).slice(8, -1) !== "Array") {
|
|
2238
|
+
return {
|
|
2239
|
+
type: "Nothing"
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
result = [];
|
|
2243
|
+
i = 0;
|
|
2244
|
+
for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
|
|
2245
|
+
types2 = ref$[i$];
|
|
2246
|
+
cast = typesCast(node[i], types2, options);
|
|
2247
|
+
if (toString$.call(cast).slice(8, -1) !== "Undefined") {
|
|
2248
|
+
result.push(cast);
|
|
2249
|
+
}
|
|
2250
|
+
i++;
|
|
2251
|
+
}
|
|
2252
|
+
if (node.length <= i) {
|
|
2253
|
+
return {
|
|
2254
|
+
type: "Just",
|
|
2255
|
+
value: result
|
|
2256
|
+
};
|
|
2257
|
+
} else {
|
|
2258
|
+
return {
|
|
2259
|
+
type: "Nothing"
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function castFields(node, type, options) {
|
|
2264
|
+
var typeOf, key, value;
|
|
2265
|
+
if (toString$.call(node).slice(8, -1) !== "Object") {
|
|
2266
|
+
return {
|
|
2267
|
+
type: "Nothing"
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
typeOf = type.of;
|
|
2271
|
+
return {
|
|
2272
|
+
type: "Just",
|
|
2273
|
+
value: (function() {
|
|
2274
|
+
var ref$, resultObj$ = {};
|
|
2275
|
+
for (key in ref$ = node) {
|
|
2276
|
+
value = ref$[key];
|
|
2277
|
+
resultObj$[typesCast(key, [{
|
|
2278
|
+
type: "String"
|
|
2279
|
+
}], options)] = typesCast(value, typeOf[key] || [{
|
|
2280
|
+
type: "*"
|
|
2281
|
+
}], options);
|
|
2282
|
+
}
|
|
2283
|
+
return resultObj$;
|
|
2284
|
+
})()
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
function typeCast(node, typeObj, options) {
|
|
2288
|
+
var type, structure, castFunc, ref$;
|
|
2289
|
+
type = typeObj.type, structure = typeObj.structure;
|
|
2290
|
+
if (type) {
|
|
2291
|
+
castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 0) || types[type];
|
|
2292
|
+
if (!castFunc) {
|
|
2293
|
+
throw new Error("Type not defined: " + type + ".");
|
|
2294
|
+
}
|
|
2295
|
+
return castFunc(node, options, typesCast);
|
|
2296
|
+
} else {
|
|
2297
|
+
switch (structure) {
|
|
2298
|
+
case "array":
|
|
2299
|
+
return castArray(node, typeObj, options);
|
|
2300
|
+
case "tuple":
|
|
2301
|
+
return castTuple(node, typeObj, options);
|
|
2302
|
+
case "fields":
|
|
2303
|
+
return castFields(node, typeObj, options);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
function typesCast(node, types2, options) {
|
|
2308
|
+
var i$, len$, type, ref$, valueType, value;
|
|
2309
|
+
for (i$ = 0, len$ = types2.length; i$ < len$; ++i$) {
|
|
2310
|
+
type = types2[i$];
|
|
2311
|
+
ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
|
|
2312
|
+
if (valueType === "Nothing") {
|
|
2313
|
+
continue;
|
|
2314
|
+
}
|
|
2315
|
+
if (parsedTypeCheck([type], value, {
|
|
2316
|
+
customTypes: options.customTypes
|
|
2317
|
+
})) {
|
|
2318
|
+
return value;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types2) + ".");
|
|
2322
|
+
}
|
|
2323
|
+
module.exports = function(node, types2, options) {
|
|
2324
|
+
if (!options.explicit && types2.length === 1 && types2[0].type === "String") {
|
|
2325
|
+
return node;
|
|
2326
|
+
}
|
|
2327
|
+
return typesCast(node, types2, options);
|
|
2328
|
+
};
|
|
2329
|
+
}).call(exports);
|
|
2330
|
+
}
|
|
2331
|
+
});
|
|
2332
|
+
|
|
2333
|
+
// node_modules/levn/lib/index.js
|
|
2334
|
+
var require_lib3 = __commonJS({
|
|
2335
|
+
"node_modules/levn/lib/index.js"(exports, module) {
|
|
2336
|
+
(function() {
|
|
2337
|
+
var parseString, cast, parseType, VERSION, parsedTypeParse, parse;
|
|
2338
|
+
parseString = require_parse_string();
|
|
2339
|
+
cast = require_cast();
|
|
2340
|
+
parseType = require_lib2().parseType;
|
|
2341
|
+
VERSION = "0.4.1";
|
|
2342
|
+
parsedTypeParse = function(parsedType, string, options) {
|
|
2343
|
+
options == null && (options = {});
|
|
2344
|
+
options.explicit == null && (options.explicit = false);
|
|
2345
|
+
options.customTypes == null && (options.customTypes = {});
|
|
2346
|
+
return cast(parseString(parsedType, string, options), parsedType, options);
|
|
2347
|
+
};
|
|
2348
|
+
parse = function(type, string, options) {
|
|
2349
|
+
return parsedTypeParse(parseType(type), string, options);
|
|
2350
|
+
};
|
|
2351
|
+
module.exports = {
|
|
2352
|
+
VERSION,
|
|
2353
|
+
parse,
|
|
2354
|
+
parsedTypeParse
|
|
2355
|
+
};
|
|
2356
|
+
}).call(exports);
|
|
2357
|
+
}
|
|
2358
|
+
});
|
|
2359
|
+
|
|
2360
|
+
// mechanisms/eslint/runner/core-install.ts
|
|
2361
|
+
var INSTALL_MANIFEST = "package.json";
|
|
2362
|
+
var namedManifestSchema = external_exports.object({ name: external_exports.string() });
|
|
2363
|
+
var manifestFailure = (request) => ({
|
|
2364
|
+
outcome: "failed",
|
|
2365
|
+
error: { kind: "tool-failed", detail: `the core install's ${request.manifest} ${request.problem}` }
|
|
2366
|
+
});
|
|
2367
|
+
var packageNamedIn = (request) => {
|
|
2368
|
+
const document = parsedJson({ text: request.text });
|
|
2369
|
+
if (document.outcome === "failed") {
|
|
2370
|
+
return manifestFailure({ manifest: request.manifest, problem: `is not JSON: ${document.error}` });
|
|
2371
|
+
}
|
|
2372
|
+
const named = namedManifestSchema.safeParse(document.value);
|
|
2373
|
+
return named.success ? { outcome: "ok", value: { form: "package", root: request.installRoot, name: named.data.name } } : manifestFailure({ manifest: request.manifest, problem: "names no package" });
|
|
2374
|
+
};
|
|
2375
|
+
var coreInstallOf = (request) => {
|
|
2376
|
+
if (installFormOf({ moduleExtension: request.moduleExtension }) === "source") {
|
|
2377
|
+
return { outcome: "ok", value: { form: "source" } };
|
|
2378
|
+
}
|
|
2379
|
+
const manifest = request.path.join({ segments: [request.installRoot, INSTALL_MANIFEST] });
|
|
2380
|
+
const text = request.fileText.read({ path: manifest });
|
|
2381
|
+
return text.outcome === "failed" ? manifestFailure({ manifest, problem: `cannot be read: ${text.error.detail}` }) : packageNamedIn({ installRoot: request.installRoot, manifest, text: text.value });
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
// mechanisms/eslint/runner/eslint-config-schema.ts
|
|
2385
|
+
var resolvedConfigSchema = external_exports.union([
|
|
2386
|
+
external_exports.undefined(),
|
|
2387
|
+
external_exports.looseObject({
|
|
2388
|
+
rules: external_exports.record(
|
|
2389
|
+
external_exports.string(),
|
|
2390
|
+
external_exports.tuple([external_exports.union([external_exports.literal(0), external_exports.literal(1), external_exports.literal(2)])], external_exports.unknown())
|
|
2391
|
+
).optional()
|
|
2392
|
+
})
|
|
2393
|
+
]);
|
|
2394
|
+
var ruleStateOf = (request) => {
|
|
2395
|
+
if (request.resolved === void 0) {
|
|
2396
|
+
return { state: "file-ignored" };
|
|
2397
|
+
}
|
|
2398
|
+
const entry = request.resolved.rules?.[request.ruleId];
|
|
2399
|
+
if (entry === void 0) {
|
|
2400
|
+
return { state: "rule-absent" };
|
|
2401
|
+
}
|
|
2402
|
+
return { state: "configured", severity: entry[0] };
|
|
2403
|
+
};
|
|
2404
|
+
|
|
2405
|
+
// mechanisms/eslint/runner/eslint-plugin-schema.ts
|
|
2406
|
+
var ruleVisitorSchema = external_exports.record(
|
|
2407
|
+
external_exports.string(),
|
|
2408
|
+
external_exports.function({ input: external_exports.array(external_exports.unknown()), output: external_exports.unknown() })
|
|
2409
|
+
);
|
|
2410
|
+
var ruleSchema = external_exports.looseObject({
|
|
2411
|
+
meta: external_exports.looseObject({
|
|
2412
|
+
type: external_exports.enum(["problem", "suggestion", "layout"]),
|
|
2413
|
+
messages: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
2414
|
+
}),
|
|
2415
|
+
create: external_exports.function({ input: [external_exports.unknown()], output: ruleVisitorSchema })
|
|
2416
|
+
});
|
|
2417
|
+
var eslintPluginModuleSchema = external_exports.object({
|
|
2418
|
+
default: external_exports.looseObject({ rules: external_exports.record(external_exports.string(), ruleSchema) })
|
|
2419
|
+
});
|
|
2420
|
+
var inlineConfigNodesSchema = external_exports.array(
|
|
2421
|
+
external_exports.looseObject({ type: external_exports.enum(["Line", "Block"]), value: external_exports.string() })
|
|
2422
|
+
);
|
|
2423
|
+
|
|
2424
|
+
// node_modules/@eslint/plugin-kit/dist/esm/index.js
|
|
2425
|
+
var import_levn = __toESM(require_lib3(), 1);
|
|
2426
|
+
var directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
|
2427
|
+
var validSeverities = /* @__PURE__ */ new Set([0, 1, 2, "off", "warn", "error"]);
|
|
2428
|
+
function isSeverityValid(ruleConfig) {
|
|
2429
|
+
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
|
2430
|
+
return validSeverities.has(severity);
|
|
2431
|
+
}
|
|
2432
|
+
function isEverySeverityValid(rulesConfig) {
|
|
2433
|
+
return Object.values(rulesConfig).every(isSeverityValid);
|
|
2434
|
+
}
|
|
2435
|
+
var DirectiveComment = class {
|
|
2436
|
+
/**
|
|
2437
|
+
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
|
2438
|
+
* @type {string}
|
|
2439
|
+
*/
|
|
2440
|
+
label = "";
|
|
2441
|
+
/**
|
|
2442
|
+
* The value of the directive (the string after the label).
|
|
2443
|
+
* @type {string}
|
|
2444
|
+
*/
|
|
2445
|
+
value = "";
|
|
2446
|
+
/**
|
|
2447
|
+
* The justification of the directive (the string after the --).
|
|
2448
|
+
* @type {string}
|
|
2449
|
+
*/
|
|
2450
|
+
justification = "";
|
|
2451
|
+
/**
|
|
2452
|
+
* Creates a new directive comment.
|
|
2453
|
+
* @param {string} label The label of the directive.
|
|
2454
|
+
* @param {string} value The value of the directive.
|
|
2455
|
+
* @param {string} justification The justification of the directive.
|
|
2456
|
+
*/
|
|
2457
|
+
constructor(label, value, justification) {
|
|
2458
|
+
this.label = label;
|
|
2459
|
+
this.value = value;
|
|
2460
|
+
this.justification = justification;
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
var ConfigCommentParser = class {
|
|
2464
|
+
/**
|
|
2465
|
+
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
|
2466
|
+
* whitespace. Used for "global" comments.
|
|
2467
|
+
* @param {string} string The string to parse.
|
|
2468
|
+
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
|
2469
|
+
*/
|
|
2470
|
+
parseStringConfig(string) {
|
|
2471
|
+
const items = (
|
|
2472
|
+
/** @type {StringConfig} */
|
|
2473
|
+
/* @__PURE__ */ Object.create(null)
|
|
2474
|
+
);
|
|
2475
|
+
const trimmedString = string.trim().replace(/(?<!\s)\s*([:,])\s*/gu, "$1");
|
|
2476
|
+
trimmedString.split(/\s|,+/u).forEach((name) => {
|
|
2477
|
+
if (!name) {
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
const [key, value = null] = name.split(":");
|
|
2481
|
+
items[key] = value;
|
|
2482
|
+
});
|
|
2483
|
+
return items;
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Parses a JSON-like config.
|
|
2487
|
+
* @param {string} string The string to parse.
|
|
2488
|
+
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
|
2489
|
+
*/
|
|
2490
|
+
parseJSONLikeConfig(string) {
|
|
2491
|
+
try {
|
|
2492
|
+
const items = (
|
|
2493
|
+
/** @type {RulesConfig} */
|
|
2494
|
+
import_levn.default.parse("Object", string) || {}
|
|
2495
|
+
);
|
|
2496
|
+
if (isEverySeverityValid(items)) {
|
|
2497
|
+
return {
|
|
2498
|
+
ok: true,
|
|
2499
|
+
config: items
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
} catch {
|
|
2503
|
+
}
|
|
2504
|
+
const normalizedString = string.replace(/(?<![-a-zA-Z0-9/])([-a-zA-Z0-9/]+):/gu, '"$1":').replace(/([\]0-9])\s+(?=")/u, "$1,");
|
|
2505
|
+
try {
|
|
2506
|
+
const items = JSON.parse(`{${normalizedString}}`);
|
|
2507
|
+
return {
|
|
2508
|
+
ok: true,
|
|
2509
|
+
config: items
|
|
2510
|
+
};
|
|
2511
|
+
} catch (ex) {
|
|
2512
|
+
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
|
2513
|
+
return {
|
|
2514
|
+
ok: false,
|
|
2515
|
+
error: {
|
|
2516
|
+
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`
|
|
2517
|
+
}
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
/**
|
|
2522
|
+
* Parses a config of values separated by comma.
|
|
2523
|
+
* @param {string} string The string to parse.
|
|
2524
|
+
* @returns {BooleanConfig} Result map of values and true values
|
|
2525
|
+
*/
|
|
2526
|
+
parseListConfig(string) {
|
|
2527
|
+
const items = (
|
|
2528
|
+
/** @type {BooleanConfig} */
|
|
2529
|
+
/* @__PURE__ */ Object.create(null)
|
|
2530
|
+
);
|
|
2531
|
+
string.split(",").forEach((name) => {
|
|
2532
|
+
const trimmedName = name.trim().replace(
|
|
2533
|
+
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
|
2534
|
+
"$<ruleId>"
|
|
2535
|
+
);
|
|
2536
|
+
if (trimmedName) {
|
|
2537
|
+
items[trimmedName] = true;
|
|
2538
|
+
}
|
|
2539
|
+
});
|
|
2540
|
+
return items;
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Extract the directive and the justification from a given directive comment and trim them.
|
|
2544
|
+
* @param {string} value The comment text to extract.
|
|
2545
|
+
* @returns {{directivePart: string, justificationPart: string}} The extracted directive and justification.
|
|
2546
|
+
*/
|
|
2547
|
+
#extractDirectiveComment(value) {
|
|
2548
|
+
const match = /\s-{2,}\s/u.exec(value);
|
|
2549
|
+
if (!match) {
|
|
2550
|
+
return { directivePart: value.trim(), justificationPart: "" };
|
|
2551
|
+
}
|
|
2552
|
+
const directive = value.slice(0, match.index).trim();
|
|
2553
|
+
const justification = value.slice(match.index + match[0].length).trim();
|
|
2554
|
+
return { directivePart: directive, justificationPart: justification };
|
|
2555
|
+
}
|
|
2556
|
+
/**
|
|
2557
|
+
* Parses a directive comment into directive text and value.
|
|
2558
|
+
* @param {string} string The string with the directive to be parsed.
|
|
2559
|
+
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
|
2560
|
+
*/
|
|
2561
|
+
parseDirective(string) {
|
|
2562
|
+
const { directivePart, justificationPart } = this.#extractDirectiveComment(string);
|
|
2563
|
+
const match = directivesPattern.exec(directivePart);
|
|
2564
|
+
if (!match) {
|
|
2565
|
+
return void 0;
|
|
2566
|
+
}
|
|
2567
|
+
const directiveText = match[1];
|
|
2568
|
+
const directiveValue = directivePart.slice(
|
|
2569
|
+
match.index + directiveText.length
|
|
2570
|
+
);
|
|
2571
|
+
return new DirectiveComment(
|
|
2572
|
+
directiveText,
|
|
2573
|
+
directiveValue.trim(),
|
|
2574
|
+
justificationPart
|
|
2575
|
+
);
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2579
|
+
// mechanisms/eslint/runner/inline-config-parser.ts
|
|
2580
|
+
var DISABLE_LABELS = [
|
|
2581
|
+
"eslint-disable",
|
|
2582
|
+
"eslint-disable-line",
|
|
2583
|
+
"eslint-disable-next-line"
|
|
2584
|
+
];
|
|
2585
|
+
var RULE_CONFIG_LABEL = "eslint";
|
|
2586
|
+
var commentParser = new ConfigCommentParser();
|
|
2587
|
+
var directiveLabelKindOf = (request) => {
|
|
2588
|
+
if (DISABLE_LABELS.includes(request.label)) {
|
|
2589
|
+
return "disable";
|
|
2590
|
+
}
|
|
2591
|
+
return request.label === RULE_CONFIG_LABEL ? "rule-config" : "other";
|
|
2592
|
+
};
|
|
2593
|
+
var ruleConfigComment = (request) => {
|
|
2594
|
+
const ruleConfig = commentParser.parseJSONLikeConfig(request.value);
|
|
2595
|
+
if (!ruleConfig.ok) {
|
|
2596
|
+
return { kind: "unparseable-rule-config" };
|
|
2597
|
+
}
|
|
2598
|
+
return { kind: "rule-config", ruleIds: Object.keys(ruleConfig.config) };
|
|
2599
|
+
};
|
|
2600
|
+
var parseInlineConfigComment = (request) => {
|
|
2601
|
+
const directive = commentParser.parseDirective(request.text);
|
|
2602
|
+
if (directive === void 0) {
|
|
2603
|
+
return { kind: "not-an-exception" };
|
|
2604
|
+
}
|
|
2605
|
+
const labelKind = directiveLabelKindOf({ label: directive.label });
|
|
2606
|
+
switch (labelKind) {
|
|
2607
|
+
case "other":
|
|
2608
|
+
return { kind: "not-an-exception" };
|
|
2609
|
+
case "disable":
|
|
2610
|
+
return { kind: "disable", ruleIds: Object.keys(commentParser.parseListConfig(directive.value)) };
|
|
2611
|
+
case "rule-config":
|
|
2612
|
+
return ruleConfigComment({ value: directive.value });
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2616
|
+
// mechanisms/eslint/runner/eslint-instance.ts
|
|
2617
|
+
var reservedNamespace = TOOL_IDENTITY.reservedEslintNamespace;
|
|
2618
|
+
var INLINE_CONFIG_RULE = "inline-config";
|
|
2619
|
+
var INLINE_CONFIG_RULE_ID = `${reservedNamespace}/${INLINE_CONFIG_RULE}`;
|
|
2620
|
+
var GOVERNED_FILES = ["**/*.{ts,tsx,mts,cts}"];
|
|
2621
|
+
var PLUGIN_REDEFINITION_MESSAGE = "Cannot redefine plugin";
|
|
2622
|
+
var INLINE_CONFIG_UNREADABLE = "inline-config-unreadable";
|
|
2623
|
+
var commentText = (request) => {
|
|
2624
|
+
switch (request.comment.type) {
|
|
2625
|
+
case "Line":
|
|
2626
|
+
return `//${request.comment.value}`.trim();
|
|
2627
|
+
case "Block":
|
|
2628
|
+
return `/*${request.comment.value}*/`.trim();
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
var selectionReach = (request) => request.named.some((ruleId) => request.ruleIds.includes(ruleId)) ? "names-selected-rule" : "names-no-selected-rule";
|
|
2632
|
+
var inlineConfigMessageId = (request) => {
|
|
2633
|
+
const parsed = parseInlineConfigComment({ text: request.text });
|
|
2634
|
+
switch (parsed.kind) {
|
|
2635
|
+
case "disable": {
|
|
2636
|
+
if (parsed.ruleIds.length > 0 && selectionReach({ named: parsed.ruleIds, ruleIds: request.ruleIds }) === "names-no-selected-rule") {
|
|
2637
|
+
return "not-reported";
|
|
2638
|
+
}
|
|
2639
|
+
return "inline-disable";
|
|
2640
|
+
}
|
|
2641
|
+
case "rule-config": {
|
|
2642
|
+
if (selectionReach({ named: parsed.ruleIds, ruleIds: request.ruleIds }) === "names-no-selected-rule") {
|
|
2643
|
+
return "not-reported";
|
|
2644
|
+
}
|
|
2645
|
+
return "inline-rule-config";
|
|
2646
|
+
}
|
|
2647
|
+
case "unparseable-rule-config":
|
|
2648
|
+
return "inline-rule-config";
|
|
2649
|
+
case "not-an-exception":
|
|
2650
|
+
return "not-reported";
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2653
|
+
var reportedComment = (request) => {
|
|
2654
|
+
const messageId = inlineConfigMessageId({ text: request.comment.value, ruleIds: request.ruleIds });
|
|
2655
|
+
if (messageId === "not-reported") {
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
request.context.report({
|
|
2659
|
+
node: request.comment,
|
|
2660
|
+
messageId,
|
|
2661
|
+
data: { text: commentText({ comment: request.comment }) }
|
|
2662
|
+
});
|
|
2663
|
+
};
|
|
2664
|
+
var reportedProgram = (request) => {
|
|
2665
|
+
const configNodes = inlineConfigNodesSchema.safeParse(request.context.sourceCode.getInlineConfigNodes?.());
|
|
2666
|
+
if (!configNodes.success) {
|
|
2667
|
+
request.context.report({ node: request.programNode, messageId: INLINE_CONFIG_UNREADABLE });
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
configNodes.data.forEach((comment) => {
|
|
2671
|
+
reportedComment({ context: request.context, comment, ruleIds: request.ruleIds });
|
|
2672
|
+
});
|
|
2673
|
+
};
|
|
2674
|
+
var inlineConfigPlugin = (request) => ({
|
|
2675
|
+
rules: {
|
|
2676
|
+
[INLINE_CONFIG_RULE]: {
|
|
2677
|
+
meta: {
|
|
2678
|
+
type: "problem",
|
|
2679
|
+
schema: [],
|
|
2680
|
+
messages: {
|
|
2681
|
+
"inline-disable": "{{text}}",
|
|
2682
|
+
"inline-rule-config": "{{text}}",
|
|
2683
|
+
[INLINE_CONFIG_UNREADABLE]: "inline configuration comments could not be read"
|
|
2684
|
+
}
|
|
2685
|
+
},
|
|
2686
|
+
create: (context) => ({
|
|
2687
|
+
Program: (programNode) => reportedProgram({ context, programNode, ruleIds: request.ruleIds })
|
|
2688
|
+
})
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
var enabledRuleEntry = (request) => request.options.length === 0 ? "error" : ["error", ...request.options];
|
|
2693
|
+
var governanceConfig = (request) => ({
|
|
2694
|
+
files: GOVERNED_FILES,
|
|
2695
|
+
languageOptions: { parser: request.parser },
|
|
2696
|
+
plugins: {
|
|
2697
|
+
...request.plugins,
|
|
2698
|
+
[reservedNamespace]: inlineConfigPlugin({ ruleIds: request.rules.map((governed) => governed.ruleId) })
|
|
2699
|
+
},
|
|
2700
|
+
rules: Object.fromEntries(
|
|
2701
|
+
[...request.rules, { ruleId: INLINE_CONFIG_RULE_ID, options: [] }].map(
|
|
2702
|
+
(governed) => [governed.ruleId, enabledRuleEntry({ options: governed.options })]
|
|
2703
|
+
)
|
|
2704
|
+
)
|
|
2705
|
+
});
|
|
2706
|
+
var governanceOptions = (request) => ({
|
|
2707
|
+
cwd: request.cwd,
|
|
2708
|
+
overrideConfigFile: true,
|
|
2709
|
+
ignore: false,
|
|
2710
|
+
allowInlineConfig: false,
|
|
2711
|
+
overrideConfig: governanceConfig({ plugins: request.plugins, rules: request.rules, parser: request.parser })
|
|
2712
|
+
});
|
|
2713
|
+
var thrownDetail = (thrown) => thrown instanceof Error ? thrown.message : String(thrown);
|
|
2714
|
+
var toolFailed = (thrown) => ({
|
|
2715
|
+
outcome: "failed",
|
|
2716
|
+
error: { kind: "tool-failed", detail: thrownDetail(thrown) }
|
|
2717
|
+
});
|
|
2718
|
+
var queryFailed = (thrown) => {
|
|
2719
|
+
const detail = thrownDetail(thrown);
|
|
2720
|
+
return {
|
|
2721
|
+
outcome: "failed",
|
|
2722
|
+
error: detail.includes(PLUGIN_REDEFINITION_MESSAGE) ? { kind: "plugin-conflict", detail } : { kind: "team-config-unloadable", detail }
|
|
2723
|
+
};
|
|
2724
|
+
};
|
|
2725
|
+
var builtSurface = (request) => Promise.resolve().then(() => request.createEslint({ options: request.options })).then((surface) => ({ outcome: "ok", value: surface }), toolFailed);
|
|
2726
|
+
var actedOn = (request) => Promise.resolve().then(() => request.act(request.surface)).then((acted) => ({ outcome: "ok", value: acted }), request.onRejected);
|
|
2727
|
+
var onSurface = (request) => request.surface.then(
|
|
2728
|
+
(built) => built.outcome === "failed" ? built : actedOn({ surface: built.value, act: request.act, onRejected: request.onRejected })
|
|
2729
|
+
);
|
|
2730
|
+
var ignoredStateOf = (request) => request.eslint.isPathIgnored({ filePath: request.file }).then((ignored) => ignored ? "ignored" : "checked");
|
|
2731
|
+
var resolvedRuleState = (request) => {
|
|
2732
|
+
if (request.resolved.outcome === "failed") {
|
|
2733
|
+
return request.resolved;
|
|
2734
|
+
}
|
|
2735
|
+
const parsed = resolvedConfigSchema.safeParse(request.resolved.value);
|
|
2736
|
+
if (!parsed.success) {
|
|
2737
|
+
return {
|
|
2738
|
+
outcome: "failed",
|
|
2739
|
+
error: { kind: "runner-invalid-output", detail: external_exports.prettifyError(parsed.error) }
|
|
2740
|
+
};
|
|
2741
|
+
}
|
|
2742
|
+
return { outcome: "ok", value: ruleStateOf({ resolved: parsed.data, ruleId: request.ruleId }) };
|
|
2743
|
+
};
|
|
2744
|
+
var queryInstanceOf = (request) => ({
|
|
2745
|
+
ignoredState: (query) => onSurface({
|
|
2746
|
+
surface: request.surface,
|
|
2747
|
+
act: (eslint) => ignoredStateOf({ eslint, file: query.file }),
|
|
2748
|
+
onRejected: queryFailed
|
|
2749
|
+
}),
|
|
2750
|
+
ruleState: (query) => onSurface({
|
|
2751
|
+
surface: request.surface,
|
|
2752
|
+
act: (eslint) => eslint.calculateConfigForFile({ filePath: query.file }),
|
|
2753
|
+
onRejected: queryFailed
|
|
2754
|
+
}).then((resolved) => resolvedRuleState({ resolved, ruleId: query.ruleId }))
|
|
2755
|
+
});
|
|
2756
|
+
var lintedCaseOf = (request) => request.eslint.lintText({ code: request.sourceCase.source, filePath: request.sourceCase.fileName }).then((linted) => ({
|
|
2757
|
+
caseName: request.sourceCase.name,
|
|
2758
|
+
messages: linted.flatMap((file) => file.messages)
|
|
2759
|
+
}));
|
|
2760
|
+
var lintedCasesOf = (request) => Promise.all(request.cases.map((sourceCase) => lintedCaseOf({ eslint: request.eslint, sourceCase })));
|
|
2761
|
+
var unreadableCaseOf = (request) => request.lintedCases.find(
|
|
2762
|
+
(lintedCase) => lintedCase.messages.some(
|
|
2763
|
+
(message) => message.ruleId === INLINE_CONFIG_RULE_ID && message.messageId === INLINE_CONFIG_UNREADABLE
|
|
2764
|
+
)
|
|
2765
|
+
);
|
|
2766
|
+
var ruleLessCaseOf = (request) => request.lintedCases.find((lintedCase) => lintedCase.messages.some((message) => message.ruleId === null));
|
|
2767
|
+
var ruleLessDetail = (request) => `case ${request.lintedCase.caseName} was not linted as a rule source: ${request.lintedCase.messages.filter((message) => message.ruleId === null).map((message) => message.message).join("; ")}`;
|
|
2768
|
+
var caseVerdictOf = (request) => ({
|
|
2769
|
+
caseName: request.lintedCase.caseName,
|
|
2770
|
+
flaggedLines: request.lintedCase.messages.filter((message) => message.ruleId === request.ruleId).map((message) => message.line)
|
|
2771
|
+
});
|
|
2772
|
+
var caseVerdicts = (request) => {
|
|
2773
|
+
if (request.lintedCases.outcome === "failed") {
|
|
2774
|
+
return request.lintedCases;
|
|
2775
|
+
}
|
|
2776
|
+
const lintedCases = request.lintedCases.value;
|
|
2777
|
+
const unreadableCase = unreadableCaseOf({ lintedCases });
|
|
2778
|
+
if (unreadableCase !== void 0) {
|
|
2779
|
+
return {
|
|
2780
|
+
outcome: "failed",
|
|
2781
|
+
error: {
|
|
2782
|
+
kind: "tool-failed",
|
|
2783
|
+
detail: `inline configuration comments could not be read in case ${unreadableCase.caseName}`
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
const ruleLessCase = ruleLessCaseOf({ lintedCases });
|
|
2788
|
+
if (ruleLessCase !== void 0) {
|
|
2789
|
+
return {
|
|
2790
|
+
outcome: "failed",
|
|
2791
|
+
error: { kind: "runner-invalid-output", detail: ruleLessDetail({ lintedCase: ruleLessCase }) }
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
return {
|
|
2795
|
+
outcome: "ok",
|
|
2796
|
+
value: lintedCases.map((lintedCase) => caseVerdictOf({ lintedCase, ruleId: request.ruleId }))
|
|
2797
|
+
};
|
|
2798
|
+
};
|
|
2799
|
+
var sourceCaseVerdicts = (request) => {
|
|
2800
|
+
const ruleId = `${request.pluginNamespace}/${request.rule}`;
|
|
2801
|
+
return onSurface({
|
|
2802
|
+
surface: builtSurface({
|
|
2803
|
+
createEslint: request.toolchain.createEslint,
|
|
2804
|
+
options: governanceOptions({
|
|
2805
|
+
cwd: request.cwd,
|
|
2806
|
+
parser: request.toolchain.typescriptParser,
|
|
2807
|
+
plugins: { [request.pluginNamespace]: request.plugin },
|
|
2808
|
+
rules: [{ ruleId, options: request.options }]
|
|
2809
|
+
})
|
|
2810
|
+
}),
|
|
2811
|
+
act: (eslint) => lintedCasesOf({ eslint, cases: request.cases }),
|
|
2812
|
+
onRejected: toolFailed
|
|
2813
|
+
}).then((lintedCases) => caseVerdicts({ lintedCases, ruleId }));
|
|
2814
|
+
};
|
|
2815
|
+
var createEslintPort = (options) => ({
|
|
2816
|
+
createQueryInstance: (request) => queryInstanceOf({
|
|
2817
|
+
surface: builtSurface({
|
|
2818
|
+
createEslint: options.toolchain.createEslint,
|
|
2819
|
+
options: request.configFile === void 0 ? { cwd: request.repoRoot } : { cwd: request.repoRoot, overrideConfigFile: request.configFile }
|
|
2820
|
+
})
|
|
2821
|
+
}),
|
|
2822
|
+
createGovernanceInstance: (request) => {
|
|
2823
|
+
const surface = builtSurface({
|
|
2824
|
+
createEslint: options.toolchain.createEslint,
|
|
2825
|
+
options: governanceOptions({
|
|
2826
|
+
cwd: request.repoRoot,
|
|
2827
|
+
plugins: request.plugins,
|
|
2828
|
+
rules: request.rules,
|
|
2829
|
+
parser: options.toolchain.typescriptParser
|
|
2830
|
+
})
|
|
2831
|
+
});
|
|
2832
|
+
return {
|
|
2833
|
+
lintFiles: (lint) => onSurface({ surface, act: (eslint) => eslint.lintFiles({ filePaths: lint.files }), onRejected: toolFailed })
|
|
2834
|
+
};
|
|
2835
|
+
},
|
|
2836
|
+
lintSourceCases: (request) => sourceCaseVerdicts({ ...request, toolchain: options.toolchain })
|
|
2837
|
+
});
|
|
2838
|
+
var NEAREST_CONFIG_LOOKUPS = [
|
|
2839
|
+
{ releases: { packageName: "eslint", lines: [{ floor: "9.12.0", below: "9.30.0" }] }, flags: ["unstable_config_lookup_from_file"] },
|
|
2840
|
+
{ releases: { packageName: "eslint", lines: [{ floor: "9.30.0", below: "10.0.0" }] }, flags: ["v10_config_lookup_from_file"] }
|
|
2841
|
+
];
|
|
2842
|
+
var lookupFlagsOf = (request) => NEAREST_CONFIG_LOOKUPS.find((lookup) => versionSupport({ requirement: lookup.releases, version: request.version }) === "supported")?.flags ?? [];
|
|
2843
|
+
var lintedMessageOf = (message) => ({
|
|
2844
|
+
ruleId: message.ruleId,
|
|
2845
|
+
...message.messageId === void 0 ? {} : { messageId: message.messageId },
|
|
2846
|
+
line: message.line,
|
|
2847
|
+
column: message.column,
|
|
2848
|
+
message: message.message,
|
|
2849
|
+
...message.fatal === true ? { fatal: true } : {}
|
|
2850
|
+
});
|
|
2851
|
+
var lintedFileOf = (lintResult) => ({
|
|
2852
|
+
filePath: lintResult.filePath,
|
|
2853
|
+
messages: lintResult.messages.map(lintedMessageOf)
|
|
2854
|
+
});
|
|
2855
|
+
var overrideConfigOf = (request) => ({
|
|
2856
|
+
...request.overrideConfig,
|
|
2857
|
+
files: [...request.overrideConfig.files],
|
|
2858
|
+
rules: Object.fromEntries(
|
|
2859
|
+
Object.entries(request.overrideConfig.rules).map(([ruleId, entry]) => [
|
|
2860
|
+
ruleId,
|
|
2861
|
+
typeof entry === "string" ? entry : [...entry]
|
|
2862
|
+
])
|
|
2863
|
+
)
|
|
2864
|
+
});
|
|
2865
|
+
var lookupOptionsOf = (request) => {
|
|
2866
|
+
const flags = lookupFlagsOf(request);
|
|
2867
|
+
return request.options.overrideConfigFile === void 0 && flags.length > 0 ? { flags: [...flags] } : {};
|
|
2868
|
+
};
|
|
2869
|
+
var eslintOptionsOf = (request) => {
|
|
2870
|
+
const { overrideConfig, ...sharedOptions } = request.options;
|
|
2871
|
+
return {
|
|
2872
|
+
...sharedOptions,
|
|
2873
|
+
...lookupOptionsOf(request),
|
|
2874
|
+
...overrideConfig === void 0 ? {} : { overrideConfig: overrideConfigOf({ overrideConfig }) }
|
|
2875
|
+
};
|
|
2876
|
+
};
|
|
2877
|
+
var createEslintOn = (request) => (create) => {
|
|
2878
|
+
const eslint = new request.eslintClass(eslintOptionsOf({ version: request.eslintClass.version, options: create.options }));
|
|
2879
|
+
return {
|
|
2880
|
+
isPathIgnored: (query) => eslint.isPathIgnored(query.filePath),
|
|
2881
|
+
calculateConfigForFile: (query) => eslint.calculateConfigForFile(query.filePath),
|
|
2882
|
+
lintFiles: (lint) => eslint.lintFiles([...lint.filePaths]).then((results) => results.map(lintedFileOf)),
|
|
2883
|
+
lintText: (lint) => eslint.lintText(lint.code, { filePath: lint.filePath }).then((results) => results.map(lintedFileOf))
|
|
2884
|
+
};
|
|
2885
|
+
};
|
|
2886
|
+
|
|
2887
|
+
// mechanisms/eslint/runner/eslint-piece-settings-schema.ts
|
|
2888
|
+
var pieceModulePathSchema = external_exports.string().superRefine((text, context) => {
|
|
2889
|
+
if (isRepoPathText({ text }) === "not-repo-path" || moduleFileForm({ text }) === "not-module-file") {
|
|
2890
|
+
context.addIssue({
|
|
2891
|
+
code: "custom",
|
|
2892
|
+
message: "not a path inside the piece folder ending in .ts, or .js in a built install"
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2896
|
+
var eslintPieceSettingsSchema = external_exports.strictObject({
|
|
2897
|
+
pluginNamespace: external_exports.string(),
|
|
2898
|
+
pluginModule: pieceModulePathSchema,
|
|
2899
|
+
rule: external_exports.string(),
|
|
2900
|
+
options: external_exports.array(external_exports.json()).readonly().optional()
|
|
2901
|
+
}).readonly();
|
|
2902
|
+
var ruleOptionsOf = (request) => request.settings.options ?? [];
|
|
2903
|
+
|
|
2904
|
+
// mechanisms/eslint/runner/eslint-file-schemas.ts
|
|
2905
|
+
var packageJsonSchema = external_exports.looseObject({
|
|
2906
|
+
scripts: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
2907
|
+
});
|
|
2908
|
+
var suppressionsFileSchema = external_exports.record(
|
|
2909
|
+
external_exports.string(),
|
|
2910
|
+
external_exports.record(external_exports.string(), external_exports.looseObject({ count: external_exports.number() }))
|
|
2911
|
+
);
|
|
2912
|
+
var eslintVersionFileSchema = external_exports.looseObject({ version: external_exports.string() });
|
|
2913
|
+
var selectionLookupSchema = external_exports.looseObject({ eslintConfigLookup: eslintConfigLookupSchema.optional() });
|
|
2914
|
+
|
|
2915
|
+
// mechanisms/eslint/runner/package-script-scanner.ts
|
|
2916
|
+
var SCRIPT_PIECES = /(?<single>'[^']*')|(?<double>"[^"]*")|(?<operator>&&|\|\||[;|])|(?<space>\s+)|(?<text>[^'"\s;|&]+|&)|(?<stray>['"])/g;
|
|
2917
|
+
var ESLINT_TOKEN = "eslint";
|
|
2918
|
+
var ESLINT_VERSIONED_PREFIX = "eslint@";
|
|
2919
|
+
var ESLINT_PATH_SUFFIXES = ["/eslint", "/eslint.js"];
|
|
2920
|
+
var FORWARDED_OPTIONS_SEPARATOR = "--";
|
|
2921
|
+
var SUPPRESSIONS_LOCATION_OPTION = "--suppressions-location";
|
|
2922
|
+
var RULE_VALUE_SEPARATORS = /[,:]/;
|
|
2923
|
+
var SURROUNDING_QUOTES = /^(["'])(?<inner>.*)\1$/;
|
|
2924
|
+
var WEAKENING_OPTIONS = [
|
|
2925
|
+
{ name: "--rule", arity: "takes-value", reach: "named-rules" },
|
|
2926
|
+
{ name: "--suppress-rule", arity: "takes-value", reach: "named-rules" },
|
|
2927
|
+
{ name: "--suppress-all", arity: "flag", reach: "every-clause" },
|
|
2928
|
+
{ name: "--ignore-pattern", arity: "takes-value", reach: "every-clause" },
|
|
2929
|
+
{ name: "-c", arity: "takes-value", reach: "every-clause" },
|
|
2930
|
+
{ name: "--config", arity: "takes-value", reach: "every-clause" },
|
|
2931
|
+
{ name: "--no-config-lookup", arity: "flag", reach: "every-clause" },
|
|
2932
|
+
{ name: "--parser", arity: "takes-value", reach: "every-clause" },
|
|
2933
|
+
{ name: "--parser-options", arity: "takes-value", reach: "every-clause" },
|
|
2934
|
+
{ name: "--plugin", arity: "takes-value", reach: "every-clause" }
|
|
2935
|
+
];
|
|
2936
|
+
var scriptPieceOf = (request) => {
|
|
2937
|
+
const groups = request.match.groups ?? {};
|
|
2938
|
+
if (groups.single !== void 0) {
|
|
2939
|
+
return { kind: "quoted", text: groups.single.slice(1, -1) };
|
|
2940
|
+
}
|
|
2941
|
+
if (groups.double !== void 0) {
|
|
2942
|
+
return { kind: "quoted", text: groups.double.slice(1, -1) };
|
|
2943
|
+
}
|
|
2944
|
+
if (groups.operator !== void 0) {
|
|
2945
|
+
return { kind: "operator" };
|
|
2946
|
+
}
|
|
2947
|
+
if (groups.space !== void 0) {
|
|
2948
|
+
return { kind: "space" };
|
|
2949
|
+
}
|
|
2950
|
+
if (groups.text !== void 0) {
|
|
2951
|
+
return { kind: "text", text: groups.text };
|
|
2952
|
+
}
|
|
2953
|
+
return { kind: "stray-quote" };
|
|
2954
|
+
};
|
|
2955
|
+
var tokensWithCurrent = (request) => request.token.presence === "started" ? [...request.tokens, request.token.text] : request.tokens;
|
|
2956
|
+
var extendedToken = (request) => ({
|
|
2957
|
+
presence: "started",
|
|
2958
|
+
text: request.token.presence === "started" ? `${request.token.text}${request.text}` : request.text
|
|
2959
|
+
});
|
|
2960
|
+
var nextTokenizerState = (request) => {
|
|
2961
|
+
const state = request.state;
|
|
2962
|
+
if (state.status === "unterminated") {
|
|
2963
|
+
return state;
|
|
2964
|
+
}
|
|
2965
|
+
switch (request.piece.kind) {
|
|
2966
|
+
case "stray-quote":
|
|
2967
|
+
return { status: "unterminated" };
|
|
2968
|
+
case "quoted":
|
|
2969
|
+
case "text":
|
|
2970
|
+
return { ...state, token: extendedToken({ token: state.token, text: request.piece.text }) };
|
|
2971
|
+
case "space":
|
|
2972
|
+
return {
|
|
2973
|
+
...state,
|
|
2974
|
+
tokens: tokensWithCurrent({ tokens: state.tokens, token: state.token }),
|
|
2975
|
+
token: { presence: "none" }
|
|
2976
|
+
};
|
|
2977
|
+
case "operator":
|
|
2978
|
+
return {
|
|
2979
|
+
status: "reading",
|
|
2980
|
+
commands: [...state.commands, tokensWithCurrent({ tokens: state.tokens, token: state.token })],
|
|
2981
|
+
tokens: [],
|
|
2982
|
+
token: { presence: "none" }
|
|
2983
|
+
};
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
var scriptCommandsOf = (request) => {
|
|
2987
|
+
const finalState = [...request.script.matchAll(SCRIPT_PIECES)].map((match) => scriptPieceOf({ match })).reduce((state, piece) => nextTokenizerState({ state, piece }), {
|
|
2988
|
+
status: "reading",
|
|
2989
|
+
commands: [],
|
|
2990
|
+
tokens: [],
|
|
2991
|
+
token: { presence: "none" }
|
|
2992
|
+
});
|
|
2993
|
+
if (finalState.status === "unterminated") {
|
|
2994
|
+
return { outcome: "failed", error: { kind: "unterminated-quote" } };
|
|
2995
|
+
}
|
|
2996
|
+
return {
|
|
2997
|
+
outcome: "ok",
|
|
2998
|
+
value: [
|
|
2999
|
+
...finalState.commands,
|
|
3000
|
+
tokensWithCurrent({ tokens: finalState.tokens, token: finalState.token })
|
|
3001
|
+
].filter((command) => command.length > 0)
|
|
3002
|
+
};
|
|
3003
|
+
};
|
|
3004
|
+
var eslintNamingOf = (request) => request.token === ESLINT_TOKEN || request.token.startsWith(ESLINT_VERSIONED_PREFIX) || ESLINT_PATH_SUFFIXES.some((suffix) => request.token.endsWith(suffix)) ? "names-eslint" : "names-other";
|
|
3005
|
+
var invocationOf = (request) => {
|
|
3006
|
+
const eslintIndex = request.command.findIndex((token) => eslintNamingOf({ token }) === "names-eslint");
|
|
3007
|
+
if (eslintIndex === -1) {
|
|
3008
|
+
return [];
|
|
3009
|
+
}
|
|
3010
|
+
return [
|
|
3011
|
+
{
|
|
3012
|
+
options: request.command.slice(eslintIndex + 1).filter((token) => token !== FORWARDED_OPTIONS_SEPARATOR)
|
|
3013
|
+
}
|
|
3014
|
+
];
|
|
3015
|
+
};
|
|
3016
|
+
var eslintInvocationsOf = (request) => request.commands.flatMap((command) => invocationOf({ command }));
|
|
3017
|
+
var occurrenceFormOf = (request) => {
|
|
3018
|
+
if (request.arity === "takes-value" && request.token.startsWith(`${request.name}=`)) {
|
|
3019
|
+
return "joined-value";
|
|
3020
|
+
}
|
|
3021
|
+
return request.token === request.name ? "separate" : "not-this-option";
|
|
3022
|
+
};
|
|
3023
|
+
var occurrenceAt = (request) => {
|
|
3024
|
+
const form = occurrenceFormOf({ token: request.token, name: request.name, arity: request.arity });
|
|
3025
|
+
if (form === "not-this-option") {
|
|
3026
|
+
return [];
|
|
3027
|
+
}
|
|
3028
|
+
if (form === "joined-value") {
|
|
3029
|
+
return [{ option: request.token, optionValue: request.token.slice(request.name.length + 1) }];
|
|
3030
|
+
}
|
|
3031
|
+
const optionValue = request.arity === "takes-value" ? request.next : "";
|
|
3032
|
+
return [
|
|
3033
|
+
{
|
|
3034
|
+
option: optionValue === "" ? request.token : `${request.token} ${optionValue}`,
|
|
3035
|
+
optionValue
|
|
3036
|
+
}
|
|
3037
|
+
];
|
|
3038
|
+
};
|
|
3039
|
+
var ruleIdsNamedBy = (request) => {
|
|
3040
|
+
const named = request.value.split(RULE_VALUE_SEPARATORS).map((part) => part.trim()).map((part) => SURROUNDING_QUOTES.exec(part)?.groups?.inner ?? part);
|
|
3041
|
+
return request.selectedRuleIds.filter((ruleId) => named.includes(ruleId));
|
|
3042
|
+
};
|
|
3043
|
+
var reachedRuleIds = (request) => request.spec.reach === "every-clause" ? request.selectedRuleIds : ruleIdsNamedBy({ value: request.optionValue, selectedRuleIds: request.selectedRuleIds });
|
|
3044
|
+
var specWeakenings = (request) => occurrenceAt({
|
|
3045
|
+
token: request.token,
|
|
3046
|
+
next: request.next,
|
|
3047
|
+
name: request.spec.name,
|
|
3048
|
+
arity: request.spec.arity
|
|
3049
|
+
}).map((occurrence) => ({
|
|
3050
|
+
option: occurrence.option,
|
|
3051
|
+
ruleIds: reachedRuleIds({
|
|
3052
|
+
spec: request.spec,
|
|
3053
|
+
optionValue: occurrence.optionValue,
|
|
3054
|
+
selectedRuleIds: request.selectedRuleIds
|
|
3055
|
+
})
|
|
3056
|
+
}));
|
|
3057
|
+
var tokenWeakenings = (request) => WEAKENING_OPTIONS.flatMap((spec) => specWeakenings({ ...request, spec }));
|
|
3058
|
+
var commandLineOptionsOf = (request) => request.invocation.options.flatMap(
|
|
3059
|
+
(token, index) => tokenWeakenings({
|
|
3060
|
+
token,
|
|
3061
|
+
next: request.invocation.options[index + 1] ?? "",
|
|
3062
|
+
selectedRuleIds: request.selectedRuleIds
|
|
3063
|
+
})
|
|
3064
|
+
).filter((weakening) => weakening.ruleIds.length > 0);
|
|
3065
|
+
var suppressionsLocationsAt = (request) => occurrenceAt({
|
|
3066
|
+
token: request.token,
|
|
3067
|
+
next: request.next,
|
|
3068
|
+
name: SUPPRESSIONS_LOCATION_OPTION,
|
|
3069
|
+
arity: "takes-value"
|
|
3070
|
+
}).map((occurrence) => occurrence.optionValue);
|
|
3071
|
+
var suppressionsLocationValuesOf = (request) => request.invocation.options.flatMap(
|
|
3072
|
+
(token, index) => suppressionsLocationsAt({ token, next: request.invocation.options[index + 1] ?? "" })
|
|
3073
|
+
);
|
|
3074
|
+
var nextWalk = (request) => {
|
|
3075
|
+
const walk = request.walk;
|
|
3076
|
+
if (walk.position === "outside" || request.segment === "" || request.segment === ".") {
|
|
3077
|
+
return walk;
|
|
3078
|
+
}
|
|
3079
|
+
if (request.segment === ".." && walk.segments.length === 0) {
|
|
3080
|
+
return { position: "outside" };
|
|
3081
|
+
}
|
|
3082
|
+
if (request.segment === "..") {
|
|
3083
|
+
return { position: "inside", segments: walk.segments.slice(0, -1) };
|
|
3084
|
+
}
|
|
3085
|
+
return { position: "inside", segments: [...walk.segments, request.segment] };
|
|
3086
|
+
};
|
|
3087
|
+
var walkedSegments = (request) => [...request.baseSegments, ...request.path.split("/")].reduce(
|
|
3088
|
+
(walk, segment) => nextWalk({ walk, segment }),
|
|
3089
|
+
{ position: "inside", segments: [] }
|
|
3090
|
+
);
|
|
3091
|
+
var repoPathResolved = (request) => {
|
|
3092
|
+
const refused = {
|
|
3093
|
+
outcome: "failed",
|
|
3094
|
+
error: { kind: "not-repo-path", path: request.path }
|
|
3095
|
+
};
|
|
3096
|
+
if (request.path.startsWith("/")) {
|
|
3097
|
+
return refused;
|
|
3098
|
+
}
|
|
3099
|
+
const walk = walkedSegments(request);
|
|
3100
|
+
if (walk.position === "outside") {
|
|
3101
|
+
return refused;
|
|
3102
|
+
}
|
|
3103
|
+
const parsed = repoPathSchema.safeParse(walk.segments.join("/"));
|
|
3104
|
+
if (!parsed.success) {
|
|
3105
|
+
return refused;
|
|
3106
|
+
}
|
|
3107
|
+
return { outcome: "ok", value: parsed.data };
|
|
3108
|
+
};
|
|
3109
|
+
var weakeningExceptions = (request) => request.selectedRules.filter((rule) => request.weakening.ruleIds.includes(rule.ruleId)).map(
|
|
3110
|
+
(rule) => ({
|
|
3111
|
+
kind: "command-line-option",
|
|
3112
|
+
clause: rule.clause,
|
|
3113
|
+
location: request.path,
|
|
3114
|
+
script: request.script,
|
|
3115
|
+
option: request.weakening.option
|
|
3116
|
+
})
|
|
3117
|
+
);
|
|
3118
|
+
var commandLineExceptions = (request) => {
|
|
3119
|
+
const selectedRuleIds = request.selectedRules.map((rule) => rule.ruleId);
|
|
3120
|
+
return request.invocations.flatMap((invocation) => commandLineOptionsOf({ invocation, selectedRuleIds })).flatMap((weakening) => weakeningExceptions({ ...request, weakening }));
|
|
3121
|
+
};
|
|
3122
|
+
var locatedScan = (request) => {
|
|
3123
|
+
if (request.scan.outcome === "failed") {
|
|
3124
|
+
return request.scan;
|
|
3125
|
+
}
|
|
3126
|
+
const location = repoPathResolved({ baseSegments: request.baseSegments, path: request.locationText });
|
|
3127
|
+
if (location.outcome === "failed") {
|
|
3128
|
+
return {
|
|
3129
|
+
outcome: "failed",
|
|
3130
|
+
error: {
|
|
3131
|
+
kind: "tool-failed",
|
|
3132
|
+
detail: `script "${request.script}" in ${request.path} names --suppressions-location ${request.locationText}, which is not a repo path`
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
return {
|
|
3137
|
+
outcome: "ok",
|
|
3138
|
+
value: {
|
|
3139
|
+
nativeExceptions: request.scan.value.nativeExceptions,
|
|
3140
|
+
suppressionsLocations: [
|
|
3141
|
+
...request.scan.value.suppressionsLocations,
|
|
3142
|
+
{ location: location.value, script: request.script }
|
|
3143
|
+
]
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
};
|
|
3147
|
+
var scriptScan = (request) => {
|
|
3148
|
+
const commands = scriptCommandsOf({ script: request.scriptText });
|
|
3149
|
+
if (commands.outcome === "failed") {
|
|
3150
|
+
return {
|
|
3151
|
+
outcome: "failed",
|
|
3152
|
+
error: {
|
|
3153
|
+
kind: "tool-failed",
|
|
3154
|
+
detail: `script "${request.script}" in ${request.path} has an unterminated quote`
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
const invocations = eslintInvocationsOf({ commands: commands.value });
|
|
3159
|
+
const baseSegments = request.path.split("/").slice(0, -1);
|
|
3160
|
+
return invocations.flatMap((invocation) => suppressionsLocationValuesOf({ invocation })).reduce(
|
|
3161
|
+
(scan, locationText) => locatedScan({ scan, locationText, baseSegments, path: request.path, script: request.script }),
|
|
3162
|
+
{
|
|
3163
|
+
outcome: "ok",
|
|
3164
|
+
value: {
|
|
3165
|
+
nativeExceptions: commandLineExceptions({ ...request, invocations }),
|
|
3166
|
+
suppressionsLocations: []
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
);
|
|
3170
|
+
};
|
|
3171
|
+
var mergedScriptScan = (request) => {
|
|
3172
|
+
if (request.scan.outcome === "failed") {
|
|
3173
|
+
return request.scan;
|
|
3174
|
+
}
|
|
3175
|
+
const scanned = scriptScan({
|
|
3176
|
+
path: request.path,
|
|
3177
|
+
script: request.script,
|
|
3178
|
+
scriptText: request.scriptText,
|
|
3179
|
+
selectedRules: request.selectedRules
|
|
3180
|
+
});
|
|
3181
|
+
if (scanned.outcome === "failed") {
|
|
3182
|
+
return scanned;
|
|
3183
|
+
}
|
|
3184
|
+
return {
|
|
3185
|
+
outcome: "ok",
|
|
3186
|
+
value: {
|
|
3187
|
+
nativeExceptions: [...request.scan.value.nativeExceptions, ...scanned.value.nativeExceptions],
|
|
3188
|
+
suppressionsLocations: [
|
|
3189
|
+
...request.scan.value.suppressionsLocations,
|
|
3190
|
+
...scanned.value.suppressionsLocations
|
|
3191
|
+
]
|
|
3192
|
+
}
|
|
3193
|
+
};
|
|
3194
|
+
};
|
|
3195
|
+
var scanPackageJson = (request) => {
|
|
3196
|
+
const json = parsedJson({ text: request.text });
|
|
3197
|
+
if (json.outcome === "failed") {
|
|
3198
|
+
return { outcome: "failed", error: { kind: "tool-failed", detail: `${request.path}: ${json.error}` } };
|
|
3199
|
+
}
|
|
3200
|
+
const packageJson = packageJsonSchema.safeParse(json.value);
|
|
3201
|
+
if (!packageJson.success) {
|
|
3202
|
+
return {
|
|
3203
|
+
outcome: "failed",
|
|
3204
|
+
error: { kind: "tool-failed", detail: `${request.path}: ${external_exports.prettifyError(packageJson.error)}` }
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
return Object.entries(packageJson.data.scripts ?? {}).reduce(
|
|
3208
|
+
(scan, [script, scriptText]) => mergedScriptScan({ scan, script, scriptText, path: request.path, selectedRules: request.selectedRules }),
|
|
3209
|
+
{ outcome: "ok", value: { nativeExceptions: [], suppressionsLocations: [] } }
|
|
3210
|
+
);
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
// mechanisms/eslint/runner/config-lookup.ts
|
|
3214
|
+
var ROOT_LOOKUP_MAJOR = 9;
|
|
3215
|
+
var ESLINT_PACKAGE_JSON = ["node_modules", "eslint", "package.json"];
|
|
3216
|
+
var SELECTION_FILE = "disciplines.json";
|
|
3217
|
+
var PACKAGE_JSON_NAME = "package.json";
|
|
3218
|
+
var FLAG_OPTION = "--flag";
|
|
3219
|
+
var FLAG_OPTION_JOINED = `${FLAG_OPTION}=`;
|
|
3220
|
+
var NEAREST_LOOKUP_FLAGS = /* @__PURE__ */ new Set([
|
|
3221
|
+
"v10_config_lookup_from_file",
|
|
3222
|
+
"unstable_config_lookup_from_file"
|
|
3223
|
+
]);
|
|
3224
|
+
var ROOT_CONFIG_NAMES = [
|
|
3225
|
+
"eslint.config.js",
|
|
3226
|
+
"eslint.config.mjs",
|
|
3227
|
+
"eslint.config.cjs",
|
|
3228
|
+
"eslint.config.ts",
|
|
3229
|
+
"eslint.config.mts",
|
|
3230
|
+
"eslint.config.cts"
|
|
3231
|
+
];
|
|
3232
|
+
var NEAREST = { kind: "nearest-to-file" };
|
|
3233
|
+
var installedEslintMajor = (request) => {
|
|
3234
|
+
const text = request.fileText.read({ path: request.path.join({ segments: [request.repoRoot, ...ESLINT_PACKAGE_JSON] }) });
|
|
3235
|
+
if (text.outcome === "failed") {
|
|
3236
|
+
return "unknown";
|
|
3237
|
+
}
|
|
3238
|
+
const json = parsedJson({ text: text.value });
|
|
3239
|
+
const parsed = json.outcome === "ok" ? eslintVersionFileSchema.safeParse(json.value) : void 0;
|
|
3240
|
+
const major = parsed?.success ? Number.parseInt(parsed.data.version, 10) : Number.NaN;
|
|
3241
|
+
return Number.isNaN(major) ? "unknown" : major;
|
|
3242
|
+
};
|
|
3243
|
+
var flagsNamedBy = (request) => request.options.flatMap((option, index) => {
|
|
3244
|
+
if (option.startsWith(FLAG_OPTION_JOINED)) {
|
|
3245
|
+
return [option.slice(FLAG_OPTION_JOINED.length)];
|
|
3246
|
+
}
|
|
3247
|
+
const next = request.options[index + 1];
|
|
3248
|
+
return option === FLAG_OPTION && next !== void 0 ? [next] : [];
|
|
3249
|
+
});
|
|
3250
|
+
var scriptsOf = (request) => {
|
|
3251
|
+
const text = request.fileText.read({ path: request.path.join({ segments: [request.repoRoot, request.packagePath] }) });
|
|
3252
|
+
const json = text.outcome === "ok" ? parsedJson({ text: text.value }) : void 0;
|
|
3253
|
+
const parsed = json?.outcome === "ok" ? packageJsonSchema.safeParse(json.value) : void 0;
|
|
3254
|
+
return parsed?.success ? Object.values(parsed.data.scripts ?? {}) : [];
|
|
3255
|
+
};
|
|
3256
|
+
var lintScriptsSelectNearest = (request) => request.trackedPaths.filter((path) => path.split("/").at(-1) === PACKAGE_JSON_NAME).flatMap((packagePath) => scriptsOf({ ...request, packagePath })).flatMap((script) => {
|
|
3257
|
+
const commands = scriptCommandsOf({ script });
|
|
3258
|
+
return commands.outcome === "ok" ? eslintInvocationsOf({ commands: commands.value }) : [];
|
|
3259
|
+
}).flatMap((invocation) => flagsNamedBy({ options: invocation.options })).some((flag) => NEAREST_LOOKUP_FLAGS.has(flag)) ? "selects-nearest" : "selects-root";
|
|
3260
|
+
var rootConfigFile = (request) => ROOT_CONFIG_NAMES.map((name) => request.path.join({ segments: [request.repoRoot, name] })).find(
|
|
3261
|
+
(candidate) => request.fileText.exists({ path: candidate }) === "present"
|
|
3262
|
+
);
|
|
3263
|
+
var declaredLookup = (request) => {
|
|
3264
|
+
const text = request.fileText.read({ path: request.path.join({ segments: [request.repoRoot, SELECTION_FILE] }) });
|
|
3265
|
+
const json = text.outcome === "ok" ? parsedJson({ text: text.value }) : void 0;
|
|
3266
|
+
const parsed = json?.outcome === "ok" ? selectionLookupSchema.safeParse(json.value) : void 0;
|
|
3267
|
+
return parsed?.success ? parsed.data.eslintConfigLookup : void 0;
|
|
3268
|
+
};
|
|
3269
|
+
var detectedLookup = (request) => installedEslintMajor(request) !== ROOT_LOOKUP_MAJOR || lintScriptsSelectNearest(request) === "selects-nearest" ? "nearest-to-file" : "repository-root";
|
|
3270
|
+
var teamConfigLookup = (request) => {
|
|
3271
|
+
if ((declaredLookup(request) ?? detectedLookup(request)) === "nearest-to-file") {
|
|
3272
|
+
return { outcome: "ok", value: NEAREST };
|
|
3273
|
+
}
|
|
3274
|
+
const configFile = rootConfigFile(request);
|
|
3275
|
+
return configFile === void 0 ? {
|
|
3276
|
+
outcome: "failed",
|
|
3277
|
+
error: {
|
|
3278
|
+
kind: "team-config-unloadable",
|
|
3279
|
+
detail: "the repository root has no eslint.config.* for a root-only config lookup; add one there, or set eslintConfigLookup to nearest-to-file in disciplines.json if ESLint runs from each package"
|
|
3280
|
+
}
|
|
3281
|
+
} : { outcome: "ok", value: { kind: "repository-root", configFile } };
|
|
3282
|
+
};
|
|
3283
|
+
|
|
3284
|
+
// mechanisms/eslint/runner/projection.ts
|
|
3285
|
+
var PROJECTION_PATH = repoPathSchema.parse("disciplines.eslint.mjs");
|
|
3286
|
+
var SOURCE_FILES = "**/*.{ts,tsx,mts,cts}";
|
|
3287
|
+
var GLOB_SPECIAL_CHARACTERS = /[\\*?[\]{}()!+@]/g;
|
|
3288
|
+
var PARENT_PREFIX = "../";
|
|
3289
|
+
var codeUnitOrder = (request) => {
|
|
3290
|
+
if (request.left < request.right) {
|
|
3291
|
+
return -1;
|
|
3292
|
+
}
|
|
3293
|
+
return request.left > request.right ? 1 : 0;
|
|
3294
|
+
};
|
|
3295
|
+
var quoted = (request) => JSON.stringify(request.text);
|
|
3296
|
+
var escapedGlobPath = (request) => request.path.replace(GLOB_SPECIAL_CHARACTERS, (character) => `\\${character}`);
|
|
3297
|
+
var relativeImportOf = (request) => {
|
|
3298
|
+
const location = request.path.relative({ from: request.repoRoot, to: request.modulePath });
|
|
3299
|
+
if (location.relation === "different-root") {
|
|
3300
|
+
return { placement: "piece-on-another-root" };
|
|
3301
|
+
}
|
|
3302
|
+
return {
|
|
3303
|
+
placement: "importable",
|
|
3304
|
+
specifier: location.path.startsWith(PARENT_PREFIX) ? location.path : `./${location.path}`
|
|
3305
|
+
};
|
|
3306
|
+
};
|
|
3307
|
+
var pathInsidePackage = (request) => {
|
|
3308
|
+
const location = request.path.relative({ from: request.packageRoot, to: request.modulePath });
|
|
3309
|
+
return location.relation === "within-root" && !location.path.startsWith(PARENT_PREFIX) ? location.path : void 0;
|
|
3310
|
+
};
|
|
3311
|
+
var packageImportOf = (request) => {
|
|
3312
|
+
const inside = pathInsidePackage({ path: request.path, packageRoot: request.install.root, modulePath: request.modulePath });
|
|
3313
|
+
return inside === void 0 ? void 0 : { placement: "importable", specifier: `${request.install.name}/${inside}` };
|
|
3314
|
+
};
|
|
3315
|
+
var pluginImportOf = (request) => {
|
|
3316
|
+
const modulePath = request.path.join({ segments: [request.pieceRoot, request.pluginModule] });
|
|
3317
|
+
const packaged = request.install.form === "package" ? packageImportOf({ path: request.path, install: request.install, modulePath }) : void 0;
|
|
3318
|
+
return packaged ?? relativeImportOf({ path: request.path, repoRoot: request.repoRoot, modulePath });
|
|
3319
|
+
};
|
|
3320
|
+
var rulesLine = (request) => ` rules: { ${[...request.rules].sort((left, right) => codeUnitOrder({ left: left.ruleId, right: right.ruleId })).map((rule) => `${quoted({ text: rule.ruleId })}: ${rule.entry}`).join(", ")} },`;
|
|
3321
|
+
var enabledLine = (request) => ({
|
|
3322
|
+
ruleId: request.clause.ruleId,
|
|
3323
|
+
entry: JSON.stringify(enabledRuleEntry({ options: request.clause.options }))
|
|
3324
|
+
});
|
|
3325
|
+
var offLines = (request) => request.ruleIds.map((ruleId) => ({ ruleId, entry: quoted({ text: "off" }) }));
|
|
3326
|
+
var blockText = (request) => [" {", ...request.lines, " },"].join("\n");
|
|
3327
|
+
var pieceBlock = (request) => blockText({
|
|
3328
|
+
lines: [
|
|
3329
|
+
` name: ${quoted({ text: `${reservedNamespace}/piece/${request.piece.pluginNamespace}` })},`,
|
|
3330
|
+
` files: [${quoted({ text: SOURCE_FILES })}],`,
|
|
3331
|
+
` plugins: { ${quoted({ text: request.piece.pluginNamespace })}: ${request.importName} },`,
|
|
3332
|
+
rulesLine({ rules: request.piece.clauses.map((clause) => enabledLine({ clause })) })
|
|
3333
|
+
]
|
|
3334
|
+
});
|
|
3335
|
+
var ruleIdsOfClause = (request) => request.pieces.flatMap((piece) => piece.clauses).filter(
|
|
3336
|
+
(clause) => sameClauseAddress({ left: clause.address, right: request.address }) === "same"
|
|
3337
|
+
).map((clause) => clause.ruleId).sort((left, right) => codeUnitOrder({ left, right }));
|
|
3338
|
+
var fileRecordBlock = (request) => blockText({
|
|
3339
|
+
lines: [
|
|
3340
|
+
` name: ${quoted({
|
|
3341
|
+
text: `${reservedNamespace}/${request.record.kind}/${clauseAddressText({ address: request.record.clause })}/${request.record.file}`
|
|
3342
|
+
})},`,
|
|
3343
|
+
` files: [${quoted({ text: escapedGlobPath({ path: request.record.file }) })}],`,
|
|
3344
|
+
rulesLine({ rules: offLines({ ruleIds: ruleIdsOfClause({ pieces: request.pieces, address: request.record.clause }) }) })
|
|
3345
|
+
]
|
|
3346
|
+
});
|
|
3347
|
+
var clauseWideBlock = (request) => blockText({
|
|
3348
|
+
lines: [
|
|
3349
|
+
` name: ${quoted({
|
|
3350
|
+
text: `${reservedNamespace}/${request.record.kind}/${clauseAddressText({ address: request.record.clause })}`
|
|
3351
|
+
})},`,
|
|
3352
|
+
rulesLine({ rules: offLines({ ruleIds: ruleIdsOfClause({ pieces: request.pieces, address: request.record.clause }) }) })
|
|
3353
|
+
]
|
|
3354
|
+
});
|
|
3355
|
+
var fileRecordOrder = (request) => codeUnitOrder({
|
|
3356
|
+
left: clauseAddressText({ address: request.left.clause }),
|
|
3357
|
+
right: clauseAddressText({ address: request.right.clause })
|
|
3358
|
+
}) || codeUnitOrder({ left: request.left.file, right: request.right.file });
|
|
3359
|
+
var clauseWideOrder = (request) => codeUnitOrder({
|
|
3360
|
+
left: clauseAddressText({ address: request.left.clause }),
|
|
3361
|
+
right: clauseAddressText({ address: request.right.clause })
|
|
3362
|
+
});
|
|
3363
|
+
var sortedFileRecords = (request) => request.records.flatMap((record) => record.kind === "clause-wide-carve-out" ? [] : [record]).sort((left, right) => fileRecordOrder({ left, right }));
|
|
3364
|
+
var sortedClauseWideRecords = (request) => request.records.flatMap((record) => record.kind === "clause-wide-carve-out" ? [record] : []).sort((left, right) => clauseWideOrder({ left, right }));
|
|
3365
|
+
var sortedPieces = (request) => [...request.pieces].sort(
|
|
3366
|
+
(left, right) => codeUnitOrder({ left: left.pluginNamespace, right: right.pluginNamespace })
|
|
3367
|
+
);
|
|
3368
|
+
var importLines = (request) => request.pieces.map((piece, index) => `import piece${index} from ${quoted({ text: piece.pluginImport })};`);
|
|
3369
|
+
var configBlocks = (request) => [
|
|
3370
|
+
...request.pieces.map((piece, index) => pieceBlock({ piece, importName: `piece${index}` })),
|
|
3371
|
+
...sortedFileRecords({ records: request.records }).map(
|
|
3372
|
+
(record) => fileRecordBlock({ record, pieces: request.pieces })
|
|
3373
|
+
),
|
|
3374
|
+
...sortedClauseWideRecords({ records: request.records }).map(
|
|
3375
|
+
(record) => clauseWideBlock({ record, pieces: request.pieces })
|
|
3376
|
+
)
|
|
3377
|
+
];
|
|
3378
|
+
var projectionText = (request) => {
|
|
3379
|
+
const pieces = sortedPieces({ pieces: request.selectedPieces });
|
|
3380
|
+
const imports = importLines({ pieces });
|
|
3381
|
+
const blocks = configBlocks({ pieces, records: request.records });
|
|
3382
|
+
return `${imports.join("\n")}
|
|
3383
|
+
|
|
3384
|
+
export default [
|
|
3385
|
+
${blocks.join("\n")}
|
|
3386
|
+
];
|
|
3387
|
+
`;
|
|
3388
|
+
};
|
|
3389
|
+
var projectionState = (request) => {
|
|
3390
|
+
if (request.current.presence === "absent") {
|
|
3391
|
+
return "missing";
|
|
3392
|
+
}
|
|
3393
|
+
return request.current.text === request.generated ? "current" : "out-of-date";
|
|
3394
|
+
};
|
|
3395
|
+
var currentProjection = (request) => {
|
|
3396
|
+
const projectionFile = request.path.join({ segments: [request.repoRoot, PROJECTION_PATH] });
|
|
3397
|
+
if (request.fileText.exists({ path: projectionFile }) === "absent") {
|
|
3398
|
+
return { outcome: "ok", value: { presence: "absent" } };
|
|
3399
|
+
}
|
|
3400
|
+
const text = request.fileText.read({ path: projectionFile });
|
|
3401
|
+
if (text.outcome === "failed") {
|
|
3402
|
+
return {
|
|
3403
|
+
outcome: "failed",
|
|
3404
|
+
error: { kind: "file-unreadable", file: PROJECTION_PATH, detail: text.error.detail }
|
|
3405
|
+
};
|
|
3406
|
+
}
|
|
3407
|
+
return { outcome: "ok", value: { presence: "present", text: text.value.replaceAll("\r\n", "\n") } };
|
|
3408
|
+
};
|
|
3409
|
+
var writtenProjection = (request) => {
|
|
3410
|
+
const written = request.fileText.write({
|
|
3411
|
+
path: request.path.join({ segments: [request.repoRoot, PROJECTION_PATH] }),
|
|
3412
|
+
text: request.text
|
|
3413
|
+
});
|
|
3414
|
+
if (written.outcome === "failed") {
|
|
3415
|
+
return { outcome: "failed", error: { kind: "tool-failed", detail: written.error.detail } };
|
|
3416
|
+
}
|
|
3417
|
+
return { outcome: "ok", value: { path: PROJECTION_PATH, effect: "written" } };
|
|
3418
|
+
};
|
|
3419
|
+
var writeProjection = (request) => {
|
|
3420
|
+
const current = currentProjection({ fileText: request.fileText, path: request.path, repoRoot: request.repoRoot });
|
|
3421
|
+
if (current.outcome === "failed") {
|
|
3422
|
+
return current;
|
|
3423
|
+
}
|
|
3424
|
+
if (projectionState({ current: current.value, generated: request.text }) === "current") {
|
|
3425
|
+
return { outcome: "ok", value: { path: PROJECTION_PATH, effect: "unchanged" } };
|
|
3426
|
+
}
|
|
3427
|
+
return writtenProjection(request);
|
|
3428
|
+
};
|
|
3429
|
+
|
|
3430
|
+
// mechanisms/eslint/runner/suppressions-scanner.ts
|
|
3431
|
+
var REPO_ROOT = "repo-root";
|
|
3432
|
+
var ruleExceptions = (request) => request.ruleIds.flatMap(
|
|
3433
|
+
(ruleId) => request.selectedRules.filter((rule) => rule.ruleId === ruleId).map(
|
|
3434
|
+
(rule) => ({
|
|
3435
|
+
kind: "suppression-entry",
|
|
3436
|
+
clause: rule.clause,
|
|
3437
|
+
file: request.file,
|
|
3438
|
+
location: request.location
|
|
3439
|
+
})
|
|
3440
|
+
)
|
|
3441
|
+
);
|
|
3442
|
+
var appendedEntry = (request) => {
|
|
3443
|
+
if (request.entries.outcome === "failed") {
|
|
3444
|
+
return request.entries;
|
|
3445
|
+
}
|
|
3446
|
+
const file = repoPathResolved({ baseSegments: request.baseSegments, path: request.key });
|
|
3447
|
+
if (file.outcome === "failed") {
|
|
3448
|
+
return {
|
|
3449
|
+
outcome: "failed",
|
|
3450
|
+
error: {
|
|
3451
|
+
kind: "tool-failed",
|
|
3452
|
+
detail: `${request.location}: key ${request.key} names no file inside the repository`
|
|
3453
|
+
}
|
|
3454
|
+
};
|
|
3455
|
+
}
|
|
3456
|
+
return {
|
|
3457
|
+
outcome: "ok",
|
|
3458
|
+
value: [
|
|
3459
|
+
...request.entries.value,
|
|
3460
|
+
...ruleExceptions({
|
|
3461
|
+
ruleIds: request.ruleIds,
|
|
3462
|
+
file: file.value,
|
|
3463
|
+
location: request.location,
|
|
3464
|
+
selectedRules: request.selectedRules
|
|
3465
|
+
})
|
|
3466
|
+
]
|
|
3467
|
+
};
|
|
3468
|
+
};
|
|
3469
|
+
var baseSegmentsOf = (request) => request.keysRelativeTo === REPO_ROOT ? [] : request.keysRelativeTo.split("/");
|
|
3470
|
+
var suppressionEntriesOf = (request) => {
|
|
3471
|
+
const json = parsedJson({ text: request.text });
|
|
3472
|
+
if (json.outcome === "failed") {
|
|
3473
|
+
return {
|
|
3474
|
+
outcome: "failed",
|
|
3475
|
+
error: { kind: "tool-failed", detail: `${request.location}: ${json.error}` }
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
const suppressions = suppressionsFileSchema.safeParse(json.value);
|
|
3479
|
+
if (!suppressions.success) {
|
|
3480
|
+
return {
|
|
3481
|
+
outcome: "failed",
|
|
3482
|
+
error: { kind: "tool-failed", detail: `${request.location}: ${external_exports.prettifyError(suppressions.error)}` }
|
|
3483
|
+
};
|
|
3484
|
+
}
|
|
3485
|
+
const baseSegments = baseSegmentsOf({ keysRelativeTo: request.keysRelativeTo });
|
|
3486
|
+
return Object.entries(suppressions.data).reduce(
|
|
3487
|
+
(entries, [key, rules]) => appendedEntry({
|
|
3488
|
+
entries,
|
|
3489
|
+
key,
|
|
3490
|
+
ruleIds: Object.keys(rules),
|
|
3491
|
+
baseSegments,
|
|
3492
|
+
location: request.location,
|
|
3493
|
+
selectedRules: request.selectedRules
|
|
3494
|
+
}),
|
|
3495
|
+
{ outcome: "ok", value: [] }
|
|
3496
|
+
);
|
|
3497
|
+
};
|
|
3498
|
+
var scriptSuppressionEntries = (request) => {
|
|
3499
|
+
const text = request.fileText.read({
|
|
3500
|
+
path: request.path.join({ segments: [request.repoRoot, request.location] })
|
|
3501
|
+
});
|
|
3502
|
+
if (text.outcome === "failed") {
|
|
3503
|
+
return {
|
|
3504
|
+
outcome: "failed",
|
|
3505
|
+
error: { kind: "file-unreadable", file: request.location, detail: text.error.detail }
|
|
3506
|
+
};
|
|
3507
|
+
}
|
|
3508
|
+
return suppressionEntriesOf({
|
|
3509
|
+
location: request.location,
|
|
3510
|
+
keysRelativeTo: request.keysRelativeTo,
|
|
3511
|
+
text: text.value,
|
|
3512
|
+
selectedRules: request.selectedRules
|
|
3513
|
+
});
|
|
3514
|
+
};
|
|
3515
|
+
|
|
3516
|
+
// mechanisms/eslint/runner/create-eslint-runner.ts
|
|
3517
|
+
var SUPPRESSIONS_FILE_NAME = "eslint-suppressions.json";
|
|
3518
|
+
var PACKAGE_JSON_NAME2 = "package.json";
|
|
3519
|
+
var INLINE_DISABLE = "inline-disable";
|
|
3520
|
+
var INLINE_RULE_CONFIG = "inline-rule-config";
|
|
3521
|
+
var LINE_BREAK = /\r\n|[\r\n\u2028\u2029]/;
|
|
3522
|
+
var pieceInvalid = (request) => ({
|
|
3523
|
+
outcome: "failed",
|
|
3524
|
+
error: { kind: "piece-invalid", pieceRoot: request.pieceRoot, detail: request.detail }
|
|
3525
|
+
});
|
|
3526
|
+
var appendedOutcome = (request) => {
|
|
3527
|
+
if (request.gathered.outcome === "failed") {
|
|
3528
|
+
return request.gathered;
|
|
3529
|
+
}
|
|
3530
|
+
if (request.next.outcome === "failed") {
|
|
3531
|
+
return request.next;
|
|
3532
|
+
}
|
|
3533
|
+
return { outcome: "ok", value: [...request.gathered.value, ...request.next.value] };
|
|
3534
|
+
};
|
|
3535
|
+
var collectOutcomes = (request) => request.outcomes.reduce((gathered, next) => appendedOutcome({ gathered, next }), {
|
|
3536
|
+
outcome: "ok",
|
|
3537
|
+
value: []
|
|
3538
|
+
});
|
|
3539
|
+
var mappedOutcome = (request) => request.outcome.outcome === "failed" ? request.outcome : { outcome: "ok", value: request.map(request.outcome.value) };
|
|
3540
|
+
var listedOutcome = (request) => mappedOutcome({ outcome: request.outcome, map: (okValue) => [okValue] });
|
|
3541
|
+
var configuredClause = (request) => {
|
|
3542
|
+
const settings = eslintPieceSettingsSchema.safeParse(request.clause.settings);
|
|
3543
|
+
if (!settings.success) {
|
|
3544
|
+
return pieceInvalid({ pieceRoot: request.clause.pieceRoot, detail: external_exports.prettifyError(settings.error) });
|
|
3545
|
+
}
|
|
3546
|
+
if (settings.data.pluginNamespace === reservedNamespace) {
|
|
3547
|
+
return pieceInvalid({
|
|
3548
|
+
pieceRoot: request.clause.pieceRoot,
|
|
3549
|
+
detail: `the plugin namespace ${reservedNamespace} is reserved for ${TOOL_IDENTITY.command}'s own rules`
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
return {
|
|
3553
|
+
outcome: "ok",
|
|
3554
|
+
value: {
|
|
3555
|
+
clause: request.clause,
|
|
3556
|
+
settings: settings.data,
|
|
3557
|
+
ruleId: `${settings.data.pluginNamespace}/${settings.data.rule}`,
|
|
3558
|
+
modulePath: request.path.join({
|
|
3559
|
+
segments: [request.clause.pieceRoot, settings.data.pluginModule]
|
|
3560
|
+
})
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
};
|
|
3564
|
+
var placedClause = (request) => {
|
|
3565
|
+
const pluginImport = pluginImportOf({
|
|
3566
|
+
path: request.path,
|
|
3567
|
+
repoRoot: request.origin.repoRoot,
|
|
3568
|
+
install: request.origin.install,
|
|
3569
|
+
pieceRoot: request.configured.clause.pieceRoot,
|
|
3570
|
+
pluginModule: request.configured.settings.pluginModule
|
|
3571
|
+
});
|
|
3572
|
+
if (pluginImport.placement === "piece-on-another-root") {
|
|
3573
|
+
return pieceInvalid({
|
|
3574
|
+
pieceRoot: request.configured.clause.pieceRoot,
|
|
3575
|
+
detail: "the piece is on a different root from the repository, so the committed projection cannot import it by a relative path"
|
|
3576
|
+
});
|
|
3577
|
+
}
|
|
3578
|
+
return { outcome: "ok", value: { ...request.configured, pluginImport: pluginImport.specifier } };
|
|
3579
|
+
};
|
|
3580
|
+
var placedConfiguredClause = (request) => {
|
|
3581
|
+
const configured = configuredClause({ clause: request.clause, path: request.path });
|
|
3582
|
+
if (configured.outcome === "failed") {
|
|
3583
|
+
return configured;
|
|
3584
|
+
}
|
|
3585
|
+
return placedClause({ configured: configured.value, path: request.path, origin: request.origin });
|
|
3586
|
+
};
|
|
3587
|
+
var clashOf = (request) => request.earlier.ruleId === request.entry.ruleId || request.earlier.settings.pluginNamespace === request.entry.settings.pluginNamespace && request.earlier.modulePath !== request.entry.modulePath ? "clashing" : "distinct";
|
|
3588
|
+
var clashingClause = (request) => request.configured.find(
|
|
3589
|
+
(entry, index) => request.configured.slice(0, index).some((earlier) => clashOf({ earlier, entry }) === "clashing")
|
|
3590
|
+
);
|
|
3591
|
+
var configuredSelection = (request) => {
|
|
3592
|
+
const configured = collectOutcomes({
|
|
3593
|
+
outcomes: request.clauses.map(
|
|
3594
|
+
(clause) => listedOutcome({ outcome: placedConfiguredClause({ clause, path: request.path, origin: request.origin }) })
|
|
3595
|
+
)
|
|
3596
|
+
});
|
|
3597
|
+
if (configured.outcome === "failed") {
|
|
3598
|
+
return configured;
|
|
3599
|
+
}
|
|
3600
|
+
const clashing = clashingClause({ configured: configured.value });
|
|
3601
|
+
if (clashing !== void 0) {
|
|
3602
|
+
return pieceInvalid({
|
|
3603
|
+
pieceRoot: clashing.clause.pieceRoot,
|
|
3604
|
+
detail: `the rule ${clashing.ruleId} or its plugin namespace ${clashing.settings.pluginNamespace} is already selected from another piece`
|
|
3605
|
+
});
|
|
3606
|
+
}
|
|
3607
|
+
return configured;
|
|
3608
|
+
};
|
|
3609
|
+
var parsedPluginOf = (request) => {
|
|
3610
|
+
if (request.loaded.outcome === "failed") {
|
|
3611
|
+
return { outcome: "failed", error: { detail: request.loaded.error.detail } };
|
|
3612
|
+
}
|
|
3613
|
+
const parsed = eslintPluginModuleSchema.safeParse(request.loaded.value);
|
|
3614
|
+
if (!parsed.success) {
|
|
3615
|
+
return { outcome: "failed", error: { detail: external_exports.prettifyError(parsed.error) } };
|
|
3616
|
+
}
|
|
3617
|
+
return { outcome: "ok", value: parsed.data.default };
|
|
3618
|
+
};
|
|
3619
|
+
var parsedPlugin = (request) => request.modules.load({ path: request.modulePath }).then((loaded) => parsedPluginOf({ loaded }));
|
|
3620
|
+
var pluginOf = (request) => {
|
|
3621
|
+
const pieceRoot = request.configured.clause.pieceRoot;
|
|
3622
|
+
if (request.parsed.outcome === "failed") {
|
|
3623
|
+
return pieceInvalid({ pieceRoot, detail: request.parsed.error.detail });
|
|
3624
|
+
}
|
|
3625
|
+
if (!Object.hasOwn(request.parsed.value.rules, request.configured.settings.rule)) {
|
|
3626
|
+
return pieceInvalid({
|
|
3627
|
+
pieceRoot,
|
|
3628
|
+
detail: `the plugin has no rule named ${request.configured.settings.rule}`
|
|
3629
|
+
});
|
|
3630
|
+
}
|
|
3631
|
+
return { outcome: "ok", value: { ...request.configured, plugin: request.parsed.value } };
|
|
3632
|
+
};
|
|
3633
|
+
var loadedPlugin = (request) => parsedPlugin({ modulePath: request.configured.modulePath, modules: request.modules }).then(
|
|
3634
|
+
(parsed) => pluginOf({ parsed, configured: request.configured })
|
|
3635
|
+
);
|
|
3636
|
+
var distinctModules = (request) => [...new Set(request.configured.map((entry) => entry.modulePath))].map((modulePath) => ({
|
|
3637
|
+
modulePath,
|
|
3638
|
+
parsed: parsedPlugin({ modulePath, modules: request.modules })
|
|
3639
|
+
}));
|
|
3640
|
+
var sharedPluginsOf = (request) => request.loaded.filter((module) => module.modulePath === request.entry.modulePath).map((module) => ({ configured: request.entry, parsed: module.parsed }));
|
|
3641
|
+
var sharedPlugins = (request) => {
|
|
3642
|
+
const loaded = distinctModules(request);
|
|
3643
|
+
return request.configured.flatMap((entry) => sharedPluginsOf({ entry, loaded }));
|
|
3644
|
+
};
|
|
3645
|
+
var listedSelection = (request) => request.shared.parsed.then(
|
|
3646
|
+
(parsed) => listedOutcome({ outcome: pluginOf({ parsed, configured: request.shared.configured }) })
|
|
3647
|
+
);
|
|
3648
|
+
var selectedClauses = (request) => {
|
|
3649
|
+
const configured = configuredSelection({ clauses: request.clauses, path: request.path, origin: request.origin });
|
|
3650
|
+
if (configured.outcome === "failed") {
|
|
3651
|
+
return Promise.resolve(configured);
|
|
3652
|
+
}
|
|
3653
|
+
return Promise.all(
|
|
3654
|
+
sharedPlugins({ configured: configured.value, modules: request.modules }).map(
|
|
3655
|
+
(shared) => listedSelection({ shared })
|
|
3656
|
+
)
|
|
3657
|
+
).then((outcomes) => collectOutcomes({ outcomes }));
|
|
3658
|
+
};
|
|
3659
|
+
var namespaceLeaders = (request) => request.configured.filter(
|
|
3660
|
+
(entry, index) => request.configured.findIndex((other) => other.settings.pluginNamespace === entry.settings.pluginNamespace) === index
|
|
3661
|
+
);
|
|
3662
|
+
var projectedPieceOf = (request) => ({
|
|
3663
|
+
pluginNamespace: request.first.settings.pluginNamespace,
|
|
3664
|
+
pluginImport: request.first.pluginImport,
|
|
3665
|
+
clauses: request.configured.filter((entry) => entry.settings.pluginNamespace === request.first.settings.pluginNamespace).map((entry) => ({
|
|
3666
|
+
address: entry.clause.address,
|
|
3667
|
+
ruleId: entry.ruleId,
|
|
3668
|
+
options: ruleOptionsOf({ settings: entry.settings })
|
|
3669
|
+
}))
|
|
3670
|
+
});
|
|
3671
|
+
var projectedPieces = (request) => namespaceLeaders({ configured: request.configured }).map((first) => projectedPieceOf({ ...request, first }));
|
|
3672
|
+
var generatedProjection = (request) => projectionText({
|
|
3673
|
+
selectedPieces: projectedPieces({ configured: request.configured }),
|
|
3674
|
+
records: request.records
|
|
3675
|
+
});
|
|
3676
|
+
var fileRuleStates = (request) => request.query.ruleState({ file: request.file, ruleId: request.ruleId }).then(
|
|
3677
|
+
(state) => mappedOutcome({ outcome: state, map: (ruleState) => [{ ruleId: request.ruleId, state: ruleState }] })
|
|
3678
|
+
);
|
|
3679
|
+
var checkedQueriedFile = (request) => Promise.all(
|
|
3680
|
+
request.ruleIds.map((ruleId) => fileRuleStates({ query: request.query, file: request.file, ruleId }))
|
|
3681
|
+
).then(
|
|
3682
|
+
(outcomes) => mappedOutcome({
|
|
3683
|
+
outcome: collectOutcomes({ outcomes }),
|
|
3684
|
+
map: (states) => [{ file: request.file, ignored: "checked", states }]
|
|
3685
|
+
})
|
|
3686
|
+
);
|
|
3687
|
+
var queriedFileOf = (request) => {
|
|
3688
|
+
if (request.ignoredState.outcome === "failed") {
|
|
3689
|
+
return Promise.resolve(request.ignoredState);
|
|
3690
|
+
}
|
|
3691
|
+
if (request.ignoredState.value === "ignored") {
|
|
3692
|
+
return Promise.resolve({ outcome: "ok", value: [{ file: request.file, ignored: "ignored" }] });
|
|
3693
|
+
}
|
|
3694
|
+
return checkedQueriedFile({ query: request.query, file: request.file, ruleIds: request.ruleIds });
|
|
3695
|
+
};
|
|
3696
|
+
var queriedFile = (request) => request.query.ignoredState({ file: request.file }).then((ignoredState) => queriedFileOf({ ...request, ignoredState }));
|
|
3697
|
+
var checkedFileOf = (request) => request.entry.ignored === "checked" ? [{ file: request.entry.file, states: request.entry.states }] : [];
|
|
3698
|
+
var partitionedFiles = (request) => ({
|
|
3699
|
+
ignored: request.queried.filter((entry) => entry.ignored === "ignored").map((entry) => entry.file),
|
|
3700
|
+
checked: request.queried.flatMap((entry) => checkedFileOf({ entry }))
|
|
3701
|
+
});
|
|
3702
|
+
var queriedFiles = (request) => Promise.all(
|
|
3703
|
+
request.files.map((file) => queriedFile({ query: request.query, file, ruleIds: request.ruleIds }))
|
|
3704
|
+
).then(
|
|
3705
|
+
(outcomes) => mappedOutcome({
|
|
3706
|
+
outcome: collectOutcomes({ outcomes }),
|
|
3707
|
+
map: (queried) => partitionedFiles({ queried })
|
|
3708
|
+
})
|
|
3709
|
+
);
|
|
3710
|
+
var severityOf = (request) => request.checked.states.find((entry) => entry.ruleId === request.ruleId)?.state;
|
|
3711
|
+
var offEffect = (request) => request.state?.state === "configured" && request.state.severity === 0 ? "in-effect" : "not-in-effect";
|
|
3712
|
+
var ruleIdsOfRecord = (request) => request.selected.filter(
|
|
3713
|
+
(entry) => sameClauseAddress({ left: entry.clause.address, right: request.record.clause }) === "same"
|
|
3714
|
+
).map((entry) => entry.ruleId);
|
|
3715
|
+
var governedChecked = (request) => {
|
|
3716
|
+
const record = request.record;
|
|
3717
|
+
if (record.kind === "clause-wide-carve-out") {
|
|
3718
|
+
return request.checked;
|
|
3719
|
+
}
|
|
3720
|
+
return request.checked.filter((checked) => checked.file === record.file);
|
|
3721
|
+
};
|
|
3722
|
+
var fileOffEffect = (request) => request.ruleIds.every(
|
|
3723
|
+
(ruleId) => offEffect({ state: severityOf({ checked: request.checked, ruleId }) }) === "in-effect"
|
|
3724
|
+
) ? "in-effect" : "not-in-effect";
|
|
3725
|
+
var recordEffect = (request) => {
|
|
3726
|
+
const ruleIds = ruleIdsOfRecord({ record: request.record, selected: request.selected });
|
|
3727
|
+
return governedChecked({ record: request.record, checked: request.checked }).every(
|
|
3728
|
+
(checked) => fileOffEffect({ checked, ruleIds }) === "in-effect"
|
|
3729
|
+
) ? "in-effect" : "not-in-effect";
|
|
3730
|
+
};
|
|
3731
|
+
var ruleEnablement = (request) => request.checked.length === 0 || request.checked.some((checked) => severityOf({ checked, ruleId: request.ruleId })?.state === "configured") ? "in-effect" : "not-in-effect";
|
|
3732
|
+
var enabledEffect = (request) => request.selected.every(
|
|
3733
|
+
(entry) => ruleEnablement({ ruleId: entry.ruleId, checked: request.checked }) === "in-effect"
|
|
3734
|
+
) ? "in-effect" : "not-in-effect";
|
|
3735
|
+
var exemptingEffect = (request) => request.records.every(
|
|
3736
|
+
(record) => recordEffect({ record, selected: request.selected, checked: request.checked }) === "in-effect"
|
|
3737
|
+
) ? "in-effect" : "not-in-effect";
|
|
3738
|
+
var projectionEffect = (request) => {
|
|
3739
|
+
const enabled = enabledEffect({ selected: request.selected, checked: request.queried.checked });
|
|
3740
|
+
const exempting = exemptingEffect({
|
|
3741
|
+
selected: request.selected,
|
|
3742
|
+
records: request.records,
|
|
3743
|
+
checked: request.queried.checked
|
|
3744
|
+
});
|
|
3745
|
+
return enabled === "in-effect" && exempting === "in-effect" ? "in-effect" : "not-in-effect";
|
|
3746
|
+
};
|
|
3747
|
+
var ruleEnforcement = (request) => {
|
|
3748
|
+
const state = severityOf({ checked: request.checked, ruleId: request.ruleId });
|
|
3749
|
+
return state?.state === "configured" && state.severity === 2 ? "enforced" : "weakened";
|
|
3750
|
+
};
|
|
3751
|
+
var ignoreExceptions = (request) => request.selected.map((entry) => ({ kind: "ignore", clause: entry.clause.address, file: request.file }));
|
|
3752
|
+
var overrideExceptions = (request) => request.selected.filter((entry) => ruleEnforcement({ checked: request.checked, ruleId: entry.ruleId }) === "weakened").map(
|
|
3753
|
+
(entry) => ({
|
|
3754
|
+
kind: "config-override",
|
|
3755
|
+
clause: entry.clause.address,
|
|
3756
|
+
file: request.checked.file
|
|
3757
|
+
})
|
|
3758
|
+
);
|
|
3759
|
+
var queryExceptions = (request) => [
|
|
3760
|
+
...request.queried.ignored.flatMap((file) => ignoreExceptions({ selected: request.selected, file })),
|
|
3761
|
+
...request.queried.checked.flatMap((checked) => overrideExceptions({ selected: request.selected, checked }))
|
|
3762
|
+
];
|
|
3763
|
+
var commentValueOf = (request) => {
|
|
3764
|
+
if (request.text.startsWith("//")) {
|
|
3765
|
+
return request.text.slice(2);
|
|
3766
|
+
}
|
|
3767
|
+
return request.text.startsWith("/*") && request.text.endsWith("*/") ? request.text.slice(2, -2) : request.text;
|
|
3768
|
+
};
|
|
3769
|
+
var inlineClauses = (request) => {
|
|
3770
|
+
const parsed = parseInlineConfigComment({ text: commentValueOf({ text: request.text }) });
|
|
3771
|
+
switch (parsed.kind) {
|
|
3772
|
+
case "disable":
|
|
3773
|
+
return parsed.ruleIds.length === 0 ? request.selected : request.selected.filter((entry) => parsed.ruleIds.includes(entry.ruleId));
|
|
3774
|
+
case "rule-config":
|
|
3775
|
+
return request.selected.filter((entry) => parsed.ruleIds.includes(entry.ruleId));
|
|
3776
|
+
case "unparseable-rule-config":
|
|
3777
|
+
return request.selected;
|
|
3778
|
+
case "not-an-exception":
|
|
3779
|
+
return [];
|
|
3780
|
+
}
|
|
3781
|
+
};
|
|
3782
|
+
var inlineExceptionKindOf = (request) => request.messageId === INLINE_DISABLE || request.messageId === INLINE_RULE_CONFIG ? request.messageId : "not-inline";
|
|
3783
|
+
var inlineException = (request) => {
|
|
3784
|
+
const message = request.message;
|
|
3785
|
+
const kind = inlineExceptionKindOf({ messageId: message.messageId });
|
|
3786
|
+
if (kind === "not-inline") {
|
|
3787
|
+
return {
|
|
3788
|
+
outcome: "failed",
|
|
3789
|
+
error: { kind: "tool-failed", detail: `${request.file}: ${message.message}` }
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3792
|
+
return {
|
|
3793
|
+
outcome: "ok",
|
|
3794
|
+
value: inlineClauses({ text: message.message, selected: request.selected }).map(
|
|
3795
|
+
(entry) => ({
|
|
3796
|
+
kind,
|
|
3797
|
+
clause: entry.clause.address,
|
|
3798
|
+
file: request.file,
|
|
3799
|
+
line: message.line,
|
|
3800
|
+
text: message.message
|
|
3801
|
+
})
|
|
3802
|
+
)
|
|
3803
|
+
};
|
|
3804
|
+
};
|
|
3805
|
+
var sourceLineOf = (request) => {
|
|
3806
|
+
const text = request.fileText.read({
|
|
3807
|
+
path: request.path.join({ segments: [request.repoRoot, request.file] })
|
|
3808
|
+
});
|
|
3809
|
+
if (text.outcome === "failed") {
|
|
3810
|
+
return {
|
|
3811
|
+
outcome: "failed",
|
|
3812
|
+
error: { kind: "file-unreadable", file: request.file, detail: text.error.detail }
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3815
|
+
return { outcome: "ok", value: (text.value.split(LINE_BREAK)[request.line - 1] ?? "").trim() };
|
|
3816
|
+
};
|
|
3817
|
+
var outsideRepository = (request) => ({
|
|
3818
|
+
outcome: "failed",
|
|
3819
|
+
error: {
|
|
3820
|
+
kind: "tool-failed",
|
|
3821
|
+
detail: `ESLint linted ${request.linted.filePath}, which is outside the repository`
|
|
3822
|
+
}
|
|
3823
|
+
});
|
|
3824
|
+
var lintedRepoPath = (request) => {
|
|
3825
|
+
const location = request.path.relative({ from: request.repoRoot, to: request.linted.filePath });
|
|
3826
|
+
if (location.relation === "different-root") {
|
|
3827
|
+
return outsideRepository(request);
|
|
3828
|
+
}
|
|
3829
|
+
const file = repoPathSchema.safeParse(location.path);
|
|
3830
|
+
return file.success ? { outcome: "ok", value: file.data } : outsideRepository(request);
|
|
3831
|
+
};
|
|
3832
|
+
var parseableFile = (request) => {
|
|
3833
|
+
const file = lintedRepoPath(request);
|
|
3834
|
+
if (file.outcome === "failed") {
|
|
3835
|
+
return file;
|
|
3836
|
+
}
|
|
3837
|
+
const fatal = request.linted.messages.find((message) => message.fatal === true);
|
|
3838
|
+
if (fatal !== void 0) {
|
|
3839
|
+
return {
|
|
3840
|
+
outcome: "failed",
|
|
3841
|
+
error: { kind: "file-unparseable", file: file.value, detail: fatal.message }
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
return file;
|
|
3845
|
+
};
|
|
3846
|
+
var ruleFindings = (request) => mappedOutcome({
|
|
3847
|
+
outcome: sourceLineOf({
|
|
3848
|
+
fileText: request.ports.fileText,
|
|
3849
|
+
path: request.ports.path,
|
|
3850
|
+
repoRoot: request.repoRoot,
|
|
3851
|
+
file: request.file,
|
|
3852
|
+
line: request.message.line
|
|
3853
|
+
}),
|
|
3854
|
+
map: (snippet) => [
|
|
3855
|
+
{
|
|
3856
|
+
hits: [
|
|
3857
|
+
{
|
|
3858
|
+
clause: request.clause.clause.address,
|
|
3859
|
+
file: request.file,
|
|
3860
|
+
anchor: { line: request.message.line, column: request.message.column - 1 },
|
|
3861
|
+
snippet
|
|
3862
|
+
}
|
|
3863
|
+
],
|
|
3864
|
+
nativeExceptions: []
|
|
3865
|
+
}
|
|
3866
|
+
]
|
|
3867
|
+
});
|
|
3868
|
+
var messageFindings = (request) => {
|
|
3869
|
+
if (request.message.ruleId === INLINE_CONFIG_RULE_ID) {
|
|
3870
|
+
return mappedOutcome({
|
|
3871
|
+
outcome: inlineException({ message: request.message, file: request.file, selected: request.selected }),
|
|
3872
|
+
map: (nativeExceptions) => [{ hits: [], nativeExceptions }]
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3875
|
+
const clause = request.selected.find((entry) => entry.ruleId === request.message.ruleId);
|
|
3876
|
+
if (clause === void 0) {
|
|
3877
|
+
return { outcome: "ok", value: [] };
|
|
3878
|
+
}
|
|
3879
|
+
return ruleFindings({ ...request, clause });
|
|
3880
|
+
};
|
|
3881
|
+
var lintedFindings = (request) => {
|
|
3882
|
+
const file = parseableFile({ linted: request.linted, path: request.ports.path, repoRoot: request.repoRoot });
|
|
3883
|
+
if (file.outcome === "failed") {
|
|
3884
|
+
return file;
|
|
3885
|
+
}
|
|
3886
|
+
return collectOutcomes({
|
|
3887
|
+
outcomes: request.linted.messages.map(
|
|
3888
|
+
(message) => messageFindings({
|
|
3889
|
+
message,
|
|
3890
|
+
file: file.value,
|
|
3891
|
+
selected: request.selected,
|
|
3892
|
+
ports: request.ports,
|
|
3893
|
+
repoRoot: request.repoRoot
|
|
3894
|
+
})
|
|
3895
|
+
)
|
|
3896
|
+
});
|
|
3897
|
+
};
|
|
3898
|
+
var directoryOf = (request) => {
|
|
3899
|
+
const directory = repoPathSchema.safeParse(request.path.split("/").slice(0, -1).join("/"));
|
|
3900
|
+
return directory.success ? directory.data : "repo-root";
|
|
3901
|
+
};
|
|
3902
|
+
var fileNameOf = (request) => request.path.split("/").at(-1);
|
|
3903
|
+
var trackedText = (request) => {
|
|
3904
|
+
const text = request.fileText.read({
|
|
3905
|
+
path: request.path.join({ segments: [request.repoRoot, request.repoPath] })
|
|
3906
|
+
});
|
|
3907
|
+
return text.outcome === "failed" ? { outcome: "failed", error: { kind: "file-unreadable", file: request.repoPath, detail: text.error.detail } } : text;
|
|
3908
|
+
};
|
|
3909
|
+
var filesNamed = (request) => request.trackedPaths.filter((path) => fileNameOf({ path }) === request.name);
|
|
3910
|
+
var suppressionsFileExceptions = (request) => {
|
|
3911
|
+
const text = trackedText({
|
|
3912
|
+
fileText: request.fileText,
|
|
3913
|
+
path: request.path,
|
|
3914
|
+
repoRoot: request.repoRoot,
|
|
3915
|
+
repoPath: request.location
|
|
3916
|
+
});
|
|
3917
|
+
if (text.outcome === "failed") {
|
|
3918
|
+
return text;
|
|
3919
|
+
}
|
|
3920
|
+
return suppressionEntriesOf({
|
|
3921
|
+
location: request.location,
|
|
3922
|
+
keysRelativeTo: directoryOf({ path: request.location }),
|
|
3923
|
+
text: text.value,
|
|
3924
|
+
selectedRules: request.selectedRules
|
|
3925
|
+
});
|
|
3926
|
+
};
|
|
3927
|
+
var scannedPackageExceptions = (request) => collectOutcomes({
|
|
3928
|
+
outcomes: [
|
|
3929
|
+
{ outcome: "ok", value: request.scan.nativeExceptions },
|
|
3930
|
+
...request.scan.suppressionsLocations.map(
|
|
3931
|
+
(scripted) => scriptSuppressionEntries({
|
|
3932
|
+
fileText: request.fileText,
|
|
3933
|
+
path: request.path,
|
|
3934
|
+
repoRoot: request.repoRoot,
|
|
3935
|
+
location: scripted.location,
|
|
3936
|
+
keysRelativeTo: directoryOf({ path: request.packagePath }),
|
|
3937
|
+
selectedRules: request.selectedRules
|
|
3938
|
+
})
|
|
3939
|
+
)
|
|
3940
|
+
]
|
|
3941
|
+
});
|
|
3942
|
+
var packageJsonExceptions = (request) => {
|
|
3943
|
+
const text = trackedText({
|
|
3944
|
+
fileText: request.fileText,
|
|
3945
|
+
path: request.path,
|
|
3946
|
+
repoRoot: request.repoRoot,
|
|
3947
|
+
repoPath: request.packagePath
|
|
3948
|
+
});
|
|
3949
|
+
if (text.outcome === "failed") {
|
|
3950
|
+
return text;
|
|
3951
|
+
}
|
|
3952
|
+
const scan = scanPackageJson({
|
|
3953
|
+
path: request.packagePath,
|
|
3954
|
+
text: text.value,
|
|
3955
|
+
selectedRules: request.selectedRules
|
|
3956
|
+
});
|
|
3957
|
+
if (scan.outcome === "failed") {
|
|
3958
|
+
return scan;
|
|
3959
|
+
}
|
|
3960
|
+
return scannedPackageExceptions({ ...request, scan: scan.value });
|
|
3961
|
+
};
|
|
3962
|
+
var trackedExceptions = (request) => collectOutcomes({
|
|
3963
|
+
outcomes: [
|
|
3964
|
+
...filesNamed({ trackedPaths: request.trackedPaths, name: SUPPRESSIONS_FILE_NAME }).map(
|
|
3965
|
+
(location) => suppressionsFileExceptions({ ...request, location })
|
|
3966
|
+
),
|
|
3967
|
+
...filesNamed({ trackedPaths: request.trackedPaths, name: PACKAGE_JSON_NAME2 }).map(
|
|
3968
|
+
(packagePath) => packageJsonExceptions({ ...request, packagePath })
|
|
3969
|
+
)
|
|
3970
|
+
]
|
|
3971
|
+
});
|
|
3972
|
+
var reportWith = (request) => ({
|
|
3973
|
+
outcome: "ok",
|
|
3974
|
+
value: { hits: [], nativeExceptions: [], projection: request.projection }
|
|
3975
|
+
});
|
|
3976
|
+
var ruleIdsOf = (request) => request.selected.map((entry) => entry.ruleId);
|
|
3977
|
+
var governedRulesOf = (request) => request.selected.map((entry) => ({ ruleId: entry.ruleId, options: ruleOptionsOf({ settings: entry.settings }) }));
|
|
3978
|
+
var pluginsByNamespace = (request) => Object.fromEntries(request.selected.map((entry) => [entry.settings.pluginNamespace, entry.plugin]));
|
|
3979
|
+
var selectedRulesOf = (request) => request.selected.map((entry) => ({ ruleId: entry.ruleId, clause: entry.clause.address }));
|
|
3980
|
+
var recordsUnderCheck = (request) => request.records.filter(
|
|
3981
|
+
(record) => record.kind === "clause-wide-carve-out" || request.checked.some((checked) => checked.file === record.file)
|
|
3982
|
+
);
|
|
3983
|
+
var governedLint = (request) => {
|
|
3984
|
+
if (request.run.files.length === 0 || request.selected.length === 0) {
|
|
3985
|
+
return Promise.resolve({ outcome: "ok", value: [] });
|
|
3986
|
+
}
|
|
3987
|
+
return request.eslint.createGovernanceInstance({
|
|
3988
|
+
repoRoot: request.run.repoRoot,
|
|
3989
|
+
plugins: pluginsByNamespace({ selected: request.selected }),
|
|
3990
|
+
rules: governedRulesOf({ selected: request.selected })
|
|
3991
|
+
}).lintFiles({ files: request.run.files });
|
|
3992
|
+
};
|
|
3993
|
+
var governedReport = (request) => {
|
|
3994
|
+
const findings = collectOutcomes({
|
|
3995
|
+
outcomes: request.lintedFiles.map(
|
|
3996
|
+
(linted) => lintedFindings({ linted, selected: request.selected, ports: request.ports, repoRoot: request.run.repoRoot })
|
|
3997
|
+
)
|
|
3998
|
+
});
|
|
3999
|
+
if (findings.outcome === "failed") {
|
|
4000
|
+
return findings;
|
|
4001
|
+
}
|
|
4002
|
+
const tracked = trackedExceptions({
|
|
4003
|
+
fileText: request.ports.fileText,
|
|
4004
|
+
path: request.ports.path,
|
|
4005
|
+
repoRoot: request.run.repoRoot,
|
|
4006
|
+
trackedPaths: request.run.trackedPaths,
|
|
4007
|
+
selectedRules: selectedRulesOf({ selected: request.selected })
|
|
4008
|
+
});
|
|
4009
|
+
if (tracked.outcome === "failed") {
|
|
4010
|
+
return tracked;
|
|
4011
|
+
}
|
|
4012
|
+
return {
|
|
4013
|
+
outcome: "ok",
|
|
4014
|
+
value: {
|
|
4015
|
+
hits: findings.value.flatMap((found) => found.hits),
|
|
4016
|
+
nativeExceptions: [
|
|
4017
|
+
...queryExceptions({ selected: request.selected, queried: request.queried }),
|
|
4018
|
+
...findings.value.flatMap((found) => found.nativeExceptions),
|
|
4019
|
+
...tracked.value
|
|
4020
|
+
],
|
|
4021
|
+
projection: request.projection
|
|
4022
|
+
}
|
|
4023
|
+
};
|
|
4024
|
+
};
|
|
4025
|
+
var lintedReport = (request) => governedLint({ run: request.run, selected: request.selected, eslint: request.ports.eslint }).then(
|
|
4026
|
+
(lintedFiles) => lintedFiles.outcome === "failed" ? lintedFiles : governedReport({ ...request, lintedFiles: lintedFiles.value })
|
|
4027
|
+
);
|
|
4028
|
+
var queriedReport = (request) => {
|
|
4029
|
+
if (request.queried.outcome === "failed") {
|
|
4030
|
+
return Promise.resolve(request.queried);
|
|
4031
|
+
}
|
|
4032
|
+
const queried = request.queried.value;
|
|
4033
|
+
const records = recordsUnderCheck({ records: request.run.records, checked: queried.checked });
|
|
4034
|
+
if (projectionEffect({ selected: request.selected, records, queried }) === "not-in-effect") {
|
|
4035
|
+
return Promise.resolve(reportWith({ projection: "not-included" }));
|
|
4036
|
+
}
|
|
4037
|
+
return lintedReport({ ...request, queried });
|
|
4038
|
+
};
|
|
4039
|
+
var governedRun = (request) => {
|
|
4040
|
+
const lookup = teamConfigLookup({
|
|
4041
|
+
fileText: request.ports.fileText,
|
|
4042
|
+
path: request.ports.path,
|
|
4043
|
+
repoRoot: request.run.repoRoot,
|
|
4044
|
+
trackedPaths: request.run.trackedPaths
|
|
4045
|
+
});
|
|
4046
|
+
if (lookup.outcome === "failed") {
|
|
4047
|
+
return Promise.resolve(lookup);
|
|
4048
|
+
}
|
|
4049
|
+
return queriedFiles({
|
|
4050
|
+
query: request.ports.eslint.createQueryInstance(
|
|
4051
|
+
lookup.value.kind === "repository-root" ? { repoRoot: request.run.repoRoot, configFile: lookup.value.configFile } : { repoRoot: request.run.repoRoot }
|
|
4052
|
+
),
|
|
4053
|
+
files: request.run.files,
|
|
4054
|
+
ruleIds: ruleIdsOf({ selected: request.selected })
|
|
4055
|
+
}).then((queried) => queriedReport({ ...request, queried }));
|
|
4056
|
+
};
|
|
4057
|
+
var presentProjectionState = (request) => projectionState({
|
|
4058
|
+
current: request.current,
|
|
4059
|
+
generated: generatedProjection({ configured: request.selected, records: request.records })
|
|
4060
|
+
}) === "current" ? "current" : "out-of-date";
|
|
4061
|
+
var selectedRun = (request) => {
|
|
4062
|
+
const current = currentProjection({
|
|
4063
|
+
fileText: request.ports.fileText,
|
|
4064
|
+
path: request.ports.path,
|
|
4065
|
+
repoRoot: request.run.repoRoot
|
|
4066
|
+
});
|
|
4067
|
+
if (current.outcome === "failed") {
|
|
4068
|
+
return Promise.resolve(current);
|
|
4069
|
+
}
|
|
4070
|
+
if (current.value.presence === "absent") {
|
|
4071
|
+
return Promise.resolve(reportWith({ projection: "missing" }));
|
|
4072
|
+
}
|
|
4073
|
+
return governedRun({
|
|
4074
|
+
...request,
|
|
4075
|
+
projection: presentProjectionState({
|
|
4076
|
+
current: current.value,
|
|
4077
|
+
selected: request.selected,
|
|
4078
|
+
records: request.run.records
|
|
4079
|
+
})
|
|
4080
|
+
});
|
|
4081
|
+
};
|
|
4082
|
+
var lintedSourceCases = (request) => {
|
|
4083
|
+
if (request.selected.outcome === "failed") {
|
|
4084
|
+
return Promise.resolve(request.selected);
|
|
4085
|
+
}
|
|
4086
|
+
return request.eslint.lintSourceCases({
|
|
4087
|
+
cwd: request.cwd,
|
|
4088
|
+
plugin: request.selected.value.plugin,
|
|
4089
|
+
pluginNamespace: request.selected.value.settings.pluginNamespace,
|
|
4090
|
+
rule: request.selected.value.settings.rule,
|
|
4091
|
+
options: ruleOptionsOf({ settings: request.selected.value.settings }),
|
|
4092
|
+
cases: request.cases
|
|
4093
|
+
});
|
|
4094
|
+
};
|
|
4095
|
+
var conformedCases = (request) => {
|
|
4096
|
+
const configured = configuredClause({ clause: request.clause, path: request.ports.path });
|
|
4097
|
+
if (configured.outcome === "failed") {
|
|
4098
|
+
return Promise.resolve(configured);
|
|
4099
|
+
}
|
|
4100
|
+
const cwd = absolutePathSchema.safeParse(request.clause.pieceRoot);
|
|
4101
|
+
if (!cwd.success) {
|
|
4102
|
+
return Promise.resolve(pieceInvalid({ pieceRoot: request.clause.pieceRoot, detail: external_exports.prettifyError(cwd.error) }));
|
|
4103
|
+
}
|
|
4104
|
+
return loadedPlugin({ configured: configured.value, modules: request.ports.modules }).then(
|
|
4105
|
+
(selected) => lintedSourceCases({ selected, cwd: cwd.data, cases: request.cases, eslint: request.ports.eslint })
|
|
4106
|
+
);
|
|
4107
|
+
};
|
|
4108
|
+
var importOriginOf = (request) => {
|
|
4109
|
+
const install = coreInstallOf({
|
|
4110
|
+
fileText: request.ports.fileText,
|
|
4111
|
+
path: request.ports.path,
|
|
4112
|
+
installRoot: request.installRoot,
|
|
4113
|
+
moduleExtension: request.ports.moduleExtension
|
|
4114
|
+
});
|
|
4115
|
+
return install.outcome === "failed" ? install : { outcome: "ok", value: { repoRoot: request.repoRoot, install: install.value } };
|
|
4116
|
+
};
|
|
4117
|
+
var projectedWrite = (request) => {
|
|
4118
|
+
const origin = importOriginOf({
|
|
4119
|
+
ports: request.ports,
|
|
4120
|
+
repoRoot: request.request.repoRoot,
|
|
4121
|
+
installRoot: request.request.installRoot
|
|
4122
|
+
});
|
|
4123
|
+
if (origin.outcome === "failed") {
|
|
4124
|
+
return Promise.resolve(origin);
|
|
4125
|
+
}
|
|
4126
|
+
const configured = configuredSelection({
|
|
4127
|
+
clauses: request.request.clauses,
|
|
4128
|
+
path: request.ports.path,
|
|
4129
|
+
origin: origin.value
|
|
4130
|
+
});
|
|
4131
|
+
if (configured.outcome === "failed") {
|
|
4132
|
+
return Promise.resolve(configured);
|
|
4133
|
+
}
|
|
4134
|
+
return Promise.resolve(
|
|
4135
|
+
writeProjection({
|
|
4136
|
+
fileText: request.ports.fileText,
|
|
4137
|
+
path: request.ports.path,
|
|
4138
|
+
repoRoot: request.request.repoRoot,
|
|
4139
|
+
text: generatedProjection({ configured: configured.value, records: request.request.records })
|
|
4140
|
+
})
|
|
4141
|
+
);
|
|
4142
|
+
};
|
|
4143
|
+
var ranClauses = (request) => {
|
|
4144
|
+
const origin = importOriginOf({ ports: request.ports, repoRoot: request.run.repoRoot, installRoot: request.run.installRoot });
|
|
4145
|
+
if (origin.outcome === "failed") {
|
|
4146
|
+
return Promise.resolve(origin);
|
|
4147
|
+
}
|
|
4148
|
+
return selectedClauses({
|
|
4149
|
+
clauses: request.run.clauses,
|
|
4150
|
+
path: request.ports.path,
|
|
4151
|
+
origin: origin.value,
|
|
4152
|
+
modules: request.ports.modules
|
|
4153
|
+
}).then(
|
|
4154
|
+
(selected) => selected.outcome === "failed" ? selected : selectedRun({ run: request.run, selected: selected.value, ports: request.ports })
|
|
4155
|
+
);
|
|
4156
|
+
};
|
|
4157
|
+
var ESLINT_PROJECTED_KINDS = ["config-override"];
|
|
4158
|
+
var createEslintRunner = (ports) => ({
|
|
4159
|
+
exceptionPath: "embedded",
|
|
4160
|
+
projectedKinds: ESLINT_PROJECTED_KINDS,
|
|
4161
|
+
run: (request) => ranClauses({ run: request, ports }),
|
|
4162
|
+
conform: (request) => conformedCases({ clause: request.clause, cases: request.cases, ports }),
|
|
4163
|
+
project: (request) => projectedWrite({ request, ports })
|
|
4164
|
+
});
|
|
4165
|
+
|
|
4166
|
+
// mechanisms/eslint/runner/eslint-toolchain.ts
|
|
4167
|
+
var ESLINT_REQUIREMENT = {
|
|
4168
|
+
packageName: "eslint",
|
|
4169
|
+
peer: "optional",
|
|
4170
|
+
lines: [
|
|
4171
|
+
{ floor: "9.12.0", below: "10.0.0" },
|
|
4172
|
+
{ floor: "10.0.0", below: "11.0.0" }
|
|
4173
|
+
]
|
|
4174
|
+
};
|
|
4175
|
+
var TYPESCRIPT_ESLINT_PARSER_REQUIREMENT = {
|
|
4176
|
+
packageName: "@typescript-eslint/parser",
|
|
4177
|
+
peer: "optional",
|
|
4178
|
+
lines: [{ floor: "8.56.0", below: "9.0.0" }]
|
|
4179
|
+
};
|
|
4180
|
+
var TYPESCRIPT_ESLINT_PLUGIN_REQUIREMENT = {
|
|
4181
|
+
packageName: "@typescript-eslint/eslint-plugin",
|
|
4182
|
+
peer: "optional",
|
|
4183
|
+
lines: [{ floor: "8.56.0", below: "9.0.0" }]
|
|
4184
|
+
};
|
|
4185
|
+
var defaultEslintToolchainModules = {
|
|
4186
|
+
eslint: () => import("eslint"),
|
|
4187
|
+
typescriptParser: () => import("@typescript-eslint/parser"),
|
|
4188
|
+
typescriptEslintPlugin: () => import("@typescript-eslint/eslint-plugin")
|
|
4189
|
+
};
|
|
4190
|
+
var defaultEslintToolchainPeers = (options) => ({
|
|
4191
|
+
location: createDefaultPackageLocationPort(options),
|
|
4192
|
+
modules: defaultEslintToolchainModules
|
|
4193
|
+
});
|
|
4194
|
+
var afterLoaded = (request) => request.loaded.then((loaded) => loaded.outcome === "failed" ? loaded : request.next(loaded.value));
|
|
4195
|
+
var loadedToolchainOn = (request) => afterLoaded({
|
|
4196
|
+
loaded: loadedPeer({
|
|
4197
|
+
requirement: TYPESCRIPT_ESLINT_PLUGIN_REQUIREMENT,
|
|
4198
|
+
location: request.peers.location,
|
|
4199
|
+
load: request.peers.modules.typescriptEslintPlugin,
|
|
4200
|
+
versionOf: (plugin) => plugin.default.meta.version
|
|
4201
|
+
}),
|
|
4202
|
+
next: () => Promise.resolve({
|
|
4203
|
+
outcome: "ok",
|
|
4204
|
+
value: {
|
|
4205
|
+
eslintVersion: request.eslint.ESLint.version,
|
|
4206
|
+
createEslint: createEslintOn({ eslintClass: request.eslint.ESLint }),
|
|
4207
|
+
typescriptParser: request.typescriptParser
|
|
4208
|
+
}
|
|
4209
|
+
})
|
|
4210
|
+
});
|
|
4211
|
+
var loadEslintToolchain = (request) => afterLoaded({
|
|
4212
|
+
loaded: loadedPeer({
|
|
4213
|
+
requirement: ESLINT_REQUIREMENT,
|
|
4214
|
+
location: request.peers.location,
|
|
4215
|
+
load: request.peers.modules.eslint,
|
|
4216
|
+
versionOf: (eslint) => eslint.ESLint.version
|
|
4217
|
+
}),
|
|
4218
|
+
next: (eslint) => afterLoaded({
|
|
4219
|
+
loaded: loadedPeer({
|
|
4220
|
+
requirement: TYPESCRIPT_ESLINT_PARSER_REQUIREMENT,
|
|
4221
|
+
location: request.peers.location,
|
|
4222
|
+
load: request.peers.modules.typescriptParser,
|
|
4223
|
+
versionOf: (parser) => parser.version
|
|
4224
|
+
}),
|
|
4225
|
+
next: (typescriptParser) => loadedToolchainOn({ peers: request.peers, eslint, typescriptParser })
|
|
4226
|
+
})
|
|
4227
|
+
});
|
|
4228
|
+
|
|
4229
|
+
// mechanisms/eslint/runner/runner.ts
|
|
4230
|
+
var runner = toolchainBoundEmbeddedRunner({
|
|
4231
|
+
toolchain: loadEslintToolchain({
|
|
4232
|
+
peers: defaultEslintToolchainPeers({
|
|
4233
|
+
installRoot: installRootOfRunnerEntry({ entryFile: import.meta.filename }),
|
|
4234
|
+
installForm: installFormOf({ moduleExtension: moduleExtensionOf({ moduleUrl: import.meta.url }) })
|
|
4235
|
+
})
|
|
4236
|
+
}),
|
|
4237
|
+
projectedKinds: ESLINT_PROJECTED_KINDS,
|
|
4238
|
+
runnerOf: (toolchain) => createEslintRunner({
|
|
4239
|
+
fileText: createDefaultFileTextPort({}),
|
|
4240
|
+
modules: createDefaultModuleLoaderPort({}),
|
|
4241
|
+
path: createDefaultPathPort({}),
|
|
4242
|
+
eslint: createEslintPort({ toolchain }),
|
|
4243
|
+
moduleExtension: moduleExtensionOf({ moduleUrl: import.meta.url })
|
|
4244
|
+
})
|
|
4245
|
+
});
|
|
4246
|
+
export {
|
|
4247
|
+
runner
|
|
4248
|
+
};
|