Merge branch 'master' into new-playground
commit
8811e45002
|
@ -24,6 +24,16 @@ JSON:
|
|||
}
|
||||
```
|
||||
|
||||
JS:
|
||||
|
||||
```js
|
||||
// .prettierrc.js
|
||||
module.exports = {
|
||||
printWidth: 100,
|
||||
parser: "flow"
|
||||
};
|
||||
```
|
||||
|
||||
YAML:
|
||||
|
||||
```yaml
|
||||
|
|
45
index.js
45
index.js
|
@ -1,17 +1,22 @@
|
|||
"use strict";
|
||||
|
||||
const comments = require("./src/main/comments");
|
||||
const docblock = require("jest-docblock");
|
||||
|
||||
const version = require("./package.json").version;
|
||||
const printAstToDoc = require("./src/main/ast-to-doc");
|
||||
|
||||
const util = require("./src/common/util");
|
||||
const getSupportInfo = require("./src/common/support").getSupportInfo;
|
||||
|
||||
const comments = require("./src/main/comments");
|
||||
const printAstToDoc = require("./src/main/ast-to-doc");
|
||||
const normalizeOptions = require("./src/main/options").normalize;
|
||||
const parser = require("./src/main/parser");
|
||||
|
||||
const config = require("./src/config/resolve-config");
|
||||
|
||||
const doc = require("./src/doc");
|
||||
const printDocToString = doc.printer.printDocToString;
|
||||
const printDocToDebug = doc.debug.printDocToDebug;
|
||||
const normalizeOptions = require("./src/common/options").normalize;
|
||||
const parser = require("./src/main/parser");
|
||||
const config = require("./src/config/resolve-config");
|
||||
const getSupportInfo = require("./src/common/support").getSupportInfo;
|
||||
const docblock = require("jest-docblock");
|
||||
|
||||
function guessLineEnding(text) {
|
||||
const index = text.indexOf("\n");
|
||||
|
@ -101,7 +106,7 @@ function formatWithCursor(text, opts, addAlignmentSize) {
|
|||
|
||||
let cursorOffset;
|
||||
if (opts.cursorOffset >= 0) {
|
||||
const cursorNodeAndParents = findNodeAtOffset(ast, opts.cursorOffset);
|
||||
const cursorNodeAndParents = findNodeAtOffset(ast, opts.cursorOffset, opts);
|
||||
const cursorNode = cursorNodeAndParents.node;
|
||||
if (cursorNode) {
|
||||
cursorOffset = opts.cursorOffset - util.locStart(cursorNode);
|
||||
|
@ -179,16 +184,21 @@ function findSiblingAncestors(startNodeAndParents, endNodeAndParents) {
|
|||
};
|
||||
}
|
||||
|
||||
function findNodeAtOffset(node, offset, predicate, parentNodes) {
|
||||
function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
|
||||
predicate = predicate || (() => true);
|
||||
parentNodes = parentNodes || [];
|
||||
const start = util.locStart(node);
|
||||
const end = util.locEnd(node);
|
||||
if (start <= offset && offset <= end) {
|
||||
for (const childNode of comments.getSortedChildNodes(node)) {
|
||||
for (const childNode of comments.getSortedChildNodes(
|
||||
node,
|
||||
undefined /* text */,
|
||||
options
|
||||
)) {
|
||||
const childResult = findNodeAtOffset(
|
||||
childNode,
|
||||
offset,
|
||||
options,
|
||||
predicate,
|
||||
[node].concat(parentNodes)
|
||||
);
|
||||
|
@ -301,11 +311,17 @@ function calculateRange(text, opts, ast) {
|
|||
}
|
||||
}
|
||||
|
||||
const startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, node =>
|
||||
isSourceElement(opts, node)
|
||||
const startNodeAndParents = findNodeAtOffset(
|
||||
ast,
|
||||
startNonWhitespace,
|
||||
opts,
|
||||
node => isSourceElement(opts, node)
|
||||
);
|
||||
const endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, node =>
|
||||
isSourceElement(opts, node)
|
||||
const endNodeAndParents = findNodeAtOffset(
|
||||
ast,
|
||||
endNonWhitespace,
|
||||
opts,
|
||||
node => isSourceElement(opts, node)
|
||||
);
|
||||
|
||||
if (!startNodeAndParents || !endNodeAndParents) {
|
||||
|
@ -398,6 +414,7 @@ module.exports = {
|
|||
/* istanbul ignore next */
|
||||
__debug: {
|
||||
parse: function(text, opts) {
|
||||
opts = normalizeOptions(opts);
|
||||
return parser.parse(text, opts);
|
||||
},
|
||||
formatAST: function(ast, opts) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"emoji-regex": "6.5.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"esutils": "2.0.2",
|
||||
"find-project-root": "1.1.1",
|
||||
"flow-parser": "0.59.0",
|
||||
"get-stream": "3.0.0",
|
||||
"globby": "6.1.0",
|
||||
|
@ -39,7 +40,6 @@
|
|||
"minimatch": "3.0.4",
|
||||
"minimist": "1.2.0",
|
||||
"parse5": "3.0.3",
|
||||
"path-root": "0.1.1",
|
||||
"postcss-less": "1.1.3",
|
||||
"postcss-media-query-parser": "0.2.3",
|
||||
"postcss-scss": "1.0.2",
|
||||
|
@ -50,7 +50,7 @@
|
|||
"resolve": "1.5.0",
|
||||
"semver": "5.4.1",
|
||||
"string-width": "2.1.1",
|
||||
"typescript": "2.6.2",
|
||||
"typescript": "2.7.0-insiders.20171214",
|
||||
"typescript-eslint-parser": "11.0.0",
|
||||
"unicode-regex": "1.0.1",
|
||||
"unified": "6.1.6"
|
||||
|
|
|
@ -443,10 +443,19 @@ const detailedOptionMap = detailedOptions.reduce(
|
|||
{}
|
||||
);
|
||||
|
||||
const apiDetailedOptionMap = detailedOptions.reduce(
|
||||
(current, option) =>
|
||||
option.forwardToApi && option.forwardToApi !== option.name
|
||||
? Object.assign(current, { [option.forwardToApi]: option })
|
||||
: current,
|
||||
{}
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
categoryOrder,
|
||||
minimistOptions,
|
||||
detailedOptions,
|
||||
detailedOptionMap,
|
||||
apiDetailedOptionMap,
|
||||
usageSummary
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ const cleanAST = require("../common/clean-ast").cleanAST;
|
|||
const resolver = require("../config/resolve-config");
|
||||
const constant = require("./constant");
|
||||
const validator = require("./validator");
|
||||
const apiDefaultOptions = require("../common/options").defaults;
|
||||
const apiDefaultOptions = require("../main/options").defaults;
|
||||
const errors = require("../common/errors");
|
||||
const logger = require("./logger");
|
||||
const thirdParty = require("../common/third-party");
|
||||
|
@ -37,9 +37,12 @@ function getOptions(argv) {
|
|||
);
|
||||
}
|
||||
|
||||
function dashifyObject(object) {
|
||||
function cliifyOptions(object) {
|
||||
return Object.keys(object || {}).reduce((output, key) => {
|
||||
output[dashify(key)] = object[key];
|
||||
const apiOption = constant.apiDetailedOptionMap[key];
|
||||
const cliKey = apiOption ? apiOption.name : key;
|
||||
|
||||
output[dashify(cliKey)] = object[key];
|
||||
return output;
|
||||
}, {});
|
||||
}
|
||||
|
@ -202,8 +205,8 @@ function parseArgsToOptions(argv, overrideDefaults) {
|
|||
boolean: constant.minimistOptions.boolean,
|
||||
default: Object.assign(
|
||||
{},
|
||||
dashifyObject(apiDefaultOptions),
|
||||
dashifyObject(overrideDefaults)
|
||||
cliifyOptions(apiDefaultOptions),
|
||||
cliifyOptions(overrideDefaults)
|
||||
)
|
||||
})
|
||||
),
|
||||
|
@ -619,7 +622,10 @@ function normalizeConfig(type, rawConfig, options) {
|
|||
return;
|
||||
}
|
||||
|
||||
const option = constant.detailedOptionMap[key];
|
||||
let option = constant.detailedOptionMap[key];
|
||||
if (type === "api" && option === undefined) {
|
||||
option = constant.apiDetailedOptionMap[key];
|
||||
}
|
||||
|
||||
// unknown option
|
||||
if (option === undefined) {
|
||||
|
|
|
@ -12,9 +12,15 @@ function loadPlugins(options) {
|
|||
require("../language-markdown"),
|
||||
require("../language-html"),
|
||||
require("../language-vue")
|
||||
];
|
||||
].filter(plugin => {
|
||||
return options.plugins.indexOf(plugin) < 0;
|
||||
});
|
||||
|
||||
const externalPlugins = options.plugins.map(plugin => {
|
||||
if (typeof plugin !== "string") {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
const pluginPath = resolve.sync(plugin, { basedir: process.cwd() });
|
||||
return eval("require")(pluginPath);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const editorconfig = require("editorconfig");
|
||||
const mem = require("mem");
|
||||
const pathRoot = require("path-root");
|
||||
const editorConfigToPrettier = require("editorconfig-to-prettier");
|
||||
const findProjectRoot = require("find-project-root");
|
||||
|
||||
const maybeParse = (filePath, config, parse) => {
|
||||
const root = filePath && pathRoot(filePath);
|
||||
const root = findProjectRoot(path.dirname(path.resolve(filePath)));
|
||||
return filePath && !config && parse(filePath, { root });
|
||||
};
|
||||
|
||||
|
|
|
@ -539,7 +539,24 @@ function printSequence(sequencePath, options, print) {
|
|||
});
|
||||
}
|
||||
|
||||
function canAttachComment(node) {
|
||||
return node.kind && node.kind !== "Comment";
|
||||
}
|
||||
|
||||
function printComment(commentPath) {
|
||||
const comment = commentPath.getValue();
|
||||
|
||||
switch (comment.kind) {
|
||||
case "Comment":
|
||||
return "#" + comment.value.trimRight();
|
||||
default:
|
||||
throw new Error("Not a comment: " + JSON.stringify(comment));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
print: genericPrint,
|
||||
hasPrettierIgnore: util.hasIgnoreComment
|
||||
hasPrettierIgnore: util.hasIgnoreComment,
|
||||
printComment,
|
||||
canAttachComment
|
||||
};
|
||||
|
|
|
@ -39,8 +39,10 @@ function embed(path, print, textToDoc /*, options */) {
|
|||
parent &&
|
||||
((parent.type === "TaggedTemplateExpression" &&
|
||||
((parent.tag.type === "MemberExpression" &&
|
||||
parent.tag.object.name === "graphql" &&
|
||||
parent.tag.property.name === "experimental") ||
|
||||
((parent.tag.object.name === "graphql" &&
|
||||
parent.tag.property.name === "experimental") ||
|
||||
(parent.tag.object.name === "Relay" &&
|
||||
parent.tag.property.name === "QL"))) ||
|
||||
(parent.tag.type === "Identifier" &&
|
||||
(parent.tag.name === "gql" || parent.tag.name === "graphql")))) ||
|
||||
(parent.type === "CallExpression" &&
|
||||
|
|
|
@ -5167,9 +5167,77 @@ function willPrintOwnComments(path) {
|
|||
);
|
||||
}
|
||||
|
||||
function canAttachComment(node) {
|
||||
return (
|
||||
node.type &&
|
||||
node.type !== "CommentBlock" &&
|
||||
node.type !== "CommentLine" &&
|
||||
node.type !== "Line" &&
|
||||
node.type !== "Block" &&
|
||||
node.type !== "EmptyStatement" &&
|
||||
node.type !== "TemplateElement" &&
|
||||
node.type !== "Import" &&
|
||||
!(node.callee && node.callee.type === "Import")
|
||||
);
|
||||
}
|
||||
|
||||
function printComment(commentPath, options) {
|
||||
const comment = commentPath.getValue();
|
||||
|
||||
switch (comment.type) {
|
||||
case "CommentBlock":
|
||||
case "Block": {
|
||||
if (isJsDocComment(comment)) {
|
||||
return printJsDocComment(comment);
|
||||
}
|
||||
|
||||
const isInsideFlowComment =
|
||||
options.originalText.substr(util.locEnd(comment) - 3, 3) === "*-/";
|
||||
|
||||
return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
|
||||
}
|
||||
case "CommentLine":
|
||||
case "Line":
|
||||
// Print shebangs with the proper comment characters
|
||||
if (options.originalText.slice(util.locStart(comment)).startsWith("#!")) {
|
||||
return "#!" + comment.value.trimRight();
|
||||
}
|
||||
return "//" + comment.value.trimRight();
|
||||
default:
|
||||
throw new Error("Not a comment: " + JSON.stringify(comment));
|
||||
}
|
||||
}
|
||||
|
||||
function isJsDocComment(comment) {
|
||||
const lines = comment.value.split("\n");
|
||||
return (
|
||||
lines.length > 1 &&
|
||||
lines.slice(0, lines.length - 1).every(line => line.trim()[0] === "*")
|
||||
);
|
||||
}
|
||||
|
||||
function printJsDocComment(comment) {
|
||||
const lines = comment.value.split("\n");
|
||||
|
||||
return concat([
|
||||
"/*",
|
||||
join(
|
||||
hardline,
|
||||
lines.map(
|
||||
(line, index) =>
|
||||
(index > 0 ? " " : "") +
|
||||
(index < lines.length - 1 ? line.trim() : line.trimLeft())
|
||||
)
|
||||
),
|
||||
"*/"
|
||||
]);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
print: genericPrint,
|
||||
embed,
|
||||
hasPrettierIgnore,
|
||||
willPrintOwnComments
|
||||
willPrintOwnComments,
|
||||
canAttachComment,
|
||||
printComment
|
||||
};
|
||||
|
|
|
@ -12,12 +12,11 @@ const concat = docBuilders.concat;
|
|||
const hardline = docBuilders.hardline;
|
||||
const addAlignmentToDoc = docBuilders.addAlignmentToDoc;
|
||||
const docUtils = doc.utils;
|
||||
const getPrinter = require("./get-printer");
|
||||
|
||||
function printAstToDoc(ast, options, addAlignmentSize) {
|
||||
addAlignmentSize = addAlignmentSize || 0;
|
||||
|
||||
const printer = getPrinter(options);
|
||||
const printer = options.printer;
|
||||
const cache = new Map();
|
||||
|
||||
function printGenerically(path, args) {
|
||||
|
@ -32,11 +31,11 @@ function printAstToDoc(ast, options, addAlignmentSize) {
|
|||
// UnionTypeAnnotation has to align the child without the comments
|
||||
let res;
|
||||
if (printer.willPrintOwnComments && printer.willPrintOwnComments(path)) {
|
||||
res = genericPrint(path, options, printer, printGenerically, args);
|
||||
res = genericPrint(path, options, printGenerically, args);
|
||||
} else {
|
||||
res = comments.printComments(
|
||||
path,
|
||||
p => genericPrint(p, options, printer, printGenerically, args),
|
||||
p => genericPrint(p, options, printGenerically, args),
|
||||
options,
|
||||
args && args.needsSemi
|
||||
);
|
||||
|
@ -68,10 +67,11 @@ function printAstToDoc(ast, options, addAlignmentSize) {
|
|||
return doc;
|
||||
}
|
||||
|
||||
function genericPrint(path, options, printer, printPath, args) {
|
||||
function genericPrint(path, options, printPath, args) {
|
||||
assert.ok(path instanceof FastPath);
|
||||
|
||||
const node = path.getValue();
|
||||
const printer = options.printer;
|
||||
|
||||
// Escape hatch
|
||||
if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
|
||||
|
@ -81,7 +81,7 @@ function genericPrint(path, options, printer, printPath, args) {
|
|||
if (node) {
|
||||
try {
|
||||
// Potentially switch to a different parser
|
||||
const sub = multiparser.printSubtree(printer, path, printPath, options);
|
||||
const sub = multiparser.printSubtree(path, printPath, options);
|
||||
if (sub) {
|
||||
return sub;
|
||||
}
|
||||
|
|
|
@ -18,25 +18,14 @@ const getNextNonSpaceNonCommentCharacter =
|
|||
const getNextNonSpaceNonCommentCharacterIndex =
|
||||
util.getNextNonSpaceNonCommentCharacterIndex;
|
||||
|
||||
function getSortedChildNodes(node, text, resultArray) {
|
||||
function getSortedChildNodes(node, text, options, resultArray) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const printer = options.printer;
|
||||
|
||||
if (resultArray) {
|
||||
if (
|
||||
node &&
|
||||
((node.type &&
|
||||
node.type !== "CommentBlock" &&
|
||||
node.type !== "CommentLine" &&
|
||||
node.type !== "Line" &&
|
||||
node.type !== "Block" &&
|
||||
node.type !== "EmptyStatement" &&
|
||||
node.type !== "TemplateElement" &&
|
||||
node.type !== "Import" &&
|
||||
!(node.callee && node.callee.type === "Import")) ||
|
||||
(node.kind && node.kind !== "Comment"))
|
||||
) {
|
||||
if (node && printer.canAttachComment && printer.canAttachComment(node)) {
|
||||
// This reverse insertion sort almost always takes constant
|
||||
// time because we almost always (maybe always?) append the
|
||||
// nodes in order anyway.
|
||||
|
@ -74,7 +63,7 @@ function getSortedChildNodes(node, text, resultArray) {
|
|||
}
|
||||
|
||||
for (let i = 0, nameCount = names.length; i < nameCount; ++i) {
|
||||
getSortedChildNodes(node[names[i]], text, resultArray);
|
||||
getSortedChildNodes(node[names[i]], text, options, resultArray);
|
||||
}
|
||||
|
||||
return resultArray;
|
||||
|
@ -83,8 +72,8 @@ function getSortedChildNodes(node, text, resultArray) {
|
|||
// As efficiently as possible, decorate the comment object with
|
||||
// .precedingNode, .enclosingNode, and/or .followingNode properties, at
|
||||
// least one of which is guaranteed to be defined.
|
||||
function decorateComment(node, comment, text) {
|
||||
const childNodes = getSortedChildNodes(node, text);
|
||||
function decorateComment(node, comment, text, options) {
|
||||
const childNodes = getSortedChildNodes(node, text, options);
|
||||
let precedingNode;
|
||||
let followingNode;
|
||||
// Time to dust off the old binary search robes and wizard hat.
|
||||
|
@ -101,7 +90,7 @@ function decorateComment(node, comment, text) {
|
|||
// The comment is completely contained by this child node.
|
||||
comment.enclosingNode = child;
|
||||
|
||||
decorateComment(child, comment, text);
|
||||
decorateComment(child, comment, text, options);
|
||||
return; // Abandon the binary search at this level.
|
||||
}
|
||||
|
||||
|
@ -174,7 +163,7 @@ function attach(comments, ast, text, options) {
|
|||
return;
|
||||
}
|
||||
|
||||
decorateComment(ast, comment, text);
|
||||
decorateComment(ast, comment, text, options);
|
||||
|
||||
const precedingNode = comment.precedingNode;
|
||||
const enclosingNode = comment.enclosingNode;
|
||||
|
@ -923,56 +912,7 @@ function handleVariableDeclaratorComments(
|
|||
function printComment(commentPath, options) {
|
||||
const comment = commentPath.getValue();
|
||||
comment.printed = true;
|
||||
|
||||
switch (comment.type || comment.kind) {
|
||||
case "Comment":
|
||||
return "#" + comment.value.trimRight();
|
||||
case "CommentBlock":
|
||||
case "Block": {
|
||||
if (isJsDocComment(comment)) {
|
||||
return printJsDocComment(comment);
|
||||
}
|
||||
|
||||
const isInsideFlowComment =
|
||||
options.originalText.substr(util.locEnd(comment) - 3, 3) === "*-/";
|
||||
|
||||
return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
|
||||
}
|
||||
case "CommentLine":
|
||||
case "Line":
|
||||
// Print shebangs with the proper comment characters
|
||||
if (options.originalText.slice(util.locStart(comment)).startsWith("#!")) {
|
||||
return "#!" + comment.value.trimRight();
|
||||
}
|
||||
return "//" + comment.value.trimRight();
|
||||
default:
|
||||
throw new Error("Not a comment: " + JSON.stringify(comment));
|
||||
}
|
||||
}
|
||||
|
||||
function isJsDocComment(comment) {
|
||||
const lines = comment.value.split("\n");
|
||||
return (
|
||||
lines.length > 1 &&
|
||||
lines.slice(0, lines.length - 1).every(line => line.trim()[0] === "*")
|
||||
);
|
||||
}
|
||||
|
||||
function printJsDocComment(comment) {
|
||||
const lines = comment.value.split("\n");
|
||||
|
||||
return concat([
|
||||
"/*",
|
||||
join(
|
||||
hardline,
|
||||
lines.map(
|
||||
(line, index) =>
|
||||
(index > 0 ? " " : "") +
|
||||
(index < lines.length - 1 ? line.trim() : line.trimLeft())
|
||||
)
|
||||
),
|
||||
"*/"
|
||||
]);
|
||||
return options.printer.printComment(commentPath, options);
|
||||
}
|
||||
|
||||
function findExpressionIndexForComment(quasis, comment) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const loadPlugins = require("../common/load-plugins");
|
||||
const parser = require("./parser");
|
||||
|
||||
function getPrinter(options) {
|
||||
const plugins = loadPlugins(options);
|
||||
const parsers = parser.getParsers(plugins, options);
|
||||
const astFormat = parser.resolveParser(parsers, options).astFormat;
|
||||
const printerPlugin = plugins.find(plugin => plugin.printers[astFormat]);
|
||||
const astFormat = options.astFormat;
|
||||
|
||||
if (!astFormat) {
|
||||
throw new Error("getPrinter() requires astFormat to be set");
|
||||
}
|
||||
const printerPlugin = options.plugins.find(
|
||||
plugin => plugin.printers[astFormat]
|
||||
);
|
||||
if (!printerPlugin) {
|
||||
throw new Error(
|
||||
`Couldn't find printer plugin for AST format "${astFormat}"`
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
const normalize = require("./options").normalize;
|
||||
const comments = require("./comments");
|
||||
|
||||
function printSubtree(printer, path, print, options) {
|
||||
if (printer.embed) {
|
||||
return printer.embed(
|
||||
function printSubtree(path, print, options) {
|
||||
if (options.printer.embed) {
|
||||
return options.printer.embed(
|
||||
path,
|
||||
print,
|
||||
(text, partialNextOptions) =>
|
||||
|
@ -15,13 +16,12 @@ function printSubtree(printer, path, print, options) {
|
|||
}
|
||||
|
||||
function textToDoc(text, partialNextOptions, parentOptions) {
|
||||
const nextOptions = Object.assign({}, parentOptions, partialNextOptions, {
|
||||
parentParser: parentOptions.parser,
|
||||
originalText: text
|
||||
});
|
||||
if (nextOptions.parser === "json") {
|
||||
nextOptions.trailingComma = "none";
|
||||
}
|
||||
const nextOptions = normalize(
|
||||
Object.assign({}, parentOptions, partialNextOptions, {
|
||||
parentParser: parentOptions.parser,
|
||||
originalText: text
|
||||
})
|
||||
);
|
||||
|
||||
const ast = require("./parser").parse(text, nextOptions);
|
||||
const astComments = ast.comments;
|
||||
|
|
|
@ -4,7 +4,10 @@ const path = require("path");
|
|||
|
||||
const validate = require("jest-validate").validate;
|
||||
const deprecatedConfig = require("./deprecated");
|
||||
const getSupportInfo = require("./support").getSupportInfo;
|
||||
const getSupportInfo = require("../common/support").getSupportInfo;
|
||||
const loadPlugins = require("../common/load-plugins");
|
||||
const resolveParser = require("./parser").resolveParser;
|
||||
const getPrinter = require("./get-printer");
|
||||
|
||||
const defaults = {
|
||||
cursorOffset: -1,
|
||||
|
@ -18,12 +21,16 @@ const defaults = {
|
|||
bracketSpacing: true,
|
||||
jsxBracketSameLine: false,
|
||||
parser: "babylon",
|
||||
parentParser: "",
|
||||
insertPragma: false,
|
||||
requirePragma: false,
|
||||
semi: true,
|
||||
proseWrap: "preserve",
|
||||
arrowParens: "avoid",
|
||||
plugins: []
|
||||
plugins: [],
|
||||
astFormat: "estree",
|
||||
printer: {},
|
||||
__inJsTemplate: false
|
||||
};
|
||||
|
||||
const exampleConfig = Object.assign({}, defaults, {
|
||||
|
@ -37,14 +44,17 @@ function normalize(options) {
|
|||
const normalized = Object.assign({}, options || {});
|
||||
const filepath = normalized.filepath;
|
||||
|
||||
normalized.plugins = loadPlugins(normalized);
|
||||
|
||||
if (
|
||||
filepath &&
|
||||
!normalized.parentParser &&
|
||||
(!normalized.parser || normalized.parser === defaults.parser)
|
||||
) {
|
||||
const extension = path.extname(filepath);
|
||||
const filename = path.basename(filepath).toLowerCase();
|
||||
|
||||
const language = getSupportInfo().languages.find(
|
||||
const language = getSupportInfo(null, normalized).languages.find(
|
||||
language =>
|
||||
typeof language.since === "string" &&
|
||||
(language.extensions.indexOf(extension) > -1 ||
|
||||
|
@ -114,6 +124,9 @@ function normalize(options) {
|
|||
delete normalized.useFlowParser;
|
||||
}
|
||||
|
||||
normalized.astFormat = resolveParser(normalized).astFormat;
|
||||
normalized.printer = getPrinter(normalized);
|
||||
|
||||
Object.keys(defaults).forEach(k => {
|
||||
if (normalized[k] == null) {
|
||||
normalized[k] = defaults[k];
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
const path = require("path");
|
||||
const ConfigError = require("../common/errors").ConfigError;
|
||||
const loadPlugins = require("../common/load-plugins");
|
||||
|
||||
function getParsers(plugins) {
|
||||
return plugins.reduce(
|
||||
function getParsers(options) {
|
||||
return options.plugins.reduce(
|
||||
(parsers, plugin) => Object.assign({}, parsers, plugin.parsers),
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
function resolveParser(parsers, opts) {
|
||||
function resolveParser(opts, parsers) {
|
||||
parsers = parsers || getParsers(opts);
|
||||
|
||||
if (typeof opts.parser === "function") {
|
||||
// Custom parser API always works with JavaScript.
|
||||
return {
|
||||
|
@ -39,7 +40,7 @@ function resolveParser(parsers, opts) {
|
|||
}
|
||||
|
||||
function parse(text, opts) {
|
||||
const parsers = getParsers(loadPlugins(opts), opts);
|
||||
const parsers = getParsers(opts);
|
||||
|
||||
// Copy the "parse" function from parser to a new object whose values are
|
||||
// functions. Use defineProperty()/getOwnPropertyDescriptor() such that we
|
||||
|
@ -54,7 +55,7 @@ function parse(text, opts) {
|
|||
{}
|
||||
);
|
||||
|
||||
const parser = resolveParser(parsers, opts);
|
||||
const parser = resolveParser(opts, parsers);
|
||||
|
||||
try {
|
||||
return parser.parse(text, parsersForCustomParserApi, opts);
|
||||
|
@ -75,4 +76,4 @@ function parse(text, opts) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = { getParsers, parse, resolveParser };
|
||||
module.exports = { parse, resolveParser };
|
||||
|
|
|
@ -1 +1 @@
|
|||
run_spec(__dirname, ["babylon"]);
|
||||
run_spec(__dirname, ["babylon", "typescript"]);
|
||||
|
|
|
@ -394,6 +394,7 @@ gql\`
|
|||
|
||||
exports[`react-relay.js 1`] = `
|
||||
const { graphql } = require("react-relay");
|
||||
const Relay = require("react-relay/classic");
|
||||
|
||||
graphql\`
|
||||
mutation MarkReadNotificationMutation(
|
||||
|
@ -410,8 +411,17 @@ graphql.experimental\`
|
|||
)
|
||||
{ markReadNotification(data: $input ) { notification {seenState} } }
|
||||
\`;
|
||||
|
||||
Relay.QL\`
|
||||
mutation MarkReadNotificationMutation(
|
||||
$input
|
||||
: MarkReadNotificationData!
|
||||
)
|
||||
{ markReadNotification(data: $input ) { notification {seenState} } }
|
||||
\`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const { graphql } = require("react-relay");
|
||||
const Relay = require("react-relay/classic");
|
||||
|
||||
graphql\`
|
||||
mutation MarkReadNotificationMutation($input: MarkReadNotificationData!) {
|
||||
|
@ -433,4 +443,14 @@ graphql.experimental\`
|
|||
}
|
||||
\`;
|
||||
|
||||
Relay.QL\`
|
||||
mutation MarkReadNotificationMutation($input: MarkReadNotificationData!) {
|
||||
markReadNotification(data: $input) {
|
||||
notification {
|
||||
seenState
|
||||
}
|
||||
}
|
||||
}
|
||||
\`;
|
||||
|
||||
`;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const { graphql } = require("react-relay");
|
||||
const Relay = require("react-relay/classic");
|
||||
|
||||
graphql`
|
||||
mutation MarkReadNotificationMutation(
|
||||
|
@ -15,3 +16,11 @@ graphql.experimental`
|
|||
)
|
||||
{ markReadNotification(data: $input ) { notification {seenState} } }
|
||||
`;
|
||||
|
||||
Relay.QL`
|
||||
mutation MarkReadNotificationMutation(
|
||||
$input
|
||||
: MarkReadNotificationData!
|
||||
)
|
||||
{ markReadNotification(data: $input ) { notification {seenState} } }
|
||||
`;
|
||||
|
|
|
@ -5,7 +5,7 @@ const foo = {
|
|||
bar: props.bar ? props.bar : noop,
|
||||
baz: props.baz
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const foo = {
|
||||
bar: props.bar
|
||||
? props.bar
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
const fs = require("fs");
|
||||
const extname = require("path").extname;
|
||||
const prettier = require("./require_prettier");
|
||||
const parser = require("../src/main/parser");
|
||||
const massageAST = require("../src/common/clean-ast.js").massageAST;
|
||||
|
||||
const AST_COMPARE = process.env["AST_COMPARE"];
|
||||
const VERIFY_ALL_PARSERS = process.env["VERIFY_ALL_PARSERS"] || false;
|
||||
const ALL_PARSERS = process.env["ALL_PARSERS"]
|
||||
? JSON.parse(process.env["ALL_PARSERS"])
|
||||
: ["flow", "graphql", "babylon", "typescript"];
|
||||
|
||||
function run_spec(dirname, parsers, options) {
|
||||
/* instabul ignore if */
|
||||
|
@ -46,22 +41,20 @@ function run_spec(dirname, parsers, options) {
|
|||
});
|
||||
const output = prettyprint(source, path, mergedOptions);
|
||||
test(`${filename} - ${mergedOptions.parser}-verify`, () => {
|
||||
expect(raw(source + "~".repeat(80) + "\n" + output)).toMatchSnapshot(
|
||||
filename
|
||||
);
|
||||
expect(
|
||||
raw(source + "~".repeat(mergedOptions.printWidth) + "\n" + output)
|
||||
).toMatchSnapshot(filename);
|
||||
});
|
||||
|
||||
getParsersToVerify(mergedOptions.parser, parsers.slice(1)).forEach(
|
||||
parserName => {
|
||||
test(`${filename} - ${parserName}-verify`, () => {
|
||||
const verifyOptions = Object.assign(mergedOptions, {
|
||||
parser: parserName
|
||||
});
|
||||
const verifyOutput = prettyprint(source, path, verifyOptions);
|
||||
expect(output).toEqual(verifyOutput);
|
||||
parsers.slice(1).forEach(parserName => {
|
||||
test(`${filename} - ${parserName}-verify`, () => {
|
||||
const verifyOptions = Object.assign(mergedOptions, {
|
||||
parser: parserName
|
||||
});
|
||||
}
|
||||
);
|
||||
const verifyOutput = prettyprint(source, path, verifyOptions);
|
||||
expect(output).toEqual(verifyOutput);
|
||||
});
|
||||
});
|
||||
|
||||
if (AST_COMPARE) {
|
||||
const ast = parse(source, mergedOptions);
|
||||
|
@ -89,6 +82,7 @@ function run_spec(dirname, parsers, options) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
global.run_spec = run_spec;
|
||||
|
||||
function stripLocation(ast) {
|
||||
|
@ -116,7 +110,7 @@ function stripLocation(ast) {
|
|||
}
|
||||
|
||||
function parse(string, opts) {
|
||||
return stripLocation(parser.parse(string, opts));
|
||||
return stripLocation(prettier.__debug.parse(string, opts));
|
||||
}
|
||||
|
||||
function prettyprint(src, filename, options) {
|
||||
|
@ -155,10 +149,3 @@ function mergeDefaultOptions(parserConfig) {
|
|||
parserConfig
|
||||
);
|
||||
}
|
||||
|
||||
function getParsersToVerify(parser, additionalParsers) {
|
||||
if (VERIFY_ALL_PARSERS) {
|
||||
return ALL_PARSERS.splice(ALL_PARSERS.indexOf(parser), 1);
|
||||
}
|
||||
return additionalParsers;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ function f() {
|
|||
\\"should have space width 8\\"
|
||||
)
|
||||
}
|
||||
function f() {
|
||||
console.log(
|
||||
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
|
||||
)
|
||||
}
|
||||
console.log(
|
||||
\\"jest/__best-tests__/file.js should have semi\\"
|
||||
);
|
||||
|
@ -108,6 +113,11 @@ function f() {
|
|||
function f() {
|
||||
console.log(\\"should have space width 8\\")
|
||||
}
|
||||
function f() {
|
||||
console.log(
|
||||
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
|
||||
)
|
||||
}
|
||||
console.log(\\"jest/__best-tests__/file.js should have semi\\");
|
||||
console.log(\\"jest/Component.js should not have semi\\")
|
||||
console.log(\\"jest/Component.test.js should have semi\\");
|
||||
|
|
|
@ -95,6 +95,11 @@ function f() {
|
|||
\\"should have space width 8\\"
|
||||
)
|
||||
}
|
||||
function f() {
|
||||
console.log(
|
||||
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
|
||||
)
|
||||
}
|
||||
console.log(
|
||||
\\"jest/__best-tests__/file.js should have semi\\"
|
||||
);
|
||||
|
@ -167,6 +172,11 @@ function f() {
|
|||
\\"should have space width 8\\"
|
||||
)
|
||||
}
|
||||
function f() {
|
||||
console.log(
|
||||
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
|
||||
)
|
||||
}
|
||||
console.log(
|
||||
\\"jest/__best-tests__/file.js should have semi\\"
|
||||
);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
This isn't really a Mercurial repo, but we want to pretend it is for testing purposes.
|
||||
See https://github.com/prettier/prettier/pull/3559#issuecomment-353857109
|
|
@ -0,0 +1,3 @@
|
|||
function f() {
|
||||
console.log("should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present");
|
||||
}
|
|
@ -44,298 +44,16 @@
|
|||
|
||||
<script src="/playground2.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
html {
|
||||
background-color: #fafafa;
|
||||
color: #6a6a6a;
|
||||
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
|
||||
Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans",
|
||||
"Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
<link rel="stylesheet" href="/playground.css">
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#root, .playground-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 30px;
|
||||
padding: 11px 27px;
|
||||
background-color: #1a2b34;
|
||||
color: #e0e0e0;
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
header {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
header a,
|
||||
header a:visited,
|
||||
header a:focus,
|
||||
header a:active,
|
||||
header a:hover {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.logo-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 34px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: 20px;
|
||||
display: block;
|
||||
font-family: inherit;
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
position: relative;
|
||||
z-index: 9999;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#version {
|
||||
font-size: 0.5em;
|
||||
line-height: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.links {
|
||||
display: flex;
|
||||
font-size: 16px;
|
||||
}
|
||||
.links > * + * {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.editors-container {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.editors {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.editor {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex: 1 1 100%;
|
||||
position: relative;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* display as 2x2 grid */
|
||||
@media (min-width: 800px) {
|
||||
.options-container {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.editor {
|
||||
flex-basis: 50%;
|
||||
border-left: 1px solid #ddd;
|
||||
margin-left: -1px;
|
||||
}
|
||||
}
|
||||
|
||||
/* display as four columns */
|
||||
@media (min-width: 1200px) {
|
||||
.editor {
|
||||
flex-basis: 25%;
|
||||
}
|
||||
}
|
||||
|
||||
.editor.loading {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
height: auto;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.bottom-bar {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons {
|
||||
z-index: 10;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons > * + * {
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
||||
@media (max-width: 799px) {
|
||||
.bottom-bar-buttons {
|
||||
top: auto;
|
||||
bottom: 100%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons > * + * {
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.options-container {
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
width: 225px;
|
||||
height: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
|
||||
.options-container.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sub-options {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
padding: 15px 0 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.sub-options:last-child {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.sub-options > summary {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sub-options > summary:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.sub-options > * {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: Consolas, Courier New, Courier, monospace;
|
||||
margin: 10px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
max-width: 40px;
|
||||
}
|
||||
|
||||
/* Copied from the GitHub button styling. */
|
||||
.btn {
|
||||
box-sizing: content-box;
|
||||
display: inline-block;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border: 1px solid #d1d2d3;
|
||||
border-radius: 0.25em;
|
||||
background-image: linear-gradient(to bottom, #fafbfc, #e4ebf0);
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
color: #24292e;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn:focus {
|
||||
border-color: #c8e1ff;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background-color: #e6ebf1;
|
||||
background-image: linear-gradient(to bottom, #f0f3f6, #dce3ec);
|
||||
border-color: #afb1b2;
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
background-color: #e9ecef;
|
||||
background-image: none;
|
||||
border-color: #afb1b2;
|
||||
box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15);
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
margin-top: 4px;
|
||||
padding: 0.4em 0.8em;
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
border-radius: 0.4em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.tooltip::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border: 6px solid transparent;
|
||||
border-bottom: none;
|
||||
border-top-color: #000;
|
||||
}
|
||||
</style>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111350464-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-111350464-1');
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -74,6 +74,7 @@ const siteConfig = {
|
|||
);
|
||||
}
|
||||
],
|
||||
separateCss: "/playground.css",
|
||||
gaTrackingId: "UA-111350464-1"
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,283 @@
|
|||
html {
|
||||
background-color: #fafafa;
|
||||
color: #6a6a6a;
|
||||
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
|
||||
Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans",
|
||||
"Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 30px;
|
||||
padding: 11px 27px;
|
||||
background-color: #1a2b34;
|
||||
color: #e0e0e0;
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
header {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
header a,
|
||||
header a:visited,
|
||||
header a:focus,
|
||||
header a:active,
|
||||
header a:hover {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.logo-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 34px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: 20px;
|
||||
display: block;
|
||||
font-family: inherit;
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
position: relative;
|
||||
z-index: 9999;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#version {
|
||||
font-size: 0.5em;
|
||||
line-height: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.links {
|
||||
display: flex;
|
||||
font-size: 16px;
|
||||
}
|
||||
.links > * + * {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.editors-container {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.editors {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.editor {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex: 1 1 100%;
|
||||
position: relative;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* display as 2x2 grid */
|
||||
@media (min-width: 800px) {
|
||||
.options-container {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.editor {
|
||||
flex-basis: 50%;
|
||||
border-left: 1px solid #ddd;
|
||||
margin-left: -1px;
|
||||
}
|
||||
}
|
||||
|
||||
/* display as four columns */
|
||||
@media (min-width: 1200px) {
|
||||
.editor {
|
||||
flex-basis: 25%;
|
||||
}
|
||||
}
|
||||
|
||||
.editor.loading {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
height: auto;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.bottom-bar {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons {
|
||||
z-index: 10;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons > * + * {
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
||||
@media (max-width: 799px) {
|
||||
.bottom-bar-buttons {
|
||||
top: auto;
|
||||
bottom: 100%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.bottom-bar-buttons > * + * {
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.options-container {
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
width: 225px;
|
||||
height: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
|
||||
.options-container.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sub-options {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
padding: 15px 0 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.sub-options:last-child {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.sub-options > summary {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sub-options > summary:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.sub-options > * {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: Consolas, Courier New, Courier, monospace;
|
||||
margin: 10px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
max-width: 40px;
|
||||
}
|
||||
|
||||
/* Copied from the GitHub button styling. */
|
||||
.btn {
|
||||
box-sizing: content-box;
|
||||
display: inline-block;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border: 1px solid #d1d2d3;
|
||||
border-radius: 0.25em;
|
||||
background-image: linear-gradient(to bottom, #fafbfc, #e4ebf0);
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
color: #24292e;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn:focus {
|
||||
border-color: #c8e1ff;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background-color: #e6ebf1;
|
||||
background-image: linear-gradient(to bottom, #f0f3f6, #dce3ec);
|
||||
border-color: #afb1b2;
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
background-color: #e9ecef;
|
||||
background-image: none;
|
||||
border-color: #afb1b2;
|
||||
box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15);
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
margin-top: 4px;
|
||||
padding: 0.4em 0.8em;
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
border-radius: 0.4em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.tooltip::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border: 6px solid transparent;
|
||||
border-bottom: none;
|
||||
border-top-color: #000;
|
||||
}
|
|
@ -96,8 +96,8 @@ window.onload = function() {
|
|||
prettierVersion;
|
||||
} else {
|
||||
link.href =
|
||||
"https://github.com/j-f1/forked-prettier/blob/master/CHANGELOG.md#" +
|
||||
prettierVersion;
|
||||
"https://github.com/prettier/prettier/blob/master/CHANGELOG.md#" +
|
||||
prettierVersion.replace(/\./g, "");
|
||||
}
|
||||
link.textContent = "v" + prettierVersion;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,14 @@ self.require = function require(path) {
|
|||
return self[path];
|
||||
};
|
||||
|
||||
var prettier;
|
||||
importScripts("lib/index.js");
|
||||
var prettier = index; // eslint-disable-line
|
||||
if (typeof prettier === "undefined") {
|
||||
prettier = module.exports; // eslint-disable-line
|
||||
}
|
||||
if (typeof prettier === "undefined") {
|
||||
prettier = index; // eslint-disable-line
|
||||
}
|
||||
|
||||
var parsersLoaded = {};
|
||||
|
||||
|
|
20
yarn.lock
20
yarn.lock
|
@ -1774,6 +1774,10 @@ fill-range@^2.1.0:
|
|||
repeat-element "^1.1.2"
|
||||
repeat-string "^1.5.2"
|
||||
|
||||
find-project-root@1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/find-project-root/-/find-project-root-1.1.1.tgz#d242727a2d904725df5714f23dfdcdedda0b6ef8"
|
||||
|
||||
find-up@^1.0.0:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"
|
||||
|
@ -3363,16 +3367,6 @@ path-parse@^1.0.5:
|
|||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
|
||||
|
||||
path-root-regex@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d"
|
||||
|
||||
path-root@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7"
|
||||
dependencies:
|
||||
path-root-regex "^0.1.0"
|
||||
|
||||
path-to-regexp@^1.0.1:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
|
||||
|
@ -4430,9 +4424,9 @@ typescript-eslint-parser@11.0.0:
|
|||
lodash.unescape "4.0.1"
|
||||
semver "5.4.1"
|
||||
|
||||
typescript@2.6.2:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
|
||||
typescript@2.7.0-insiders.20171214:
|
||||
version "2.7.0-insiders.20171214"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.0-insiders.20171214.tgz#841344ddae5f498a97c0435fcd12860480050e71"
|
||||
|
||||
uglify-es@3.0.28:
|
||||
version "3.0.28"
|
||||
|
|
Loading…
Reference in New Issue