Comparing version 0.19.0 to 0.20.0
@@ -50,3 +50,3 @@ #!/usr/bin/env node | ||
const write = argv["write"]; | ||
const stdin = argv["stdin"] || !filepatterns.length && !process.stdin.isTTY; | ||
const stdin = argv["stdin"] || (!filepatterns.length && !process.stdin.isTTY); | ||
@@ -109,4 +109,6 @@ function getParserOption() { | ||
case "": | ||
console.warn("Warning: `--trailing-comma` was used without an argument. This is deprecated. " + | ||
'Specify "none", "es5", or "all".') | ||
console.warn( | ||
"Warning: `--trailing-comma` was used without an argument. This is deprecated. " + | ||
'Specify "none", "es5", or "all".' | ||
); | ||
case "es5": | ||
@@ -176,3 +178,3 @@ return "es5"; | ||
if (argv["help"] || !filepatterns.length && !stdin) { | ||
if (argv["help"] || (!filepatterns.length && !stdin)) { | ||
console.log( | ||
@@ -179,0 +181,0 @@ "Usage: prettier [opts] [filename ...]\n\n" + |
@@ -0,1 +1,23 @@ | ||
# 0.20.0 | ||
[link](https://github.com/jlongster/prettier/compare/0.19.0...0.20.0) | ||
* Fix extra parens for update expressions (#796) | ||
* Fix empty options (#803) | ||
* Eagerly evaluate `ifBreak` when processing template literals (fixes #795 | ||
* Fix function declaration params comments (#802) | ||
* Update flow to 0.40 (#808) | ||
* Correct link for travis | ||
* Fix function call args (#809) | ||
* Properly support `do` (#811) | ||
* Do not put parenthesis around not named default export (#819) | ||
* Adds another preset to related projects (#820) | ||
* Fix trailing commas in docs (#825) | ||
* Put short body of arrow functions on the same line (#829) | ||
* Preserve new lines for comments after `=` (#830) | ||
* Fix indentation of a merged group (#828) | ||
* Migrate class comments to the beginning (#831) | ||
* Update list of related projects (#833) | ||
* Allow breaking for logical expressions in member chains (#827) | ||
# 0.19.0 | ||
@@ -2,0 +24,0 @@ |
@@ -5,3 +5,2 @@ import resolve from 'rollup-plugin-node-resolve'; | ||
import globals from 'rollup-plugin-node-globals'; | ||
import babili from 'rollup-plugin-real-babili'; | ||
import json from 'rollup-plugin-json'; | ||
@@ -19,3 +18,2 @@ | ||
builtins(), | ||
babili({comments: false, sourceMap: false}), | ||
], | ||
@@ -22,0 +20,0 @@ useStrict: false, |
{ | ||
"name": "prettier", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "Prettier is an opinionated JavaScript formatter", | ||
@@ -24,3 +24,3 @@ "bin": { | ||
"esutils": "2.0.2", | ||
"flow-parser": "0.38.0", | ||
"flow-parser": "0.40.0", | ||
"get-stdin": "5.0.1", | ||
@@ -39,4 +39,3 @@ "glob": "7.1.1", | ||
"rollup-plugin-node-globals": "1.1.0", | ||
"rollup-plugin-node-resolve": "2.0.0", | ||
"rollup-plugin-real-babili": "1.0.0-alpha3" | ||
"rollup-plugin-node-resolve": "2.0.0" | ||
}, | ||
@@ -43,0 +42,0 @@ "scripts": { |
# Prettier | ||
[![Gitter](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/jlongster/prettier) | ||
[![Build Status](https://travis-ci.org/jlongster/prettier.svg?branch=master)](https://travis-ci.org/jlongster/prettier) | ||
[![Build Status](https://travis-ci.org/jlongster/prettier.svg?branch=master)](https://travis-ci.org/prettier/prettier) | ||
[![NPM version](https://img.shields.io/npm/v/prettier.svg)](https://www.npmjs.com/package/prettier) | ||
@@ -268,5 +268,5 @@ | ||
- [`eslint-plugin-prettier`](https://github.com/not-an-aardvark/eslint-plugin-prettier) plugs `prettier` into your `eslint` workflow | ||
- [`eslint-config-prettier`](https://github.com/lydell/eslint-config-prettier) turns all `eslint` rules that are unnecessary or might conflict with prettier off | ||
- [`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint) | ||
- [`eslint-plugin-prettier`](https://github.com/not-an-aardvark/eslint-plugin-prettier) plugs prettier into your ESLint workflow | ||
- [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) turns off all ESLint rules that are unnecessary or might conflict with prettier | ||
- [`prettier-eslint`](https://github.com/prettier/prettier-eslint) | ||
passes `prettier` output to `eslint --fix` | ||
@@ -277,2 +277,3 @@ - [`prettier-standard-formatter`](https://github.com/dtinth/prettier-standard-formatter) | ||
allows you to configure prettier to use `tabs` | ||
- [`neutrino-preset-prettier`](https://github.com/SpencerCDixon/neutrino-preset-prettier) allows you to use prettier as a neutrino preset | ||
@@ -279,0 +280,0 @@ |
@@ -147,4 +147,5 @@ "use strict"; | ||
handleMemberExpressionComments(enclosingNode, followingNode, comment) || | ||
handleIfStatementComments(enclosingNode, followingNode, comment) || | ||
handleTryStatementComments(enclosingNode, followingNode, comment) | ||
handleIfStatementComments(enclosingNode, followingNode, comment) || | ||
handleTryStatementComments(enclosingNode, followingNode, comment) || | ||
handleClassComments(enclosingNode, comment) | ||
) { | ||
@@ -172,3 +173,4 @@ // We're good | ||
) || | ||
handleTemplateLiteralComments(enclosingNode, comment) | ||
handleTemplateLiteralComments(enclosingNode, comment) || | ||
handleClassComments(enclosingNode, comment) | ||
) { | ||
@@ -191,4 +193,5 @@ // We're good | ||
handleIfStatementComments(enclosingNode, followingNode, comment) || | ||
handleObjectProperty(enclosingNode, precedingNode, comment) || | ||
handleTemplateLiteralComments(enclosingNode, comment) | ||
handleObjectProperty(enclosingNode, precedingNode, comment) || | ||
handleTemplateLiteralComments(enclosingNode, comment) || | ||
handleFunctionDeclarationComments(enclosingNode, comment) | ||
) { | ||
@@ -418,8 +421,10 @@ // We're good | ||
function handleObjectProperty(enclosingNode, precedingNode, comment) { | ||
if (enclosingNode && | ||
(enclosingNode.type === "ObjectProperty" || | ||
enclosingNode.type === "Property") && | ||
enclosingNode.shorthand && | ||
enclosingNode.key === precedingNode && | ||
enclosingNode.value.type === "AssignmentPattern") { | ||
if ( | ||
enclosingNode && | ||
(enclosingNode.type === "ObjectProperty" || | ||
enclosingNode.type === "Property") && | ||
enclosingNode.shorthand && | ||
enclosingNode.key === precedingNode && | ||
enclosingNode.value.type === "AssignmentPattern" | ||
) { | ||
addTrailingComment(enclosingNode.value.left, comment); | ||
@@ -432,10 +437,7 @@ return true; | ||
function handleTemplateLiteralComments(enclosingNode, comment) { | ||
if ( | ||
enclosingNode && | ||
enclosingNode.type === "TemplateLiteral" | ||
) { | ||
if (enclosingNode && enclosingNode.type === "TemplateLiteral") { | ||
const expressionIndex = findExpressionIndexForComment( | ||
enclosingNode.expressions, | ||
comment | ||
) | ||
); | ||
// Enforce all comments to be leading block comments. | ||
@@ -449,2 +451,25 @@ comment.type = "CommentBlock"; | ||
function handleFunctionDeclarationComments(enclosingNode, comment) { | ||
// Only add dangling comments to fix the case when no params are present, | ||
// i.e. a function without any argument. | ||
if ( | ||
enclosingNode && enclosingNode.type === "FunctionDeclaration" && | ||
enclosingNode.params.length === 0 | ||
) { | ||
addDanglingComment(enclosingNode, comment); | ||
return true; | ||
} | ||
return false; | ||
} | ||
function handleClassComments(enclosingNode, comment) { | ||
if (enclosingNode && | ||
(enclosingNode.type === "ClassDeclaration" || | ||
enclosingNode.type === "ClassExpression")) { | ||
addLeadingComment(enclosingNode, comment); | ||
return true; | ||
} | ||
return false; | ||
} | ||
function printComment(commentPath) { | ||
@@ -472,9 +497,7 @@ const comment = commentPath.getValue(); | ||
for (let i = 0; i < expressions.length; ++i) { | ||
const range = getExpressionRange(expressions[i]) | ||
const range = getExpressionRange(expressions[i]); | ||
if ( | ||
(startPos >= range.start && | ||
startPos <= range.end) || | ||
(endPos >= range.start && | ||
endPos<= range.end) | ||
(startPos >= range.start && startPos <= range.end) || | ||
(endPos >= range.start && endPos <= range.end) | ||
) { | ||
@@ -486,3 +509,3 @@ match = i; | ||
return match | ||
return match; | ||
} | ||
@@ -493,6 +516,6 @@ | ||
// Babylon | ||
return {start: expr.start, end: expr.end} | ||
return { start: expr.start, end: expr.end }; | ||
} | ||
// Flow | ||
return {start: expr.range[0], end: expr.range[1]} | ||
return { start: expr.range[0], end: expr.range[1] }; | ||
} | ||
@@ -499,0 +522,0 @@ |
@@ -8,3 +8,3 @@ "use strict"; | ||
if ( | ||
!(typeof val === "string" || val != null && typeof val.type === "string") | ||
!(typeof val === "string" || (val != null && typeof val.type === "string")) | ||
) { | ||
@@ -11,0 +11,0 @@ throw new Error( |
@@ -39,4 +39,6 @@ "use strict"; | ||
if(doc.type === "concat") { | ||
return Object.assign({}, doc, { parts: doc.parts.map(d => mapDoc(d, func)) }); | ||
if (doc.type === "concat") { | ||
return Object.assign({}, doc, { | ||
parts: doc.parts.map(d => mapDoc(d, func)) | ||
}); | ||
} else if (doc.type === "if-break") { | ||
@@ -47,3 +49,3 @@ return Object.assign({}, doc, { | ||
}); | ||
} else if(doc.contents) { | ||
} else if (doc.contents) { | ||
return Object.assign({}, doc, { contents: mapDoc(doc.contents, func) }); | ||
@@ -50,0 +52,0 @@ } else { |
@@ -261,3 +261,2 @@ var assert = require("assert"); | ||
case "TaggedTemplateExpression": | ||
case "CallExpression": | ||
case "NewExpression": | ||
@@ -269,4 +268,4 @@ return true; | ||
node.prefix && | ||
(node.operator === "++" && parent.operator === "+" || | ||
node.operator === "--" && parent.operator === "-") | ||
((node.operator === "++" && parent.operator === "+") || | ||
(node.operator === "--" && parent.operator === "-")) | ||
) { | ||
@@ -457,5 +456,12 @@ return true; | ||
} | ||
return false; | ||
case "ExportDefaultDeclaration": | ||
return node.type !== "ArrowFunctionExpression"; | ||
if (node.type === "ArrowFunctionExpression") { | ||
return false; | ||
} | ||
if (node.type === "FunctionExpression" && !node.id) { | ||
return false; | ||
} | ||
return true; | ||
@@ -462,0 +468,0 @@ case "ExpressionStatement": |
@@ -24,15 +24,16 @@ "use strict"; | ||
function normalize(options) { | ||
if(typeof options.trailingComma === "boolean") { | ||
const normalized = Object.assign({}, options || {}); | ||
if (typeof normalized.trailingComma === "boolean") { | ||
// Support a deprecated boolean type for the trailing comma config | ||
// for a few versions. This code can be removed later. | ||
options.trailingComma = "es5"; | ||
normalized.trailingComma = "es5"; | ||
console.warn( | ||
"Warning: `trailingComma` without any argument is deprecated. " + | ||
'Specify "none", "es5", or "all".' | ||
'Specify "none", "es5", or "all".' | ||
); | ||
} | ||
validate(options, { exampleConfig, deprecatedConfig }); | ||
const normalized = Object.assign({}, options || {}); | ||
validate(normalized, { exampleConfig, deprecatedConfig }); | ||
@@ -39,0 +40,0 @@ // For backward compatibility. Deprecated in 0.0.10 |
@@ -38,4 +38,4 @@ "use strict"; | ||
} else if ( | ||
n.MethodDefinition && n.MethodDefinition.check(node) || | ||
n.Property.check(node) && (node.method || node.shorthand) | ||
(n.MethodDefinition && n.MethodDefinition.check(node)) || | ||
(n.Property.check(node) && (node.method || node.shorthand)) | ||
) { | ||
@@ -83,2 +83,9 @@ if (n.FunctionExpression.check(node.value)) { | ||
function getPenultimate(arr) { | ||
if (arr.length > 1) { | ||
return arr[arr.length - 2]; | ||
} | ||
return null; | ||
} | ||
function getLast(arr) { | ||
@@ -309,2 +316,3 @@ if (arr.length > 0) { | ||
getParentExportDeclaration, | ||
getPenultimate, | ||
getLast, | ||
@@ -311,0 +319,0 @@ skipWhitespace, |
@@ -1,4 +0,1 @@ | ||
` | ||
${// $FlowFixMe found when converting React.createClass to ES6 | ||
ExampleStory.getFragment('story')} | ||
` | ||
return 10; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1400000
8
31116
324
1
+ Addedflow-parser@0.40.0(transitive)
- Removedflow-parser@0.38.0(transitive)
Updatedflow-parser@0.40.0