Use destructuring for imports (#4554)

* Use destructuring for imports

* Clean up integration tests

* Use moduleNameMapper for require_prettier
master
Lucas Azzola 2018-05-27 21:36:12 +10:00 committed by GitHub
parent 5508546de8
commit b0cb63a7bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 891 additions and 905 deletions

View File

@ -2,11 +2,21 @@
const ENABLE_COVERAGE = !!process.env.CI;
const requiresPrettierInternals = [
"tests_integration/__tests__/util-shared.js",
"tests_integration/__tests__/help-options.js"
];
const semver = require("semver");
const isOldNode = semver.parse(process.version).major <= 4;
module.exports = {
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
snapshotSerializers: ["<rootDir>/tests_config/raw-serializer.js"],
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
testPathIgnorePatterns: ["tests/new_react", "tests/more_react"],
testPathIgnorePatterns: ["tests/new_react", "tests/more_react"].concat(
isOldNode ? requiresPrettierInternals : []
),
collectCoverage: ENABLE_COVERAGE,
collectCoverageFrom: ["src/**/*.js", "index.js", "!<rootDir>/node_modules/"],
coveragePathIgnorePatterns: [
@ -19,7 +29,9 @@ module.exports = {
// `graceful-fs` does `require('fs')`.
// Ref: https://github.com/facebook/jest/issues/2179#issuecomment-355231418
// If this is removed, see also scripts/build/build.js.
"graceful-fs": "<rootDir>/tests_config/fs.js"
"graceful-fs": "<rootDir>/tests_config/fs.js",
"prettier/local": "<rootDir>/tests_config/require_prettier.js"
},
transform: {}
};

View File

@ -1,7 +1,7 @@
"use strict";
const util = require("./util");
const docUtils = require("../doc/doc-utils");
const { mapDoc } = require("../doc").utils;
function isNextLineEmpty(text, node, options) {
return util.isNextLineEmpty(text, node, options.locEnd);
@ -19,7 +19,7 @@ module.exports = {
isNextLineEmpty,
isNextLineEmptyAfterIndex: util.isNextLineEmptyAfterIndex,
getNextNonSpaceNonCommentCharacterIndex,
mapDoc: docUtils.mapDoc, // TODO: remove in 2.0, we already exposed it in docUtils
mapDoc, // TODO: remove in 2.0, we already exposed it in docUtils
makeString: util.makeString,
addLeadingComment: util.addLeadingComment,
addDanglingComment: util.addDanglingComment,

View File

@ -1,10 +1,7 @@
"use strict";
const util = require("../common/util");
const docBuilders = require("./doc-builders");
const concat = docBuilders.concat;
const fill = docBuilders.fill;
const cursor = docBuilders.cursor;
const { concat, fill, cursor } = require("./doc-builders");
const MODE_BREAK = 1;
const MODE_FLAT = 2;

View File

@ -1,67 +1,71 @@
"use strict";
const clean = require("./clean");
const privateUtil = require("../common/util");
const sharedUtil = require("../common/util-shared");
const {
printNumber,
printString,
hasIgnoreComment,
hasNewline
} = require("../common/util");
const { isNextLineEmpty } = require("../common/util-shared");
const doc = require("../doc");
const docBuilders = doc.builders;
const concat = docBuilders.concat;
const join = docBuilders.join;
const line = docBuilders.line;
const hardline = docBuilders.hardline;
const softline = docBuilders.softline;
const group = docBuilders.group;
const fill = docBuilders.fill;
const indent = docBuilders.indent;
const dedent = docBuilders.dedent;
const ifBreak = docBuilders.ifBreak;
const {
builders: {
concat,
join,
line,
hardline,
softline,
group,
fill,
indent,
dedent,
ifBreak
},
utils: { removeLines }
} = require("../doc");
const docUtils = doc.utils;
const removeLines = docUtils.removeLines;
const utils = require("./utils");
const getAncestorNode = utils.getAncestorNode;
const getPropOfDeclNode = utils.getPropOfDeclNode;
const maybeToLowerCase = utils.maybeToLowerCase;
const insideValueFunctionNode = utils.insideValueFunctionNode;
const insideICSSRuleNode = utils.insideICSSRuleNode;
const insideAtRuleNode = utils.insideAtRuleNode;
const insideURLFunctionInImportAtRuleNode =
utils.insideURLFunctionInImportAtRuleNode;
const isKeyframeAtRuleKeywords = utils.isKeyframeAtRuleKeywords;
const isHTMLTag = utils.isHTMLTag;
const isWideKeywords = utils.isWideKeywords;
const isSCSS = utils.isSCSS;
const isLastNode = utils.isLastNode;
const isSCSSControlDirectiveNode = utils.isSCSSControlDirectiveNode;
const isDetachedRulesetDeclarationNode = utils.isDetachedRulesetDeclarationNode;
const isRelationalOperatorNode = utils.isRelationalOperatorNode;
const isEqualityOperatorNode = utils.isEqualityOperatorNode;
const isMultiplicationNode = utils.isMultiplicationNode;
const isDivisionNode = utils.isDivisionNode;
const isAdditionNode = utils.isAdditionNode;
const isSubtractionNode = utils.isSubtractionNode;
const isMathOperatorNode = utils.isMathOperatorNode;
const isEachKeywordNode = utils.isEachKeywordNode;
const isForKeywordNode = utils.isForKeywordNode;
const isURLFunctionNode = utils.isURLFunctionNode;
const isIfElseKeywordNode = utils.isIfElseKeywordNode;
const hasComposesNode = utils.hasComposesNode;
const hasParensAroundNode = utils.hasParensAroundNode;
const hasEmptyRawBefore = utils.hasEmptyRawBefore;
const isKeyValuePairNode = utils.isKeyValuePairNode;
const isDetachedRulesetCallNode = utils.isDetachedRulesetCallNode;
const isPostcssSimpleVarNode = utils.isPostcssSimpleVarNode;
const isSCSSMapItemNode = utils.isSCSSMapItemNode;
const isInlineValueCommentNode = utils.isInlineValueCommentNode;
const isHashNode = utils.isHashNode;
const isLeftCurlyBraceNode = utils.isLeftCurlyBraceNode;
const isRightCurlyBraceNode = utils.isRightCurlyBraceNode;
const isWordNode = utils.isWordNode;
const isColonNode = utils.isColonNode;
const isMediaAndSupportsKeywords = utils.isMediaAndSupportsKeywords;
const {
getAncestorNode,
getPropOfDeclNode,
maybeToLowerCase,
insideValueFunctionNode,
insideICSSRuleNode,
insideAtRuleNode,
insideURLFunctionInImportAtRuleNode,
isKeyframeAtRuleKeywords,
isHTMLTag,
isWideKeywords,
isSCSS,
isLastNode,
isSCSSControlDirectiveNode,
isDetachedRulesetDeclarationNode,
isRelationalOperatorNode,
isEqualityOperatorNode,
isMultiplicationNode,
isDivisionNode,
isAdditionNode,
isSubtractionNode,
isMathOperatorNode,
isEachKeywordNode,
isForKeywordNode,
isURLFunctionNode,
isIfElseKeywordNode,
hasComposesNode,
hasParensAroundNode,
hasEmptyRawBefore,
isKeyValuePairNode,
isDetachedRulesetCallNode,
isPostcssSimpleVarNode,
isSCSSMapItemNode,
isInlineValueCommentNode,
isHashNode,
isLeftCurlyBraceNode,
isRightCurlyBraceNode,
isWordNode,
isColonNode,
isMediaAndSupportsKeywords
} = require("./utils");
function shouldPrintComma(options) {
switch (options.trailingComma) {
@ -744,7 +748,7 @@ function genericPrint(path, options, print) {
return node.value;
}
case "value-number": {
return concat([printNumber(node.value), maybeToLowerCase(node.unit)]);
return concat([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
}
case "value-operator": {
return node.value;
@ -767,7 +771,7 @@ function genericPrint(path, options, print) {
return concat([node.value, " "]);
}
case "value-string": {
return privateUtil.printString(
return printString(
node.raws.quote + node.value + node.raws.quote,
options
);
@ -812,7 +816,7 @@ function printNodeSequence(path, options, print) {
if (i !== node.nodes.length - 1) {
if (
(node.nodes[i + 1].type === "css-comment" &&
!privateUtil.hasNewline(
!hasNewline(
options.originalText,
options.locStart(node.nodes[i + 1]),
{ backwards: true }
@ -825,11 +829,7 @@ function printNodeSequence(path, options, print) {
} else {
parts.push(hardline);
if (
sharedUtil.isNextLineEmpty(
options.originalText,
pathChild.getValue(),
options
)
isNextLineEmpty(options.originalText, pathChild.getValue(), options)
) {
parts.push(hardline);
}
@ -855,9 +855,7 @@ const ADJUST_NUMBERS_REGEX = RegExp(
);
function adjustStrings(value, options) {
return value.replace(STRING_REGEX, match =>
privateUtil.printString(match, options)
);
return value.replace(STRING_REGEX, match => printString(match, options));
}
function quoteAttributeValue(value, options) {
@ -872,15 +870,16 @@ function adjustNumbers(value) {
ADJUST_NUMBERS_REGEX,
(match, quote, wordPart, number, unit) =>
!wordPart && number
? (wordPart || "") + printNumber(number) + maybeToLowerCase(unit || "")
? (wordPart || "") +
printCssNumber(number) +
maybeToLowerCase(unit || "")
: match
);
}
function printNumber(rawNumber) {
function printCssNumber(rawNumber) {
return (
privateUtil
.printNumber(rawNumber)
printNumber(rawNumber)
// Remove trailing `.0`.
.replace(/\.0(?=$|e)/, "")
);
@ -888,6 +887,6 @@ function printNumber(rawNumber) {
module.exports = {
print: genericPrint,
hasPrettierIgnore: privateUtil.hasIgnoreComment,
hasPrettierIgnore: hasIgnoreComment,
massageAstNode: clean
};

View File

@ -1,16 +1,17 @@
"use strict";
const docBuilders = require("../doc").builders;
const concat = docBuilders.concat;
const join = docBuilders.join;
const hardline = docBuilders.hardline;
const line = docBuilders.line;
const softline = docBuilders.softline;
const group = docBuilders.group;
const indent = docBuilders.indent;
const ifBreak = docBuilders.ifBreak;
const privateUtil = require("../common/util");
const sharedUtil = require("../common/util-shared");
const {
concat,
join,
hardline,
line,
softline,
group,
indent,
ifBreak
} = require("../doc").builders;
const { hasIgnoreComment } = require("../common/util");
const { isNextLineEmpty } = require("../common/util-shared");
function genericPrint(path, options, print) {
const n = path.getValue();
@ -30,11 +31,7 @@ function genericPrint(path, options, print) {
parts.push(hardline);
if (
index !== n.definitions.length - 1 &&
sharedUtil.isNextLineEmpty(
options.originalText,
pathChild.getValue(),
options
)
isNextLineEmpty(options.originalText, pathChild.getValue(), options)
) {
parts.push(hardline);
}
@ -614,11 +611,7 @@ function printSequence(sequencePath, options, print) {
const printed = print(path);
if (
sharedUtil.isNextLineEmpty(
options.originalText,
path.getValue(),
options
) &&
isNextLineEmpty(options.originalText, path.getValue(), options) &&
i < count - 1
) {
return concat([printed, hardline]);
@ -663,7 +656,7 @@ function clean(node, newNode /*, parent*/) {
module.exports = {
print: genericPrint,
massageAstNode: clean,
hasPrettierIgnore: privateUtil.hasIgnoreComment,
hasPrettierIgnore: hasIgnoreComment,
printComment,
canAttachComment
};

View File

@ -1,14 +1,15 @@
"use strict";
const docBuilders = require("../doc/doc-builders");
const concat = docBuilders.concat;
const join = docBuilders.join;
const softline = docBuilders.softline;
const hardline = docBuilders.hardline;
const line = docBuilders.line;
const group = docBuilders.group;
const indent = docBuilders.indent;
const ifBreak = docBuilders.ifBreak;
const {
concat,
join,
softline,
hardline,
line,
group,
indent,
ifBreak
} = require("../doc").builders;
// http://w3c.github.io/html/single-page.html#void-elements
const voidTags = [

View File

@ -1,11 +1,10 @@
"use strict";
const privateUtil = require("../common/util");
const doc = require("../doc");
const docUtils = doc.utils;
const docBuilders = doc.builders;
const hardline = docBuilders.hardline;
const concat = docBuilders.concat;
const { hasNewlineInRange } = require("../common/util");
const {
builders: { hardline, concat },
utils: { stripTrailingHardline, removeLines }
} = require("../doc");
function embed(path, print, textToDoc, options) {
const node = path.getValue();
@ -42,7 +41,7 @@ function embed(path, print, textToDoc, options) {
// Inline Styles
if (parent.type === "style") {
const doc = textToDoc(getText(options, node), { parser: "css" });
return concat([hardline, docUtils.stripTrailingHardline(doc)]);
return concat([hardline, stripTrailingHardline(doc)]);
}
break;
@ -66,9 +65,9 @@ function embed(path, print, textToDoc, options) {
return concat([
node.key,
'="',
privateUtil.hasNewlineInRange(node.value, 0, node.value.length)
hasNewlineInRange(node.value, 0, node.value.length)
? doc
: docUtils.removeLines(doc),
: removeLines(doc),
'"'
]);
}

View File

@ -2,15 +2,16 @@
const embed = require("./embed");
const clean = require("./clean");
const privateUtil = require("../common/util");
const docBuilders = require("../doc").builders;
const concat = docBuilders.concat;
const join = docBuilders.join;
const hardline = docBuilders.hardline;
const line = docBuilders.line;
const softline = docBuilders.softline;
const group = docBuilders.group;
const indent = docBuilders.indent;
const { hasNewlineInRange, hasIgnoreComment } = require("../common/util");
const {
concat,
join,
hardline,
line,
softline,
group,
indent
} = require("../doc").builders;
// http://w3c.github.io/html/single-page.html#void-elements
const voidTags = {
@ -56,7 +57,7 @@ function genericPrint(path, options, print) {
const selfClose = voidTags[n.name] ? ">" : " />";
const children = printChildren(path, print);
const hasNewline = privateUtil.hasNewlineInRange(
const hasNewline = hasNewlineInRange(
options.originalText,
options.locStart(n),
options.locEnd(n)
@ -119,5 +120,5 @@ module.exports = {
print: genericPrint,
massageAstNode: clean,
embed,
hasPrettierIgnore: privateUtil.hasIgnoreComment
hasPrettierIgnore: hasIgnoreComment
};

View File

@ -1,15 +1,17 @@
"use strict";
const doc = require("../doc");
const docUtils = doc.utils;
const docBuilders = doc.builders;
const indent = docBuilders.indent;
const join = docBuilders.join;
const hardline = docBuilders.hardline;
const softline = docBuilders.softline;
const literalline = docBuilders.literalline;
const concat = docBuilders.concat;
const dedentToRoot = docBuilders.dedentToRoot;
const {
builders: {
indent,
join,
hardline,
softline,
literalline,
concat,
dedentToRoot
},
utils: { mapDoc, stripTrailingHardline }
} = require("../doc");
function embed(path, print, textToDoc /*, options */) {
const node = path.getValue();
@ -101,9 +103,7 @@ function embed(path, print, textToDoc /*, options */) {
if (commentsAndWhitespaceOnly) {
doc = printGraphqlComments(lines);
} else {
doc = docUtils.stripTrailingHardline(
textToDoc(text, { parser: "graphql" })
);
doc = stripTrailingHardline(textToDoc(text, { parser: "graphql" }));
}
if (doc) {
@ -175,7 +175,7 @@ function embed(path, print, textToDoc /*, options */) {
function printMarkdown(text) {
const doc = textToDoc(text, { parser: "markdown", __inJsTemplate: true });
return docUtils.stripTrailingHardline(escapeBackticks(doc));
return stripTrailingHardline(escapeBackticks(doc));
}
}
@ -197,7 +197,7 @@ function getIndentation(str) {
}
function escapeBackticks(doc) {
return docUtils.mapDoc(doc, currentDoc => {
return mapDoc(doc, currentDoc => {
if (!currentDoc.parts) {
return currentDoc;
}
@ -235,7 +235,7 @@ function transformCssDoc(quasisDoc, path, print) {
}
return concat([
"`",
indent(concat([hardline, docUtils.stripTrailingHardline(newDoc)])),
indent(concat([hardline, stripTrailingHardline(newDoc)])),
softline,
"`"
]);
@ -252,7 +252,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
const expressions = expressionDocs.slice();
let replaceCounter = 0;
const newDoc = docUtils.mapDoc(quasisDoc, doc => {
const newDoc = mapDoc(quasisDoc, doc => {
if (!doc || !doc.parts || !doc.parts.length) {
return doc;
}

View File

@ -1,11 +1,6 @@
"use strict";
const docBuilders = require("../doc/doc-builders");
const concat = docBuilders.concat;
const hardline = docBuilders.hardline;
const indent = docBuilders.indent;
const join = docBuilders.join;
const { concat, hardline, indent, join } = require("../doc").builders;
function genericPrint(path, options, print) {
const node = path.getValue();

View File

@ -3,8 +3,29 @@
const assert = require("assert");
// TODO(azz): anything that imports from main shouldn't be in a `language-*` dir.
const comments = require("../main/comments");
const privateUtil = require("../common/util");
const sharedUtil = require("../common/util-shared");
const {
getParentExportDeclaration,
isExportDeclaration,
shouldFlatten,
getNextNonSpaceNonCommentCharacter,
hasNewline,
hasNewlineInRange,
getLast,
getStringWidth,
printString,
printNumber,
hasIgnoreComment,
skipWhitespace,
hasNodeIgnoreComment,
getPenultimate,
startsWithNoLookaheadToken,
getIndentSize
} = require("../common/util");
const {
isNextLineEmpty,
isNextLineEmptyAfterIndex,
getNextNonSpaceNonCommentCharacterIndex
} = require("../common/util-shared");
const isIdentifierName = require("esutils").keyword.isIdentifierNameES6;
const embed = require("./embed");
const clean = require("./clean");
@ -12,30 +33,28 @@ const insertPragma = require("./pragma").insertPragma;
const handleComments = require("./comments");
const pathNeedsParens = require("./needs-parens");
const doc = require("../doc");
const docBuilders = doc.builders;
const concat = docBuilders.concat;
const join = docBuilders.join;
const line = docBuilders.line;
const hardline = docBuilders.hardline;
const softline = docBuilders.softline;
const literalline = docBuilders.literalline;
const group = docBuilders.group;
const indent = docBuilders.indent;
const align = docBuilders.align;
const conditionalGroup = docBuilders.conditionalGroup;
const fill = docBuilders.fill;
const ifBreak = docBuilders.ifBreak;
const breakParent = docBuilders.breakParent;
const lineSuffixBoundary = docBuilders.lineSuffixBoundary;
const addAlignmentToDoc = docBuilders.addAlignmentToDoc;
const dedent = docBuilders.dedent;
const printDocToString = doc.printer.printDocToString;
const docUtils = doc.utils;
const willBreak = docUtils.willBreak;
const isLineNext = docUtils.isLineNext;
const isEmpty = docUtils.isEmpty;
const {
builders: {
concat,
join,
line,
hardline,
softline,
literalline,
group,
indent,
align,
conditionalGroup,
fill,
ifBreak,
breakParent,
lineSuffixBoundary,
addAlignmentToDoc,
dedent
},
utils: { willBreak, isLineNext, isEmpty, removeLines },
printer: { printDocToString }
} = require("../doc");
function shouldPrintComma(options, level) {
level = level || "es5";
@ -72,7 +91,7 @@ function genericPrint(path, options, printPath, args) {
node.decorators.length > 0 &&
// If the parent node is an export declaration, it will be
// responsible for printing node.decorators.
!privateUtil.getParentExportDeclaration(path)
!getParentExportDeclaration(path)
) {
let separator = hardline;
path.each(decoratorPath => {
@ -107,7 +126,7 @@ function genericPrint(path, options, printPath, args) {
decorators.push(printPath(decoratorPath), separator);
}, "decorators");
} else if (
privateUtil.isExportDeclaration(node) &&
isExportDeclaration(node) &&
node.declaration &&
node.declaration.decorators
) {
@ -146,7 +165,7 @@ function genericPrint(path, options, printPath, args) {
}
function hasPrettierIgnore(path) {
return privateUtil.hasIgnoreComment(path) || hasJsxIgnoreComment(path);
return hasIgnoreComment(path) || hasJsxIgnoreComment(path);
}
function hasJsxIgnoreComment(path) {
@ -359,11 +378,7 @@ function printPathNoParens(path, options, print, args) {
path.each(childPath => {
parts.push(print(childPath), semi, hardline);
if (
sharedUtil.isNextLineEmpty(
options.originalText,
childPath.getValue(),
options
)
isNextLineEmpty(options.originalText, childPath.getValue(), options)
) {
parts.push(hardline);
}
@ -481,8 +496,7 @@ function printPathNoParens(path, options, print, args) {
parent.type === "Property";
const samePrecedenceSubExpression =
isBinaryish(n.left) &&
privateUtil.shouldFlatten(n.operator, n.left.operator);
isBinaryish(n.left) && shouldFlatten(n.operator, n.left.operator);
if (
shouldNotIndent ||
@ -662,7 +676,7 @@ function printPathNoParens(path, options, print, args) {
options,
/* sameIndent */ true,
comment => {
const nextCharacter = sharedUtil.getNextNonSpaceNonCommentCharacterIndex(
const nextCharacter = getNextNonSpaceNonCommentCharacterIndex(
options.originalText,
comment,
options
@ -723,10 +737,7 @@ function printPathNoParens(path, options, print, args) {
// a <= a ? a : a
const shouldAddParens =
n.body.type === "ConditionalExpression" &&
!privateUtil.startsWithNoLookaheadToken(
n.body,
/* forbidFunctionAndClass */ false
);
!startsWithNoLookaheadToken(n.body, /* forbidFunctionAndClass */ false);
return group(
concat([
@ -952,11 +963,7 @@ function printPathNoParens(path, options, print, args) {
path.each(childPath => {
parts.push(indent(concat([hardline, print(childPath), semi])));
if (
sharedUtil.isNextLineEmpty(
options.originalText,
childPath.getValue(),
options
)
isNextLineEmpty(options.originalText, childPath.getValue(), options)
) {
parts.push(hardline);
}
@ -1117,7 +1124,7 @@ function printPathNoParens(path, options, print, args) {
property.value.type === "ArrayPattern")
)) ||
(n.type !== "ObjectPattern" &&
privateUtil.hasNewlineInRange(
hasNewlineInRange(
options.originalText,
options.locStart(n),
options.locEnd(n)
@ -1174,26 +1181,24 @@ function printPathNoParens(path, options, print, args) {
separatorParts = [separator, line];
if (
prop.node.type === "TSPropertySignature" &&
privateUtil.hasNodeIgnoreComment(prop.node)
hasNodeIgnoreComment(prop.node)
) {
separatorParts.shift();
}
if (
sharedUtil.isNextLineEmpty(options.originalText, prop.node, options)
) {
if (isNextLineEmpty(options.originalText, prop.node, options)) {
separatorParts.push(hardline);
}
return result;
});
const lastElem = privateUtil.getLast(n[propertiesField]);
const lastElem = getLast(n[propertiesField]);
const canHaveTrailingSeparator = !(
lastElem &&
(lastElem.type === "RestProperty" ||
lastElem.type === "RestElement" ||
lastElem.type === "ExperimentalRestProperty" ||
privateUtil.hasNodeIgnoreComment(lastElem))
hasNodeIgnoreComment(lastElem))
);
let content;
@ -1312,7 +1317,7 @@ function printPathNoParens(path, options, print, args) {
);
}
} else {
const lastElem = privateUtil.getLast(n.elements);
const lastElem = getLast(n.elements);
const canHaveTrailingComma = !(
lastElem && lastElem.type === "RestElement"
);
@ -1325,7 +1330,7 @@ function printPathNoParens(path, options, print, args) {
// [1,].length === 1
// [1,,].length === 2
//
// Note that privateUtil.getLast returns null if the array is empty, but
// Note that getLast returns null if the array is empty, but
// we already check for an empty array just above so we are safe
const needsForcedTrailingComma =
canHaveTrailingComma && lastElem === null;
@ -1398,7 +1403,7 @@ function printPathNoParens(path, options, print, args) {
case "RegExpLiteral": // Babel 6 Literal split
return printRegex(n);
case "NumericLiteral": // Babel 6 Literal split
return privateUtil.printNumber(n.extra.raw);
return printNumber(n.extra.raw);
case "BooleanLiteral": // Babel 6 Literal split
case "StringLiteral": // Babel 6 Literal split
case "Literal": {
@ -1406,7 +1411,7 @@ function printPathNoParens(path, options, print, args) {
return printRegex(n.regex);
}
if (typeof n.value === "number") {
return privateUtil.printNumber(n.raw);
return printNumber(n.raw);
}
if (typeof n.value !== "string") {
return "" + n.value;
@ -1753,11 +1758,7 @@ function printPathNoParens(path, options, print, args) {
return concat([
casePath.call(print),
n.cases.indexOf(caseNode) !== n.cases.length - 1 &&
sharedUtil.isNextLineEmpty(
options.originalText,
caseNode,
options
)
isNextLineEmpty(options.originalText, caseNode, options)
? hardline
: ""
]);
@ -1952,8 +1953,7 @@ function printPathNoParens(path, options, print, args) {
}
const lastAttrHasTrailingComments =
n.attributes.length &&
hasTrailingComment(privateUtil.getLast(n.attributes));
n.attributes.length && hasTrailingComment(getLast(n.attributes));
const bracketSameLine =
options.jsxBracketSameLine &&
@ -2200,7 +2200,7 @@ function printPathNoParens(path, options, print, args) {
row.cells.forEach((cell, index) => {
maxColumnWidths[index] = Math.max(
maxColumnWidths[index],
privateUtil.getStringWidth(cell)
getStringWidth(cell)
);
});
});
@ -2221,8 +2221,7 @@ function printPathNoParens(path, options, print, args) {
? cell
: cell +
" ".repeat(
maxColumnWidths[index] -
privateUtil.getStringWidth(cell)
maxColumnWidths[index] - getStringWidth(cell)
)
)
)
@ -2257,7 +2256,7 @@ function printPathNoParens(path, options, print, args) {
// expression inside at the beginning of ${ instead of the beginning
// of the `.
const tabWidth = options.tabWidth;
const indentSize = privateUtil.getIndentSize(
const indentSize = getIndentSize(
childPath.getValue().value.raw,
tabWidth
);
@ -2705,9 +2704,9 @@ function printPathNoParens(path, options, print, args) {
assert.strictEqual(typeof n.value, "number");
if (n.extra != null) {
return privateUtil.printNumber(n.extra.raw);
return printNumber(n.extra.raw);
}
return privateUtil.printNumber(n.raw);
return printNumber(n.raw);
case "StringTypeAnnotation":
return "string";
@ -3199,7 +3198,7 @@ function printPathNoParens(path, options, print, args) {
case "InterpreterDirective":
parts.push("#!", n.value, hardline);
if (sharedUtil.isNextLineEmpty(options.originalText, n, options)) {
if (isNextLineEmpty(options.originalText, n, options)) {
parts.push(hardline);
}
@ -3265,10 +3264,7 @@ function printStatementSequence(path, options, print) {
}
}
if (
sharedUtil.isNextLineEmpty(text, stmt, options) &&
!isLastStatement(stmtPath)
) {
if (isNextLineEmpty(text, stmt, options) && !isLastStatement(stmtPath)) {
parts.push(hardline);
}
@ -3393,8 +3389,8 @@ function couldGroupArg(arg) {
}
function shouldGroupLastArg(args) {
const lastArg = privateUtil.getLast(args);
const penultimateArg = privateUtil.getPenultimate(args);
const lastArg = getLast(args);
const penultimateArg = getPenultimate(args);
return (
!hasLeadingComment(lastArg) &&
!hasTrailingComment(lastArg) &&
@ -3470,7 +3466,7 @@ function printArgumentsList(path, options, print) {
if (index === lastArgIndex) {
// do nothing
} else if (sharedUtil.isNextLineEmpty(options.originalText, arg, options)) {
} else if (isNextLineEmpty(options.originalText, arg, options)) {
if (index === 0) {
hasEmptyLineFollowingFirstArg = true;
}
@ -3566,7 +3562,7 @@ function printArgumentsList(path, options, print) {
: concat([
"(",
concat(printedArguments.slice(0, -1)),
group(privateUtil.getLast(printedExpanded), {
group(getLast(printedExpanded), {
shouldBreak: true
}),
")"
@ -3655,7 +3651,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
options,
/* sameIndent */ true,
comment =>
privateUtil.getNextNonSpaceNonCommentCharacter(
getNextNonSpaceNonCommentCharacter(
options.originalText,
comment,
options.locEnd
@ -3665,7 +3661,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
]);
}
const lastParam = privateUtil.getLast(fun[paramsField]);
const lastParam = getLast(fun[paramsField]);
// If the parent is a call with the first/last argument expansion and this is the
// params of the first/last argument, we dont want the arguments to break and instead
@ -3683,9 +3679,9 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
) {
return group(
concat([
docUtils.removeLines(typeParams),
removeLines(typeParams),
"(",
join(", ", printed.map(docUtils.removeLines)),
join(", ", printed.map(removeLines)),
")"
])
);
@ -3989,7 +3985,7 @@ function printExportDeclaration(path, options, print) {
}
function printFlowDeclaration(path, parts) {
const parentExportDecl = privateUtil.getParentExportDeclaration(path);
const parentExportDecl = getParentExportDeclaration(path);
if (parentExportDecl) {
assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
@ -4242,7 +4238,7 @@ function printMemberChain(path, options, print) {
// the first group whether it is in parentheses or not
function shouldInsertEmptyLineAfter(node) {
const originalText = options.originalText;
const nextCharIndex = sharedUtil.getNextNonSpaceNonCommentCharacterIndex(
const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex(
originalText,
node,
options
@ -4252,14 +4248,14 @@ function printMemberChain(path, options, print) {
// if it is cut off by a parenthesis, we only account for one typed empty
// line after that parenthesis
if (nextChar == ")") {
return sharedUtil.isNextLineEmptyAfterIndex(
return isNextLineEmptyAfterIndex(
originalText,
nextCharIndex + 1,
options
);
}
return sharedUtil.isNextLineEmpty(originalText, node, options);
return isNextLineEmpty(originalText, node, options);
}
function rec(path) {
@ -4475,7 +4471,7 @@ function printMemberChain(path, options, print) {
);
}
const lastNode = privateUtil.getLast(groups[0]).node;
const lastNode = getLast(groups[0]).node;
return (
(lastNode.type === "MemberExpression" ||
lastNode.type === "OptionalMemberExpression") &&
@ -4539,7 +4535,7 @@ function printMemberChain(path, options, print) {
// Find out the last node in the first group and check if it has an
// empty line after
const lastNodeBeforeIndent = privateUtil.getLast(
const lastNodeBeforeIndent = getLast(
shouldMerge ? groups.slice(1, 2)[0] : groups[0]
).node;
const shouldHaveEmptyLineBeforeIndent =
@ -4767,7 +4763,7 @@ function printJSXChildren(path, options, print, jsxWhitespace) {
let endWhitespace;
// Ends with whitespace
if (privateUtil.getLast(words) === "") {
if (getLast(words) === "") {
words.pop();
endWhitespace = words.pop();
}
@ -4955,8 +4951,7 @@ function printJSXElement(path, options, print) {
// Trim trailing lines (or empty strings)
while (
children.length &&
(isLineNext(privateUtil.getLast(children)) ||
isEmpty(privateUtil.getLast(children)))
(isLineNext(getLast(children)) || isEmpty(getLast(children)))
) {
children.pop();
}
@ -5130,7 +5125,7 @@ function printBinaryishExpressions(
// precedence level and should be treated as a separate group, so
// print them normally. (This doesn't hold for the `**` operator,
// which is unique in that it is right-associative.)
if (privateUtil.shouldFlatten(node.operator, node.left.operator)) {
if (shouldFlatten(node.operator, node.left.operator)) {
// Flatten them out by recursively calling this function.
parts = parts.concat(
path.call(
@ -5247,7 +5242,7 @@ function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
const raw = rawText(node);
const isDirectiveLiteral =
isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
return privateUtil.printString(raw, options, isDirectiveLiteral);
return printString(raw, options, isDirectiveLiteral);
}
function printRegex(node) {
@ -5280,14 +5275,13 @@ function hasTrailingComment(node) {
function hasLeadingOwnLineComment(text, node, options) {
if (isJSXNode(node)) {
return privateUtil.hasNodeIgnoreComment(node);
return hasNodeIgnoreComment(node);
}
const res =
node.comments &&
node.comments.some(
comment =>
comment.leading && privateUtil.hasNewline(text, options.locEnd(comment))
comment => comment.leading && hasNewline(text, options.locEnd(comment))
);
return res;
}
@ -5311,7 +5305,7 @@ function hasNakedLeftSide(node) {
function isFlowAnnotationComment(text, typeAnnotation, options) {
const start = options.locStart(typeAnnotation);
const end = privateUtil.skipWhitespace(text, options.locEnd(typeAnnotation));
const end = skipWhitespace(text, options.locEnd(typeAnnotation));
return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
}
@ -5625,7 +5619,7 @@ function isTemplateOnItsOwnLine(n, text, options) {
((n.type === "TemplateLiteral" && templateLiteralHasNewLines(n)) ||
(n.type === "TaggedTemplateExpression" &&
templateLiteralHasNewLines(n.quasi))) &&
!privateUtil.hasNewline(text, options.locStart(n), { backwards: true })
!hasNewline(text, options.locStart(n), { backwards: true })
);
}
@ -5640,11 +5634,7 @@ function printArrayItems(path, options, printPath, print) {
separatorParts = [",", line];
if (
childPath.getValue() &&
sharedUtil.isNextLineEmpty(
options.originalText,
childPath.getValue(),
options
)
isNextLineEmpty(options.originalText, childPath.getValue(), options)
) {
separatorParts.push(softline);
}
@ -5664,7 +5654,7 @@ function needsHardlineAfterDanglingComment(node) {
if (!node.comments) {
return false;
}
const lastDanglingComment = privateUtil.getLast(
const lastDanglingComment = getLast(
node.comments.filter(comment => !comment.leading && !comment.trailing)
);
return (
@ -5809,7 +5799,7 @@ function willPrintOwnComments(path) {
((parent.type === "ClassDeclaration" ||
parent.type === "ClassExpression") &&
parent.superClass === node)))) &&
!privateUtil.hasIgnoreComment(path)
!hasIgnoreComment(path)
);
}
@ -5840,11 +5830,9 @@ function printComment(commentPath, options) {
// interleaved. See https://github.com/prettier/prettier/issues/4412
if (
comment.trailing &&
!privateUtil.hasNewline(
options.originalText,
options.locStart(comment),
{ backwards: true }
)
!hasNewline(options.originalText, options.locStart(comment), {
backwards: true
})
) {
return concat([hardline, printed]);
}

View File

@ -1,14 +1,11 @@
"use strict";
const docUtils = require("../doc/doc-utils");
const util = require("../common/util");
const support = require("../main/support");
const doc = require("../doc");
const docBuilders = doc.builders;
const hardline = docBuilders.hardline;
const literalline = docBuilders.literalline;
const concat = docBuilders.concat;
const markAsRoot = docBuilders.markAsRoot;
const {
builders: { hardline, literalline, concat, markAsRoot },
utils: { mapDoc }
} = require("../doc");
function embed(path, print, textToDoc, options) {
const node = path.getValue();
@ -55,7 +52,7 @@ function embed(path, print, textToDoc, options) {
}
function replaceNewlinesWithLiterallines(doc) {
return docUtils.mapDoc(
return mapDoc(
doc,
currentDoc =>
typeof currentDoc === "string" && currentDoc.includes("\n")

View File

@ -1,21 +1,23 @@
"use strict";
const docUtils = require("../doc/doc-utils");
const privateUtil = require("../common/util");
const embed = require("./embed");
const pragma = require("./pragma");
const doc = require("../doc");
const docBuilders = doc.builders;
const concat = docBuilders.concat;
const join = docBuilders.join;
const line = docBuilders.line;
const hardline = docBuilders.hardline;
const softline = docBuilders.softline;
const fill = docBuilders.fill;
const align = docBuilders.align;
const indent = docBuilders.indent;
const group = docBuilders.group;
const printDocToString = doc.printer.printDocToString;
const {
builders: {
concat,
join,
line,
hardline,
softline,
fill,
align,
indent,
group
},
utils: { mapDoc },
printer: { printDocToString }
} = require("../doc");
const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
@ -732,7 +734,7 @@ function shouldRemainTheSameContent(path) {
}
function normalizeDoc(doc) {
return docUtils.mapDoc(doc, currentDoc => {
return mapDoc(doc, currentDoc => {
if (!currentDoc.parts) {
return currentDoc;
}

View File

@ -1,8 +1,6 @@
"use strict";
const docBuilders = require("../doc").builders;
const concat = docBuilders.concat;
const hardline = docBuilders.hardline;
const { concat, hardline } = require("../doc").builders;
function embed(path, print, textToDoc, options) {
const node = path.getValue();

View File

@ -1,9 +1,7 @@
"use strict";
const embed = require("./embed");
const docBuilders = require("../doc").builders;
const concat = docBuilders.concat;
const hardline = docBuilders.hardline;
const { concat, hardline } = require("../doc").builders;
function genericPrint(path, options, print) {
const n = path.getValue();

View File

@ -1,22 +1,27 @@
"use strict";
const assert = require("assert");
const docBuilders = require("../doc").builders;
const concat = docBuilders.concat;
const hardline = docBuilders.hardline;
const breakParent = docBuilders.breakParent;
const indent = docBuilders.indent;
const lineSuffix = docBuilders.lineSuffix;
const join = docBuilders.join;
const cursor = docBuilders.cursor;
const privateUtil = require("../common/util");
const sharedUtil = require("../common/util-shared");
const {
concat,
hardline,
breakParent,
indent,
lineSuffix,
join,
cursor
} = require("../doc").builders;
const {
hasNewline,
skipNewline,
isPreviousLineEmpty
} = require("../common/util");
const {
addLeadingComment,
addDanglingComment,
addTrailingComment
} = require("../common/util-shared");
const childNodesCacheKey = Symbol("child-nodes");
const addLeadingComment = sharedUtil.addLeadingComment;
const addTrailingComment = sharedUtil.addTrailingComment;
const addDanglingComment = sharedUtil.addDanglingComment;
function getSortedChildNodes(node, options, resultArray) {
if (!node) {
return;
@ -207,7 +212,7 @@ function attach(comments, ast, text, options) {
const isLastComment = comments.length - 1 === i;
if (privateUtil.hasNewline(text, locStart(comment), { backwards: true })) {
if (hasNewline(text, locStart(comment), { backwards: true })) {
// If a comment exists on its own line, prefer a leading comment.
// We also need to check if it's the first line of the file.
if (
@ -226,7 +231,7 @@ function attach(comments, ast, text, options) {
/* istanbul ignore next */
addDanglingComment(ast, comment);
}
} else if (privateUtil.hasNewline(text, locEnd(comment))) {
} else if (hasNewline(text, locEnd(comment))) {
if (
pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)
) {
@ -379,9 +384,7 @@ function printLeadingComment(commentPath, print, options) {
if (isBlock) {
return concat([
contents,
privateUtil.hasNewline(options.originalText, options.locEnd(comment))
? hardline
: " "
hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "
]);
}
@ -409,7 +412,7 @@ function printTrailingComment(commentPath, print, options) {
parentParentNode.superClass === parentNode;
if (
privateUtil.hasNewline(options.originalText, options.locStart(comment), {
hasNewline(options.originalText, options.locStart(comment), {
backwards: true
})
) {
@ -425,7 +428,7 @@ function printTrailingComment(commentPath, print, options) {
// if this a comment on its own line; normal trailing comments are
// always at the end of another expression.
const isLineBeforeEmpty = privateUtil.isPreviousLineEmpty(
const isLineBeforeEmpty = isPreviousLineEmpty(
options.originalText,
comment,
options.locStart
@ -504,12 +507,7 @@ function printComments(path, print, options, needsSemi) {
leadingParts.push(contents);
const text = options.originalText;
if (
privateUtil.hasNewline(
text,
privateUtil.skipNewline(text, options.locEnd(comment))
)
) {
if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
leadingParts.push(hardline);
}
} else if (trailing) {

View File

@ -8,12 +8,11 @@ const comments = require("./comments");
const parser = require("./parser");
const printAstToDoc = require("./ast-to-doc");
const rangeUtil = require("./range-util");
const privateUtil = require("../common/util");
const doc = require("../doc");
const printDocToString = doc.printer.printDocToString;
const printDocToDebug = doc.debug.printDocToDebug;
const {
printer: { printDocToString },
debug: { printDocToDebug }
} = require("../doc");
const UTF8BOM = 0xfeff;

View File

@ -1,6 +1,6 @@
run_spec(__dirname, ["babylon", "typescript", "flow"]);
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
test("translates cursor correctly in basic case", () => {
expect(

View File

@ -2,7 +2,7 @@
const fs = require("fs");
const extname = require("path").extname;
const prettier = require("./require_prettier");
const prettier = require("prettier/local");
const AST_COMPARE = process.env["AST_COMPARE"];

View File

@ -1,182 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`show detailed usage with --help arrow-parens (stderr) 1`] = `""`;
exports[`show detailed usage with --help arrow-parens (stdout) 1`] = `
"--arrow-parens <avoid|always>
Include parentheses around a sole arrow function parameter.
Valid options:
avoid Omit parens when possible. Example: \`x => x\`
always Always include parens. Example: \`(x) => x\`
Default: avoid
"
`;
exports[`show detailed usage with --help arrow-parens (write) 1`] = `Array []`;
exports[`show detailed usage with --help bracket-spacing (stderr) 1`] = `""`;
exports[`show detailed usage with --help bracket-spacing (stdout) 1`] = `
"--bracket-spacing
Print spaces between brackets.
Default: true
"
`;
exports[`show detailed usage with --help bracket-spacing (write) 1`] = `Array []`;
exports[`show detailed usage with --help color (stderr) 1`] = `""`;
exports[`show detailed usage with --help color (stdout) 1`] = `
"--color
Colorize error messages.
Default: true
"
`;
exports[`show detailed usage with --help color (write) 1`] = `Array []`;
exports[`show detailed usage with --help config (stderr) 1`] = `""`;
exports[`show detailed usage with --help config (stdout) 1`] = `
"--config <path>
Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).
"
`;
exports[`show detailed usage with --help config (write) 1`] = `Array []`;
exports[`show detailed usage with --help config-precedence (stderr) 1`] = `""`;
exports[`show detailed usage with --help config-precedence (stdout) 1`] = `
"--config-precedence <cli-override|file-override|prefer-file>
Define in which order config files and CLI options should be evaluated.
Valid options:
cli-override CLI options take precedence over config file
file-override Config file take precedence over CLI options
prefer-file If a config file is found will evaluate it and ignore other CLI options.
If no config file is found CLI options will evaluate as normal.
Default: cli-override
"
`;
exports[`show detailed usage with --help config-precedence (write) 1`] = `Array []`;
exports[`show detailed usage with --help cursor-offset (stderr) 1`] = `""`;
exports[`show detailed usage with --help cursor-offset (stdout) 1`] = `
"--cursor-offset <int>
Print (to stderr) where a cursor at the given position would move to after formatting.
This option cannot be used with --range-start and --range-end.
Default: -1
"
`;
exports[`show detailed usage with --help cursor-offset (write) 1`] = `Array []`;
exports[`show detailed usage with --help editorconfig (stderr) 1`] = `""`;
exports[`show detailed usage with --help editorconfig (stdout) 1`] = `
"--editorconfig
Take .editorconfig into account when parsing configuration.
Default: true
"
`;
exports[`show detailed usage with --help editorconfig (write) 1`] = `Array []`;
exports[`show detailed usage with --help file-info (stderr) 1`] = `""`;
exports[`show detailed usage with --help file-info (stdout) 1`] = `
"--file-info <path>
Extract the following info (as JSON) for a given file path. Reported fields:
* ignored (boolean) - true if file path is filtered by --ignore-path
* inferredParser (string | null) - name of parser inferred from file path
"
`;
exports[`show detailed usage with --help file-info (write) 1`] = `Array []`;
exports[`show detailed usage with --help find-config-path (stderr) 1`] = `""`;
exports[`show detailed usage with --help find-config-path (stdout) 1`] = `
"--find-config-path <path>
Find and print the path to a configuration file for the given input file.
"
`;
exports[`show detailed usage with --help find-config-path (write) 1`] = `Array []`;
exports[`show detailed usage with --help help (stderr) 1`] = `""`;
exports[`show detailed usage with --help help (stdout) 1`] = `
"-h, --help <flag>
Show CLI usage, or details about the given flag.
Example: --help write
"
`;
exports[`show detailed usage with --help help (write) 1`] = `Array []`;
exports[`show detailed usage with --help ignore-path (stderr) 1`] = `""`;
exports[`show detailed usage with --help ignore-path (stdout) 1`] = `
"--ignore-path <path>
Path to a file with patterns describing files to ignore.
Default: .prettierignore
"
`;
exports[`show detailed usage with --help ignore-path (write) 1`] = `Array []`;
exports[`show detailed usage with --help insert-pragma (stderr) 1`] = `""`;
exports[`show detailed usage with --help insert-pragma (stdout) 1`] = `
"--insert-pragma
Insert @format pragma into file's first docblock comment.
Default: false
"
`;
exports[`show detailed usage with --help insert-pragma (write) 1`] = `Array []`;
exports[`show detailed usage with --help jsx-bracket-same-line (stderr) 1`] = `""`;
exports[`show detailed usage with --help jsx-bracket-same-line (stdout) 1`] = `
"--jsx-bracket-same-line
Put > on the last line instead of at a new line.
Default: false
"
`;
exports[`show detailed usage with --help jsx-bracket-same-line (write) 1`] = `Array []`;
exports[`show detailed usage with --help l (alias) (stderr) 1`] = `""`;
exports[`show detailed usage with --help l (alias) (stdout) 1`] = `
@ -188,360 +11,6 @@ exports[`show detailed usage with --help l (alias) (stdout) 1`] = `
exports[`show detailed usage with --help l (alias) (write) 1`] = `Array []`;
exports[`show detailed usage with --help list-different (stderr) 1`] = `""`;
exports[`show detailed usage with --help list-different (stdout) 1`] = `
"-l, --list-different
Print the names of files that are different from Prettier's formatting.
"
`;
exports[`show detailed usage with --help list-different (write) 1`] = `Array []`;
exports[`show detailed usage with --help loglevel (stderr) 1`] = `""`;
exports[`show detailed usage with --help loglevel (stdout) 1`] = `
"--loglevel <silent|error|warn|log|debug>
What level of logs to report.
Valid options:
silent
error
warn
log
debug
Default: log
"
`;
exports[`show detailed usage with --help loglevel (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-bracket-spacing (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-bracket-spacing (stdout) 1`] = `
"--no-bracket-spacing
Do not print spaces between brackets.
"
`;
exports[`show detailed usage with --help no-bracket-spacing (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-color (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-color (stdout) 1`] = `
"--no-color
Do not colorize error messages.
"
`;
exports[`show detailed usage with --help no-color (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-config (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-config (stdout) 1`] = `
"--no-config
Do not look for a configuration file.
"
`;
exports[`show detailed usage with --help no-config (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-editorconfig (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-editorconfig (stdout) 1`] = `
"--no-editorconfig
Don't take .editorconfig into account when parsing configuration.
"
`;
exports[`show detailed usage with --help no-editorconfig (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-semi (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-semi (stdout) 1`] = `
"--no-semi
Do not print semicolons, except at the beginning of lines which may need them.
"
`;
exports[`show detailed usage with --help no-semi (write) 1`] = `Array []`;
exports[`show detailed usage with --help parser (stderr) 1`] = `""`;
exports[`show detailed usage with --help parser (stdout) 1`] = `
"--parser <flow|babylon|typescript|css|less|scss|json|json5|json-stringify|graphql|markdown|vue>
Which parser to use.
Valid options:
flow Flow
babylon JavaScript
typescript TypeScript
css CSS
less Less
scss SCSS
json JSON
json5 JSON5
json-stringify JSON.stringify
graphql GraphQL
markdown Markdown
vue Vue
"
`;
exports[`show detailed usage with --help parser (write) 1`] = `Array []`;
exports[`show detailed usage with --help plugin (stderr) 1`] = `""`;
exports[`show detailed usage with --help plugin (stdout) 1`] = `
"--plugin <path>
Add a plugin. Multiple plugins can be passed as separate \`--plugin\`s.
Default: []
"
`;
exports[`show detailed usage with --help plugin (write) 1`] = `Array []`;
exports[`show detailed usage with --help plugin-search-dir (stderr) 1`] = `""`;
exports[`show detailed usage with --help plugin-search-dir (stdout) 1`] = `
"--plugin-search-dir <path>
Custom directory that contains prettier plugins in node_modules subdirectory.
Overrides default behavior when plugins are searched relatively to the location of Prettier.
Multiple values are accepted.
Default: []
"
`;
exports[`show detailed usage with --help plugin-search-dir (write) 1`] = `Array []`;
exports[`show detailed usage with --help print-width (stderr) 1`] = `""`;
exports[`show detailed usage with --help print-width (stdout) 1`] = `
"--print-width <int>
The line length where Prettier will try wrap.
Default: 80
"
`;
exports[`show detailed usage with --help print-width (write) 1`] = `Array []`;
exports[`show detailed usage with --help prose-wrap (stderr) 1`] = `""`;
exports[`show detailed usage with --help prose-wrap (stdout) 1`] = `
"--prose-wrap <always|never|preserve>
How to wrap prose. (markdown)
Valid options:
always Wrap prose if it exceeds the print width.
never Do not wrap prose.
preserve Wrap prose as-is.
Default: preserve
"
`;
exports[`show detailed usage with --help prose-wrap (write) 1`] = `Array []`;
exports[`show detailed usage with --help range-end (stderr) 1`] = `""`;
exports[`show detailed usage with --help range-end (stdout) 1`] = `
"--range-end <int>
Format code ending at a given character offset (exclusive).
The range will extend forwards to the end of the selected statement.
This option cannot be used with --cursor-offset.
Default: Infinity
"
`;
exports[`show detailed usage with --help range-end (write) 1`] = `Array []`;
exports[`show detailed usage with --help range-start (stderr) 1`] = `""`;
exports[`show detailed usage with --help range-start (stdout) 1`] = `
"--range-start <int>
Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.
Default: 0
"
`;
exports[`show detailed usage with --help range-start (write) 1`] = `Array []`;
exports[`show detailed usage with --help require-pragma (stderr) 1`] = `""`;
exports[`show detailed usage with --help require-pragma (stdout) 1`] = `
"--require-pragma
Require either '@prettier' or '@format' to be present in the file's first docblock comment
in order for it to be formatted.
Default: false
"
`;
exports[`show detailed usage with --help require-pragma (write) 1`] = `Array []`;
exports[`show detailed usage with --help semi (stderr) 1`] = `""`;
exports[`show detailed usage with --help semi (stdout) 1`] = `
"--semi
Print semicolons.
Default: true
"
`;
exports[`show detailed usage with --help semi (write) 1`] = `Array []`;
exports[`show detailed usage with --help single-quote (stderr) 1`] = `""`;
exports[`show detailed usage with --help single-quote (stdout) 1`] = `
"--single-quote
Use single quotes instead of double quotes.
Default: false
"
`;
exports[`show detailed usage with --help single-quote (write) 1`] = `Array []`;
exports[`show detailed usage with --help stdin (stderr) 1`] = `""`;
exports[`show detailed usage with --help stdin (stdout) 1`] = `
"--stdin
Force reading input from stdin.
"
`;
exports[`show detailed usage with --help stdin (write) 1`] = `Array []`;
exports[`show detailed usage with --help stdin-filepath (stderr) 1`] = `""`;
exports[`show detailed usage with --help stdin-filepath (stdout) 1`] = `
"--stdin-filepath <path>
Path to the file to pretend that stdin comes from.
"
`;
exports[`show detailed usage with --help stdin-filepath (write) 1`] = `Array []`;
exports[`show detailed usage with --help support-info (stderr) 1`] = `""`;
exports[`show detailed usage with --help support-info (stdout) 1`] = `
"--support-info
Print support information as JSON.
"
`;
exports[`show detailed usage with --help support-info (write) 1`] = `Array []`;
exports[`show detailed usage with --help tab-width (stderr) 1`] = `""`;
exports[`show detailed usage with --help tab-width (stdout) 1`] = `
"--tab-width <int>
Number of spaces per indentation level.
Default: 2
"
`;
exports[`show detailed usage with --help tab-width (write) 1`] = `Array []`;
exports[`show detailed usage with --help trailing-comma (stderr) 1`] = `""`;
exports[`show detailed usage with --help trailing-comma (stdout) 1`] = `
"--trailing-comma <none|es5|all>
Print trailing commas wherever possible when multi-line.
Valid options:
none No trailing commas.
es5 Trailing commas where valid in ES5 (objects, arrays, etc.)
all Trailing commas wherever possible (including function arguments).
Default: none
"
`;
exports[`show detailed usage with --help trailing-comma (write) 1`] = `Array []`;
exports[`show detailed usage with --help use-tabs (stderr) 1`] = `""`;
exports[`show detailed usage with --help use-tabs (stdout) 1`] = `
"--use-tabs
Indent with tabs instead of spaces.
Default: false
"
`;
exports[`show detailed usage with --help use-tabs (write) 1`] = `Array []`;
exports[`show detailed usage with --help version (stderr) 1`] = `""`;
exports[`show detailed usage with --help version (stdout) 1`] = `
"-v, --version
Print Prettier version.
"
`;
exports[`show detailed usage with --help version (write) 1`] = `Array []`;
exports[`show detailed usage with --help with-node-modules (stderr) 1`] = `""`;
exports[`show detailed usage with --help with-node-modules (stdout) 1`] = `
"--with-node-modules
Process files inside 'node_modules' directory.
"
`;
exports[`show detailed usage with --help with-node-modules (write) 1`] = `Array []`;
exports[`show detailed usage with --help write (stderr) 1`] = `""`;
exports[`show detailed usage with --help write (stdout) 1`] = `
"--write
Edit files in-place. (Beware!)
"
`;
exports[`show detailed usage with --help write (write) 1`] = `Array []`;
exports[`show detailed usage with plugin options (automatic resolution) (stderr) 1`] = `""`;
exports[`show detailed usage with plugin options (automatic resolution) (stdout) 1`] = `

View File

@ -0,0 +1,532 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`show detailed usage with --help arrow-parens (stderr) 1`] = `""`;
exports[`show detailed usage with --help arrow-parens (stdout) 1`] = `
"--arrow-parens <avoid|always>
Include parentheses around a sole arrow function parameter.
Valid options:
avoid Omit parens when possible. Example: \`x => x\`
always Always include parens. Example: \`(x) => x\`
Default: avoid
"
`;
exports[`show detailed usage with --help arrow-parens (write) 1`] = `Array []`;
exports[`show detailed usage with --help bracket-spacing (stderr) 1`] = `""`;
exports[`show detailed usage with --help bracket-spacing (stdout) 1`] = `
"--bracket-spacing
Print spaces between brackets.
Default: true
"
`;
exports[`show detailed usage with --help bracket-spacing (write) 1`] = `Array []`;
exports[`show detailed usage with --help color (stderr) 1`] = `""`;
exports[`show detailed usage with --help color (stdout) 1`] = `
"--color
Colorize error messages.
Default: true
"
`;
exports[`show detailed usage with --help color (write) 1`] = `Array []`;
exports[`show detailed usage with --help config (stderr) 1`] = `""`;
exports[`show detailed usage with --help config (stdout) 1`] = `
"--config <path>
Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).
"
`;
exports[`show detailed usage with --help config (write) 1`] = `Array []`;
exports[`show detailed usage with --help config-precedence (stderr) 1`] = `""`;
exports[`show detailed usage with --help config-precedence (stdout) 1`] = `
"--config-precedence <cli-override|file-override|prefer-file>
Define in which order config files and CLI options should be evaluated.
Valid options:
cli-override CLI options take precedence over config file
file-override Config file take precedence over CLI options
prefer-file If a config file is found will evaluate it and ignore other CLI options.
If no config file is found CLI options will evaluate as normal.
Default: cli-override
"
`;
exports[`show detailed usage with --help config-precedence (write) 1`] = `Array []`;
exports[`show detailed usage with --help cursor-offset (stderr) 1`] = `""`;
exports[`show detailed usage with --help cursor-offset (stdout) 1`] = `
"--cursor-offset <int>
Print (to stderr) where a cursor at the given position would move to after formatting.
This option cannot be used with --range-start and --range-end.
Default: -1
"
`;
exports[`show detailed usage with --help cursor-offset (write) 1`] = `Array []`;
exports[`show detailed usage with --help editorconfig (stderr) 1`] = `""`;
exports[`show detailed usage with --help editorconfig (stdout) 1`] = `
"--editorconfig
Take .editorconfig into account when parsing configuration.
Default: true
"
`;
exports[`show detailed usage with --help editorconfig (write) 1`] = `Array []`;
exports[`show detailed usage with --help file-info (stderr) 1`] = `""`;
exports[`show detailed usage with --help file-info (stdout) 1`] = `
"--file-info <path>
Extract the following info (as JSON) for a given file path. Reported fields:
* ignored (boolean) - true if file path is filtered by --ignore-path
* inferredParser (string | null) - name of parser inferred from file path
"
`;
exports[`show detailed usage with --help file-info (write) 1`] = `Array []`;
exports[`show detailed usage with --help find-config-path (stderr) 1`] = `""`;
exports[`show detailed usage with --help find-config-path (stdout) 1`] = `
"--find-config-path <path>
Find and print the path to a configuration file for the given input file.
"
`;
exports[`show detailed usage with --help find-config-path (write) 1`] = `Array []`;
exports[`show detailed usage with --help help (stderr) 1`] = `""`;
exports[`show detailed usage with --help help (stdout) 1`] = `
"-h, --help <flag>
Show CLI usage, or details about the given flag.
Example: --help write
"
`;
exports[`show detailed usage with --help help (write) 1`] = `Array []`;
exports[`show detailed usage with --help ignore-path (stderr) 1`] = `""`;
exports[`show detailed usage with --help ignore-path (stdout) 1`] = `
"--ignore-path <path>
Path to a file with patterns describing files to ignore.
Default: .prettierignore
"
`;
exports[`show detailed usage with --help ignore-path (write) 1`] = `Array []`;
exports[`show detailed usage with --help insert-pragma (stderr) 1`] = `""`;
exports[`show detailed usage with --help insert-pragma (stdout) 1`] = `
"--insert-pragma
Insert @format pragma into file's first docblock comment.
Default: false
"
`;
exports[`show detailed usage with --help insert-pragma (write) 1`] = `Array []`;
exports[`show detailed usage with --help jsx-bracket-same-line (stderr) 1`] = `""`;
exports[`show detailed usage with --help jsx-bracket-same-line (stdout) 1`] = `
"--jsx-bracket-same-line
Put > on the last line instead of at a new line.
Default: false
"
`;
exports[`show detailed usage with --help jsx-bracket-same-line (write) 1`] = `Array []`;
exports[`show detailed usage with --help list-different (stderr) 1`] = `""`;
exports[`show detailed usage with --help list-different (stdout) 1`] = `
"-l, --list-different
Print the names of files that are different from Prettier's formatting.
"
`;
exports[`show detailed usage with --help list-different (write) 1`] = `Array []`;
exports[`show detailed usage with --help loglevel (stderr) 1`] = `""`;
exports[`show detailed usage with --help loglevel (stdout) 1`] = `
"--loglevel <silent|error|warn|log|debug>
What level of logs to report.
Valid options:
silent
error
warn
log
debug
Default: log
"
`;
exports[`show detailed usage with --help loglevel (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-bracket-spacing (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-bracket-spacing (stdout) 1`] = `
"--no-bracket-spacing
Do not print spaces between brackets.
"
`;
exports[`show detailed usage with --help no-bracket-spacing (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-color (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-color (stdout) 1`] = `
"--no-color
Do not colorize error messages.
"
`;
exports[`show detailed usage with --help no-color (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-config (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-config (stdout) 1`] = `
"--no-config
Do not look for a configuration file.
"
`;
exports[`show detailed usage with --help no-config (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-editorconfig (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-editorconfig (stdout) 1`] = `
"--no-editorconfig
Don't take .editorconfig into account when parsing configuration.
"
`;
exports[`show detailed usage with --help no-editorconfig (write) 1`] = `Array []`;
exports[`show detailed usage with --help no-semi (stderr) 1`] = `""`;
exports[`show detailed usage with --help no-semi (stdout) 1`] = `
"--no-semi
Do not print semicolons, except at the beginning of lines which may need them.
"
`;
exports[`show detailed usage with --help no-semi (write) 1`] = `Array []`;
exports[`show detailed usage with --help parser (stderr) 1`] = `""`;
exports[`show detailed usage with --help parser (stdout) 1`] = `
"--parser <flow|babylon|typescript|css|less|scss|json|json5|json-stringify|graphql|markdown|vue>
Which parser to use.
Valid options:
flow Flow
babylon JavaScript
typescript TypeScript
css CSS
less Less
scss SCSS
json JSON
json5 JSON5
json-stringify JSON.stringify
graphql GraphQL
markdown Markdown
vue Vue
"
`;
exports[`show detailed usage with --help parser (write) 1`] = `Array []`;
exports[`show detailed usage with --help plugin (stderr) 1`] = `""`;
exports[`show detailed usage with --help plugin (stdout) 1`] = `
"--plugin <path>
Add a plugin. Multiple plugins can be passed as separate \`--plugin\`s.
Default: []
"
`;
exports[`show detailed usage with --help plugin (write) 1`] = `Array []`;
exports[`show detailed usage with --help plugin-search-dir (stderr) 1`] = `""`;
exports[`show detailed usage with --help plugin-search-dir (stdout) 1`] = `
"--plugin-search-dir <path>
Custom directory that contains prettier plugins in node_modules subdirectory.
Overrides default behavior when plugins are searched relatively to the location of Prettier.
Multiple values are accepted.
Default: []
"
`;
exports[`show detailed usage with --help plugin-search-dir (write) 1`] = `Array []`;
exports[`show detailed usage with --help print-width (stderr) 1`] = `""`;
exports[`show detailed usage with --help print-width (stdout) 1`] = `
"--print-width <int>
The line length where Prettier will try wrap.
Default: 80
"
`;
exports[`show detailed usage with --help print-width (write) 1`] = `Array []`;
exports[`show detailed usage with --help prose-wrap (stderr) 1`] = `""`;
exports[`show detailed usage with --help prose-wrap (stdout) 1`] = `
"--prose-wrap <always|never|preserve>
How to wrap prose. (markdown)
Valid options:
always Wrap prose if it exceeds the print width.
never Do not wrap prose.
preserve Wrap prose as-is.
Default: preserve
"
`;
exports[`show detailed usage with --help prose-wrap (write) 1`] = `Array []`;
exports[`show detailed usage with --help range-end (stderr) 1`] = `""`;
exports[`show detailed usage with --help range-end (stdout) 1`] = `
"--range-end <int>
Format code ending at a given character offset (exclusive).
The range will extend forwards to the end of the selected statement.
This option cannot be used with --cursor-offset.
Default: Infinity
"
`;
exports[`show detailed usage with --help range-end (write) 1`] = `Array []`;
exports[`show detailed usage with --help range-start (stderr) 1`] = `""`;
exports[`show detailed usage with --help range-start (stdout) 1`] = `
"--range-start <int>
Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.
Default: 0
"
`;
exports[`show detailed usage with --help range-start (write) 1`] = `Array []`;
exports[`show detailed usage with --help require-pragma (stderr) 1`] = `""`;
exports[`show detailed usage with --help require-pragma (stdout) 1`] = `
"--require-pragma
Require either '@prettier' or '@format' to be present in the file's first docblock comment
in order for it to be formatted.
Default: false
"
`;
exports[`show detailed usage with --help require-pragma (write) 1`] = `Array []`;
exports[`show detailed usage with --help semi (stderr) 1`] = `""`;
exports[`show detailed usage with --help semi (stdout) 1`] = `
"--semi
Print semicolons.
Default: true
"
`;
exports[`show detailed usage with --help semi (write) 1`] = `Array []`;
exports[`show detailed usage with --help single-quote (stderr) 1`] = `""`;
exports[`show detailed usage with --help single-quote (stdout) 1`] = `
"--single-quote
Use single quotes instead of double quotes.
Default: false
"
`;
exports[`show detailed usage with --help single-quote (write) 1`] = `Array []`;
exports[`show detailed usage with --help stdin (stderr) 1`] = `""`;
exports[`show detailed usage with --help stdin (stdout) 1`] = `
"--stdin
Force reading input from stdin.
"
`;
exports[`show detailed usage with --help stdin (write) 1`] = `Array []`;
exports[`show detailed usage with --help stdin-filepath (stderr) 1`] = `""`;
exports[`show detailed usage with --help stdin-filepath (stdout) 1`] = `
"--stdin-filepath <path>
Path to the file to pretend that stdin comes from.
"
`;
exports[`show detailed usage with --help stdin-filepath (write) 1`] = `Array []`;
exports[`show detailed usage with --help support-info (stderr) 1`] = `""`;
exports[`show detailed usage with --help support-info (stdout) 1`] = `
"--support-info
Print support information as JSON.
"
`;
exports[`show detailed usage with --help support-info (write) 1`] = `Array []`;
exports[`show detailed usage with --help tab-width (stderr) 1`] = `""`;
exports[`show detailed usage with --help tab-width (stdout) 1`] = `
"--tab-width <int>
Number of spaces per indentation level.
Default: 2
"
`;
exports[`show detailed usage with --help tab-width (write) 1`] = `Array []`;
exports[`show detailed usage with --help trailing-comma (stderr) 1`] = `""`;
exports[`show detailed usage with --help trailing-comma (stdout) 1`] = `
"--trailing-comma <none|es5|all>
Print trailing commas wherever possible when multi-line.
Valid options:
none No trailing commas.
es5 Trailing commas where valid in ES5 (objects, arrays, etc.)
all Trailing commas wherever possible (including function arguments).
Default: none
"
`;
exports[`show detailed usage with --help trailing-comma (write) 1`] = `Array []`;
exports[`show detailed usage with --help use-tabs (stderr) 1`] = `""`;
exports[`show detailed usage with --help use-tabs (stdout) 1`] = `
"--use-tabs
Indent with tabs instead of spaces.
Default: false
"
`;
exports[`show detailed usage with --help use-tabs (write) 1`] = `Array []`;
exports[`show detailed usage with --help version (stderr) 1`] = `""`;
exports[`show detailed usage with --help version (stdout) 1`] = `
"-v, --version
Print Prettier version.
"
`;
exports[`show detailed usage with --help version (write) 1`] = `Array []`;
exports[`show detailed usage with --help with-node-modules (stderr) 1`] = `""`;
exports[`show detailed usage with --help with-node-modules (stdout) 1`] = `
"--with-node-modules
Process files inside 'node_modules' directory.
"
`;
exports[`show detailed usage with --help with-node-modules (write) 1`] = `Array []`;
exports[`show detailed usage with --help write (stderr) 1`] = `""`;
exports[`show detailed usage with --help write (stdout) 1`] = `
"--write
Edit files in-place. (Beware!)
"
`;
exports[`show detailed usage with --help write (write) 1`] = `Array []`;

View File

@ -3,7 +3,7 @@
const path = require("path");
const runPrettier = require("../runPrettier");
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
expect.addSnapshotSerializer(require("../path-serializer"));

View File

@ -1,6 +1,6 @@
"use strict";
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
let warnings = "";

View File

@ -1,10 +1,7 @@
"use strict";
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
const runPrettier = require("../runPrettier");
const constant = require("../../src/cli/constant");
const util = require("../../src/cli/util");
const arrayify = require("../../src/utils/arrayify");
describe("show version with --version", () => {
runPrettier("cli/with-shebang", ["--version"]).test({
@ -47,34 +44,6 @@ describe(`show detailed usage with plugin options (manual resolution)`, () => {
});
});
arrayify(
Object.assign(
{},
util.createDetailedOptionMap(
prettier.getSupportInfo(null, {
showDeprecated: true,
showUnreleased: true,
showInternal: true
}).options
),
util.normalizeDetailedOptionMap(constant.options)
),
"name"
).forEach(option => {
const optionNames = [
option.description ? option.name : null,
option.oppositeDescription ? `no-${option.name}` : null
].filter(Boolean);
optionNames.forEach(optionName => {
describe(`show detailed usage with --help ${optionName}`, () => {
runPrettier("cli", ["--help", optionName]).test({
status: 0
});
});
});
});
describe("show warning with --help not-found", () => {
runPrettier("cli", ["--help", "not-found"]).test({
status: 0

View File

@ -3,7 +3,7 @@
const path = require("path");
const runPrettier = require("../runPrettier");
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
expect.addSnapshotSerializer(require("../path-serializer"));

View File

@ -0,0 +1,35 @@
"use strict";
const prettier = require("prettier/local");
const runPrettier = require("../runPrettier");
const constant = require("../../src/cli/constant");
const util = require("../../src/cli/util");
const arrayify = require("../../src/utils/arrayify");
arrayify(
Object.assign(
{},
util.createDetailedOptionMap(
prettier.getSupportInfo(null, {
showDeprecated: true,
showUnreleased: true,
showInternal: true
}).options
),
util.normalizeDetailedOptionMap(constant.options)
),
"name"
).forEach(option => {
const optionNames = [
option.description ? option.name : null,
option.oppositeDescription ? `no-${option.name}` : null
].filter(Boolean);
optionNames.forEach(optionName => {
describe(`show detailed usage with --help ${optionName}`, () => {
runPrettier("cli", ["--help", optionName]).test({
status: 0
});
});
});
});

View File

@ -1,7 +1,7 @@
"use strict";
const runPrettier = require("../runPrettier");
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
describe("stdin no path and no parser", () => {
describe("logs error and exits with 2", () => {

View File

@ -1,6 +1,6 @@
"use strict";
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
const runPrettier = require("../runPrettier");
test("allows custom parser provided as object", () => {

View File

@ -1,6 +1,6 @@
"use strict";
const prettier = require("../..");
const prettier = require("prettier/local");
const generateSchema = require("../../scripts/generate-schema");
test("schema", () => {

View File

@ -1,6 +1,6 @@
"use strict";
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
const runPrettier = require("../runPrettier");
const snapshotDiff = require("snapshot-diff");

View File

@ -1,7 +1,7 @@
"use strict";
const runPrettier = require("../runPrettier");
const prettier = require("../../tests_config/require_prettier");
const prettier = require("prettier/local");
describe("infers postcss parser", () => {
runPrettier("cli/with-parser-inference", ["*"]).test({

View File

@ -1,6 +1,7 @@
"use strict";
const concat = require("../../../../../../src/doc").builders.concat;
const prettier = require("prettier/local");
const concat = prettier.doc.builders.concat;
module.exports = {
languages: [

View File

@ -1,6 +1,7 @@
"use strict";
const concat = require("../../../../../src/doc").builders.concat;
const prettier = require("prettier/local");
const concat = prettier.doc.builders.concat;
module.exports = {
languages: [

View File

@ -1,6 +1,7 @@
"use strict";
const concat = require("../../../../../../src/doc").builders.concat;
const prettier = require("prettier/local");
const concat = prettier.doc.builders.concat;
module.exports = {
languages: [

View File

@ -1,6 +1,7 @@
"use strict";
const concat = require("../../../src/doc").builders.concat;
const prettier = require("prettier/local");
const concat = prettier.doc.builders.concat;
module.exports = {
languages: [