Upgrade prettier to v1.4.0, fix lint issues (#1888)

master
Joseph Frazier 2017-06-02 14:48:43 -04:00 committed by Christopher Chedeau
parent 4915e0228e
commit 26e829b987
7 changed files with 42 additions and 83 deletions

View File

@ -32,7 +32,7 @@
"postcss-scss": "1.0.0",
"postcss-selector-parser": "2.2.3",
"postcss-values-parser": "git://github.com/shellscape/postcss-values-parser.git#5e351360479116f3fe309602cdd15b0a233bc29f",
"prettier": "1.3.1",
"prettier": "1.4.0",
"rimraf": "2.6.1",
"rollup": "0.41.1",
"rollup-plugin-commonjs": "7.0.0",

View File

@ -68,7 +68,12 @@ function getSortedChildNodes(node, text, resultArray) {
});
}
for (let i = 0, nameCount = names.length; i < nameCount; ++i) {
for (
let i = 0,
nameCount = names.length;
i < nameCount;
++i
) {
getSortedChildNodes(node[names[i]], text, resultArray);
}
@ -82,7 +87,8 @@ function decorateComment(node, comment, text) {
const childNodes = getSortedChildNodes(node, text);
let precedingNode, followingNode;
// Time to dust off the old binary search robes and wizard hat.
let left = 0, right = childNodes.length;
let left = 0,
right = childNodes.length;
while (left < right) {
const middle = (left + right) >> 1;
const child = childNodes[middle];

View File

@ -189,7 +189,6 @@ function printDocToString(doc, options) {
}
// fallthrough
case MODE_BREAK: {
shouldRemeasure = false;
@ -372,7 +371,6 @@ function printDocToString(doc, options) {
}
// fallthrough
case MODE_BREAK:
if (lineSuffix.length) {
cmds.push([ind, mode, doc]);

View File

@ -38,7 +38,8 @@ function parse(text) {
throw createError(
// babel error prints (l:c) with cols that are zero indexed
// so we need our custom error
originalError.message.replace(/ \(.*\)/, ""),
originalError.message
.replace(/ \(.*\)/, ""),
originalError.loc.line,
originalError.loc.column + 1
);

View File

@ -44,7 +44,7 @@ function isProbablyJsx(text) {
[
"(^[^\"'`]*</)", // Contains "</" when probably not in a string
"|",
"(^[^/]{2}.*\/>)" // Contains "/>" on line not starting with "//"
"(^[^/]{2}.*/>)" // Contains "/>" on line not starting with "//"
].join(""),
"m"
).test(text);

View File

@ -867,8 +867,10 @@ function genericPrintNoParens(path, options, print, args) {
const lastElem = util.getLast(n[propertiesField]);
const canHaveTrailingSeparator = !(lastElem &&
(lastElem.type === "RestProperty" || lastElem.type === "RestElement"));
const canHaveTrailingSeparator = !(
lastElem &&
(lastElem.type === "RestProperty" || lastElem.type === "RestElement")
);
let content;
if (props.length === 0 && !n.typeAnnotation) {
@ -996,8 +998,9 @@ function genericPrintNoParens(path, options, print, args) {
}
} else {
const lastElem = util.getLast(n.elements);
const canHaveTrailingComma = !(lastElem &&
lastElem.type === "RestElement");
const canHaveTrailingComma = !(
lastElem && lastElem.type === "RestElement"
);
// JavaScript allows you to have empty elements in an array which
// changes its length based on the number of commas. The algorithm
@ -1882,13 +1885,14 @@ function genericPrintNoParens(path, options, print, args) {
const parentParentParent = path.getParentNode(2);
let isArrowFunctionTypeAnnotation =
n.type === "TSFunctionType" ||
!((parent.type === "ObjectTypeProperty" &&
!getFlowVariance(parent) &&
!parent.optional &&
util.locStart(parent) === util.locStart(n)) ||
!(
(parent.type === "ObjectTypeProperty" &&
!getFlowVariance(parent) &&
!parent.optional &&
util.locStart(parent) === util.locStart(n)) ||
parent.type === "ObjectTypeCallProperty" ||
(parentParentParent &&
parentParentParent.type === "DeclareFunction"));
(parentParentParent && parentParentParent.type === "DeclareFunction")
);
let needsColon =
isArrowFunctionTypeAnnotation && parent.type === "TypeAnnotation";
@ -2015,9 +2019,11 @@ function genericPrintNoParens(path, options, print, args) {
const shouldIndent =
parent.type !== "TypeParameterInstantiation" &&
parent.type !== "GenericTypeAnnotation" &&
!((parent.type === "TypeAlias" ||
parent.type === "VariableDeclarator") &&
hasLeadingOwnLineComment(options.originalText, n));
!(
(parent.type === "TypeAlias" ||
parent.type === "VariableDeclarator") &&
hasLeadingOwnLineComment(options.originalText, n)
);
// {
// a: string
@ -3254,8 +3260,10 @@ function printFunctionParams(path, print, options, expandArg) {
fun[paramsField][0].typeAnnotation &&
flowTypeAnnotations.indexOf(fun[paramsField][0].typeAnnotation.type) !==
-1 &&
!(fun[paramsField][0].typeAnnotation.type === "GenericTypeAnnotation" &&
fun[paramsField][0].typeAnnotation.typeParameters) &&
!(
fun[paramsField][0].typeAnnotation.type === "GenericTypeAnnotation" &&
fun[paramsField][0].typeAnnotation.typeParameters
) &&
!fun.rest;
if (isFlowShorthandWithOneArg) {
@ -4593,7 +4601,9 @@ function classChildNeedsASIProtection(node) {
if (!node.computed) {
const name = node.key && node.key.name;
if (name === "in" || name === "instanceof") return true;
if (name === "in" || name === "instanceof") {
return true;
}
}
switch (node.type) {
case "ClassProperty":

View File

@ -169,10 +169,6 @@ assert@^1.1.1:
dependencies:
util "0.10.3"
ast-types@0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.8.tgz#6cb6a40beba31f49f20928e28439fc14a3dab078"
async-each@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
@ -339,10 +335,6 @@ babylon@7.0.0-beta.10:
version "7.0.0-beta.10"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.10.tgz#07a210ea6a4480c9581794403907a6c72abc607c"
babylon@7.0.0-beta.8:
version "7.0.0-beta.8"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.8.tgz#2bdc5ae366041442c27e068cce6f0d7c06ea9949"
babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0:
version "6.17.1"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"
@ -1185,10 +1177,6 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
flow-parser@0.45.0:
version "0.45.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.45.0.tgz#aa29d4ae27f06aa02817772bba0fcbefef7e62f0"
flow-parser@0.47.0:
version "0.47.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.47.0.tgz#c57d35ff19bb40fb0f07222298e58cd4afa8a59a"
@ -1293,17 +1281,6 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob@7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.2"
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
@ -1825,13 +1802,6 @@ jest-jasmine2@^20.0.4:
once "^1.4.0"
p-map "^1.1.1"
jest-matcher-utils@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-19.0.0.tgz#5ecd9b63565d2b001f61fbf7ec4c7f537964564d"
dependencies:
chalk "^1.1.3"
pretty-format "^19.0.0"
jest-matcher-utils@^20.0.3:
version "20.0.3"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-20.0.3.tgz#b3a6b8e37ca577803b0832a98b164f44b7815612"
@ -1921,15 +1891,6 @@ jest-util@^20.0.3:
leven "^2.1.0"
mkdirp "^0.5.1"
jest-validate@19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-19.0.0.tgz#8c6318a20ecfeaba0ba5378bfbb8277abded4173"
dependencies:
chalk "^1.1.1"
jest-matcher-utils "^19.0.0"
leven "^2.0.0"
pretty-format "^19.0.0"
jest-validate@20.0.3, jest-validate@^20.0.3:
version "20.0.3"
resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-20.0.3.tgz#d0cfd1de4f579f298484925c280f8f1d94ec3cab"
@ -2053,7 +2014,7 @@ lcid@^1.0.0:
dependencies:
invert-kv "^1.0.0"
leven@^2.0.0, leven@^2.1.0:
leven@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"
@ -2565,26 +2526,9 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.3.1.tgz#fa0ea84b45ac0ba6de6a1e4cecdcff900d563151"
dependencies:
ast-types "0.9.8"
babel-code-frame "6.22.0"
babylon "7.0.0-beta.8"
chalk "1.1.3"
esutils "2.0.2"
flow-parser "0.45.0"
get-stdin "5.0.1"
glob "7.1.1"
jest-validate "19.0.0"
minimist "1.2.0"
pretty-format@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-19.0.0.tgz#56530d32acb98a3fa4851c4e2b9d37b420684c84"
dependencies:
ansi-styles "^3.0.0"
prettier@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.4.0.tgz#e648862b3737c85e3592cf85571dc42939bb5216"
pretty-format@^20.0.3:
version "20.0.3"