prettier 1.13.4 → 1.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/bin-prettier.js +124 -42
- package/index.js +123 -41
- package/package.json +5 -2
- package/parser-typescript.js +1 -1
- package/standalone.js +32 -17
package/README.md
CHANGED
|
@@ -22,18 +22,22 @@
|
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
25
|
-
<a href="https://gitter.im/jlongster/prettier">
|
|
26
|
-
<img alt="Chat on Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
|
|
27
|
-
</a>
|
|
28
25
|
<a href="https://travis-ci.org/prettier/prettier">
|
|
29
26
|
<img alt="Travis CI Build Status" src="https://img.shields.io/travis/prettier/prettier/master.svg?style=flat-square&label=Travis+CI">
|
|
30
27
|
</a>
|
|
31
28
|
<a href="https://circleci.com/gh/prettier/prettier">
|
|
32
29
|
<img alt="CircleCI Build Status" src="https://img.shields.io/circleci/project/github/prettier/prettier/master.svg?style=flat-square&label=CircleCI">
|
|
33
30
|
</a>
|
|
31
|
+
<a href="https://ci.appveyor.com/project/azz/prettier">
|
|
32
|
+
<img alt="AppVeyor Build Status" src="https://img.shields.io/appveyor/ci/azz/prettier.svg?style=flat-square&label=AppVeyor">
|
|
33
|
+
</a>
|
|
34
34
|
<a href="https://codecov.io/gh/prettier/prettier">
|
|
35
35
|
<img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square">
|
|
36
36
|
</a>
|
|
37
|
+
<a href="https://twitter.com/acdlite/status/974390255393505280">
|
|
38
|
+
<img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square">
|
|
39
|
+
</a>
|
|
40
|
+
<br/>
|
|
37
41
|
<a href="https://www.npmjs.com/package/prettier">
|
|
38
42
|
<img alt="npm version" src="https://img.shields.io/npm/v/prettier.svg?style=flat-square">
|
|
39
43
|
</a>
|
|
@@ -43,6 +47,9 @@
|
|
|
43
47
|
<a href="#badge">
|
|
44
48
|
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square">
|
|
45
49
|
</a>
|
|
50
|
+
<a href="https://gitter.im/jlongster/prettier">
|
|
51
|
+
<img alt="Chat on Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
|
|
52
|
+
</a>
|
|
46
53
|
<a href="https://twitter.com/PrettierCode">
|
|
47
54
|
<img alt="Follow Prettier on Twitter" src="https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square">
|
|
48
55
|
</a>
|
package/bin-prettier.js
CHANGED
|
@@ -14,7 +14,7 @@ var thirdParty__default = thirdParty['default'];
|
|
|
14
14
|
var readline = _interopDefault(require('readline'));
|
|
15
15
|
|
|
16
16
|
var name = "prettier";
|
|
17
|
-
var version$1 = "1.13.
|
|
17
|
+
var version$1 = "1.13.5";
|
|
18
18
|
var description = "Prettier is an opinionated code formatter";
|
|
19
19
|
var bin = {
|
|
20
20
|
"prettier": "./bin/prettier.js"
|
|
@@ -69,7 +69,7 @@ var dependencies = {
|
|
|
69
69
|
"semver": "5.4.1",
|
|
70
70
|
"string-width": "2.1.1",
|
|
71
71
|
"typescript": "2.9.0-dev.20180421",
|
|
72
|
-
"typescript-eslint-parser": "
|
|
72
|
+
"typescript-eslint-parser": "16.0.0",
|
|
73
73
|
"unicode-regex": "1.0.1",
|
|
74
74
|
"unified": "6.1.6"
|
|
75
75
|
};
|
|
@@ -88,7 +88,7 @@ var devDependencies = {
|
|
|
88
88
|
"eslint-plugin-react": "7.7.0",
|
|
89
89
|
"jest": "21.1.0",
|
|
90
90
|
"mkdirp": "0.5.1",
|
|
91
|
-
"prettier": "1.13.
|
|
91
|
+
"prettier": "1.13.4",
|
|
92
92
|
"prettylint": "1.0.0",
|
|
93
93
|
"rimraf": "2.6.2",
|
|
94
94
|
"rollup": "0.47.6",
|
|
@@ -8829,8 +8829,7 @@ function printDocToString$1(doc, options) {
|
|
|
8829
8829
|
out.pop();
|
|
8830
8830
|
}
|
|
8831
8831
|
|
|
8832
|
-
if (out.length && typeof out[out.length - 1] === "string"
|
|
8833
|
-
!/\S {2}$/.test(out[out.length - 1]))) {
|
|
8832
|
+
if (out.length && typeof out[out.length - 1] === "string") {
|
|
8834
8833
|
out[out.length - 1] = out[out.length - 1].replace(/[^\S\n]*$/, "");
|
|
8835
8834
|
}
|
|
8836
8835
|
}
|
|
@@ -10188,6 +10187,13 @@ function attachComments(text, ast, opts) {
|
|
|
10188
10187
|
}
|
|
10189
10188
|
|
|
10190
10189
|
function coreFormat(text, opts, addAlignmentSize) {
|
|
10190
|
+
if (!text || !text.trim().length) {
|
|
10191
|
+
return {
|
|
10192
|
+
formatted: "",
|
|
10193
|
+
cursorOffset: 0
|
|
10194
|
+
};
|
|
10195
|
+
}
|
|
10196
|
+
|
|
10191
10197
|
addAlignmentSize = addAlignmentSize || 0;
|
|
10192
10198
|
var parsed = parser.parse(text, opts);
|
|
10193
10199
|
var ast = parsed.ast;
|
|
@@ -10778,22 +10784,76 @@ typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32
|
|
|
10778
10784
|
};
|
|
10779
10785
|
}
|
|
10780
10786
|
|
|
10781
|
-
|
|
10782
|
-
|
|
10787
|
+
/**
|
|
10788
|
+
* @param {string} filename
|
|
10789
|
+
* @returns {Promise<null | string>}
|
|
10790
|
+
*/
|
|
10783
10791
|
|
|
10784
|
-
if (ignorePath) {
|
|
10785
|
-
var resolvedIgnorePath = path.resolve(ignorePath);
|
|
10786
10792
|
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
if (
|
|
10791
|
-
|
|
10793
|
+
function getFileContentOrNull(filename) {
|
|
10794
|
+
return new Promise(function (resolve, reject) {
|
|
10795
|
+
fs.readFile(filename, "utf8", function (error, data) {
|
|
10796
|
+
if (error && error.code !== "ENOENT") {
|
|
10797
|
+
reject(createError(filename, error));
|
|
10798
|
+
} else {
|
|
10799
|
+
resolve(error ? null : data);
|
|
10792
10800
|
}
|
|
10801
|
+
});
|
|
10802
|
+
});
|
|
10803
|
+
}
|
|
10804
|
+
/**
|
|
10805
|
+
* @param {string} filename
|
|
10806
|
+
* @returns {null | string}
|
|
10807
|
+
*/
|
|
10808
|
+
|
|
10809
|
+
|
|
10810
|
+
getFileContentOrNull.sync = function (filename) {
|
|
10811
|
+
try {
|
|
10812
|
+
return fs.readFileSync(filename, "utf8");
|
|
10813
|
+
} catch (error) {
|
|
10814
|
+
if (error && error.code === "ENOENT") {
|
|
10815
|
+
return null;
|
|
10793
10816
|
}
|
|
10817
|
+
|
|
10818
|
+
throw createError(filename, error);
|
|
10794
10819
|
}
|
|
10820
|
+
};
|
|
10821
|
+
|
|
10822
|
+
function createError(filename, error) {
|
|
10823
|
+
return new Error(`Unable to read ${filename}: ${error.message}`);
|
|
10824
|
+
}
|
|
10825
|
+
|
|
10826
|
+
var getFileContentOrNull_1 = getFileContentOrNull;
|
|
10827
|
+
|
|
10828
|
+
/**
|
|
10829
|
+
* @param {undefined | string} ignorePath
|
|
10830
|
+
* @param {undefined | boolean} withNodeModules
|
|
10831
|
+
*/
|
|
10832
|
+
|
|
10833
|
+
|
|
10834
|
+
function createIgnorer(ignorePath, withNodeModules) {
|
|
10835
|
+
return (!ignorePath ? Promise.resolve(null) : getFileContentOrNull_1(path.resolve(ignorePath))).then(function (ignoreContent) {
|
|
10836
|
+
return _createIgnorer(ignoreContent, withNodeModules);
|
|
10837
|
+
});
|
|
10838
|
+
}
|
|
10839
|
+
/**
|
|
10840
|
+
* @param {undefined | string} ignorePath
|
|
10841
|
+
* @param {undefined | boolean} withNodeModules
|
|
10842
|
+
*/
|
|
10795
10843
|
|
|
10796
|
-
|
|
10844
|
+
|
|
10845
|
+
createIgnorer.sync = function (ignorePath, withNodeModules) {
|
|
10846
|
+
var ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path.resolve(ignorePath));
|
|
10847
|
+
return _createIgnorer(ignoreContent, withNodeModules);
|
|
10848
|
+
};
|
|
10849
|
+
/**
|
|
10850
|
+
* @param {null | string} ignoreContent
|
|
10851
|
+
* @param {undefined | boolean} withNodeModules
|
|
10852
|
+
*/
|
|
10853
|
+
|
|
10854
|
+
|
|
10855
|
+
function _createIgnorer(ignoreContent, withNodeModules) {
|
|
10856
|
+
var ignorer = ignore().add(ignoreContent || "");
|
|
10797
10857
|
|
|
10798
10858
|
if (!withNodeModules) {
|
|
10799
10859
|
ignorer.add("node_modules");
|
|
@@ -10804,9 +10864,15 @@ function createIgnorer(ignorePath, withNodeModules) {
|
|
|
10804
10864
|
|
|
10805
10865
|
var createIgnorer_1 = createIgnorer;
|
|
10806
10866
|
|
|
10867
|
+
/**
|
|
10868
|
+
* @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
|
|
10869
|
+
* @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
|
|
10870
|
+
*/
|
|
10871
|
+
|
|
10807
10872
|
/**
|
|
10808
10873
|
* @param {string} filePath
|
|
10809
|
-
* @param {
|
|
10874
|
+
* @param {FileInfoOptions} opts
|
|
10875
|
+
* @returns {Promise<FileInfoResult>}
|
|
10810
10876
|
*
|
|
10811
10877
|
* Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
|
|
10812
10878
|
* not an object. A transformation from this array to an object is automatically done
|
|
@@ -10814,25 +10880,32 @@ var createIgnorer_1 = createIgnorer;
|
|
|
10814
10880
|
*/
|
|
10815
10881
|
|
|
10816
10882
|
|
|
10817
|
-
function
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10883
|
+
function getFileInfo(filePath, opts) {
|
|
10884
|
+
return createIgnorer_1(opts.ignorePath, opts.withNodeModules).then(function (ignorer) {
|
|
10885
|
+
return _getFileInfo(ignorer, filePath, opts.plugins);
|
|
10886
|
+
});
|
|
10887
|
+
}
|
|
10888
|
+
/**
|
|
10889
|
+
* @param {string} filePath
|
|
10890
|
+
* @param {FileInfoOptions} opts
|
|
10891
|
+
* @returns {FileInfoResult}
|
|
10892
|
+
*/
|
|
10893
|
+
|
|
10894
|
+
|
|
10895
|
+
getFileInfo.sync = function (filePath, opts) {
|
|
10896
|
+
var ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
|
|
10897
|
+
return _getFileInfo(ignorer, filePath, opts.plugins);
|
|
10898
|
+
};
|
|
10899
|
+
|
|
10900
|
+
function _getFileInfo(ignorer, filePath, plugins) {
|
|
10901
|
+
var ignored = ignorer.ignores(filePath);
|
|
10902
|
+
var inferredParser = options.inferParser(filePath, plugins) || null;
|
|
10822
10903
|
return {
|
|
10823
10904
|
ignored,
|
|
10824
10905
|
inferredParser
|
|
10825
10906
|
};
|
|
10826
|
-
} // the method has been implemented as asynchronous to avoid possible breaking changes in future
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
function getFileInfo(filePath, opts) {
|
|
10830
|
-
return Promise.resolve().then(function () {
|
|
10831
|
-
return _getFileInfo(filePath, opts);
|
|
10832
|
-
});
|
|
10833
10907
|
}
|
|
10834
10908
|
|
|
10835
|
-
getFileInfo.sync = _getFileInfo;
|
|
10836
10909
|
var getFileInfo_1 = getFileInfo;
|
|
10837
10910
|
|
|
10838
10911
|
var lodash_uniqby = createCommonjsModule(function (module, exports) {
|
|
@@ -22362,12 +22435,13 @@ function printMemberChain(path$$1, options, print) {
|
|
|
22362
22435
|
// .map(x => x)
|
|
22363
22436
|
//
|
|
22364
22437
|
// In order to detect those cases, we use an heuristic: if the first
|
|
22365
|
-
// node is an identifier with the name starting with a capital
|
|
22366
|
-
// The rationale is that they are
|
|
22438
|
+
// node is an identifier with the name starting with a capital
|
|
22439
|
+
// letter or just a sequence of _$. The rationale is that they are
|
|
22440
|
+
// likely to be factories.
|
|
22367
22441
|
|
|
22368
22442
|
|
|
22369
22443
|
function isFactory(name) {
|
|
22370
|
-
return /^[A-Z]
|
|
22444
|
+
return /^[A-Z]|^[_$]+$/.test(name);
|
|
22371
22445
|
} // In case the Identifier is shorter than tab width, we can keep the
|
|
22372
22446
|
// first call in a single line, if it's an ExpressionStatement.
|
|
22373
22447
|
//
|
|
@@ -23509,6 +23583,10 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
23509
23583
|
|
|
23510
23584
|
case "Identifier":
|
|
23511
23585
|
return JSON.stringify(node.name);
|
|
23586
|
+
|
|
23587
|
+
default:
|
|
23588
|
+
/* istanbul ignore next */
|
|
23589
|
+
throw new Error("unknown type: " + JSON.stringify(node.type));
|
|
23512
23590
|
}
|
|
23513
23591
|
}
|
|
23514
23592
|
|
|
@@ -25455,9 +25533,9 @@ var languageGraphql = {
|
|
|
25455
25533
|
|
|
25456
25534
|
var _require$$0$builders$6 = doc.builders;
|
|
25457
25535
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
25458
|
-
var literalline$
|
|
25536
|
+
var literalline$4 = _require$$0$builders$6.literalline;
|
|
25459
25537
|
var concat$11 = _require$$0$builders$6.concat;
|
|
25460
|
-
var markAsRoot$
|
|
25538
|
+
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
25461
25539
|
var mapDoc$4 = doc.utils.mapDoc;
|
|
25462
25540
|
|
|
25463
25541
|
function embed$2(path$$1, print, textToDoc, options) {
|
|
@@ -25474,7 +25552,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25474
25552
|
var doc$$2 = textToDoc(node.value, {
|
|
25475
25553
|
parser
|
|
25476
25554
|
});
|
|
25477
|
-
return markAsRoot$
|
|
25555
|
+
return markAsRoot$2(concat$11([style, node.lang, hardline$10, replaceNewlinesWithLiterallines(doc$$2), style]));
|
|
25478
25556
|
}
|
|
25479
25557
|
}
|
|
25480
25558
|
|
|
@@ -25500,7 +25578,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25500
25578
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
25501
25579
|
return mapDoc$4(doc$$2, function (currentDoc) {
|
|
25502
25580
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$11(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
25503
|
-
return i % 2 === 0 ? v : literalline$
|
|
25581
|
+
return i % 2 === 0 ? v : literalline$4;
|
|
25504
25582
|
})) : currentDoc;
|
|
25505
25583
|
});
|
|
25506
25584
|
}
|
|
@@ -25564,6 +25642,8 @@ var _require$$0$builders$5 = doc.builders;
|
|
|
25564
25642
|
var concat$10 = _require$$0$builders$5.concat;
|
|
25565
25643
|
var join$8 = _require$$0$builders$5.join;
|
|
25566
25644
|
var line$7 = _require$$0$builders$5.line;
|
|
25645
|
+
var literalline$3 = _require$$0$builders$5.literalline;
|
|
25646
|
+
var markAsRoot$1 = _require$$0$builders$5.markAsRoot;
|
|
25567
25647
|
var hardline$9 = _require$$0$builders$5.hardline;
|
|
25568
25648
|
var softline$6 = _require$$0$builders$5.softline;
|
|
25569
25649
|
var fill$4 = _require$$0$builders$5.fill;
|
|
@@ -25696,7 +25776,9 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25696
25776
|
{
|
|
25697
25777
|
var _parentNode2 = path$$1.getParentNode();
|
|
25698
25778
|
|
|
25699
|
-
|
|
25779
|
+
var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
|
|
25780
|
+
var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
|
|
25781
|
+
return replaceNewlinesWith(value, isHtmlComment ? hardline$9 : markAsRoot$1(literalline$3));
|
|
25700
25782
|
}
|
|
25701
25783
|
|
|
25702
25784
|
case "list":
|
|
@@ -25774,10 +25856,10 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25774
25856
|
return printChildren(path$$1, options, print);
|
|
25775
25857
|
|
|
25776
25858
|
case "break":
|
|
25777
|
-
return
|
|
25859
|
+
return /\s/.test(options.originalText[node.position.start.offset]) ? concat$10([" ", markAsRoot$1(literalline$3)]) : concat$10(["\\", hardline$9]);
|
|
25778
25860
|
|
|
25779
25861
|
case "liquidNode":
|
|
25780
|
-
return
|
|
25862
|
+
return replaceNewlinesWith(node.value, hardline$9);
|
|
25781
25863
|
|
|
25782
25864
|
case "tableRow": // handled in "table"
|
|
25783
25865
|
|
|
@@ -25821,8 +25903,8 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
25821
25903
|
});
|
|
25822
25904
|
}
|
|
25823
25905
|
|
|
25824
|
-
function
|
|
25825
|
-
return join$8(
|
|
25906
|
+
function replaceNewlinesWith(str, doc$$2) {
|
|
25907
|
+
return join$8(doc$$2, str.split("\n"));
|
|
25826
25908
|
}
|
|
25827
25909
|
|
|
25828
25910
|
function getNthSiblingIndex(node, parentNode, condition) {
|
|
@@ -33231,7 +33313,7 @@ function formatStdin(context) {
|
|
|
33231
33313
|
|
|
33232
33314
|
function createIgnorerFromContextOrDie(context) {
|
|
33233
33315
|
try {
|
|
33234
|
-
return createIgnorer_1(context.argv["ignore-path"], context.argv["with-node-modules"]);
|
|
33316
|
+
return createIgnorer_1.sync(context.argv["ignore-path"], context.argv["with-node-modules"]);
|
|
33235
33317
|
} catch (e) {
|
|
33236
33318
|
context.logger.error(e.message);
|
|
33237
33319
|
process.exit(2);
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var thirdParty = require('./third-party');
|
|
|
12
12
|
var thirdParty__default = thirdParty['default'];
|
|
13
13
|
|
|
14
14
|
var name = "prettier";
|
|
15
|
-
var version$1 = "1.13.
|
|
15
|
+
var version$1 = "1.13.5";
|
|
16
16
|
var description = "Prettier is an opinionated code formatter";
|
|
17
17
|
var bin = {
|
|
18
18
|
"prettier": "./bin/prettier.js"
|
|
@@ -67,7 +67,7 @@ var dependencies = {
|
|
|
67
67
|
"semver": "5.4.1",
|
|
68
68
|
"string-width": "2.1.1",
|
|
69
69
|
"typescript": "2.9.0-dev.20180421",
|
|
70
|
-
"typescript-eslint-parser": "
|
|
70
|
+
"typescript-eslint-parser": "16.0.0",
|
|
71
71
|
"unicode-regex": "1.0.1",
|
|
72
72
|
"unified": "6.1.6"
|
|
73
73
|
};
|
|
@@ -86,7 +86,7 @@ var devDependencies = {
|
|
|
86
86
|
"eslint-plugin-react": "7.7.0",
|
|
87
87
|
"jest": "21.1.0",
|
|
88
88
|
"mkdirp": "0.5.1",
|
|
89
|
-
"prettier": "1.13.
|
|
89
|
+
"prettier": "1.13.4",
|
|
90
90
|
"prettylint": "1.0.0",
|
|
91
91
|
"rimraf": "2.6.2",
|
|
92
92
|
"rollup": "0.47.6",
|
|
@@ -8827,8 +8827,7 @@ function printDocToString$1(doc, options) {
|
|
|
8827
8827
|
out.pop();
|
|
8828
8828
|
}
|
|
8829
8829
|
|
|
8830
|
-
if (out.length && typeof out[out.length - 1] === "string"
|
|
8831
|
-
!/\S {2}$/.test(out[out.length - 1]))) {
|
|
8830
|
+
if (out.length && typeof out[out.length - 1] === "string") {
|
|
8832
8831
|
out[out.length - 1] = out[out.length - 1].replace(/[^\S\n]*$/, "");
|
|
8833
8832
|
}
|
|
8834
8833
|
}
|
|
@@ -10186,6 +10185,13 @@ function attachComments(text, ast, opts) {
|
|
|
10186
10185
|
}
|
|
10187
10186
|
|
|
10188
10187
|
function coreFormat(text, opts, addAlignmentSize) {
|
|
10188
|
+
if (!text || !text.trim().length) {
|
|
10189
|
+
return {
|
|
10190
|
+
formatted: "",
|
|
10191
|
+
cursorOffset: 0
|
|
10192
|
+
};
|
|
10193
|
+
}
|
|
10194
|
+
|
|
10189
10195
|
addAlignmentSize = addAlignmentSize || 0;
|
|
10190
10196
|
var parsed = parser.parse(text, opts);
|
|
10191
10197
|
var ast = parsed.ast;
|
|
@@ -10776,22 +10782,76 @@ typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32
|
|
|
10776
10782
|
};
|
|
10777
10783
|
}
|
|
10778
10784
|
|
|
10779
|
-
|
|
10780
|
-
|
|
10785
|
+
/**
|
|
10786
|
+
* @param {string} filename
|
|
10787
|
+
* @returns {Promise<null | string>}
|
|
10788
|
+
*/
|
|
10781
10789
|
|
|
10782
|
-
if (ignorePath) {
|
|
10783
|
-
var resolvedIgnorePath = path.resolve(ignorePath);
|
|
10784
10790
|
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
if (
|
|
10789
|
-
|
|
10791
|
+
function getFileContentOrNull(filename) {
|
|
10792
|
+
return new Promise(function (resolve, reject) {
|
|
10793
|
+
fs.readFile(filename, "utf8", function (error, data) {
|
|
10794
|
+
if (error && error.code !== "ENOENT") {
|
|
10795
|
+
reject(createError(filename, error));
|
|
10796
|
+
} else {
|
|
10797
|
+
resolve(error ? null : data);
|
|
10790
10798
|
}
|
|
10799
|
+
});
|
|
10800
|
+
});
|
|
10801
|
+
}
|
|
10802
|
+
/**
|
|
10803
|
+
* @param {string} filename
|
|
10804
|
+
* @returns {null | string}
|
|
10805
|
+
*/
|
|
10806
|
+
|
|
10807
|
+
|
|
10808
|
+
getFileContentOrNull.sync = function (filename) {
|
|
10809
|
+
try {
|
|
10810
|
+
return fs.readFileSync(filename, "utf8");
|
|
10811
|
+
} catch (error) {
|
|
10812
|
+
if (error && error.code === "ENOENT") {
|
|
10813
|
+
return null;
|
|
10791
10814
|
}
|
|
10815
|
+
|
|
10816
|
+
throw createError(filename, error);
|
|
10792
10817
|
}
|
|
10818
|
+
};
|
|
10819
|
+
|
|
10820
|
+
function createError(filename, error) {
|
|
10821
|
+
return new Error(`Unable to read ${filename}: ${error.message}`);
|
|
10822
|
+
}
|
|
10823
|
+
|
|
10824
|
+
var getFileContentOrNull_1 = getFileContentOrNull;
|
|
10825
|
+
|
|
10826
|
+
/**
|
|
10827
|
+
* @param {undefined | string} ignorePath
|
|
10828
|
+
* @param {undefined | boolean} withNodeModules
|
|
10829
|
+
*/
|
|
10830
|
+
|
|
10831
|
+
|
|
10832
|
+
function createIgnorer(ignorePath, withNodeModules) {
|
|
10833
|
+
return (!ignorePath ? Promise.resolve(null) : getFileContentOrNull_1(path.resolve(ignorePath))).then(function (ignoreContent) {
|
|
10834
|
+
return _createIgnorer(ignoreContent, withNodeModules);
|
|
10835
|
+
});
|
|
10836
|
+
}
|
|
10837
|
+
/**
|
|
10838
|
+
* @param {undefined | string} ignorePath
|
|
10839
|
+
* @param {undefined | boolean} withNodeModules
|
|
10840
|
+
*/
|
|
10793
10841
|
|
|
10794
|
-
|
|
10842
|
+
|
|
10843
|
+
createIgnorer.sync = function (ignorePath, withNodeModules) {
|
|
10844
|
+
var ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path.resolve(ignorePath));
|
|
10845
|
+
return _createIgnorer(ignoreContent, withNodeModules);
|
|
10846
|
+
};
|
|
10847
|
+
/**
|
|
10848
|
+
* @param {null | string} ignoreContent
|
|
10849
|
+
* @param {undefined | boolean} withNodeModules
|
|
10850
|
+
*/
|
|
10851
|
+
|
|
10852
|
+
|
|
10853
|
+
function _createIgnorer(ignoreContent, withNodeModules) {
|
|
10854
|
+
var ignorer = ignore().add(ignoreContent || "");
|
|
10795
10855
|
|
|
10796
10856
|
if (!withNodeModules) {
|
|
10797
10857
|
ignorer.add("node_modules");
|
|
@@ -10802,9 +10862,15 @@ function createIgnorer(ignorePath, withNodeModules) {
|
|
|
10802
10862
|
|
|
10803
10863
|
var createIgnorer_1 = createIgnorer;
|
|
10804
10864
|
|
|
10865
|
+
/**
|
|
10866
|
+
* @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
|
|
10867
|
+
* @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
|
|
10868
|
+
*/
|
|
10869
|
+
|
|
10805
10870
|
/**
|
|
10806
10871
|
* @param {string} filePath
|
|
10807
|
-
* @param {
|
|
10872
|
+
* @param {FileInfoOptions} opts
|
|
10873
|
+
* @returns {Promise<FileInfoResult>}
|
|
10808
10874
|
*
|
|
10809
10875
|
* Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
|
|
10810
10876
|
* not an object. A transformation from this array to an object is automatically done
|
|
@@ -10812,25 +10878,32 @@ var createIgnorer_1 = createIgnorer;
|
|
|
10812
10878
|
*/
|
|
10813
10879
|
|
|
10814
10880
|
|
|
10815
|
-
function
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10881
|
+
function getFileInfo(filePath, opts) {
|
|
10882
|
+
return createIgnorer_1(opts.ignorePath, opts.withNodeModules).then(function (ignorer) {
|
|
10883
|
+
return _getFileInfo(ignorer, filePath, opts.plugins);
|
|
10884
|
+
});
|
|
10885
|
+
}
|
|
10886
|
+
/**
|
|
10887
|
+
* @param {string} filePath
|
|
10888
|
+
* @param {FileInfoOptions} opts
|
|
10889
|
+
* @returns {FileInfoResult}
|
|
10890
|
+
*/
|
|
10891
|
+
|
|
10892
|
+
|
|
10893
|
+
getFileInfo.sync = function (filePath, opts) {
|
|
10894
|
+
var ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
|
|
10895
|
+
return _getFileInfo(ignorer, filePath, opts.plugins);
|
|
10896
|
+
};
|
|
10897
|
+
|
|
10898
|
+
function _getFileInfo(ignorer, filePath, plugins) {
|
|
10899
|
+
var ignored = ignorer.ignores(filePath);
|
|
10900
|
+
var inferredParser = options.inferParser(filePath, plugins) || null;
|
|
10820
10901
|
return {
|
|
10821
10902
|
ignored,
|
|
10822
10903
|
inferredParser
|
|
10823
10904
|
};
|
|
10824
|
-
} // the method has been implemented as asynchronous to avoid possible breaking changes in future
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
function getFileInfo(filePath, opts) {
|
|
10828
|
-
return Promise.resolve().then(function () {
|
|
10829
|
-
return _getFileInfo(filePath, opts);
|
|
10830
|
-
});
|
|
10831
10905
|
}
|
|
10832
10906
|
|
|
10833
|
-
getFileInfo.sync = _getFileInfo;
|
|
10834
10907
|
var getFileInfo_1 = getFileInfo;
|
|
10835
10908
|
|
|
10836
10909
|
var lodash_uniqby = createCommonjsModule(function (module, exports) {
|
|
@@ -22360,12 +22433,13 @@ function printMemberChain(path$$1, options, print) {
|
|
|
22360
22433
|
// .map(x => x)
|
|
22361
22434
|
//
|
|
22362
22435
|
// In order to detect those cases, we use an heuristic: if the first
|
|
22363
|
-
// node is an identifier with the name starting with a capital
|
|
22364
|
-
// The rationale is that they are
|
|
22436
|
+
// node is an identifier with the name starting with a capital
|
|
22437
|
+
// letter or just a sequence of _$. The rationale is that they are
|
|
22438
|
+
// likely to be factories.
|
|
22365
22439
|
|
|
22366
22440
|
|
|
22367
22441
|
function isFactory(name) {
|
|
22368
|
-
return /^[A-Z]
|
|
22442
|
+
return /^[A-Z]|^[_$]+$/.test(name);
|
|
22369
22443
|
} // In case the Identifier is shorter than tab width, we can keep the
|
|
22370
22444
|
// first call in a single line, if it's an ExpressionStatement.
|
|
22371
22445
|
//
|
|
@@ -23507,6 +23581,10 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
23507
23581
|
|
|
23508
23582
|
case "Identifier":
|
|
23509
23583
|
return JSON.stringify(node.name);
|
|
23584
|
+
|
|
23585
|
+
default:
|
|
23586
|
+
/* istanbul ignore next */
|
|
23587
|
+
throw new Error("unknown type: " + JSON.stringify(node.type));
|
|
23510
23588
|
}
|
|
23511
23589
|
}
|
|
23512
23590
|
|
|
@@ -25453,9 +25531,9 @@ var languageGraphql = {
|
|
|
25453
25531
|
|
|
25454
25532
|
var _require$$0$builders$6 = doc.builders;
|
|
25455
25533
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
25456
|
-
var literalline$
|
|
25534
|
+
var literalline$4 = _require$$0$builders$6.literalline;
|
|
25457
25535
|
var concat$11 = _require$$0$builders$6.concat;
|
|
25458
|
-
var markAsRoot$
|
|
25536
|
+
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
25459
25537
|
var mapDoc$4 = doc.utils.mapDoc;
|
|
25460
25538
|
|
|
25461
25539
|
function embed$2(path$$1, print, textToDoc, options) {
|
|
@@ -25472,7 +25550,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25472
25550
|
var doc$$2 = textToDoc(node.value, {
|
|
25473
25551
|
parser
|
|
25474
25552
|
});
|
|
25475
|
-
return markAsRoot$
|
|
25553
|
+
return markAsRoot$2(concat$11([style, node.lang, hardline$10, replaceNewlinesWithLiterallines(doc$$2), style]));
|
|
25476
25554
|
}
|
|
25477
25555
|
}
|
|
25478
25556
|
|
|
@@ -25498,7 +25576,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25498
25576
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
25499
25577
|
return mapDoc$4(doc$$2, function (currentDoc) {
|
|
25500
25578
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$11(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
25501
|
-
return i % 2 === 0 ? v : literalline$
|
|
25579
|
+
return i % 2 === 0 ? v : literalline$4;
|
|
25502
25580
|
})) : currentDoc;
|
|
25503
25581
|
});
|
|
25504
25582
|
}
|
|
@@ -25562,6 +25640,8 @@ var _require$$0$builders$5 = doc.builders;
|
|
|
25562
25640
|
var concat$10 = _require$$0$builders$5.concat;
|
|
25563
25641
|
var join$8 = _require$$0$builders$5.join;
|
|
25564
25642
|
var line$7 = _require$$0$builders$5.line;
|
|
25643
|
+
var literalline$3 = _require$$0$builders$5.literalline;
|
|
25644
|
+
var markAsRoot$1 = _require$$0$builders$5.markAsRoot;
|
|
25565
25645
|
var hardline$9 = _require$$0$builders$5.hardline;
|
|
25566
25646
|
var softline$6 = _require$$0$builders$5.softline;
|
|
25567
25647
|
var fill$4 = _require$$0$builders$5.fill;
|
|
@@ -25694,7 +25774,9 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25694
25774
|
{
|
|
25695
25775
|
var _parentNode2 = path$$1.getParentNode();
|
|
25696
25776
|
|
|
25697
|
-
|
|
25777
|
+
var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
|
|
25778
|
+
var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
|
|
25779
|
+
return replaceNewlinesWith(value, isHtmlComment ? hardline$9 : markAsRoot$1(literalline$3));
|
|
25698
25780
|
}
|
|
25699
25781
|
|
|
25700
25782
|
case "list":
|
|
@@ -25772,10 +25854,10 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25772
25854
|
return printChildren(path$$1, options, print);
|
|
25773
25855
|
|
|
25774
25856
|
case "break":
|
|
25775
|
-
return
|
|
25857
|
+
return /\s/.test(options.originalText[node.position.start.offset]) ? concat$10([" ", markAsRoot$1(literalline$3)]) : concat$10(["\\", hardline$9]);
|
|
25776
25858
|
|
|
25777
25859
|
case "liquidNode":
|
|
25778
|
-
return
|
|
25860
|
+
return replaceNewlinesWith(node.value, hardline$9);
|
|
25779
25861
|
|
|
25780
25862
|
case "tableRow": // handled in "table"
|
|
25781
25863
|
|
|
@@ -25819,8 +25901,8 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
25819
25901
|
});
|
|
25820
25902
|
}
|
|
25821
25903
|
|
|
25822
|
-
function
|
|
25823
|
-
return join$8(
|
|
25904
|
+
function replaceNewlinesWith(str, doc$$2) {
|
|
25905
|
+
return join$8(doc$$2, str.split("\n"));
|
|
25824
25906
|
}
|
|
25825
25907
|
|
|
25826
25908
|
function getNthSiblingIndex(node, parentNode, condition) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.5",
|
|
4
4
|
"description": "Prettier is an opinionated code formatter",
|
|
5
5
|
"bin": "./bin-prettier.js",
|
|
6
6
|
"repository": "prettier/prettier",
|
|
@@ -13,5 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prepublishOnly": "node -e \"assert.equal(require('.').version, require('..').version)\""
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"*.js"
|
|
19
|
+
]
|
|
17
20
|
}
|