Socket
Socket
Sign inDemoInstall

prettier

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier - npm Package Compare versions

Comparing version 0.20.0 to 0.21.0

11

bin/prettier.js

@@ -25,2 +25,3 @@ #!/usr/bin/env node

"color",
"list-different",
"help",

@@ -35,3 +36,3 @@ "version",

default: { color: true, "bracket-spacing": true, parser: "babylon" },
alias: { help: "h", version: "v" },
alias: { help: "h", version: "v", "list-different": "l" },
unknown: param => {

@@ -183,2 +184,3 @@ if (param.startsWith("-")) {

" --write Edit the file in-place. (Beware!)\n" +
" --list-different or -l Print filenames of files that are different from prettier formatting\n" +
" --stdin Read input from stdin.\n" +

@@ -194,3 +196,3 @@ " --print-width <int> Specify the length of line that the printer will wrap on. Defaults to 80.\n" +

" --color Colorize error messages. Defaults to true.\n" +
" --version Print prettier version.\n" +
" --version or -v Print prettier version.\n" +
"\n" +

@@ -271,2 +273,7 @@ "Boolean options can be turned off like this:\n" +

}
} else if (argv["list-different"]) {
if (input !== output) {
console.log(filename);
process.exitCode = 1;
}
} else {

@@ -273,0 +280,0 @@ // Don't use `console.log` here since it adds an extra newline at the end.

@@ -0,1 +1,24 @@

# 0.21.0
[link](https://github.com/jlongster/prettier/compare/0.20.0...0.21.0)
* [JSX] Break before and after jsx whitespace (#836)
* re-run snapshot tests
* Run prettier 0.20.0 (#835)
* [JSX] Don't wrap JSX Elements in parentheses in {} (#845)
* Fix comment after the last argument of a function (#856)
* Fix travis build imag
* Do not break require calls (#841)
* Stabilize import as comments (#855)
* Fix jsx expression comment that break (#852)
* Inline last arg function arguments (#847)
* Keep parenthesis on export default function (#844)
* Inline short expressions for boolean operators too (#826)
* Introduce -l option (#854)
* Add parenthesis around assignments (#862)
* Do not put \n after label (#860)
* Fix comment for `call( // comment` (#858)
* Do not break long it calls (#842)
* Fix flow union comments (#853)
# 0.20.0

@@ -2,0 +25,0 @@

2

package.json
{
"name": "prettier",
"version": "0.20.0",
"version": "0.21.0",
"description": "Prettier is an opinionated JavaScript formatter",

@@ -5,0 +5,0 @@ "bin": {

# 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/prettier/prettier)
[![Build Status](https://travis-ci.org/prettier/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)

@@ -6,0 +6,0 @@

@@ -146,6 +146,9 @@ "use strict";

if (
handleLastFunctionArgComments(precedingNode, enclosingNode, followingNode, comment) ||
handleMemberExpressionComments(enclosingNode, followingNode, comment) ||
handleIfStatementComments(enclosingNode, followingNode, comment) ||
handleTryStatementComments(enclosingNode, followingNode, comment) ||
handleClassComments(enclosingNode, comment)
handleImportSpecifierComments(enclosingNode, comment) ||
handleClassComments(enclosingNode, comment) ||
handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment)
) {

@@ -173,3 +176,5 @@ // We're good

) ||
handleImportSpecifierComments(enclosingNode, comment) ||
handleTemplateLiteralComments(enclosingNode, comment) ||
handleCallExpressionComments(precedingNode, enclosingNode, comment) ||
handleClassComments(enclosingNode, comment)

@@ -452,3 +457,4 @@ ) {

if (
enclosingNode && enclosingNode.type === "FunctionDeclaration" &&
enclosingNode &&
enclosingNode.type === "FunctionDeclaration" &&
enclosingNode.params.length === 0

@@ -462,6 +468,29 @@ ) {

function handleLastFunctionArgComments(precedingNode, enclosingNode, followingNode, comment) {
// Type definitions functions
if (precedingNode && precedingNode.type === 'FunctionTypeParam' &&
enclosingNode && enclosingNode.type === 'FunctionTypeAnnotation' &&
followingNode && followingNode.type !== 'FunctionTypeParam') {
addTrailingComment(precedingNode, comment);
return true;
}
// Real functions
if (precedingNode && precedingNode.type === 'Identifier' &&
enclosingNode && (
enclosingNode.type === 'ArrowFunctionExpression' ||
enclosingNode.type === 'FunctionExpression') &&
followingNode && followingNode.type !== 'Identifier') {
addTrailingComment(precedingNode, comment);
return true;
}
return false;
}
function handleClassComments(enclosingNode, comment) {
if (enclosingNode &&
(enclosingNode.type === "ClassDeclaration" ||
enclosingNode.type === "ClassExpression")) {
if (
enclosingNode &&
(enclosingNode.type === "ClassDeclaration" ||
enclosingNode.type === "ClassExpression")
) {
addLeadingComment(enclosingNode, comment);

@@ -473,2 +502,30 @@ return true;

function handleImportSpecifierComments(enclosingNode, comment) {
if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
addLeadingComment(enclosingNode, comment);
return true;
}
return false;
}
function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
if (enclosingNode && enclosingNode.type === "CallExpression" &&
precedingNode && enclosingNode.callee === precedingNode &&
enclosingNode.arguments.length > 0) {
addLeadingComment(enclosingNode.arguments[0], comment);
return true;
}
return false;
}
function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
if (enclosingNode && enclosingNode.type === 'UnionTypeAnnotation' &&
precedingNode && precedingNode.type === 'ObjectTypeAnnotation' &&
followingNode && followingNode.type === 'ObjectTypeAnnotation') {
addTrailingComment(precedingNode, comment);
return true;
}
return false;
}
function printComment(commentPath) {

@@ -475,0 +532,0 @@ const comment = commentPath.getValue();

@@ -410,7 +410,17 @@ var assert = require("assert");

parent.type === "ArrowFunctionExpression" &&
parent.body === node &&
node.left.type === "ObjectPattern"
parent.body === node
) {
return true;
return node.left.type === "ObjectPattern";
}
if (parent.type === "ForStatement" &&
(parent.init === node || parent.update === node)) {
return false;
}
if (parent.type === "ExpressionStatement") {
if (node.left.type === "ObjectPattern") {
return true;
}
return false;
}
return true;

@@ -458,8 +468,8 @@ case "ConditionalExpression":

case "ExportDefaultDeclaration":
if (node.type === "ArrowFunctionExpression") {
if (
node.type === "ArrowFunctionExpression" ||
node.type === "FunctionDeclaration"
) {
return false;
}
if (node.type === "FunctionExpression" && !node.id) {
return false;
}
return true;

@@ -466,0 +476,0 @@

@@ -1,1 +0,7 @@

return 10;
insertRule(`*, *:before, *:after {
box-sizing: inherit;
}`);
insertRule`*, *:before, *:after {
box-sizing: inherit;
}`;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc