prettier 2.0.3 → 2.1.1
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/LICENSE +0 -0
- package/README.md +0 -0
- package/bin-prettier.js +12252 -49160
- package/doc.js +1863 -231
- package/index.js +29647 -25664
- package/package.json +7 -5
- package/parser-angular.js +13 -617
- package/parser-babel.js +1 -1
- package/parser-flow.js +1 -1
- package/parser-glimmer.js +1 -1
- package/parser-graphql.js +1 -1
- package/parser-html.js +15 -15
- package/parser-markdown.js +4 -4
- package/parser-postcss.js +2 -2
- package/parser-typescript.js +3 -3
- package/parser-yaml.js +12 -13
- package/standalone.js +15 -32946
- package/third-party.js +5669 -7560
package/doc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(
|
|
3
|
-
typeof define === 'function' && define.amd ? define(
|
|
4
|
-
(global = global || self,
|
|
5
|
-
}(this, (function (
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.doc = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {Doc[]} parts
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* @param {number} n
|
|
40
|
+
* @param {number | string} n
|
|
41
41
|
* @param {Doc} contents
|
|
42
42
|
* @returns Doc
|
|
43
43
|
*/
|
|
@@ -295,8 +295,8 @@
|
|
|
295
295
|
};
|
|
296
296
|
|
|
297
297
|
var isFullwidthCodePoint_1 = isFullwidthCodePoint;
|
|
298
|
-
var
|
|
299
|
-
isFullwidthCodePoint_1.default =
|
|
298
|
+
var _default = isFullwidthCodePoint;
|
|
299
|
+
isFullwidthCodePoint_1.default = _default;
|
|
300
300
|
|
|
301
301
|
var emojiRegex = function emojiRegex() {
|
|
302
302
|
// https://mths.be/emoji
|
|
@@ -338,30 +338,1684 @@
|
|
|
338
338
|
|
|
339
339
|
var stringWidth_1 = stringWidth; // TODO: remove this in the next major version
|
|
340
340
|
|
|
341
|
-
var
|
|
342
|
-
stringWidth_1.default =
|
|
341
|
+
var _default$1 = stringWidth;
|
|
342
|
+
stringWidth_1.default = _default$1;
|
|
343
|
+
|
|
344
|
+
var escapeStringRegexp = string => {
|
|
345
|
+
if (typeof string !== 'string') {
|
|
346
|
+
throw new TypeError('Expected a string');
|
|
347
|
+
} // Escape characters with special meaning either inside or outside character sets.
|
|
348
|
+
// Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
var getLast = arr => arr[arr.length - 1];
|
|
355
|
+
|
|
356
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
357
|
+
if (source == null) return {};
|
|
358
|
+
var target = {};
|
|
359
|
+
var sourceKeys = Object.keys(source);
|
|
360
|
+
var key, i;
|
|
361
|
+
|
|
362
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
363
|
+
key = sourceKeys[i];
|
|
364
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
365
|
+
target[key] = source[key];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return target;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function _taggedTemplateLiteral(strings, raw) {
|
|
372
|
+
if (!raw) {
|
|
373
|
+
raw = strings.slice(0);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return Object.freeze(Object.defineProperties(strings, {
|
|
377
|
+
raw: {
|
|
378
|
+
value: Object.freeze(raw)
|
|
379
|
+
}
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
384
|
+
|
|
385
|
+
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
|
386
|
+
|
|
387
|
+
function defaultSetTimout() {
|
|
388
|
+
throw new Error('setTimeout has not been defined');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function defaultClearTimeout() {
|
|
392
|
+
throw new Error('clearTimeout has not been defined');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
var cachedSetTimeout = defaultSetTimout;
|
|
396
|
+
var cachedClearTimeout = defaultClearTimeout;
|
|
397
|
+
|
|
398
|
+
if (typeof global$1.setTimeout === 'function') {
|
|
399
|
+
cachedSetTimeout = setTimeout;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (typeof global$1.clearTimeout === 'function') {
|
|
403
|
+
cachedClearTimeout = clearTimeout;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function runTimeout(fun) {
|
|
407
|
+
if (cachedSetTimeout === setTimeout) {
|
|
408
|
+
//normal enviroments in sane situations
|
|
409
|
+
return setTimeout(fun, 0);
|
|
410
|
+
} // if setTimeout wasn't available but was latter defined
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
414
|
+
cachedSetTimeout = setTimeout;
|
|
415
|
+
return setTimeout(fun, 0);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
420
|
+
return cachedSetTimeout(fun, 0);
|
|
421
|
+
} catch (e) {
|
|
422
|
+
try {
|
|
423
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
424
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
425
|
+
} catch (e) {
|
|
426
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
427
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function runClearTimeout(marker) {
|
|
433
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
434
|
+
//normal enviroments in sane situations
|
|
435
|
+
return clearTimeout(marker);
|
|
436
|
+
} // if clearTimeout wasn't available but was latter defined
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
440
|
+
cachedClearTimeout = clearTimeout;
|
|
441
|
+
return clearTimeout(marker);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
446
|
+
return cachedClearTimeout(marker);
|
|
447
|
+
} catch (e) {
|
|
448
|
+
try {
|
|
449
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
450
|
+
return cachedClearTimeout.call(null, marker);
|
|
451
|
+
} catch (e) {
|
|
452
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
453
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
454
|
+
return cachedClearTimeout.call(this, marker);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
var queue = [];
|
|
460
|
+
var draining = false;
|
|
461
|
+
var currentQueue;
|
|
462
|
+
var queueIndex = -1;
|
|
463
|
+
|
|
464
|
+
function cleanUpNextTick() {
|
|
465
|
+
if (!draining || !currentQueue) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
draining = false;
|
|
470
|
+
|
|
471
|
+
if (currentQueue.length) {
|
|
472
|
+
queue = currentQueue.concat(queue);
|
|
473
|
+
} else {
|
|
474
|
+
queueIndex = -1;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (queue.length) {
|
|
478
|
+
drainQueue();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function drainQueue() {
|
|
483
|
+
if (draining) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
488
|
+
draining = true;
|
|
489
|
+
var len = queue.length;
|
|
490
|
+
|
|
491
|
+
while (len) {
|
|
492
|
+
currentQueue = queue;
|
|
493
|
+
queue = [];
|
|
494
|
+
|
|
495
|
+
while (++queueIndex < len) {
|
|
496
|
+
if (currentQueue) {
|
|
497
|
+
currentQueue[queueIndex].run();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
queueIndex = -1;
|
|
502
|
+
len = queue.length;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
currentQueue = null;
|
|
506
|
+
draining = false;
|
|
507
|
+
runClearTimeout(timeout);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function nextTick(fun) {
|
|
511
|
+
var args = new Array(arguments.length - 1);
|
|
512
|
+
|
|
513
|
+
if (arguments.length > 1) {
|
|
514
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
515
|
+
args[i - 1] = arguments[i];
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
queue.push(new Item(fun, args));
|
|
520
|
+
|
|
521
|
+
if (queue.length === 1 && !draining) {
|
|
522
|
+
runTimeout(drainQueue);
|
|
523
|
+
}
|
|
524
|
+
} // v8 likes predictible objects
|
|
525
|
+
|
|
526
|
+
function Item(fun, array) {
|
|
527
|
+
this.fun = fun;
|
|
528
|
+
this.array = array;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
Item.prototype.run = function () {
|
|
532
|
+
this.fun.apply(null, this.array);
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
var title = 'browser';
|
|
536
|
+
var platform = 'browser';
|
|
537
|
+
var browser = true;
|
|
538
|
+
var env = {};
|
|
539
|
+
var argv = [];
|
|
540
|
+
var version = ''; // empty string to avoid regexp issues
|
|
541
|
+
|
|
542
|
+
var versions = {};
|
|
543
|
+
var release = {};
|
|
544
|
+
var config = {};
|
|
545
|
+
|
|
546
|
+
function noop() {}
|
|
547
|
+
|
|
548
|
+
var on = noop;
|
|
549
|
+
var addListener = noop;
|
|
550
|
+
var once = noop;
|
|
551
|
+
var off = noop;
|
|
552
|
+
var removeListener = noop;
|
|
553
|
+
var removeAllListeners = noop;
|
|
554
|
+
var emit = noop;
|
|
555
|
+
function binding(name) {
|
|
556
|
+
throw new Error('process.binding is not supported');
|
|
557
|
+
}
|
|
558
|
+
function cwd() {
|
|
559
|
+
return '/';
|
|
560
|
+
}
|
|
561
|
+
function chdir(dir) {
|
|
562
|
+
throw new Error('process.chdir is not supported');
|
|
563
|
+
}
|
|
564
|
+
function umask() {
|
|
565
|
+
return 0;
|
|
566
|
+
} // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
567
|
+
|
|
568
|
+
var performance = global$1.performance || {};
|
|
569
|
+
|
|
570
|
+
var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
|
|
571
|
+
return new Date().getTime();
|
|
572
|
+
}; // generate timestamp or delta
|
|
573
|
+
// see http://nodejs.org/api/process.html#process_process_hrtime
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
function hrtime(previousTimestamp) {
|
|
577
|
+
var clocktime = performanceNow.call(performance) * 1e-3;
|
|
578
|
+
var seconds = Math.floor(clocktime);
|
|
579
|
+
var nanoseconds = Math.floor(clocktime % 1 * 1e9);
|
|
580
|
+
|
|
581
|
+
if (previousTimestamp) {
|
|
582
|
+
seconds = seconds - previousTimestamp[0];
|
|
583
|
+
nanoseconds = nanoseconds - previousTimestamp[1];
|
|
584
|
+
|
|
585
|
+
if (nanoseconds < 0) {
|
|
586
|
+
seconds--;
|
|
587
|
+
nanoseconds += 1e9;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return [seconds, nanoseconds];
|
|
592
|
+
}
|
|
593
|
+
var startTime = new Date();
|
|
594
|
+
function uptime() {
|
|
595
|
+
var currentTime = new Date();
|
|
596
|
+
var dif = currentTime - startTime;
|
|
597
|
+
return dif / 1000;
|
|
598
|
+
}
|
|
599
|
+
var process = {
|
|
600
|
+
nextTick: nextTick,
|
|
601
|
+
title: title,
|
|
602
|
+
browser: browser,
|
|
603
|
+
env: env,
|
|
604
|
+
argv: argv,
|
|
605
|
+
version: version,
|
|
606
|
+
versions: versions,
|
|
607
|
+
on: on,
|
|
608
|
+
addListener: addListener,
|
|
609
|
+
once: once,
|
|
610
|
+
off: off,
|
|
611
|
+
removeListener: removeListener,
|
|
612
|
+
removeAllListeners: removeAllListeners,
|
|
613
|
+
emit: emit,
|
|
614
|
+
binding: binding,
|
|
615
|
+
cwd: cwd,
|
|
616
|
+
chdir: chdir,
|
|
617
|
+
umask: umask,
|
|
618
|
+
hrtime: hrtime,
|
|
619
|
+
platform: platform,
|
|
620
|
+
release: release,
|
|
621
|
+
config: config,
|
|
622
|
+
uptime: uptime
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
|
|
626
|
+
var debug_1 = debug;
|
|
627
|
+
|
|
628
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
629
|
+
// Not necessarily the package version of this code.
|
|
630
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
631
|
+
const MAX_LENGTH = 256;
|
|
632
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
633
|
+
/* istanbul ignore next */
|
|
634
|
+
9007199254740991; // Max safe segment length for coercion.
|
|
635
|
+
|
|
636
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
637
|
+
var constants = {
|
|
638
|
+
SEMVER_SPEC_VERSION,
|
|
639
|
+
MAX_LENGTH,
|
|
640
|
+
MAX_SAFE_INTEGER,
|
|
641
|
+
MAX_SAFE_COMPONENT_LENGTH
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
645
|
+
return module = {
|
|
646
|
+
path: basedir,
|
|
647
|
+
exports: {},
|
|
648
|
+
require: function (path, base) {
|
|
649
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
650
|
+
}
|
|
651
|
+
}, fn(module, module.exports), module.exports;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function getCjsExportFromNamespace (n) {
|
|
655
|
+
return n && n['default'] || n;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function commonjsRequire () {
|
|
659
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
var re_1 = createCommonjsModule(function (module, exports) {
|
|
663
|
+
const {
|
|
664
|
+
MAX_SAFE_COMPONENT_LENGTH
|
|
665
|
+
} = constants;
|
|
666
|
+
exports = module.exports = {}; // The actual regexps go on exports.re
|
|
667
|
+
|
|
668
|
+
const re = exports.re = [];
|
|
669
|
+
const src = exports.src = [];
|
|
670
|
+
const t = exports.t = {};
|
|
671
|
+
let R = 0;
|
|
672
|
+
|
|
673
|
+
const createToken = (name, value, isGlobal) => {
|
|
674
|
+
const index = R++;
|
|
675
|
+
debug_1(index, value);
|
|
676
|
+
t[name] = index;
|
|
677
|
+
src[index] = value;
|
|
678
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
679
|
+
}; // The following Regular Expressions can be used for tokenizing,
|
|
680
|
+
// validating, and parsing SemVer version strings.
|
|
681
|
+
// ## Numeric Identifier
|
|
682
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
686
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
|
|
687
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
688
|
+
// more letters, digits, or hyphens.
|
|
689
|
+
|
|
690
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
|
|
691
|
+
// Three dot-separated numeric identifiers.
|
|
692
|
+
|
|
693
|
+
createToken('MAINVERSION', "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")"));
|
|
694
|
+
createToken('MAINVERSIONLOOSE', "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")")); // ## Pre-release Version Identifier
|
|
695
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
696
|
+
|
|
697
|
+
createToken('PRERELEASEIDENTIFIER', "(?:".concat(src[t.NUMERICIDENTIFIER], "|").concat(src[t.NONNUMERICIDENTIFIER], ")"));
|
|
698
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', "(?:".concat(src[t.NUMERICIDENTIFIERLOOSE], "|").concat(src[t.NONNUMERICIDENTIFIER], ")")); // ## Pre-release Version
|
|
699
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
700
|
+
// identifiers.
|
|
701
|
+
|
|
702
|
+
createToken('PRERELEASE', "(?:-(".concat(src[t.PRERELEASEIDENTIFIER], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIER], ")*))"));
|
|
703
|
+
createToken('PRERELEASELOOSE', "(?:-?(".concat(src[t.PRERELEASEIDENTIFIERLOOSE], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIERLOOSE], ")*))")); // ## Build Metadata Identifier
|
|
704
|
+
// Any combination of digits, letters, or hyphens.
|
|
705
|
+
|
|
706
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
|
|
707
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
708
|
+
// identifiers.
|
|
709
|
+
|
|
710
|
+
createToken('BUILD', "(?:\\+(".concat(src[t.BUILDIDENTIFIER], "(?:\\.").concat(src[t.BUILDIDENTIFIER], ")*))")); // ## Full Version String
|
|
711
|
+
// A main version, followed optionally by a pre-release version and
|
|
712
|
+
// build metadata.
|
|
713
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
714
|
+
// the version string are capturing groups. The build metadata is not a
|
|
715
|
+
// capturing group, because it should not ever be used in version
|
|
716
|
+
// comparison.
|
|
717
|
+
|
|
718
|
+
createToken('FULLPLAIN', "v?".concat(src[t.MAINVERSION]).concat(src[t.PRERELEASE], "?").concat(src[t.BUILD], "?"));
|
|
719
|
+
createToken('FULL', "^".concat(src[t.FULLPLAIN], "$")); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
720
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
721
|
+
// common in the npm registry.
|
|
722
|
+
|
|
723
|
+
createToken('LOOSEPLAIN', "[v=\\s]*".concat(src[t.MAINVERSIONLOOSE]).concat(src[t.PRERELEASELOOSE], "?").concat(src[t.BUILD], "?"));
|
|
724
|
+
createToken('LOOSE', "^".concat(src[t.LOOSEPLAIN], "$"));
|
|
725
|
+
createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
|
|
726
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
727
|
+
// Only the first item is strictly required.
|
|
728
|
+
|
|
729
|
+
createToken('XRANGEIDENTIFIERLOOSE', "".concat(src[t.NUMERICIDENTIFIERLOOSE], "|x|X|\\*"));
|
|
730
|
+
createToken('XRANGEIDENTIFIER', "".concat(src[t.NUMERICIDENTIFIER], "|x|X|\\*"));
|
|
731
|
+
createToken('XRANGEPLAIN', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:".concat(src[t.PRERELEASE], ")?").concat(src[t.BUILD], "?") + ")?)?");
|
|
732
|
+
createToken('XRANGEPLAINLOOSE', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:".concat(src[t.PRERELEASELOOSE], ")?").concat(src[t.BUILD], "?") + ")?)?");
|
|
733
|
+
createToken('XRANGE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAIN], "$"));
|
|
734
|
+
createToken('XRANGELOOSE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAINLOOSE], "$")); // Coercion.
|
|
735
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
736
|
+
|
|
737
|
+
createToken('COERCE', "".concat('(^|[^\\d])' + '(\\d{1,').concat(MAX_SAFE_COMPONENT_LENGTH, "})") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:$|[^\\d])");
|
|
738
|
+
createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
|
|
739
|
+
// Meaning is "reasonably at or greater than"
|
|
740
|
+
|
|
741
|
+
createToken('LONETILDE', '(?:~>?)');
|
|
742
|
+
createToken('TILDETRIM', "(\\s*)".concat(src[t.LONETILDE], "\\s+"), true);
|
|
743
|
+
exports.tildeTrimReplace = '$1~';
|
|
744
|
+
createToken('TILDE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAIN], "$"));
|
|
745
|
+
createToken('TILDELOOSE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAINLOOSE], "$")); // Caret ranges.
|
|
746
|
+
// Meaning is "at least and backwards compatible with"
|
|
747
|
+
|
|
748
|
+
createToken('LONECARET', '(?:\\^)');
|
|
749
|
+
createToken('CARETTRIM', "(\\s*)".concat(src[t.LONECARET], "\\s+"), true);
|
|
750
|
+
exports.caretTrimReplace = '$1^';
|
|
751
|
+
createToken('CARET', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAIN], "$"));
|
|
752
|
+
createToken('CARETLOOSE', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAINLOOSE], "$")); // A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
753
|
+
|
|
754
|
+
createToken('COMPARATORLOOSE', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], ")$|^$"));
|
|
755
|
+
createToken('COMPARATOR', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.FULLPLAIN], ")$|^$")); // An expression to strip any whitespace between the gtlt and the thing
|
|
756
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
757
|
+
|
|
758
|
+
createToken('COMPARATORTRIM', "(\\s*)".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], "|").concat(src[t.XRANGEPLAIN], ")"), true);
|
|
759
|
+
exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
|
|
760
|
+
// Note that these all use the loose form, because they'll be
|
|
761
|
+
// checked against either the strict or loose comparator form
|
|
762
|
+
// later.
|
|
763
|
+
|
|
764
|
+
createToken('HYPHENRANGE', "^\\s*(".concat(src[t.XRANGEPLAIN], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAIN], ")") + "\\s*$");
|
|
765
|
+
createToken('HYPHENRANGELOOSE', "^\\s*(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s*$"); // Star ranges basically just allow anything at all.
|
|
766
|
+
|
|
767
|
+
createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
|
|
768
|
+
|
|
769
|
+
createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
|
|
770
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
const numeric = /^[0-9]+$/;
|
|
774
|
+
|
|
775
|
+
const compareIdentifiers = (a, b) => {
|
|
776
|
+
const anum = numeric.test(a);
|
|
777
|
+
const bnum = numeric.test(b);
|
|
778
|
+
|
|
779
|
+
if (anum && bnum) {
|
|
780
|
+
a = +a;
|
|
781
|
+
b = +b;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
788
|
+
|
|
789
|
+
var identifiers = {
|
|
790
|
+
compareIdentifiers,
|
|
791
|
+
rcompareIdentifiers
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const {
|
|
795
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
|
796
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1
|
|
797
|
+
} = constants;
|
|
798
|
+
const {
|
|
799
|
+
re,
|
|
800
|
+
t
|
|
801
|
+
} = re_1;
|
|
802
|
+
const {
|
|
803
|
+
compareIdentifiers: compareIdentifiers$1
|
|
804
|
+
} = identifiers;
|
|
805
|
+
|
|
806
|
+
class SemVer {
|
|
807
|
+
constructor(version, options) {
|
|
808
|
+
if (!options || typeof options !== 'object') {
|
|
809
|
+
options = {
|
|
810
|
+
loose: !!options,
|
|
811
|
+
includePrerelease: false
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (version instanceof SemVer) {
|
|
816
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
817
|
+
return version;
|
|
818
|
+
} else {
|
|
819
|
+
version = version.version;
|
|
820
|
+
}
|
|
821
|
+
} else if (typeof version !== 'string') {
|
|
822
|
+
throw new TypeError("Invalid Version: ".concat(version));
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (version.length > MAX_LENGTH$1) {
|
|
826
|
+
throw new TypeError("version is longer than ".concat(MAX_LENGTH$1, " characters"));
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
debug_1('SemVer', version, options);
|
|
830
|
+
this.options = options;
|
|
831
|
+
this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
|
|
832
|
+
// don't run into trouble passing this.options around.
|
|
833
|
+
|
|
834
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
835
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
836
|
+
|
|
837
|
+
if (!m) {
|
|
838
|
+
throw new TypeError("Invalid Version: ".concat(version));
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
this.raw = version; // these are actually numbers
|
|
842
|
+
|
|
843
|
+
this.major = +m[1];
|
|
844
|
+
this.minor = +m[2];
|
|
845
|
+
this.patch = +m[3];
|
|
846
|
+
|
|
847
|
+
if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
|
|
848
|
+
throw new TypeError('Invalid major version');
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
|
|
852
|
+
throw new TypeError('Invalid minor version');
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
|
|
856
|
+
throw new TypeError('Invalid patch version');
|
|
857
|
+
} // numberify any prerelease numeric ids
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
if (!m[4]) {
|
|
861
|
+
this.prerelease = [];
|
|
862
|
+
} else {
|
|
863
|
+
this.prerelease = m[4].split('.').map(id => {
|
|
864
|
+
if (/^[0-9]+$/.test(id)) {
|
|
865
|
+
const num = +id;
|
|
866
|
+
|
|
867
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
|
|
868
|
+
return num;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
return id;
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
877
|
+
this.format();
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
format() {
|
|
881
|
+
this.version = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
|
|
882
|
+
|
|
883
|
+
if (this.prerelease.length) {
|
|
884
|
+
this.version += "-".concat(this.prerelease.join('.'));
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
return this.version;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
toString() {
|
|
891
|
+
return this.version;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
compare(other) {
|
|
895
|
+
debug_1('SemVer.compare', this.version, this.options, other);
|
|
896
|
+
|
|
897
|
+
if (!(other instanceof SemVer)) {
|
|
898
|
+
if (typeof other === 'string' && other === this.version) {
|
|
899
|
+
return 0;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
other = new SemVer(other, this.options);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
if (other.version === this.version) {
|
|
906
|
+
return 0;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
compareMain(other) {
|
|
913
|
+
if (!(other instanceof SemVer)) {
|
|
914
|
+
other = new SemVer(other, this.options);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
comparePre(other) {
|
|
921
|
+
if (!(other instanceof SemVer)) {
|
|
922
|
+
other = new SemVer(other, this.options);
|
|
923
|
+
} // NOT having a prerelease is > having one
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
927
|
+
return -1;
|
|
928
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
929
|
+
return 1;
|
|
930
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
931
|
+
return 0;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
let i = 0;
|
|
935
|
+
|
|
936
|
+
do {
|
|
937
|
+
const a = this.prerelease[i];
|
|
938
|
+
const b = other.prerelease[i];
|
|
939
|
+
debug_1('prerelease compare', i, a, b);
|
|
940
|
+
|
|
941
|
+
if (a === undefined && b === undefined) {
|
|
942
|
+
return 0;
|
|
943
|
+
} else if (b === undefined) {
|
|
944
|
+
return 1;
|
|
945
|
+
} else if (a === undefined) {
|
|
946
|
+
return -1;
|
|
947
|
+
} else if (a === b) {
|
|
948
|
+
continue;
|
|
949
|
+
} else {
|
|
950
|
+
return compareIdentifiers$1(a, b);
|
|
951
|
+
}
|
|
952
|
+
} while (++i);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
compareBuild(other) {
|
|
956
|
+
if (!(other instanceof SemVer)) {
|
|
957
|
+
other = new SemVer(other, this.options);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
let i = 0;
|
|
961
|
+
|
|
962
|
+
do {
|
|
963
|
+
const a = this.build[i];
|
|
964
|
+
const b = other.build[i];
|
|
965
|
+
debug_1('prerelease compare', i, a, b);
|
|
966
|
+
|
|
967
|
+
if (a === undefined && b === undefined) {
|
|
968
|
+
return 0;
|
|
969
|
+
} else if (b === undefined) {
|
|
970
|
+
return 1;
|
|
971
|
+
} else if (a === undefined) {
|
|
972
|
+
return -1;
|
|
973
|
+
} else if (a === b) {
|
|
974
|
+
continue;
|
|
975
|
+
} else {
|
|
976
|
+
return compareIdentifiers$1(a, b);
|
|
977
|
+
}
|
|
978
|
+
} while (++i);
|
|
979
|
+
} // preminor will bump the version up to the next minor release, and immediately
|
|
980
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
inc(release, identifier) {
|
|
984
|
+
switch (release) {
|
|
985
|
+
case 'premajor':
|
|
986
|
+
this.prerelease.length = 0;
|
|
987
|
+
this.patch = 0;
|
|
988
|
+
this.minor = 0;
|
|
989
|
+
this.major++;
|
|
990
|
+
this.inc('pre', identifier);
|
|
991
|
+
break;
|
|
992
|
+
|
|
993
|
+
case 'preminor':
|
|
994
|
+
this.prerelease.length = 0;
|
|
995
|
+
this.patch = 0;
|
|
996
|
+
this.minor++;
|
|
997
|
+
this.inc('pre', identifier);
|
|
998
|
+
break;
|
|
999
|
+
|
|
1000
|
+
case 'prepatch':
|
|
1001
|
+
// If this is already a prerelease, it will bump to the next version
|
|
1002
|
+
// drop any prereleases that might already exist, since they are not
|
|
1003
|
+
// relevant at this point.
|
|
1004
|
+
this.prerelease.length = 0;
|
|
1005
|
+
this.inc('patch', identifier);
|
|
1006
|
+
this.inc('pre', identifier);
|
|
1007
|
+
break;
|
|
1008
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
1009
|
+
// prepatch.
|
|
1010
|
+
|
|
1011
|
+
case 'prerelease':
|
|
1012
|
+
if (this.prerelease.length === 0) {
|
|
1013
|
+
this.inc('patch', identifier);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
this.inc('pre', identifier);
|
|
1017
|
+
break;
|
|
1018
|
+
|
|
1019
|
+
case 'major':
|
|
1020
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
1021
|
+
// Otherwise increment major.
|
|
1022
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
1023
|
+
// 1.1.0 bumps to 2.0.0
|
|
1024
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
1025
|
+
this.major++;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
this.minor = 0;
|
|
1029
|
+
this.patch = 0;
|
|
1030
|
+
this.prerelease = [];
|
|
1031
|
+
break;
|
|
1032
|
+
|
|
1033
|
+
case 'minor':
|
|
1034
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
1035
|
+
// Otherwise increment minor.
|
|
1036
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
1037
|
+
// 1.2.1 bumps to 1.3.0
|
|
1038
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
1039
|
+
this.minor++;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
this.patch = 0;
|
|
1043
|
+
this.prerelease = [];
|
|
1044
|
+
break;
|
|
1045
|
+
|
|
1046
|
+
case 'patch':
|
|
1047
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
1048
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
1049
|
+
// 1.2.0-5 patches to 1.2.0
|
|
1050
|
+
// 1.2.0 patches to 1.2.1
|
|
1051
|
+
if (this.prerelease.length === 0) {
|
|
1052
|
+
this.patch++;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
this.prerelease = [];
|
|
1056
|
+
break;
|
|
1057
|
+
// This probably shouldn't be used publicly.
|
|
1058
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
1059
|
+
|
|
1060
|
+
case 'pre':
|
|
1061
|
+
if (this.prerelease.length === 0) {
|
|
1062
|
+
this.prerelease = [0];
|
|
1063
|
+
} else {
|
|
1064
|
+
let i = this.prerelease.length;
|
|
1065
|
+
|
|
1066
|
+
while (--i >= 0) {
|
|
1067
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
1068
|
+
this.prerelease[i]++;
|
|
1069
|
+
i = -2;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
if (i === -1) {
|
|
1074
|
+
// didn't increment anything
|
|
1075
|
+
this.prerelease.push(0);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
if (identifier) {
|
|
1080
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
1081
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
1082
|
+
if (this.prerelease[0] === identifier) {
|
|
1083
|
+
if (isNaN(this.prerelease[1])) {
|
|
1084
|
+
this.prerelease = [identifier, 0];
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
this.prerelease = [identifier, 0];
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
break;
|
|
1092
|
+
|
|
1093
|
+
default:
|
|
1094
|
+
throw new Error("invalid increment argument: ".concat(release));
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
this.format();
|
|
1098
|
+
this.raw = this.version;
|
|
1099
|
+
return this;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
var semver = SemVer;
|
|
1105
|
+
|
|
1106
|
+
const compare = (a, b, loose) => new semver(a, loose).compare(new semver(b, loose));
|
|
1107
|
+
|
|
1108
|
+
var compare_1 = compare;
|
|
1109
|
+
|
|
1110
|
+
const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
|
|
1111
|
+
|
|
1112
|
+
var lt_1 = lt;
|
|
1113
|
+
|
|
1114
|
+
const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
|
|
1115
|
+
|
|
1116
|
+
var gte_1 = gte;
|
|
1117
|
+
|
|
1118
|
+
var arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
|
|
1119
|
+
[keyName]: key
|
|
1120
|
+
}, value));
|
|
1121
|
+
|
|
1122
|
+
var name = "prettier";
|
|
1123
|
+
var version$1 = "2.1.1";
|
|
1124
|
+
var description = "Prettier is an opinionated code formatter";
|
|
1125
|
+
var bin = "./bin/prettier.js";
|
|
1126
|
+
var repository = "prettier/prettier";
|
|
1127
|
+
var homepage = "https://prettier.io";
|
|
1128
|
+
var author = "James Long";
|
|
1129
|
+
var license = "MIT";
|
|
1130
|
+
var main = "./index.js";
|
|
1131
|
+
var browser$1 = "./standalone.js";
|
|
1132
|
+
var unpkg = "./standalone.js";
|
|
1133
|
+
var engines = {
|
|
1134
|
+
node: ">=10.13.0"
|
|
1135
|
+
};
|
|
1136
|
+
var files = [
|
|
1137
|
+
"index.js",
|
|
1138
|
+
"standalone.js",
|
|
1139
|
+
"src",
|
|
1140
|
+
"bin"
|
|
1141
|
+
];
|
|
1142
|
+
var dependencies = {
|
|
1143
|
+
"@angular/compiler": "10.0.12",
|
|
1144
|
+
"@babel/code-frame": "7.10.4",
|
|
1145
|
+
"@babel/parser": "7.11.2",
|
|
1146
|
+
"@glimmer/syntax": "0.59.0",
|
|
1147
|
+
"@iarna/toml": "2.2.5",
|
|
1148
|
+
"@typescript-eslint/typescript-estree": "3.10.0",
|
|
1149
|
+
"angular-estree-parser": "2.2.0",
|
|
1150
|
+
"angular-html-parser": "1.7.1",
|
|
1151
|
+
camelcase: "6.0.0",
|
|
1152
|
+
chalk: "4.1.0",
|
|
1153
|
+
"ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
|
|
1154
|
+
"cjk-regex": "2.0.0",
|
|
1155
|
+
cosmiconfig: "7.0.0",
|
|
1156
|
+
dashify: "2.0.0",
|
|
1157
|
+
diff: "4.0.2",
|
|
1158
|
+
editorconfig: "0.15.3",
|
|
1159
|
+
"editorconfig-to-prettier": "0.1.1",
|
|
1160
|
+
"escape-string-regexp": "4.0.0",
|
|
1161
|
+
esutils: "2.0.3",
|
|
1162
|
+
"fast-glob": "3.2.4",
|
|
1163
|
+
"fast-json-stable-stringify": "2.1.0",
|
|
1164
|
+
"find-parent-dir": "0.3.0",
|
|
1165
|
+
"flow-parser": "0.132.0",
|
|
1166
|
+
"get-stream": "6.0.0",
|
|
1167
|
+
globby: "11.0.1",
|
|
1168
|
+
graphql: "15.3.0",
|
|
1169
|
+
"html-element-attributes": "2.2.1",
|
|
1170
|
+
"html-styles": "1.0.0",
|
|
1171
|
+
"html-tag-names": "1.1.5",
|
|
1172
|
+
"html-void-elements": "1.0.5",
|
|
1173
|
+
ignore: "4.0.6",
|
|
1174
|
+
"jest-docblock": "26.0.0",
|
|
1175
|
+
json5: "2.1.3",
|
|
1176
|
+
leven: "3.1.0",
|
|
1177
|
+
"lines-and-columns": "1.1.6",
|
|
1178
|
+
"linguist-languages": "7.10.0",
|
|
1179
|
+
lodash: "4.17.20",
|
|
1180
|
+
mem: "6.1.0",
|
|
1181
|
+
minimatch: "3.0.4",
|
|
1182
|
+
minimist: "1.2.5",
|
|
1183
|
+
"n-readlines": "1.0.0",
|
|
1184
|
+
outdent: "0.7.1",
|
|
1185
|
+
"parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
|
|
1186
|
+
"please-upgrade-node": "3.2.0",
|
|
1187
|
+
"postcss-less": "3.1.4",
|
|
1188
|
+
"postcss-media-query-parser": "0.2.3",
|
|
1189
|
+
"postcss-scss": "2.1.1",
|
|
1190
|
+
"postcss-selector-parser": "2.2.3",
|
|
1191
|
+
"postcss-values-parser": "2.0.1",
|
|
1192
|
+
"regexp-util": "1.2.2",
|
|
1193
|
+
"remark-footnotes": "2.0.0",
|
|
1194
|
+
"remark-math": "1.0.6",
|
|
1195
|
+
"remark-parse": "8.0.3",
|
|
1196
|
+
resolve: "1.17.0",
|
|
1197
|
+
semver: "7.3.2",
|
|
1198
|
+
"string-width": "4.2.0",
|
|
1199
|
+
typescript: "4.0.2",
|
|
1200
|
+
"unicode-regex": "3.0.0",
|
|
1201
|
+
unified: "9.2.0",
|
|
1202
|
+
vnopts: "1.0.2",
|
|
1203
|
+
"yaml-unist-parser": "1.3.0"
|
|
1204
|
+
};
|
|
1205
|
+
var devDependencies = {
|
|
1206
|
+
"@babel/core": "7.11.4",
|
|
1207
|
+
"@babel/preset-env": "7.11.0",
|
|
1208
|
+
"@babel/types": "7.11.0",
|
|
1209
|
+
"@glimmer/reference": "0.59.0",
|
|
1210
|
+
"@rollup/plugin-alias": "3.1.1",
|
|
1211
|
+
"@rollup/plugin-babel": "5.2.0",
|
|
1212
|
+
"@rollup/plugin-commonjs": "14.0.0",
|
|
1213
|
+
"@rollup/plugin-json": "4.1.0",
|
|
1214
|
+
"@rollup/plugin-node-resolve": "9.0.0",
|
|
1215
|
+
"@rollup/plugin-replace": "2.3.3",
|
|
1216
|
+
"@types/estree": "0.0.45",
|
|
1217
|
+
"@types/node": "14.6.0",
|
|
1218
|
+
"@typescript-eslint/types": "3.10.0",
|
|
1219
|
+
"babel-loader": "8.1.0",
|
|
1220
|
+
benchmark: "2.1.4",
|
|
1221
|
+
"builtin-modules": "3.1.0",
|
|
1222
|
+
"cross-env": "7.0.2",
|
|
1223
|
+
cspell: "4.1.0",
|
|
1224
|
+
eslint: "7.7.0",
|
|
1225
|
+
"eslint-config-prettier": "6.11.0",
|
|
1226
|
+
"eslint-formatter-friendly": "7.0.0",
|
|
1227
|
+
"eslint-plugin-import": "2.22.0",
|
|
1228
|
+
"eslint-plugin-jest": "23.20.0",
|
|
1229
|
+
"eslint-plugin-prettier-internal-rules": "file:scripts/tools/eslint-plugin-prettier-internal-rules",
|
|
1230
|
+
"eslint-plugin-react": "7.20.6",
|
|
1231
|
+
"eslint-plugin-unicorn": "21.0.0",
|
|
1232
|
+
execa: "4.0.3",
|
|
1233
|
+
jest: "26.4.2",
|
|
1234
|
+
"jest-snapshot-serializer-ansi": "1.0.0",
|
|
1235
|
+
"jest-snapshot-serializer-raw": "1.1.0",
|
|
1236
|
+
"jest-watch-typeahead": "0.6.0",
|
|
1237
|
+
"npm-run-all": "4.1.5",
|
|
1238
|
+
prettier: "2.1.0",
|
|
1239
|
+
rimraf: "3.0.2",
|
|
1240
|
+
rollup: "2.26.5",
|
|
1241
|
+
"rollup-plugin-node-globals": "1.4.0",
|
|
1242
|
+
"rollup-plugin-terser": "7.0.0",
|
|
1243
|
+
shelljs: "0.8.4",
|
|
1244
|
+
"snapshot-diff": "0.8.1",
|
|
1245
|
+
"strip-ansi": "6.0.0",
|
|
1246
|
+
"synchronous-promise": "2.0.13",
|
|
1247
|
+
tempy: "0.6.0",
|
|
1248
|
+
"terser-webpack-plugin": "4.1.0",
|
|
1249
|
+
webpack: "4.44.1"
|
|
1250
|
+
};
|
|
1251
|
+
var scripts = {
|
|
1252
|
+
prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1",
|
|
1253
|
+
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
1254
|
+
test: "jest",
|
|
1255
|
+
"test:dev-package": "cross-env INSTALL_PACKAGE=1 jest",
|
|
1256
|
+
"test:dist": "cross-env NODE_ENV=production jest",
|
|
1257
|
+
"test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 jest",
|
|
1258
|
+
"test:integration": "jest tests_integration",
|
|
1259
|
+
"perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
|
1260
|
+
"perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
|
1261
|
+
"perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
|
1262
|
+
lint: "run-p lint:*",
|
|
1263
|
+
"lint:typecheck": "tsc",
|
|
1264
|
+
"lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
|
|
1265
|
+
"lint:changelog": "node ./scripts/lint-changelog.js",
|
|
1266
|
+
"lint:prettier": "prettier . \"!test*\" --check",
|
|
1267
|
+
"lint:dist": "eslint --no-eslintrc --no-ignore --env=es6,browser --parser-options=ecmaVersion:2016 \"dist/!(bin-prettier|index|third-party).js\"",
|
|
1268
|
+
"lint:spellcheck": "cspell \"**/*\" \".github/**/*\"",
|
|
1269
|
+
"lint:deps": "node ./scripts/check-deps.js",
|
|
1270
|
+
fix: "run-s fix:eslint fix:prettier",
|
|
1271
|
+
"fix:eslint": "yarn lint:eslint --fix",
|
|
1272
|
+
"fix:prettier": "yarn lint:prettier --write",
|
|
1273
|
+
build: "node ./scripts/build/build.js",
|
|
1274
|
+
"build-docs": "node ./scripts/build-docs.js"
|
|
1275
|
+
};
|
|
1276
|
+
var _package = {
|
|
1277
|
+
name: name,
|
|
1278
|
+
version: version$1,
|
|
1279
|
+
description: description,
|
|
1280
|
+
bin: bin,
|
|
1281
|
+
repository: repository,
|
|
1282
|
+
homepage: homepage,
|
|
1283
|
+
author: author,
|
|
1284
|
+
license: license,
|
|
1285
|
+
main: main,
|
|
1286
|
+
browser: browser$1,
|
|
1287
|
+
unpkg: unpkg,
|
|
1288
|
+
engines: engines,
|
|
1289
|
+
files: files,
|
|
1290
|
+
dependencies: dependencies,
|
|
1291
|
+
devDependencies: devDependencies,
|
|
1292
|
+
scripts: scripts
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
var _package$1 = /*#__PURE__*/Object.freeze({
|
|
1296
|
+
__proto__: null,
|
|
1297
|
+
name: name,
|
|
1298
|
+
version: version$1,
|
|
1299
|
+
description: description,
|
|
1300
|
+
bin: bin,
|
|
1301
|
+
repository: repository,
|
|
1302
|
+
homepage: homepage,
|
|
1303
|
+
author: author,
|
|
1304
|
+
license: license,
|
|
1305
|
+
main: main,
|
|
1306
|
+
browser: browser$1,
|
|
1307
|
+
unpkg: unpkg,
|
|
1308
|
+
engines: engines,
|
|
1309
|
+
files: files,
|
|
1310
|
+
dependencies: dependencies,
|
|
1311
|
+
devDependencies: devDependencies,
|
|
1312
|
+
scripts: scripts,
|
|
1313
|
+
'default': _package
|
|
1314
|
+
});
|
|
1315
|
+
|
|
1316
|
+
var lib = createCommonjsModule(function (module, exports) {
|
|
1317
|
+
|
|
1318
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1319
|
+
value: true
|
|
1320
|
+
}); // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
|
|
1321
|
+
|
|
1322
|
+
function noop() {
|
|
1323
|
+
var args = [];
|
|
1324
|
+
|
|
1325
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1326
|
+
args[_i] = arguments[_i];
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
function createWeakMap() {
|
|
1331
|
+
if (typeof WeakMap !== 'undefined') {
|
|
1332
|
+
return new WeakMap();
|
|
1333
|
+
} else {
|
|
1334
|
+
return fakeSetOrMap();
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
|
|
1339
|
+
*/
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
function fakeSetOrMap() {
|
|
1343
|
+
return {
|
|
1344
|
+
add: noop,
|
|
1345
|
+
delete: noop,
|
|
1346
|
+
get: noop,
|
|
1347
|
+
set: noop,
|
|
1348
|
+
has: function has(k) {
|
|
1349
|
+
return false;
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
} // Safe hasOwnProperty
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
var hop = Object.prototype.hasOwnProperty;
|
|
1356
|
+
|
|
1357
|
+
var has = function has(obj, prop) {
|
|
1358
|
+
return hop.call(obj, prop);
|
|
1359
|
+
}; // Copy all own enumerable properties from source to target
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
function extend(target, source) {
|
|
1363
|
+
for (var prop in source) {
|
|
1364
|
+
if (has(source, prop)) {
|
|
1365
|
+
target[prop] = source[prop];
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
return target;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
|
|
1373
|
+
var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
|
|
1374
|
+
var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
|
|
1375
|
+
var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
|
|
1376
|
+
var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
|
|
1377
|
+
|
|
1378
|
+
function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
|
|
1379
|
+
// If first interpolated value is a reference to outdent,
|
|
1380
|
+
// determine indentation level from the indentation of the interpolated value.
|
|
1381
|
+
var indentationLevel = 0;
|
|
1382
|
+
var match = strings[0].match(reDetectIndentation);
|
|
1383
|
+
|
|
1384
|
+
if (match) {
|
|
1385
|
+
indentationLevel = match[1].length;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
|
|
1389
|
+
var reMatchIndent = new RegExp(reSource, 'g');
|
|
1390
|
+
|
|
1391
|
+
if (firstInterpolatedValueSetsIndentationLevel) {
|
|
1392
|
+
strings = strings.slice(1);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
var newline = options.newline,
|
|
1396
|
+
trimLeadingNewline = options.trimLeadingNewline,
|
|
1397
|
+
trimTrailingNewline = options.trimTrailingNewline;
|
|
1398
|
+
var normalizeNewlines = typeof newline === 'string';
|
|
1399
|
+
var l = strings.length;
|
|
1400
|
+
var outdentedStrings = strings.map(function (v, i) {
|
|
1401
|
+
// Remove leading indentation from all lines
|
|
1402
|
+
v = v.replace(reMatchIndent, '$1'); // Trim a leading newline from the first string
|
|
1403
|
+
|
|
1404
|
+
if (i === 0 && trimLeadingNewline) {
|
|
1405
|
+
v = v.replace(reLeadingNewline, '');
|
|
1406
|
+
} // Trim a trailing newline from the last string
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
if (i === l - 1 && trimTrailingNewline) {
|
|
1410
|
+
v = v.replace(reTrailingNewline, '');
|
|
1411
|
+
} // Normalize newlines
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
if (normalizeNewlines) {
|
|
1415
|
+
v = v.replace(/\r\n|\n|\r/g, function (_) {
|
|
1416
|
+
return newline;
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
return v;
|
|
1421
|
+
});
|
|
1422
|
+
return outdentedStrings;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function concatStringsAndValues(strings, values) {
|
|
1426
|
+
var ret = '';
|
|
1427
|
+
|
|
1428
|
+
for (var i = 0, l = strings.length; i < l; i++) {
|
|
1429
|
+
ret += strings[i];
|
|
1430
|
+
|
|
1431
|
+
if (i < l - 1) {
|
|
1432
|
+
ret += values[i];
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
return ret;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
function isTemplateStringsArray(v) {
|
|
1440
|
+
return has(v, 'raw') && has(v, 'length');
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
|
|
1444
|
+
* makeInstance
|
|
1445
|
+
* @param options
|
|
1446
|
+
* @return {outdent}
|
|
1447
|
+
*/
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
function createInstance(options) {
|
|
1451
|
+
/** Cache of pre-processed template literal arrays */
|
|
1452
|
+
var arrayAutoIndentCache = createWeakMap();
|
|
1453
|
+
/**
|
|
1454
|
+
* Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
|
|
1455
|
+
* before interpolated values are injected.
|
|
1456
|
+
*/
|
|
1457
|
+
|
|
1458
|
+
var arrayFirstInterpSetsIndentCache = createWeakMap();
|
|
1459
|
+
|
|
1460
|
+
function outdent(stringsOrOptions) {
|
|
1461
|
+
var values = [];
|
|
1462
|
+
|
|
1463
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1464
|
+
values[_i - 1] = arguments[_i];
|
|
1465
|
+
}
|
|
1466
|
+
/* tslint:enable:no-shadowed-variable */
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
if (isTemplateStringsArray(stringsOrOptions)) {
|
|
1470
|
+
var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
|
|
1471
|
+
|
|
1472
|
+
var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
|
|
1473
|
+
|
|
1474
|
+
var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
|
|
1475
|
+
var renderedArray = cache.get(strings);
|
|
1476
|
+
|
|
1477
|
+
if (!renderedArray) {
|
|
1478
|
+
renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
|
|
1479
|
+
cache.set(strings, renderedArray);
|
|
1480
|
+
}
|
|
1481
|
+
/** If no interpolated values, skip concatenation step */
|
|
343
1482
|
|
|
344
|
-
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
|
|
345
1483
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
1484
|
+
if (values.length === 0) {
|
|
1485
|
+
return renderedArray[0];
|
|
1486
|
+
}
|
|
1487
|
+
/** Concatenate string literals with interpolated values */
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
|
|
1491
|
+
return rendered;
|
|
1492
|
+
} else {
|
|
1493
|
+
// Create and return a new instance of outdent with the given options
|
|
1494
|
+
return createInstance(extend(extend({}, options), stringsOrOptions || {}));
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
var fullOutdent = extend(outdent, {
|
|
1499
|
+
string: function string(str) {
|
|
1500
|
+
return _outdentArray([str], false, options)[0];
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
return fullOutdent;
|
|
349
1504
|
}
|
|
350
1505
|
|
|
351
|
-
|
|
1506
|
+
var defaultOutdent = createInstance({
|
|
1507
|
+
trimLeadingNewline: true,
|
|
1508
|
+
trimTrailingNewline: true
|
|
1509
|
+
});
|
|
1510
|
+
exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
|
|
1511
|
+
// import outdent from 'outdent';
|
|
1512
|
+
|
|
1513
|
+
exports.default = defaultOutdent;
|
|
1514
|
+
|
|
1515
|
+
{
|
|
1516
|
+
// In webpack harmony-modules environments, module.exports is read-only,
|
|
1517
|
+
// so we fail gracefully.
|
|
1518
|
+
try {
|
|
1519
|
+
module.exports = defaultOutdent;
|
|
1520
|
+
Object.defineProperty(defaultOutdent, '__esModule', {
|
|
1521
|
+
value: true
|
|
1522
|
+
});
|
|
1523
|
+
defaultOutdent.default = defaultOutdent;
|
|
1524
|
+
defaultOutdent.outdent = defaultOutdent;
|
|
1525
|
+
} catch (e) {}
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
function _templateObject6() {
|
|
1530
|
+
const data = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]);
|
|
1531
|
+
|
|
1532
|
+
_templateObject6 = function _templateObject6() {
|
|
1533
|
+
return data;
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
return data;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function _templateObject5() {
|
|
1540
|
+
const data = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
|
|
1541
|
+
|
|
1542
|
+
_templateObject5 = function _templateObject5() {
|
|
1543
|
+
return data;
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
return data;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function _templateObject4() {
|
|
1550
|
+
const data = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
|
|
1551
|
+
|
|
1552
|
+
_templateObject4 = function _templateObject4() {
|
|
1553
|
+
return data;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
return data;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
function _templateObject3() {
|
|
1560
|
+
const data = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]);
|
|
1561
|
+
|
|
1562
|
+
_templateObject3 = function _templateObject3() {
|
|
1563
|
+
return data;
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
return data;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function _templateObject2() {
|
|
1570
|
+
const data = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "]);
|
|
1571
|
+
|
|
1572
|
+
_templateObject2 = function _templateObject2() {
|
|
1573
|
+
return data;
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
return data;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
function _templateObject() {
|
|
1580
|
+
const data = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]);
|
|
1581
|
+
|
|
1582
|
+
_templateObject = function _templateObject() {
|
|
1583
|
+
return data;
|
|
1584
|
+
};
|
|
1585
|
+
|
|
1586
|
+
return data;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const {
|
|
1590
|
+
outdent
|
|
1591
|
+
} = lib;
|
|
1592
|
+
const CATEGORY_CONFIG = "Config";
|
|
1593
|
+
const CATEGORY_EDITOR = "Editor";
|
|
1594
|
+
const CATEGORY_FORMAT = "Format";
|
|
1595
|
+
const CATEGORY_OTHER = "Other";
|
|
1596
|
+
const CATEGORY_OUTPUT = "Output";
|
|
1597
|
+
const CATEGORY_GLOBAL = "Global";
|
|
1598
|
+
const CATEGORY_SPECIAL = "Special";
|
|
1599
|
+
/**
|
|
1600
|
+
* @typedef {Object} OptionInfo
|
|
1601
|
+
* @property {string} [since] - available since version
|
|
1602
|
+
* @property {string} category
|
|
1603
|
+
* @property {'int' | 'boolean' | 'choice' | 'path'} type
|
|
1604
|
+
* @property {boolean} [array] - indicate it's an array of the specified type
|
|
1605
|
+
* @property {OptionValueInfo} [default]
|
|
1606
|
+
* @property {OptionRangeInfo} [range] - for type int
|
|
1607
|
+
* @property {string} description
|
|
1608
|
+
* @property {string} [deprecated] - deprecated since version
|
|
1609
|
+
* @property {OptionRedirectInfo} [redirect] - redirect deprecated option
|
|
1610
|
+
* @property {(value: any) => boolean} [exception]
|
|
1611
|
+
* @property {OptionChoiceInfo[]} [choices] - for type choice
|
|
1612
|
+
* @property {string} [cliName]
|
|
1613
|
+
* @property {string} [cliCategory]
|
|
1614
|
+
* @property {string} [cliDescription]
|
|
1615
|
+
*
|
|
1616
|
+
* @typedef {number | boolean | string} OptionValue
|
|
1617
|
+
* @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
|
|
1618
|
+
*
|
|
1619
|
+
* @typedef {Object} OptionRedirectInfo
|
|
1620
|
+
* @property {string} option
|
|
1621
|
+
* @property {OptionValue} value
|
|
1622
|
+
*
|
|
1623
|
+
* @typedef {Object} OptionRangeInfo
|
|
1624
|
+
* @property {number} start - recommended range start
|
|
1625
|
+
* @property {number} end - recommended range end
|
|
1626
|
+
* @property {number} step - recommended range step
|
|
1627
|
+
*
|
|
1628
|
+
* @typedef {Object} OptionChoiceInfo
|
|
1629
|
+
* @property {boolean | string} value - boolean for the option that is originally boolean type
|
|
1630
|
+
* @property {string} description
|
|
1631
|
+
* @property {string} [since] - undefined if available since the first version of the option
|
|
1632
|
+
* @property {string} [deprecated] - deprecated since version
|
|
1633
|
+
* @property {OptionValueInfo} [redirect] - redirect deprecated value
|
|
1634
|
+
*/
|
|
1635
|
+
|
|
1636
|
+
/** @type {{ [name: string]: OptionInfo }} */
|
|
1637
|
+
|
|
1638
|
+
const options = {
|
|
1639
|
+
cursorOffset: {
|
|
1640
|
+
since: "1.4.0",
|
|
1641
|
+
category: CATEGORY_SPECIAL,
|
|
1642
|
+
type: "int",
|
|
1643
|
+
default: -1,
|
|
1644
|
+
range: {
|
|
1645
|
+
start: -1,
|
|
1646
|
+
end: Infinity,
|
|
1647
|
+
step: 1
|
|
1648
|
+
},
|
|
1649
|
+
description: outdent(_templateObject()),
|
|
1650
|
+
cliCategory: CATEGORY_EDITOR
|
|
1651
|
+
},
|
|
1652
|
+
endOfLine: {
|
|
1653
|
+
since: "1.15.0",
|
|
1654
|
+
category: CATEGORY_GLOBAL,
|
|
1655
|
+
type: "choice",
|
|
1656
|
+
default: [{
|
|
1657
|
+
since: "1.15.0",
|
|
1658
|
+
value: "auto"
|
|
1659
|
+
}, {
|
|
1660
|
+
since: "2.0.0",
|
|
1661
|
+
value: "lf"
|
|
1662
|
+
}],
|
|
1663
|
+
description: "Which end of line characters to apply.",
|
|
1664
|
+
choices: [{
|
|
1665
|
+
value: "lf",
|
|
1666
|
+
description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
|
|
1667
|
+
}, {
|
|
1668
|
+
value: "crlf",
|
|
1669
|
+
description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
|
|
1670
|
+
}, {
|
|
1671
|
+
value: "cr",
|
|
1672
|
+
description: "Carriage Return character only (\\r), used very rarely"
|
|
1673
|
+
}, {
|
|
1674
|
+
value: "auto",
|
|
1675
|
+
description: outdent(_templateObject2())
|
|
1676
|
+
}]
|
|
1677
|
+
},
|
|
1678
|
+
filepath: {
|
|
1679
|
+
since: "1.4.0",
|
|
1680
|
+
category: CATEGORY_SPECIAL,
|
|
1681
|
+
type: "path",
|
|
1682
|
+
description: "Specify the input filepath. This will be used to do parser inference.",
|
|
1683
|
+
cliName: "stdin-filepath",
|
|
1684
|
+
cliCategory: CATEGORY_OTHER,
|
|
1685
|
+
cliDescription: "Path to the file to pretend that stdin comes from."
|
|
1686
|
+
},
|
|
1687
|
+
insertPragma: {
|
|
1688
|
+
since: "1.8.0",
|
|
1689
|
+
category: CATEGORY_SPECIAL,
|
|
1690
|
+
type: "boolean",
|
|
1691
|
+
default: false,
|
|
1692
|
+
description: "Insert @format pragma into file's first docblock comment.",
|
|
1693
|
+
cliCategory: CATEGORY_OTHER
|
|
1694
|
+
},
|
|
1695
|
+
parser: {
|
|
1696
|
+
since: "0.0.10",
|
|
1697
|
+
category: CATEGORY_GLOBAL,
|
|
1698
|
+
type: "choice",
|
|
1699
|
+
default: [{
|
|
1700
|
+
since: "0.0.10",
|
|
1701
|
+
value: "babylon"
|
|
1702
|
+
}, {
|
|
1703
|
+
since: "1.13.0",
|
|
1704
|
+
value: undefined
|
|
1705
|
+
}],
|
|
1706
|
+
description: "Which parser to use.",
|
|
1707
|
+
exception: value => typeof value === "string" || typeof value === "function",
|
|
1708
|
+
choices: [{
|
|
1709
|
+
value: "flow",
|
|
1710
|
+
description: "Flow"
|
|
1711
|
+
}, {
|
|
1712
|
+
value: "babel",
|
|
1713
|
+
since: "1.16.0",
|
|
1714
|
+
description: "JavaScript"
|
|
1715
|
+
}, {
|
|
1716
|
+
value: "babel-flow",
|
|
1717
|
+
since: "1.16.0",
|
|
1718
|
+
description: "Flow"
|
|
1719
|
+
}, {
|
|
1720
|
+
value: "babel-ts",
|
|
1721
|
+
since: "2.0.0",
|
|
1722
|
+
description: "TypeScript"
|
|
1723
|
+
}, {
|
|
1724
|
+
value: "typescript",
|
|
1725
|
+
since: "1.4.0",
|
|
1726
|
+
description: "TypeScript"
|
|
1727
|
+
}, {
|
|
1728
|
+
value: "css",
|
|
1729
|
+
since: "1.7.1",
|
|
1730
|
+
description: "CSS"
|
|
1731
|
+
}, {
|
|
1732
|
+
value: "less",
|
|
1733
|
+
since: "1.7.1",
|
|
1734
|
+
description: "Less"
|
|
1735
|
+
}, {
|
|
1736
|
+
value: "scss",
|
|
1737
|
+
since: "1.7.1",
|
|
1738
|
+
description: "SCSS"
|
|
1739
|
+
}, {
|
|
1740
|
+
value: "json",
|
|
1741
|
+
since: "1.5.0",
|
|
1742
|
+
description: "JSON"
|
|
1743
|
+
}, {
|
|
1744
|
+
value: "json5",
|
|
1745
|
+
since: "1.13.0",
|
|
1746
|
+
description: "JSON5"
|
|
1747
|
+
}, {
|
|
1748
|
+
value: "json-stringify",
|
|
1749
|
+
since: "1.13.0",
|
|
1750
|
+
description: "JSON.stringify"
|
|
1751
|
+
}, {
|
|
1752
|
+
value: "graphql",
|
|
1753
|
+
since: "1.5.0",
|
|
1754
|
+
description: "GraphQL"
|
|
1755
|
+
}, {
|
|
1756
|
+
value: "markdown",
|
|
1757
|
+
since: "1.8.0",
|
|
1758
|
+
description: "Markdown"
|
|
1759
|
+
}, {
|
|
1760
|
+
value: "mdx",
|
|
1761
|
+
since: "1.15.0",
|
|
1762
|
+
description: "MDX"
|
|
1763
|
+
}, {
|
|
1764
|
+
value: "vue",
|
|
1765
|
+
since: "1.10.0",
|
|
1766
|
+
description: "Vue"
|
|
1767
|
+
}, {
|
|
1768
|
+
value: "yaml",
|
|
1769
|
+
since: "1.14.0",
|
|
1770
|
+
description: "YAML"
|
|
1771
|
+
}, {
|
|
1772
|
+
value: "glimmer",
|
|
1773
|
+
since: null,
|
|
1774
|
+
description: "Handlebars"
|
|
1775
|
+
}, {
|
|
1776
|
+
value: "html",
|
|
1777
|
+
since: "1.15.0",
|
|
1778
|
+
description: "HTML"
|
|
1779
|
+
}, {
|
|
1780
|
+
value: "angular",
|
|
1781
|
+
since: "1.15.0",
|
|
1782
|
+
description: "Angular"
|
|
1783
|
+
}, {
|
|
1784
|
+
value: "lwc",
|
|
1785
|
+
since: "1.17.0",
|
|
1786
|
+
description: "Lightning Web Components"
|
|
1787
|
+
}]
|
|
1788
|
+
},
|
|
1789
|
+
plugins: {
|
|
1790
|
+
since: "1.10.0",
|
|
1791
|
+
type: "path",
|
|
1792
|
+
array: true,
|
|
1793
|
+
default: [{
|
|
1794
|
+
value: []
|
|
1795
|
+
}],
|
|
1796
|
+
category: CATEGORY_GLOBAL,
|
|
1797
|
+
description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
|
|
1798
|
+
exception: value => typeof value === "string" || typeof value === "object",
|
|
1799
|
+
cliName: "plugin",
|
|
1800
|
+
cliCategory: CATEGORY_CONFIG
|
|
1801
|
+
},
|
|
1802
|
+
pluginSearchDirs: {
|
|
1803
|
+
since: "1.13.0",
|
|
1804
|
+
type: "path",
|
|
1805
|
+
array: true,
|
|
1806
|
+
default: [{
|
|
1807
|
+
value: []
|
|
1808
|
+
}],
|
|
1809
|
+
category: CATEGORY_GLOBAL,
|
|
1810
|
+
description: outdent(_templateObject3()),
|
|
1811
|
+
exception: value => typeof value === "string" || typeof value === "object",
|
|
1812
|
+
cliName: "plugin-search-dir",
|
|
1813
|
+
cliCategory: CATEGORY_CONFIG
|
|
1814
|
+
},
|
|
1815
|
+
printWidth: {
|
|
1816
|
+
since: "0.0.0",
|
|
1817
|
+
category: CATEGORY_GLOBAL,
|
|
1818
|
+
type: "int",
|
|
1819
|
+
default: 80,
|
|
1820
|
+
description: "The line length where Prettier will try wrap.",
|
|
1821
|
+
range: {
|
|
1822
|
+
start: 0,
|
|
1823
|
+
end: Infinity,
|
|
1824
|
+
step: 1
|
|
1825
|
+
}
|
|
1826
|
+
},
|
|
1827
|
+
rangeEnd: {
|
|
1828
|
+
since: "1.4.0",
|
|
1829
|
+
category: CATEGORY_SPECIAL,
|
|
1830
|
+
type: "int",
|
|
1831
|
+
default: Infinity,
|
|
1832
|
+
range: {
|
|
1833
|
+
start: 0,
|
|
1834
|
+
end: Infinity,
|
|
1835
|
+
step: 1
|
|
1836
|
+
},
|
|
1837
|
+
description: outdent(_templateObject4()),
|
|
1838
|
+
cliCategory: CATEGORY_EDITOR
|
|
1839
|
+
},
|
|
1840
|
+
rangeStart: {
|
|
1841
|
+
since: "1.4.0",
|
|
1842
|
+
category: CATEGORY_SPECIAL,
|
|
1843
|
+
type: "int",
|
|
1844
|
+
default: 0,
|
|
1845
|
+
range: {
|
|
1846
|
+
start: 0,
|
|
1847
|
+
end: Infinity,
|
|
1848
|
+
step: 1
|
|
1849
|
+
},
|
|
1850
|
+
description: outdent(_templateObject5()),
|
|
1851
|
+
cliCategory: CATEGORY_EDITOR
|
|
1852
|
+
},
|
|
1853
|
+
requirePragma: {
|
|
1854
|
+
since: "1.7.0",
|
|
1855
|
+
category: CATEGORY_SPECIAL,
|
|
1856
|
+
type: "boolean",
|
|
1857
|
+
default: false,
|
|
1858
|
+
description: outdent(_templateObject6()),
|
|
1859
|
+
cliCategory: CATEGORY_OTHER
|
|
1860
|
+
},
|
|
1861
|
+
tabWidth: {
|
|
1862
|
+
type: "int",
|
|
1863
|
+
category: CATEGORY_GLOBAL,
|
|
1864
|
+
default: 2,
|
|
1865
|
+
description: "Number of spaces per indentation level.",
|
|
1866
|
+
range: {
|
|
1867
|
+
start: 0,
|
|
1868
|
+
end: Infinity,
|
|
1869
|
+
step: 1
|
|
1870
|
+
}
|
|
1871
|
+
},
|
|
1872
|
+
useTabs: {
|
|
1873
|
+
since: "1.0.0",
|
|
1874
|
+
category: CATEGORY_GLOBAL,
|
|
1875
|
+
type: "boolean",
|
|
1876
|
+
default: false,
|
|
1877
|
+
description: "Indent with tabs instead of spaces."
|
|
1878
|
+
},
|
|
1879
|
+
embeddedLanguageFormatting: {
|
|
1880
|
+
since: "2.1.0",
|
|
1881
|
+
category: CATEGORY_GLOBAL,
|
|
1882
|
+
type: "choice",
|
|
1883
|
+
default: [{
|
|
1884
|
+
since: "2.1.0",
|
|
1885
|
+
value: "auto"
|
|
1886
|
+
}],
|
|
1887
|
+
description: "Control how Prettier formats quoted code embedded in the file.",
|
|
1888
|
+
choices: [{
|
|
1889
|
+
value: "auto",
|
|
1890
|
+
description: "Format embedded code if Prettier can automatically identify it."
|
|
1891
|
+
}, {
|
|
1892
|
+
value: "off",
|
|
1893
|
+
description: "Never automatically format embedded code."
|
|
1894
|
+
}]
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
var coreOptions = {
|
|
1898
|
+
CATEGORY_CONFIG,
|
|
1899
|
+
CATEGORY_EDITOR,
|
|
1900
|
+
CATEGORY_FORMAT,
|
|
1901
|
+
CATEGORY_OTHER,
|
|
1902
|
+
CATEGORY_OUTPUT,
|
|
1903
|
+
CATEGORY_GLOBAL,
|
|
1904
|
+
CATEGORY_SPECIAL,
|
|
1905
|
+
options
|
|
352
1906
|
};
|
|
353
1907
|
|
|
354
|
-
var
|
|
1908
|
+
var require$$3 = getCjsExportFromNamespace(_package$1);
|
|
355
1909
|
|
|
356
|
-
const
|
|
1910
|
+
const semver$1 = {
|
|
1911
|
+
compare: compare_1,
|
|
1912
|
+
lt: lt_1,
|
|
1913
|
+
gte: gte_1
|
|
1914
|
+
};
|
|
1915
|
+
const currentVersion = require$$3.version;
|
|
1916
|
+
const coreOptions$1 = coreOptions.options;
|
|
1917
|
+
/**
|
|
1918
|
+
* Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
|
|
1919
|
+
* of this function created by `withPlugins`. Don't pass them here directly.
|
|
1920
|
+
* @param {object} param0
|
|
1921
|
+
* @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
|
|
1922
|
+
* @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
|
|
1923
|
+
* @param {boolean=} param0.showUnreleased
|
|
1924
|
+
* @param {boolean=} param0.showDeprecated
|
|
1925
|
+
* @param {boolean=} param0.showInternal
|
|
1926
|
+
*/
|
|
1927
|
+
|
|
1928
|
+
function getSupportInfo({
|
|
1929
|
+
plugins = [],
|
|
1930
|
+
showUnreleased = false,
|
|
1931
|
+
showDeprecated = false,
|
|
1932
|
+
showInternal = false
|
|
1933
|
+
} = {}) {
|
|
1934
|
+
// pre-release version is smaller than the normal version in semver,
|
|
1935
|
+
// we need to treat it as the normal one so as to test new features.
|
|
1936
|
+
const version = currentVersion.split("-", 1)[0];
|
|
1937
|
+
const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince);
|
|
1938
|
+
const options = arrayify(Object.assign({}, ...plugins.map(({
|
|
1939
|
+
options
|
|
1940
|
+
}) => options), coreOptions$1), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
|
|
1941
|
+
option = Object.assign({}, option);
|
|
1942
|
+
|
|
1943
|
+
if (Array.isArray(option.default)) {
|
|
1944
|
+
option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
if (Array.isArray(option.choices)) {
|
|
1948
|
+
option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
|
|
1949
|
+
|
|
1950
|
+
if (option.name === "parser") {
|
|
1951
|
+
collectParsersFromLanguages(option, languages, plugins);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
const pluginDefaults = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).reduce((reduced, plugin) => {
|
|
1956
|
+
reduced[plugin.name] = plugin.defaultOptions[option.name];
|
|
1957
|
+
return reduced;
|
|
1958
|
+
}, {});
|
|
1959
|
+
return Object.assign({}, option, {
|
|
1960
|
+
pluginDefaults
|
|
1961
|
+
});
|
|
1962
|
+
});
|
|
1963
|
+
return {
|
|
1964
|
+
languages,
|
|
1965
|
+
options
|
|
1966
|
+
};
|
|
357
1967
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return arr[arr.length - 2];
|
|
1968
|
+
function filterSince(object) {
|
|
1969
|
+
return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since);
|
|
361
1970
|
}
|
|
362
1971
|
|
|
363
|
-
|
|
1972
|
+
function filterDeprecated(object) {
|
|
1973
|
+
return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated);
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
function mapInternal(object) {
|
|
1977
|
+
if (showInternal) {
|
|
1978
|
+
return object;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]);
|
|
1982
|
+
|
|
1983
|
+
return newObject;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
function collectParsersFromLanguages(option, languages, plugins) {
|
|
1988
|
+
const existingValues = new Set(option.choices.map(choice => choice.value));
|
|
1989
|
+
|
|
1990
|
+
for (const language of languages) {
|
|
1991
|
+
if (language.parsers) {
|
|
1992
|
+
for (const value of language.parsers) {
|
|
1993
|
+
if (!existingValues.has(value)) {
|
|
1994
|
+
existingValues.add(value);
|
|
1995
|
+
const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
|
|
1996
|
+
let description = language.name;
|
|
1997
|
+
|
|
1998
|
+
if (plugin && plugin.name) {
|
|
1999
|
+
description += " (plugin: ".concat(plugin.name, ")");
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
option.choices.push({
|
|
2003
|
+
value,
|
|
2004
|
+
description
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
364
2010
|
}
|
|
2011
|
+
|
|
2012
|
+
var support = {
|
|
2013
|
+
getSupportInfo
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
const notAsciiRegex = /[^\x20-\x7F]/;
|
|
2017
|
+
|
|
2018
|
+
const getPenultimate = arr => arr[arr.length - 2];
|
|
365
2019
|
/**
|
|
366
2020
|
* @typedef {{backwards?: boolean}} SkipOptions
|
|
367
2021
|
*/
|
|
@@ -377,6 +2031,8 @@
|
|
|
377
2031
|
const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
378
2032
|
// to check for failures (did someone say monads?).
|
|
379
2033
|
|
|
2034
|
+
/* istanbul ignore next */
|
|
2035
|
+
|
|
380
2036
|
if (index === false) {
|
|
381
2037
|
return false;
|
|
382
2038
|
}
|
|
@@ -431,7 +2087,7 @@
|
|
|
431
2087
|
* @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
|
|
432
2088
|
*/
|
|
433
2089
|
|
|
434
|
-
const skipEverythingButNewLine = skip(/[^\r
|
|
2090
|
+
const skipEverythingButNewLine = skip(/[^\n\r]/);
|
|
435
2091
|
/**
|
|
436
2092
|
* @param {string} text
|
|
437
2093
|
* @param {number | false} index
|
|
@@ -439,6 +2095,7 @@
|
|
|
439
2095
|
*/
|
|
440
2096
|
|
|
441
2097
|
function skipInlineComment(text, index) {
|
|
2098
|
+
/* istanbul ignore next */
|
|
442
2099
|
if (index === false) {
|
|
443
2100
|
return false;
|
|
444
2101
|
}
|
|
@@ -461,6 +2118,7 @@
|
|
|
461
2118
|
|
|
462
2119
|
|
|
463
2120
|
function skipTrailingComment(text, index) {
|
|
2121
|
+
/* istanbul ignore next */
|
|
464
2122
|
if (index === false) {
|
|
465
2123
|
return false;
|
|
466
2124
|
}
|
|
@@ -492,6 +2150,9 @@
|
|
|
492
2150
|
const atIndex = text.charAt(index);
|
|
493
2151
|
|
|
494
2152
|
if (backwards) {
|
|
2153
|
+
// We already replace `\r\n` with `\n` before parsing
|
|
2154
|
+
|
|
2155
|
+
/* istanbul ignore next */
|
|
495
2156
|
if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
|
|
496
2157
|
return index - 2;
|
|
497
2158
|
}
|
|
@@ -500,6 +2161,9 @@
|
|
|
500
2161
|
return index - 1;
|
|
501
2162
|
}
|
|
502
2163
|
} else {
|
|
2164
|
+
// We already replace `\r\n` with `\n` before parsing
|
|
2165
|
+
|
|
2166
|
+
/* istanbul ignore next */
|
|
503
2167
|
if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
|
|
504
2168
|
return index + 2;
|
|
505
2169
|
}
|
|
@@ -654,7 +2318,10 @@
|
|
|
654
2318
|
function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
|
|
655
2319
|
return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback?
|
|
656
2320
|
getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
|
|
657
|
-
}
|
|
2321
|
+
} // Not using, but it's public utils
|
|
2322
|
+
|
|
2323
|
+
/* istanbul ignore next */
|
|
2324
|
+
|
|
658
2325
|
/**
|
|
659
2326
|
* @param {string} text
|
|
660
2327
|
* @param {number} index
|
|
@@ -668,163 +2335,6 @@
|
|
|
668
2335
|
const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
|
|
669
2336
|
return idx !== index;
|
|
670
2337
|
}
|
|
671
|
-
/**
|
|
672
|
-
* @param {{range?: [number, number], start?: number}} node
|
|
673
|
-
* @param {number} index
|
|
674
|
-
*/
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
function setLocStart(node, index) {
|
|
678
|
-
if (node.range) {
|
|
679
|
-
node.range[0] = index;
|
|
680
|
-
} else {
|
|
681
|
-
node.start = index;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* @param {{range?: [number, number], end?: number}} node
|
|
686
|
-
* @param {number} index
|
|
687
|
-
*/
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
function setLocEnd(node, index) {
|
|
691
|
-
if (node.range) {
|
|
692
|
-
node.range[1] = index;
|
|
693
|
-
} else {
|
|
694
|
-
node.end = index;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
const PRECEDENCE = {};
|
|
699
|
-
[["|>"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach((tier, i) => {
|
|
700
|
-
tier.forEach(op => {
|
|
701
|
-
PRECEDENCE[op] = i;
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
function getPrecedence(op) {
|
|
706
|
-
return PRECEDENCE[op];
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
const equalityOperators = {
|
|
710
|
-
"==": true,
|
|
711
|
-
"!=": true,
|
|
712
|
-
"===": true,
|
|
713
|
-
"!==": true
|
|
714
|
-
};
|
|
715
|
-
const multiplicativeOperators = {
|
|
716
|
-
"*": true,
|
|
717
|
-
"/": true,
|
|
718
|
-
"%": true
|
|
719
|
-
};
|
|
720
|
-
const bitshiftOperators = {
|
|
721
|
-
">>": true,
|
|
722
|
-
">>>": true,
|
|
723
|
-
"<<": true
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
function shouldFlatten(parentOp, nodeOp) {
|
|
727
|
-
if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
|
|
728
|
-
return false;
|
|
729
|
-
} // ** is right-associative
|
|
730
|
-
// x ** y ** z --> x ** (y ** z)
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (parentOp === "**") {
|
|
734
|
-
return false;
|
|
735
|
-
} // x == y == z --> (x == y) == z
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
|
|
739
|
-
return false;
|
|
740
|
-
} // x * y % z --> (x * y) % z
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
|
|
744
|
-
return false;
|
|
745
|
-
} // x * y / z --> (x * y) / z
|
|
746
|
-
// x / y * z --> (x / y) * z
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
|
|
750
|
-
return false;
|
|
751
|
-
} // x << y << z --> (x << y) << z
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
return true;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
function isBitwiseOperator(operator) {
|
|
762
|
-
return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
|
|
763
|
-
} // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
|
|
764
|
-
// holds) `function`, `class`, or `do {}`. Will be overzealous if there's
|
|
765
|
-
// already necessary grouping parentheses.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
|
|
769
|
-
node = getLeftMost(node);
|
|
770
|
-
|
|
771
|
-
switch (node.type) {
|
|
772
|
-
case "FunctionExpression":
|
|
773
|
-
case "ClassExpression":
|
|
774
|
-
case "DoExpression":
|
|
775
|
-
return forbidFunctionClassAndDoExpr;
|
|
776
|
-
|
|
777
|
-
case "ObjectExpression":
|
|
778
|
-
return true;
|
|
779
|
-
|
|
780
|
-
case "MemberExpression":
|
|
781
|
-
case "OptionalMemberExpression":
|
|
782
|
-
return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
|
|
783
|
-
|
|
784
|
-
case "TaggedTemplateExpression":
|
|
785
|
-
if (node.tag.type === "FunctionExpression") {
|
|
786
|
-
// IIFEs are always already parenthesized
|
|
787
|
-
return false;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
|
|
791
|
-
|
|
792
|
-
case "CallExpression":
|
|
793
|
-
case "OptionalCallExpression":
|
|
794
|
-
if (node.callee.type === "FunctionExpression") {
|
|
795
|
-
// IIFEs are always already parenthesized
|
|
796
|
-
return false;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
|
|
800
|
-
|
|
801
|
-
case "ConditionalExpression":
|
|
802
|
-
return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
|
|
803
|
-
|
|
804
|
-
case "UpdateExpression":
|
|
805
|
-
return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
|
|
806
|
-
|
|
807
|
-
case "BindExpression":
|
|
808
|
-
return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
|
|
809
|
-
|
|
810
|
-
case "SequenceExpression":
|
|
811
|
-
return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
|
|
812
|
-
|
|
813
|
-
case "TSAsExpression":
|
|
814
|
-
return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
|
|
815
|
-
|
|
816
|
-
default:
|
|
817
|
-
return false;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
function getLeftMost(node) {
|
|
822
|
-
if (node.left) {
|
|
823
|
-
return getLeftMost(node.left);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
return node;
|
|
827
|
-
}
|
|
828
2338
|
/**
|
|
829
2339
|
* @param {string} value
|
|
830
2340
|
* @param {number} tabWidth
|
|
@@ -866,7 +2376,7 @@
|
|
|
866
2376
|
}
|
|
867
2377
|
|
|
868
2378
|
return getAlignmentSize( // All the leading whitespaces
|
|
869
|
-
value.slice(lastNewlineIndex + 1).match(/^[
|
|
2379
|
+
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
|
|
870
2380
|
}
|
|
871
2381
|
/**
|
|
872
2382
|
* @typedef {'"' | "'"} Quote
|
|
@@ -950,7 +2460,7 @@
|
|
|
950
2460
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
951
2461
|
const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
|
|
952
2462
|
|
|
953
|
-
const regex = /\\([\s
|
|
2463
|
+
const regex = /\\([\S\s])|(["'])/g; // Escape and unescape single and double quotes as needed to be able to
|
|
954
2464
|
// enclose `rawContent` with `enclosingQuote`.
|
|
955
2465
|
|
|
956
2466
|
const newContent = rawContent.replace(regex, (match, escaped, quote) => {
|
|
@@ -974,7 +2484,7 @@
|
|
|
974
2484
|
// Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
|
|
975
2485
|
|
|
976
2486
|
|
|
977
|
-
return unescapeUnnecessaryEscapes && /^[
|
|
2487
|
+
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
|
|
978
2488
|
});
|
|
979
2489
|
return enclosingQuote + newContent + enclosingQuote;
|
|
980
2490
|
}
|
|
@@ -1070,6 +2580,8 @@
|
|
|
1070
2580
|
// We already "print" it via the raw text, we don't need to re-print it as a
|
|
1071
2581
|
// comment
|
|
1072
2582
|
|
|
2583
|
+
/* istanbul ignore next */
|
|
2584
|
+
|
|
1073
2585
|
if (node.type === "JSXText") {
|
|
1074
2586
|
comment.printed = true;
|
|
1075
2587
|
}
|
|
@@ -1081,9 +2593,14 @@
|
|
|
1081
2593
|
addCommentHelper(node, comment);
|
|
1082
2594
|
}
|
|
1083
2595
|
|
|
1084
|
-
function addDanglingComment(node, comment) {
|
|
2596
|
+
function addDanglingComment(node, comment, marker) {
|
|
1085
2597
|
comment.leading = false;
|
|
1086
2598
|
comment.trailing = false;
|
|
2599
|
+
|
|
2600
|
+
if (marker) {
|
|
2601
|
+
comment.marker = marker;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
1087
2604
|
addCommentHelper(node, comment);
|
|
1088
2605
|
}
|
|
1089
2606
|
|
|
@@ -1091,7 +2608,10 @@
|
|
|
1091
2608
|
comment.leading = false;
|
|
1092
2609
|
comment.trailing = true;
|
|
1093
2610
|
addCommentHelper(node, comment);
|
|
1094
|
-
}
|
|
2611
|
+
} // Not using
|
|
2612
|
+
|
|
2613
|
+
/* istanbul ignore next */
|
|
2614
|
+
|
|
1095
2615
|
|
|
1096
2616
|
function isWithinParentArrayProperty(path, propertyName) {
|
|
1097
2617
|
const node = path.getValue();
|
|
@@ -1123,14 +2643,43 @@
|
|
|
1123
2643
|
return parts;
|
|
1124
2644
|
}
|
|
1125
2645
|
|
|
2646
|
+
function getParserName(lang, options) {
|
|
2647
|
+
const supportInfo = support.getSupportInfo({
|
|
2648
|
+
plugins: options.plugins
|
|
2649
|
+
});
|
|
2650
|
+
const language = supportInfo.languages.find(language => language.name.toLowerCase() === lang || language.aliases && language.aliases.includes(lang) || language.extensions && language.extensions.some(ext => ext === ".".concat(lang)));
|
|
2651
|
+
|
|
2652
|
+
if (language) {
|
|
2653
|
+
return language.parsers[0];
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
return null;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
function isFrontMatterNode(node) {
|
|
2660
|
+
return node && node.type === "front-matter";
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
function getShebang(text) {
|
|
2664
|
+
if (!text.startsWith("#!")) {
|
|
2665
|
+
return "";
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
const index = text.indexOf("\n");
|
|
2669
|
+
|
|
2670
|
+
if (index === -1) {
|
|
2671
|
+
return text;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
return text.slice(0, index);
|
|
2675
|
+
}
|
|
2676
|
+
|
|
1126
2677
|
var util = {
|
|
1127
2678
|
replaceEndOfLineWith,
|
|
1128
2679
|
getStringWidth,
|
|
1129
2680
|
getMaxContinuousCount,
|
|
1130
2681
|
getMinNotPresentContinuousCount,
|
|
1131
|
-
|
|
1132
|
-
shouldFlatten,
|
|
1133
|
-
isBitwiseOperator,
|
|
2682
|
+
getParserName,
|
|
1134
2683
|
getPenultimate,
|
|
1135
2684
|
getLast,
|
|
1136
2685
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
@@ -1150,9 +2699,6 @@
|
|
|
1150
2699
|
hasNewline,
|
|
1151
2700
|
hasNewlineInRange,
|
|
1152
2701
|
hasSpaces,
|
|
1153
|
-
setLocStart,
|
|
1154
|
-
setLocEnd,
|
|
1155
|
-
startsWithNoLookaheadToken,
|
|
1156
2702
|
getAlignmentSize,
|
|
1157
2703
|
getIndentSize,
|
|
1158
2704
|
getPreferredQuote,
|
|
@@ -1165,7 +2711,9 @@
|
|
|
1165
2711
|
addLeadingComment,
|
|
1166
2712
|
addDanglingComment,
|
|
1167
2713
|
addTrailingComment,
|
|
1168
|
-
isWithinParentArrayProperty
|
|
2714
|
+
isWithinParentArrayProperty,
|
|
2715
|
+
isFrontMatterNode,
|
|
2716
|
+
getShebang
|
|
1169
2717
|
};
|
|
1170
2718
|
|
|
1171
2719
|
function guessEndOfLine(text) {
|
|
@@ -1191,9 +2739,33 @@
|
|
|
1191
2739
|
}
|
|
1192
2740
|
}
|
|
1193
2741
|
|
|
2742
|
+
function countEndOfLineChars(text, eol) {
|
|
2743
|
+
let regex;
|
|
2744
|
+
/* istanbul ignore else */
|
|
2745
|
+
|
|
2746
|
+
if (eol === "\n") {
|
|
2747
|
+
regex = /\n/g;
|
|
2748
|
+
} else if (eol === "\r") {
|
|
2749
|
+
regex = /\r/g;
|
|
2750
|
+
} else if (eol === "\r\n") {
|
|
2751
|
+
regex = /\r\n/g;
|
|
2752
|
+
} else {
|
|
2753
|
+
throw new Error("Unexpected \"eol\" ".concat(JSON.stringify(eol), "."));
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
const endOfLines = text.match(regex);
|
|
2757
|
+
return endOfLines ? endOfLines.length : 0;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
function normalizeEndOfLine(text) {
|
|
2761
|
+
return text.replace(/\r\n?/g, "\n");
|
|
2762
|
+
}
|
|
2763
|
+
|
|
1194
2764
|
var endOfLine = {
|
|
1195
2765
|
guessEndOfLine,
|
|
1196
|
-
convertEndOfLineToChars
|
|
2766
|
+
convertEndOfLineToChars,
|
|
2767
|
+
countEndOfLineChars,
|
|
2768
|
+
normalizeEndOfLine
|
|
1197
2769
|
};
|
|
1198
2770
|
|
|
1199
2771
|
const {
|
|
@@ -1227,16 +2799,30 @@
|
|
|
1227
2799
|
}, options);
|
|
1228
2800
|
}
|
|
1229
2801
|
|
|
1230
|
-
function makeAlign(
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
2802
|
+
function makeAlign(indent, n, options) {
|
|
2803
|
+
if (n === -Infinity) {
|
|
2804
|
+
return indent.root || rootIndent();
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
if (n < 0) {
|
|
2808
|
+
return generateInd(indent, {
|
|
2809
|
+
type: "dedent"
|
|
2810
|
+
}, options);
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
if (!n) {
|
|
2814
|
+
return indent;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
if (n.type === "root") {
|
|
2818
|
+
return Object.assign({}, indent, {
|
|
2819
|
+
root: indent
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
const alignType = typeof n === "string" ? "stringAlign" : "numberAlign";
|
|
2824
|
+
return generateInd(indent, {
|
|
2825
|
+
type: alignType,
|
|
1240
2826
|
n
|
|
1241
2827
|
}, options);
|
|
1242
2828
|
}
|
|
@@ -1333,12 +2919,12 @@
|
|
|
1333
2919
|
|
|
1334
2920
|
let trimCount = 0; // Trim whitespace at the end of line
|
|
1335
2921
|
|
|
1336
|
-
while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[
|
|
2922
|
+
while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[\t ]*$/)) {
|
|
1337
2923
|
trimCount += out.pop().length;
|
|
1338
2924
|
}
|
|
1339
2925
|
|
|
1340
2926
|
if (out.length && typeof out[out.length - 1] === "string") {
|
|
1341
|
-
const trimmed = out[out.length - 1].replace(/[
|
|
2927
|
+
const trimmed = out[out.length - 1].replace(/[\t ]*$/, "");
|
|
1342
2928
|
trimCount += out[out.length - 1].length - trimmed.length;
|
|
1343
2929
|
out[out.length - 1] = trimmed;
|
|
1344
2930
|
}
|
|
@@ -1774,20 +3360,12 @@
|
|
|
1774
3360
|
continue;
|
|
1775
3361
|
}
|
|
1776
3362
|
|
|
1777
|
-
let shouldRecurse = true;
|
|
1778
|
-
|
|
1779
|
-
if (onEnter) {
|
|
1780
|
-
if (onEnter(doc) === false) {
|
|
1781
|
-
shouldRecurse = false;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
3363
|
if (onExit) {
|
|
1786
|
-
docsStack.push(doc);
|
|
1787
|
-
docsStack.push(traverseDocOnExitStackMarker);
|
|
3364
|
+
docsStack.push(doc, traverseDocOnExitStackMarker);
|
|
1788
3365
|
}
|
|
1789
3366
|
|
|
1790
|
-
if (
|
|
3367
|
+
if ( // Should Recurse
|
|
3368
|
+
!onEnter || onEnter(doc) !== false) {
|
|
1791
3369
|
// When there are multiple parts to process,
|
|
1792
3370
|
// the parts need to be pushed onto the stack in reverse order,
|
|
1793
3371
|
// so that they are processed in the original order
|
|
@@ -1965,16 +3543,34 @@
|
|
|
1965
3543
|
return mapDoc(doc, removeLinesFn);
|
|
1966
3544
|
}
|
|
1967
3545
|
|
|
1968
|
-
function
|
|
3546
|
+
function getInnerParts(doc) {
|
|
3547
|
+
let {
|
|
3548
|
+
parts
|
|
3549
|
+
} = doc;
|
|
3550
|
+
let lastPart; // Avoid a falsy element like ""
|
|
3551
|
+
|
|
3552
|
+
for (let i = doc.parts.length; i > 0 && !lastPart; i--) {
|
|
3553
|
+
lastPart = parts[i - 1];
|
|
3554
|
+
}
|
|
3555
|
+
|
|
3556
|
+
if (lastPart.type === "group") {
|
|
3557
|
+
parts = lastPart.contents.parts;
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
return parts;
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
function stripTrailingHardline(doc, withInnerParts = false) {
|
|
1969
3564
|
// HACK remove ending hardline, original PR: #1984
|
|
1970
3565
|
if (doc.type === "concat" && doc.parts.length !== 0) {
|
|
1971
|
-
const
|
|
3566
|
+
const parts = withInnerParts ? getInnerParts(doc) : doc.parts;
|
|
3567
|
+
const lastPart = parts[parts.length - 1];
|
|
1972
3568
|
|
|
1973
3569
|
if (lastPart.type === "concat") {
|
|
1974
3570
|
if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
|
|
1975
3571
|
return {
|
|
1976
3572
|
type: "concat",
|
|
1977
|
-
parts:
|
|
3573
|
+
parts: parts.slice(0, -1)
|
|
1978
3574
|
};
|
|
1979
3575
|
}
|
|
1980
3576
|
|
|
@@ -1988,6 +3584,45 @@
|
|
|
1988
3584
|
return doc;
|
|
1989
3585
|
}
|
|
1990
3586
|
|
|
3587
|
+
function normalizeParts(parts) {
|
|
3588
|
+
const newParts = [];
|
|
3589
|
+
const restParts = parts.filter(Boolean);
|
|
3590
|
+
|
|
3591
|
+
while (restParts.length !== 0) {
|
|
3592
|
+
const part = restParts.shift();
|
|
3593
|
+
|
|
3594
|
+
if (!part) {
|
|
3595
|
+
continue;
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
if (part.type === "concat") {
|
|
3599
|
+
restParts.unshift(...part.parts);
|
|
3600
|
+
continue;
|
|
3601
|
+
}
|
|
3602
|
+
|
|
3603
|
+
if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
|
|
3604
|
+
newParts[newParts.length - 1] += part;
|
|
3605
|
+
continue;
|
|
3606
|
+
}
|
|
3607
|
+
|
|
3608
|
+
newParts.push(part);
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
return newParts;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
function normalizeDoc(doc) {
|
|
3615
|
+
return mapDoc(doc, currentDoc => {
|
|
3616
|
+
if (!currentDoc.parts) {
|
|
3617
|
+
return currentDoc;
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
return Object.assign({}, currentDoc, {
|
|
3621
|
+
parts: normalizeParts(currentDoc.parts)
|
|
3622
|
+
});
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
|
|
1991
3626
|
var docUtils = {
|
|
1992
3627
|
isEmpty,
|
|
1993
3628
|
willBreak,
|
|
@@ -1997,7 +3632,9 @@
|
|
|
1997
3632
|
mapDoc,
|
|
1998
3633
|
propagateBreaks,
|
|
1999
3634
|
removeLines,
|
|
2000
|
-
stripTrailingHardline
|
|
3635
|
+
stripTrailingHardline,
|
|
3636
|
+
normalizeParts,
|
|
3637
|
+
normalizeDoc
|
|
2001
3638
|
};
|
|
2002
3639
|
|
|
2003
3640
|
function flattenDoc(doc) {
|
|
@@ -2115,23 +3752,18 @@
|
|
|
2115
3752
|
|
|
2116
3753
|
};
|
|
2117
3754
|
|
|
3755
|
+
/**
|
|
3756
|
+
* @typedef {import("./doc-builders").Doc} Doc
|
|
3757
|
+
*/
|
|
3758
|
+
|
|
3759
|
+
|
|
2118
3760
|
var document = {
|
|
2119
3761
|
builders: docBuilders,
|
|
2120
3762
|
printer: docPrinter,
|
|
2121
3763
|
utils: docUtils,
|
|
2122
3764
|
debug: docDebug
|
|
2123
3765
|
};
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
var document_3 = document.utils;
|
|
2127
|
-
var document_4 = document.debug;
|
|
2128
|
-
|
|
2129
|
-
exports.builders = document_1;
|
|
2130
|
-
exports.debug = document_4;
|
|
2131
|
-
exports.default = document;
|
|
2132
|
-
exports.printer = document_2;
|
|
2133
|
-
exports.utils = document_3;
|
|
2134
|
-
|
|
2135
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3766
|
+
|
|
3767
|
+
return document;
|
|
2136
3768
|
|
|
2137
3769
|
})));
|