source: trip-planner-front/node_modules/@istanbuljs/schema/index.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 10.7 KB
Line 
1'use strict';
2
3const defaultExclude = require('./default-exclude.js');
4const defaultExtension = require('./default-extension.js');
5
6const nycCommands = {
7 all: [null, 'check-coverage', 'instrument', 'merge', 'report'],
8 testExclude: [null, 'instrument', 'report', 'check-coverage'],
9 instrument: [null, 'instrument'],
10 checkCoverage: [null, 'report', 'check-coverage'],
11 report: [null, 'report'],
12 main: [null],
13 instrumentOnly: ['instrument']
14};
15
16const cwd = {
17 description: 'working directory used when resolving paths',
18 type: 'string',
19 get default() {
20 return process.cwd();
21 },
22 nycCommands: nycCommands.all
23};
24
25const nycrcPath = {
26 description: 'specify an explicit path to find nyc configuration',
27 nycCommands: nycCommands.all
28};
29
30const tempDir = {
31 description: 'directory to output raw coverage information to',
32 type: 'string',
33 default: './.nyc_output',
34 nycAlias: 't',
35 nycHiddenAlias: 'temp-directory',
36 nycCommands: [null, 'check-coverage', 'merge', 'report']
37};
38
39const testExclude = {
40 exclude: {
41 description: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported',
42 type: 'array',
43 items: {
44 type: 'string'
45 },
46 default: defaultExclude,
47 nycCommands: nycCommands.testExclude,
48 nycAlias: 'x'
49 },
50 excludeNodeModules: {
51 description: 'whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default',
52 type: 'boolean',
53 default: true,
54 nycCommands: nycCommands.testExclude
55 },
56 include: {
57 description: 'a list of specific files that should be covered, glob patterns are supported',
58 type: 'array',
59 items: {
60 type: 'string'
61 },
62 default: [],
63 nycCommands: nycCommands.testExclude,
64 nycAlias: 'n'
65 },
66 extension: {
67 description: 'a list of extensions that nyc should handle in addition to .js',
68 type: 'array',
69 items: {
70 type: 'string'
71 },
72 default: defaultExtension,
73 nycCommands: nycCommands.testExclude,
74 nycAlias: 'e'
75 }
76};
77
78const instrumentVisitor = {
79 coverageVariable: {
80 description: 'variable to store coverage',
81 type: 'string',
82 default: '__coverage__',
83 nycCommands: nycCommands.instrument
84 },
85 coverageGlobalScope: {
86 description: 'scope to store the coverage variable',
87 type: 'string',
88 default: 'this',
89 nycCommands: nycCommands.instrument
90 },
91 coverageGlobalScopeFunc: {
92 description: 'avoid potentially replaced `Function` when finding global scope',
93 type: 'boolean',
94 default: true,
95 nycCommands: nycCommands.instrument
96 },
97 ignoreClassMethods: {
98 description: 'class method names to ignore for coverage',
99 type: 'array',
100 items: {
101 type: 'string'
102 },
103 default: [],
104 nycCommands: nycCommands.instrument
105 }
106};
107
108const instrumentParseGen = {
109 autoWrap: {
110 description: 'allow `return` statements outside of functions',
111 type: 'boolean',
112 default: true,
113 nycCommands: nycCommands.instrument
114 },
115 esModules: {
116 description: 'should files be treated as ES Modules',
117 type: 'boolean',
118 default: true,
119 nycCommands: nycCommands.instrument
120 },
121 parserPlugins: {
122 description: 'babel parser plugins to use when parsing the source',
123 type: 'array',
124 items: {
125 type: 'string'
126 },
127 /* Babel parser plugins are to be enabled when the feature is stage 3 and
128 * implemented in a released version of node.js. */
129 default: [
130 'asyncGenerators',
131 'bigInt',
132 'classProperties',
133 'classPrivateProperties',
134 'classPrivateMethods',
135 'dynamicImport',
136 'importMeta',
137 'numericSeparator',
138 'objectRestSpread',
139 'optionalCatchBinding',
140 'topLevelAwait'
141 ],
142 nycCommands: nycCommands.instrument
143 },
144 compact: {
145 description: 'should the output be compacted?',
146 type: 'boolean',
147 default: true,
148 nycCommands: nycCommands.instrument
149 },
150 preserveComments: {
151 description: 'should comments be preserved in the output?',
152 type: 'boolean',
153 default: true,
154 nycCommands: nycCommands.instrument
155 },
156 produceSourceMap: {
157 description: 'should source maps be produced?',
158 type: 'boolean',
159 default: true,
160 nycCommands: nycCommands.instrument
161 }
162};
163
164const checkCoverage = {
165 excludeAfterRemap: {
166 description: 'should exclude logic be performed after the source-map remaps filenames?',
167 type: 'boolean',
168 default: true,
169 nycCommands: nycCommands.checkCoverage
170 },
171 branches: {
172 description: 'what % of branches must be covered?',
173 type: 'number',
174 default: 0,
175 minimum: 0,
176 maximum: 100,
177 nycCommands: nycCommands.checkCoverage
178 },
179 functions: {
180 description: 'what % of functions must be covered?',
181 type: 'number',
182 default: 0,
183 minimum: 0,
184 maximum: 100,
185 nycCommands: nycCommands.checkCoverage
186 },
187 lines: {
188 description: 'what % of lines must be covered?',
189 type: 'number',
190 default: 90,
191 minimum: 0,
192 maximum: 100,
193 nycCommands: nycCommands.checkCoverage
194 },
195 statements: {
196 description: 'what % of statements must be covered?',
197 type: 'number',
198 default: 0,
199 minimum: 0,
200 maximum: 100,
201 nycCommands: nycCommands.checkCoverage
202 },
203 perFile: {
204 description: 'check thresholds per file',
205 type: 'boolean',
206 default: false,
207 nycCommands: nycCommands.checkCoverage
208 }
209};
210
211const report = {
212 checkCoverage: {
213 description: 'check whether coverage is within thresholds provided',
214 type: 'boolean',
215 default: false,
216 nycCommands: nycCommands.report
217 },
218 reporter: {
219 description: 'coverage reporter(s) to use',
220 type: 'array',
221 items: {
222 type: 'string'
223 },
224 default: ['text'],
225 nycCommands: nycCommands.report,
226 nycAlias: 'r'
227 },
228 reportDir: {
229 description: 'directory to output coverage reports in',
230 type: 'string',
231 default: 'coverage',
232 nycCommands: nycCommands.report
233 },
234 showProcessTree: {
235 description: 'display the tree of spawned processes',
236 type: 'boolean',
237 default: false,
238 nycCommands: nycCommands.report
239 },
240 skipEmpty: {
241 description: 'don\'t show empty files (no lines of code) in report',
242 type: 'boolean',
243 default: false,
244 nycCommands: nycCommands.report
245 },
246 skipFull: {
247 description: 'don\'t show files with 100% statement, branch, and function coverage',
248 type: 'boolean',
249 default: false,
250 nycCommands: nycCommands.report
251 }
252};
253
254const nycMain = {
255 silent: {
256 description: 'don\'t output a report after tests finish running',
257 type: 'boolean',
258 default: false,
259 nycCommands: nycCommands.main,
260 nycAlias: 's'
261 },
262 all: {
263 description: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)',
264 type: 'boolean',
265 default: false,
266 nycCommands: nycCommands.main,
267 nycAlias: 'a'
268 },
269 eager: {
270 description: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)',
271 type: 'boolean',
272 default: false,
273 nycCommands: nycCommands.main
274 },
275 cache: {
276 description: 'cache instrumentation results for improved performance',
277 type: 'boolean',
278 default: true,
279 nycCommands: nycCommands.main,
280 nycAlias: 'c'
281 },
282 cacheDir: {
283 description: 'explicitly set location for instrumentation cache',
284 type: 'string',
285 nycCommands: nycCommands.main
286 },
287 babelCache: {
288 description: 'cache babel transpilation results for improved performance',
289 type: 'boolean',
290 default: false,
291 nycCommands: nycCommands.main
292 },
293 useSpawnWrap: {
294 description: 'use spawn-wrap instead of setting process.env.NODE_OPTIONS',
295 type: 'boolean',
296 default: false,
297 nycCommands: nycCommands.main
298 },
299 hookRequire: {
300 description: 'should nyc wrap require?',
301 type: 'boolean',
302 default: true,
303 nycCommands: nycCommands.main
304 },
305 hookRunInContext: {
306 description: 'should nyc wrap vm.runInContext?',
307 type: 'boolean',
308 default: false,
309 nycCommands: nycCommands.main
310 },
311 hookRunInThisContext: {
312 description: 'should nyc wrap vm.runInThisContext?',
313 type: 'boolean',
314 default: false,
315 nycCommands: nycCommands.main
316 },
317 clean: {
318 description: 'should the .nyc_output folder be cleaned before executing tests',
319 type: 'boolean',
320 default: true,
321 nycCommands: nycCommands.main
322 }
323};
324
325const instrumentOnly = {
326 inPlace: {
327 description: 'should nyc run the instrumentation in place?',
328 type: 'boolean',
329 default: false,
330 nycCommands: nycCommands.instrumentOnly
331 },
332 exitOnError: {
333 description: 'should nyc exit when an instrumentation failure occurs?',
334 type: 'boolean',
335 default: false,
336 nycCommands: nycCommands.instrumentOnly
337 },
338 delete: {
339 description: 'should the output folder be deleted before instrumenting files?',
340 type: 'boolean',
341 default: false,
342 nycCommands: nycCommands.instrumentOnly
343 },
344 completeCopy: {
345 description: 'should nyc copy all files from input to output as well as instrumented files?',
346 type: 'boolean',
347 default: false,
348 nycCommands: nycCommands.instrumentOnly
349 }
350};
351
352const nyc = {
353 description: 'nyc configuration options',
354 type: 'object',
355 properties: {
356 cwd,
357 nycrcPath,
358 tempDir,
359
360 /* Test Exclude */
361 ...testExclude,
362
363 /* Instrumentation settings */
364 ...instrumentVisitor,
365
366 /* Instrumentation parser/generator settings */
367 ...instrumentParseGen,
368 sourceMap: {
369 description: 'should nyc detect and handle source maps?',
370 type: 'boolean',
371 default: true,
372 nycCommands: nycCommands.instrument
373 },
374 require: {
375 description: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., @babel/register, @babel/polyfill',
376 type: 'array',
377 items: {
378 type: 'string'
379 },
380 default: [],
381 nycCommands: nycCommands.instrument,
382 nycAlias: 'i'
383 },
384 instrument: {
385 description: 'should nyc handle instrumentation?',
386 type: 'boolean',
387 default: true,
388 nycCommands: nycCommands.instrument
389 },
390
391 /* Check coverage */
392 ...checkCoverage,
393
394 /* Report options */
395 ...report,
396
397 /* Main command options */
398 ...nycMain,
399
400 /* Instrument command options */
401 ...instrumentOnly
402 }
403};
404
405const configs = {
406 nyc,
407 testExclude: {
408 description: 'test-exclude options',
409 type: 'object',
410 properties: {
411 cwd,
412 ...testExclude
413 }
414 },
415 babelPluginIstanbul: {
416 description: 'babel-plugin-istanbul options',
417 type: 'object',
418 properties: {
419 cwd,
420 ...testExclude,
421 ...instrumentVisitor
422 }
423 },
424 instrumentVisitor: {
425 description: 'instrument visitor options',
426 type: 'object',
427 properties: instrumentVisitor
428 },
429 instrumenter: {
430 description: 'stand-alone instrumenter options',
431 type: 'object',
432 properties: {
433 ...instrumentVisitor,
434 ...instrumentParseGen
435 }
436 }
437};
438
439function defaultsReducer(defaults, [name, {default: value}]) {
440 /* Modifying arrays in defaults is safe, does not change schema. */
441 if (Array.isArray(value)) {
442 value = [...value];
443 }
444
445 return Object.assign(defaults, {[name]: value});
446}
447
448module.exports = {
449 ...configs,
450 defaults: Object.keys(configs).reduce(
451 (defaults, id) => {
452 Object.defineProperty(defaults, id, {
453 enumerable: true,
454 get() {
455 /* This defers `process.cwd()` until defaults are requested. */
456 return Object.entries(configs[id].properties)
457 .filter(([, info]) => 'default' in info)
458 .reduce(defaultsReducer, {});
459 }
460 });
461
462 return defaults;
463 },
464 {}
465 )
466};
Note: See TracBrowser for help on using the repository browser.