prettier 1.13.1 → 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 +106 -0
- package/bin-prettier.js +176 -84
- package/index.js +163 -72
- package/package.json +6 -3
- package/parser-postcss.js +53 -13
- package/parser-typescript.js +1 -1
- package/standalone.js +72 -48
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
|
+
*/
|
|
10841
|
+
|
|
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
|
+
*/
|
|
10793
10851
|
|
|
10794
|
-
|
|
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) {
|
|
@@ -21638,28 +21711,17 @@ function shouldGroupFirstArg(args) {
|
|
|
21638
21711
|
return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && !couldGroupArg(secondArg);
|
|
21639
21712
|
}
|
|
21640
21713
|
|
|
21641
|
-
var functionCompositionFunctionNames =
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
composeP: true,
|
|
21653
|
-
// Ramda
|
|
21654
|
-
composeK: true,
|
|
21655
|
-
// Ramda
|
|
21656
|
-
flow: true,
|
|
21657
|
-
// Lodash
|
|
21658
|
-
flowRight: true,
|
|
21659
|
-
// Lodash
|
|
21660
|
-
connect: true // Redux
|
|
21661
|
-
|
|
21662
|
-
};
|
|
21714
|
+
var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
|
|
21715
|
+
"pipeP", // Ramda
|
|
21716
|
+
"pipeK", // Ramda
|
|
21717
|
+
"compose", // Ramda, Redux
|
|
21718
|
+
"composeFlipped", // Not from any library, but common in Haskell, so supported
|
|
21719
|
+
"composeP", // Ramda
|
|
21720
|
+
"composeK", // Ramda
|
|
21721
|
+
"flow", // Lodash
|
|
21722
|
+
"flowRight", // Lodash
|
|
21723
|
+
"connect" // Redux
|
|
21724
|
+
]);
|
|
21663
21725
|
|
|
21664
21726
|
function isFunctionCompositionFunction(node) {
|
|
21665
21727
|
switch (node.type) {
|
|
@@ -21671,13 +21733,13 @@ function isFunctionCompositionFunction(node) {
|
|
|
21671
21733
|
|
|
21672
21734
|
case "Identifier":
|
|
21673
21735
|
{
|
|
21674
|
-
return functionCompositionFunctionNames
|
|
21736
|
+
return functionCompositionFunctionNames.has(node.name);
|
|
21675
21737
|
}
|
|
21676
21738
|
|
|
21677
21739
|
case "StringLiteral":
|
|
21678
21740
|
case "Literal":
|
|
21679
21741
|
{
|
|
21680
|
-
return functionCompositionFunctionNames
|
|
21742
|
+
return functionCompositionFunctionNames.has(node.value);
|
|
21681
21743
|
}
|
|
21682
21744
|
}
|
|
21683
21745
|
}
|
|
@@ -22371,12 +22433,13 @@ function printMemberChain(path$$1, options, print) {
|
|
|
22371
22433
|
// .map(x => x)
|
|
22372
22434
|
//
|
|
22373
22435
|
// In order to detect those cases, we use an heuristic: if the first
|
|
22374
|
-
// node is an identifier with the name starting with a capital
|
|
22375
|
-
// 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.
|
|
22376
22439
|
|
|
22377
22440
|
|
|
22378
22441
|
function isFactory(name) {
|
|
22379
|
-
return /^[A-Z]
|
|
22442
|
+
return /^[A-Z]|^[_$]+$/.test(name);
|
|
22380
22443
|
} // In case the Identifier is shorter than tab width, we can keep the
|
|
22381
22444
|
// first call in a single line, if it's an ExpressionStatement.
|
|
22382
22445
|
//
|
|
@@ -23518,6 +23581,10 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
23518
23581
|
|
|
23519
23582
|
case "Identifier":
|
|
23520
23583
|
return JSON.stringify(node.name);
|
|
23584
|
+
|
|
23585
|
+
default:
|
|
23586
|
+
/* istanbul ignore next */
|
|
23587
|
+
throw new Error("unknown type: " + JSON.stringify(node.type));
|
|
23521
23588
|
}
|
|
23522
23589
|
}
|
|
23523
23590
|
|
|
@@ -23831,6 +23898,8 @@ function cleanCSSStrings(value) {
|
|
|
23831
23898
|
|
|
23832
23899
|
var clean_1$2 = clean$3;
|
|
23833
23900
|
|
|
23901
|
+
var colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
|
|
23902
|
+
|
|
23834
23903
|
function getAncestorCounter(path$$1, typeOrTypes) {
|
|
23835
23904
|
var types = [].concat(typeOrTypes);
|
|
23836
23905
|
var counter = -1;
|
|
@@ -24070,6 +24139,14 @@ function isMediaAndSupportsKeywords$1(node) {
|
|
|
24070
24139
|
return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
|
|
24071
24140
|
}
|
|
24072
24141
|
|
|
24142
|
+
function isColorAdjusterFuncNode$1(node) {
|
|
24143
|
+
if (node.type !== "value-func") {
|
|
24144
|
+
return false;
|
|
24145
|
+
}
|
|
24146
|
+
|
|
24147
|
+
return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
|
|
24148
|
+
}
|
|
24149
|
+
|
|
24073
24150
|
var utils$4 = {
|
|
24074
24151
|
getAncestorCounter,
|
|
24075
24152
|
getAncestorNode: getAncestorNode$1,
|
|
@@ -24113,7 +24190,8 @@ var utils$4 = {
|
|
|
24113
24190
|
isRightCurlyBraceNode: isRightCurlyBraceNode$1,
|
|
24114
24191
|
isWordNode: isWordNode$1,
|
|
24115
24192
|
isColonNode: isColonNode$1,
|
|
24116
|
-
isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1
|
|
24193
|
+
isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
|
|
24194
|
+
isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
|
|
24117
24195
|
};
|
|
24118
24196
|
|
|
24119
24197
|
var printNumber$2 = util$1.printNumber;
|
|
@@ -24172,6 +24250,7 @@ var isRightCurlyBraceNode = utils$4.isRightCurlyBraceNode;
|
|
|
24172
24250
|
var isWordNode = utils$4.isWordNode;
|
|
24173
24251
|
var isColonNode = utils$4.isColonNode;
|
|
24174
24252
|
var isMediaAndSupportsKeywords = utils$4.isMediaAndSupportsKeywords;
|
|
24253
|
+
var isColorAdjusterFuncNode = utils$4.isColorAdjusterFuncNode;
|
|
24175
24254
|
|
|
24176
24255
|
function shouldPrintComma$1(options) {
|
|
24177
24256
|
switch (options.trailingComma) {
|
|
@@ -24417,6 +24496,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
24417
24496
|
{
|
|
24418
24497
|
var _parentNode2 = path$$1.getParentNode();
|
|
24419
24498
|
|
|
24499
|
+
var parentParentNode = path$$1.getParentNode(1);
|
|
24420
24500
|
var declAncestorProp = getPropOfDeclNode(path$$1);
|
|
24421
24501
|
var isGridValue = declAncestorProp && _parentNode2.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
|
|
24422
24502
|
var atRuleAncestorNode = getAncestorNode(path$$1, "css-atrule");
|
|
@@ -24507,12 +24587,15 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
24507
24587
|
|
|
24508
24588
|
if (insideValueFunctionNode(path$$1, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
|
|
24509
24589
|
continue;
|
|
24510
|
-
}
|
|
24590
|
+
} // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
|
|
24591
|
+
// Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
|
|
24592
|
+
|
|
24511
24593
|
|
|
24594
|
+
var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
|
|
24512
24595
|
var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
|
|
24513
24596
|
var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
|
|
24514
24597
|
|
|
24515
|
-
if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
|
|
24598
|
+
if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
|
|
24516
24599
|
continue;
|
|
24517
24600
|
} // Ignore inline comment, they already contain newline at end (i.e. `// Comment`)
|
|
24518
24601
|
// Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
|
|
@@ -25134,13 +25217,16 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
25134
25217
|
var parts = [];
|
|
25135
25218
|
path$$1.map(function (pathChild, index) {
|
|
25136
25219
|
parts.push(concat$9([pathChild.call(print)]));
|
|
25137
|
-
parts.push(hardline$8);
|
|
25138
25220
|
|
|
25139
|
-
if (index !== n.definitions.length - 1
|
|
25221
|
+
if (index !== n.definitions.length - 1) {
|
|
25140
25222
|
parts.push(hardline$8);
|
|
25223
|
+
|
|
25224
|
+
if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
|
|
25225
|
+
parts.push(hardline$8);
|
|
25226
|
+
}
|
|
25141
25227
|
}
|
|
25142
25228
|
}, "definitions");
|
|
25143
|
-
return concat$9(parts, hardline$8);
|
|
25229
|
+
return concat$9([concat$9(parts), hardline$8]);
|
|
25144
25230
|
}
|
|
25145
25231
|
|
|
25146
25232
|
case "OperationDefinition":
|
|
@@ -25445,9 +25531,9 @@ var languageGraphql = {
|
|
|
25445
25531
|
|
|
25446
25532
|
var _require$$0$builders$6 = doc.builders;
|
|
25447
25533
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
25448
|
-
var literalline$
|
|
25534
|
+
var literalline$4 = _require$$0$builders$6.literalline;
|
|
25449
25535
|
var concat$11 = _require$$0$builders$6.concat;
|
|
25450
|
-
var markAsRoot$
|
|
25536
|
+
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
25451
25537
|
var mapDoc$4 = doc.utils.mapDoc;
|
|
25452
25538
|
|
|
25453
25539
|
function embed$2(path$$1, print, textToDoc, options) {
|
|
@@ -25464,7 +25550,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25464
25550
|
var doc$$2 = textToDoc(node.value, {
|
|
25465
25551
|
parser
|
|
25466
25552
|
});
|
|
25467
|
-
return markAsRoot$
|
|
25553
|
+
return markAsRoot$2(concat$11([style, node.lang, hardline$10, replaceNewlinesWithLiterallines(doc$$2), style]));
|
|
25468
25554
|
}
|
|
25469
25555
|
}
|
|
25470
25556
|
|
|
@@ -25490,7 +25576,7 @@ function embed$2(path$$1, print, textToDoc, options) {
|
|
|
25490
25576
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
25491
25577
|
return mapDoc$4(doc$$2, function (currentDoc) {
|
|
25492
25578
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$11(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
25493
|
-
return i % 2 === 0 ? v : literalline$
|
|
25579
|
+
return i % 2 === 0 ? v : literalline$4;
|
|
25494
25580
|
})) : currentDoc;
|
|
25495
25581
|
});
|
|
25496
25582
|
}
|
|
@@ -25554,6 +25640,8 @@ var _require$$0$builders$5 = doc.builders;
|
|
|
25554
25640
|
var concat$10 = _require$$0$builders$5.concat;
|
|
25555
25641
|
var join$8 = _require$$0$builders$5.join;
|
|
25556
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;
|
|
25557
25645
|
var hardline$9 = _require$$0$builders$5.hardline;
|
|
25558
25646
|
var softline$6 = _require$$0$builders$5.softline;
|
|
25559
25647
|
var fill$4 = _require$$0$builders$5.fill;
|
|
@@ -25686,7 +25774,9 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25686
25774
|
{
|
|
25687
25775
|
var _parentNode2 = path$$1.getParentNode();
|
|
25688
25776
|
|
|
25689
|
-
|
|
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));
|
|
25690
25780
|
}
|
|
25691
25781
|
|
|
25692
25782
|
case "list":
|
|
@@ -25764,10 +25854,10 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
25764
25854
|
return printChildren(path$$1, options, print);
|
|
25765
25855
|
|
|
25766
25856
|
case "break":
|
|
25767
|
-
return
|
|
25857
|
+
return /\s/.test(options.originalText[node.position.start.offset]) ? concat$10([" ", markAsRoot$1(literalline$3)]) : concat$10(["\\", hardline$9]);
|
|
25768
25858
|
|
|
25769
25859
|
case "liquidNode":
|
|
25770
|
-
return
|
|
25860
|
+
return replaceNewlinesWith(node.value, hardline$9);
|
|
25771
25861
|
|
|
25772
25862
|
case "tableRow": // handled in "table"
|
|
25773
25863
|
|
|
@@ -25811,8 +25901,8 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
25811
25901
|
});
|
|
25812
25902
|
}
|
|
25813
25903
|
|
|
25814
|
-
function
|
|
25815
|
-
return join$8(
|
|
25904
|
+
function replaceNewlinesWith(str, doc$$2) {
|
|
25905
|
+
return join$8(doc$$2, str.split("\n"));
|
|
25816
25906
|
}
|
|
25817
25907
|
|
|
25818
25908
|
function getNthSiblingIndex(node, parentNode, condition) {
|
|
@@ -26083,7 +26173,8 @@ function shouldPrePrintDoubleHardline(node, data) {
|
|
|
26083
26173
|
var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
|
|
26084
26174
|
var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
|
|
26085
26175
|
var isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
|
|
26086
|
-
|
|
26176
|
+
var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
|
|
26177
|
+
return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
|
|
26087
26178
|
}
|
|
26088
26179
|
|
|
26089
26180
|
function shouldPrePrintTripleHardline(node, data) {
|
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",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"node": ">=4"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"prepublishOnly": "node -e
|
|
16
|
-
}
|
|
15
|
+
"prepublishOnly": "node -e \"assert.equal(require('.').version, require('..').version)\""
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"*.js"
|
|
19
|
+
]
|
|
17
20
|
}
|
package/parser-postcss.js
CHANGED
|
@@ -16745,6 +16745,34 @@ module.exports = createError;
|
|
|
16745
16745
|
|
|
16746
16746
|
const htmlTagNames = __webpack_require__(101);
|
|
16747
16747
|
|
|
16748
|
+
const colorAdjusterFunctions = [
|
|
16749
|
+
"red",
|
|
16750
|
+
"green",
|
|
16751
|
+
"blue",
|
|
16752
|
+
"alpha",
|
|
16753
|
+
"a",
|
|
16754
|
+
"rgb",
|
|
16755
|
+
"hue",
|
|
16756
|
+
"h",
|
|
16757
|
+
"saturation",
|
|
16758
|
+
"s",
|
|
16759
|
+
"lightness",
|
|
16760
|
+
"l",
|
|
16761
|
+
"whiteness",
|
|
16762
|
+
"w",
|
|
16763
|
+
"blackness",
|
|
16764
|
+
"b",
|
|
16765
|
+
"tint",
|
|
16766
|
+
"shade",
|
|
16767
|
+
"blend",
|
|
16768
|
+
"blenda",
|
|
16769
|
+
"contrast",
|
|
16770
|
+
"hsl",
|
|
16771
|
+
"hsla",
|
|
16772
|
+
"hwb",
|
|
16773
|
+
"hwba"
|
|
16774
|
+
];
|
|
16775
|
+
|
|
16748
16776
|
function getAncestorCounter(path, typeOrTypes) {
|
|
16749
16777
|
const types = [].concat(typeOrTypes);
|
|
16750
16778
|
|
|
@@ -17089,6 +17117,14 @@ function isMediaAndSupportsKeywords(node) {
|
|
|
17089
17117
|
);
|
|
17090
17118
|
}
|
|
17091
17119
|
|
|
17120
|
+
function isColorAdjusterFuncNode(node) {
|
|
17121
|
+
if (node.type !== "value-func") {
|
|
17122
|
+
return false;
|
|
17123
|
+
}
|
|
17124
|
+
|
|
17125
|
+
return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
|
|
17126
|
+
}
|
|
17127
|
+
|
|
17092
17128
|
module.exports = {
|
|
17093
17129
|
getAncestorCounter,
|
|
17094
17130
|
getAncestorNode,
|
|
@@ -17132,7 +17168,8 @@ module.exports = {
|
|
|
17132
17168
|
isRightCurlyBraceNode,
|
|
17133
17169
|
isWordNode,
|
|
17134
17170
|
isColonNode,
|
|
17135
|
-
isMediaAndSupportsKeywords
|
|
17171
|
+
isMediaAndSupportsKeywords,
|
|
17172
|
+
isColorAdjusterFuncNode
|
|
17136
17173
|
};
|
|
17137
17174
|
|
|
17138
17175
|
|
|
@@ -29369,10 +29406,11 @@ function parseNestedCSS(node) {
|
|
|
29369
29406
|
let selector = "";
|
|
29370
29407
|
|
|
29371
29408
|
if (typeof node.selector === "string") {
|
|
29372
|
-
selector =
|
|
29373
|
-
|
|
29374
|
-
? node.raws.selector.
|
|
29375
|
-
: node.selector
|
|
29409
|
+
selector = node.raws.selector
|
|
29410
|
+
? node.raws.selector.scss
|
|
29411
|
+
? node.raws.selector.scss
|
|
29412
|
+
: node.raws.selector.raw
|
|
29413
|
+
: node.selector;
|
|
29376
29414
|
|
|
29377
29415
|
if (node.raws.between && node.raws.between.trim().length > 0) {
|
|
29378
29416
|
selector += node.raws.between;
|
|
@@ -29384,10 +29422,11 @@ function parseNestedCSS(node) {
|
|
|
29384
29422
|
let value = "";
|
|
29385
29423
|
|
|
29386
29424
|
if (typeof node.value === "string") {
|
|
29387
|
-
value =
|
|
29388
|
-
|
|
29389
|
-
? node.raws.value.
|
|
29390
|
-
: node.value
|
|
29425
|
+
value = node.raws.value
|
|
29426
|
+
? node.raws.value.scss
|
|
29427
|
+
? node.raws.value.scss
|
|
29428
|
+
: node.raws.value.raw
|
|
29429
|
+
: node.value;
|
|
29391
29430
|
|
|
29392
29431
|
value = value.trim();
|
|
29393
29432
|
|
|
@@ -29397,10 +29436,11 @@ function parseNestedCSS(node) {
|
|
|
29397
29436
|
let params = "";
|
|
29398
29437
|
|
|
29399
29438
|
if (typeof node.params === "string") {
|
|
29400
|
-
params =
|
|
29401
|
-
|
|
29402
|
-
? node.raws.params.
|
|
29403
|
-
: node.params
|
|
29439
|
+
params = node.raws.params
|
|
29440
|
+
? node.raws.params.scss
|
|
29441
|
+
? node.raws.params.scss
|
|
29442
|
+
: node.raws.params.raw
|
|
29443
|
+
: node.params;
|
|
29404
29444
|
|
|
29405
29445
|
if (node.raws.afterName && node.raws.afterName.trim().length > 0) {
|
|
29406
29446
|
params = node.raws.afterName + params;
|