prettier
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -231,3 +231,3 @@ #!/usr/bin/env node | ||
console.error("Unable to read file: " + filename + "\n" + err); | ||
console.error("Unable to read file: " + filename + "\n" + e); | ||
// Don't exit the process if one file failed | ||
@@ -234,0 +234,0 @@ process.exitCode = 2; |
@@ -0,1 +1,21 @@ | ||
# 1.1.0 | ||
[link](https://github.com/jlongster/prettier/compare/1.0.0...1.1.0) | ||
* Prettier 1.0 is the stabler release we've been waiting for (#1242) | ||
* fix small typo (#1255) | ||
* Fix : ReferenceError: err is not defined (#1254) | ||
* Document debugging strategies (#1253) | ||
* Do not inline member expressions as part of assignments (#1256) | ||
* Fix flow union params (#1251) | ||
* Use a whitelist instead of blacklist for member breaking (#1261) | ||
* Remove trailing whitespace (#1259) | ||
* Get rid of fixFaultyLocations code (#1252) | ||
* Fixing n.comments check in printer (#1239) | ||
* [WIP] no-semi comments (#1257) | ||
# 1.0.1 | ||
* change semi default | ||
# 1.0.0 | ||
@@ -2,0 +22,0 @@ |
{ | ||
"name": "prettier", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Prettier is an opinionated JavaScript formatter", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -43,5 +43,2 @@ # Prettier | ||
*Warning*: This is a **beta**, and the format may change over time. If you | ||
aren't OK with the format changing, wait for a more stable version. | ||
This goes way beyond [ESLint](http://eslint.org/) and other projects | ||
@@ -144,4 +141,4 @@ [built on it](https://github.com/feross/standard). Unlike ESLint, | ||
To format a file in-place, use `--write`. While this is in beta you | ||
should probably commit your code before doing that. | ||
To format a file in-place, use `--write`. You may want to consider | ||
committing your code before doing that, just in case. | ||
@@ -478,2 +475,6 @@ ```bash | ||
`node scripts/sync-flow-tests.js ../flow/tests/`. | ||
* If you would like to debug prettier locally, you can either debug it in node | ||
or the browser. The easiest way to debug it in the browser is to run the | ||
interactive `docs` REPL locally. The easiest way to debug it in node, is to | ||
create a local test file and run it in an editor like VS Code. | ||
@@ -480,0 +481,0 @@ If you can, take look at [commands.md](commands.md) and check out [Wadler's |
@@ -18,3 +18,2 @@ "use strict"; | ||
var util = require("./util"); | ||
var comparePos = util.comparePos; | ||
var childNodesCacheKey = Symbol("child-nodes"); | ||
@@ -33,6 +32,2 @@ var locStart = util.locStart; | ||
// The loc checks below are sensitive to some of the problems that | ||
// are fixed by this utility function. | ||
util.fixFaultyLocations(node, text); | ||
if (resultArray) { | ||
@@ -901,3 +896,3 @@ if (n.Node.check(node) && node.type !== "EmptyStatement") { | ||
function printComments(path, print, options) { | ||
function printComments(path, print, options, needsSemi) { | ||
var value = path.getValue(); | ||
@@ -913,3 +908,3 @@ var parent = path.getParentNode(); | ||
var leadingParts = []; | ||
var trailingParts = [printed]; | ||
var trailingParts = [needsSemi ? ";" : "", printed]; | ||
@@ -916,0 +911,0 @@ path.each(function(commentPath) { |
@@ -270,2 +270,9 @@ "use strict"; | ||
// Trim whitespace at the end of line | ||
while ( | ||
out.length > 0 && | ||
out[out.length - 1].match(/^[^\S\n]*$/) | ||
) { | ||
out.pop(); | ||
} | ||
out[out.length - 1] = out[out.length - 1].replace( | ||
@@ -272,0 +279,0 @@ /[^\S\n]*$/, |
@@ -6,53 +6,2 @@ "use strict"; | ||
function comparePos(pos1, pos2) { | ||
return pos1.line - pos2.line || pos1.column - pos2.column; | ||
} | ||
function expandLoc(parentNode, childNode) { | ||
if (locStart(childNode) - locStart(parentNode) < 0) { | ||
setLocStart(parentNode, locStart(childNode)); | ||
} | ||
if (locEnd(parentNode) - locEnd(childNode) < 0) { | ||
setLocEnd(parentNode, locEnd(childNode)); | ||
} | ||
} | ||
function fixFaultyLocations(node, text) { | ||
if (node.decorators) { | ||
// Expand the loc of the node responsible for printing the decorators | ||
// (here, the decorated node) so that it includes node.decorators. | ||
node.decorators.forEach(function(decorator) { | ||
expandLoc(node, decorator); | ||
}); | ||
} else if (node.declaration && isExportDeclaration(node)) { | ||
// Expand the loc of the node responsible for printing the decorators | ||
// (here, the export declaration) so that it includes node.decorators. | ||
var decorators = node.declaration.decorators; | ||
if (decorators) { | ||
decorators.forEach(function(decorator) { | ||
expandLoc(node, decorator); | ||
}); | ||
} | ||
} else if ( | ||
(n.MethodDefinition && n.MethodDefinition.check(node)) || | ||
(n.Property.check(node) && (node.method || node.shorthand)) | ||
) { | ||
if (n.FunctionExpression.check(node.value)) { | ||
// FunctionExpression method values should be anonymous, | ||
// because their .id fields are ignored anyway. | ||
node.value.id = null; | ||
} | ||
} else if (node.type === "ObjectTypeProperty") { | ||
var end = skipSpaces(text, locEnd(node), true); | ||
if (end !== false && text.charAt(end) === ",") { | ||
// Some parsers accidentally include trailing commas in the | ||
// end information for ObjectTypeProperty nodes. | ||
if ((end = skipSpaces(text, end - 1, true)) !== false) { | ||
setLocEnd(node, end); | ||
} | ||
} | ||
} | ||
} | ||
function isExportDeclaration(node) { | ||
@@ -326,5 +275,3 @@ if (node) | ||
module.exports = { | ||
comparePos, | ||
getPrecedence, | ||
fixFaultyLocations, | ||
isExportDeclaration, | ||
@@ -331,0 +278,0 @@ getParentExportDeclaration, |
21
test.js
@@ -1,10 +0,11 @@ | ||
function f() { | ||
return new Promise(( | ||
resolve: (event: any) => void, | ||
reject: (event: any) => void, | ||
) => { | ||
const resolveReject = new Map(); | ||
resolveReject.set('resolve', resolve); | ||
resolveReject.set('reject', reject); | ||
}); | ||
} | ||
let error = new Error(response.statusText); | ||
// comment | ||
(error: any).response = response | ||
x; | ||
/* comment */ (error: any).response = response | ||
x; | ||
(error: any).response = response; /* comment */ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1486675
481
33399