Commit Graph

1658 Commits (3cd1d003c0ae54715301e3838fd1aa64ba576d4a)

Author SHA1 Message Date
Christopher Chedeau d8d5c7bc55 Introduce --parser/parser option and deprecate --flow-parser/useFlowParser (#342)
The previous API was inconsistent. The new one is

```js
--parser flow
--parser babylon

{parser: 'flow'}
{parser: 'babylon'}
```

if we ever want to add new parsers in the future it'll allow that more easily.

I put a console.log in parser.js in both functions and tested that the test suite worked both with and without the change in run_spec. I also tested that both the previous and new command line options are working.

At some point in the future we'll likely want to get rid of the old api but might as well keep supporting it so we don't break anyone for now.
2017-01-19 14:35:12 -08:00
Kevin Gibbons a8ca2b21f4 Add semicolon to more default exports (#343) 2017-01-19 14:30:36 -08:00
Christopher Chedeau 8202a6c3b5 Normalize exports (#339)
Make all the files have a single module.exports call at the end of the file.

I added a missing `"use strict";` and removed a few unused functions from utils at the same time.
2017-01-19 13:45:36 -08:00
Christopher Chedeau aef3e387f8 Extract parser.js (#338)
Before, we would parse things inline in both index.js and run_spec. Extracting it should make it easier to manage and understand what is going on.
2017-01-19 13:23:04 -08:00
Christopher Chedeau 4e5084386d Kill fromString (#335)
This is a leftover from recast. But it doesn't do anything now.
2017-01-19 13:20:03 -08:00
Christopher Chedeau 9682c16de5 Remove unused functions from recast (#337)
Grepped in the codebase and ran the tests
2017-01-19 13:19:52 -08:00
Christopher Chedeau 173f63f043 Fix node 4 (#336)
It complained that it couldn't recognize const outside of `"use strict";`. It's a good idea to add this anyway.
2017-01-19 12:57:23 -08:00
Christopher Chedeau ad96fce6c2 Split pp.js into doc-{printer,builders,utils}.js (#334)
- doc-printer.js is now the direct implementation of the Wadler paper
- doc-builders.js are a lot of utils to generate the IR the above file needs
- doc-utils.js are small utils to traverse list of docs.
2017-01-19 12:46:57 -08:00
Christopher Chedeau ab046c6850 Remove Printer module in favor of single function (#333)
I pushed the options handling and doc->string process one level above.
2017-01-19 12:43:10 -08:00
James Long 6e57b7f2dd Print dangling comments in blocks (#331) 2017-01-19 14:46:37 -05:00
Christopher Chedeau 340da019d3 Add quotes around unicode keys in flow parser (#328)
There's a bug in the flow parser with keys using literal that contain unicode characters. Let's quote them for now.

Fixes #327
2017-01-19 12:37:24 -05:00
Christopher Chedeau a4dd760a38 Hug objects and arrays inside of JSXExpressionContainer (#213)
Fixes #197
2017-01-19 12:37:02 -05:00
Christopher Chedeau ed0023012d Properly escape JSXText (#329)
It's annoying that there's a bug inside of the flow parser, I raised it internally. While this is getting fixed, we can workaround it. This now makes babylon properly escape JSXText.
2017-01-19 11:30:35 -05:00
Christopher Chedeau a6ec181566 Fix crash for single rest on class declaration (#315)
I thought I didn't need to check the length but forgot that the rest argument is not in the list for class declaration. Now it doesn't crash anymore and there's a test...
2017-01-19 10:01:31 -05:00
Christopher Chedeau 0f54791582 Run prettier through the codebase (#316)
It's a good idea to run it right after we do a release when the number of outstanding pull requests is low :)
2017-01-18 15:31:46 -08:00
James Long a7405257ac Print binary and logical expressions in a nicer format (#262)
* Print binary and logical expressions in a nicer format (fixes #89)

* Improve algorithm (wip)

* Change grouping

* Final (hopefully?) pass at binary/logical expressions

* Update snapshots

* Add tests
2017-01-18 17:01:17 -05:00
Alex Rattray 52a44610be [JSX] Split elements on newlines and preserve whitespace (w/@yamafaktory) (#234) 2017-01-18 16:25:20 -05:00
Christopher Chedeau f79e838095 Fix trailing whitespace (#300)
In the printer, remove trailing whitespace except for template literals

Fixes #222
2017-01-18 15:38:33 -05:00
Joe Fiorini 38c8d8cd0f Remove unused variable (#304) 2017-01-18 12:37:20 -08:00
Christopher Chedeau 4c1a7b1082 Introduce second argument to ifBreak (#302) 2017-01-18 15:13:50 -05:00
Brian Ng 87b0ed3042 Fix parens around anonymous functions (#297) 2017-01-18 11:12:57 -08:00
Brian Ng c02bd6a8d5 Handle additional export default parens cases (#298) 2017-01-18 11:11:52 -08:00
Rafael Hengles 870dbd0003 Use js native String.repeat() (#293) 2017-01-18 13:33:26 -05:00
Christopher Chedeau a8eb09553a Do not output trailing commas with rest arguments (#283)
It turns out that this is not valid by the spec!
2017-01-18 12:42:20 -05:00
Christopher Chedeau 60af75b37b Update flow-parser to 0.38 (#290) 2017-01-18 12:35:42 -05:00
Christopher Chedeau a123e31e82 Workaround flow parser bug with spread in arrays (#285)
The current output of

```js
[...a, ...b]
```

is

```js
[...a, , ...b]
```

because flow parses it as

```
ArrayExpression(SpreadExpression, null, SpreadExpression)
```

This is a bug in the flow parser. Until it gets fixed, we can workaround it by deleting the `null` after a `SpreadExpression`.
2017-01-18 12:14:14 -05:00
Brian Ng 083876e66d Fix missing semi when default exporting CallExpression (#287) 2017-01-18 09:03:31 -08:00
Brian Ng b94b86331f Ensure parens on NewExpression with function callee (#282) 2017-01-17 19:45:56 -08:00
James Long 8229355508 Fix path when printing member chains so parens work properly (fixes #243) (#281) 2017-01-17 22:39:47 -05:00
Christopher Chedeau 789a3029f4 Remove +1 from newline detection (#261)
* Remove +1 from newline detection

All the changes are related to spurious `;`. Sometimes the logic is more correct, sometimes less. Since `;` are going to be removed after the first save, I don't think it matters that much.

* Handle inconsistent `end` node locations when looking for newlines
2017-01-17 22:33:55 -05:00
Christopher Chedeau 92795a0fda Fix space missing before `,` on import with bracket spacing off (#279)
Same fix as #278. We use the same (wrong) pattern in both places
2017-01-17 17:12:56 -05:00
Christopher Chedeau b580a18f30 Fix space missing before `,` on export with bracket spacing off (#278)
I copy and pasted the code for arrays which doesn't have this problem. Would be nice to come up with an abstraction for a list of stuff separated by commas. It happens a lot of time and right now it's duplicated everywhere.

Fixes #255
2017-01-17 17:12:42 -05:00
Christopher Chedeau b7455951e7 Workaround flow bug parsing astral unicode characters (#277)
According to @mroch, "Flow is using CESU-8, not UTF-8. http://www.unicode.org/reports/tr26/ ". While this is being fixed in flow, we can easily work around it inside of prettier. The downside of this approach is that we can't convert those strings to single or double quotes anymore.
2017-01-17 16:47:20 -05:00
Christopher Chedeau 0192d58bc5 Preserve the way numbers were written (#257)
The goal of the pretty printer is to make sure that the indentation is correct, not to dictate how numbers should be written :)
2017-01-16 23:01:51 -05:00
Brian Ng f0d2ad4508 Fix parens for functions inside TaggedTemplateExpression (#259) 2017-01-16 19:47:13 -08:00
Christopher Chedeau f603ca4688 Make sure empty for loops generate valid code (#224)
```js
for (;;);
function f() {}
```

The `;` was dropped meaning that the line right after was executed within the for loop which is not correct.

I tried to return `;` but it looks like

```js
for (;;)
  ;
```

which looks super weird so I ended up printing `{}` which looks like

```js
for (;;) {}
```
2017-01-16 12:54:39 -05:00
Christopher Chedeau 65a2a150b5 Fix last element of an array being null (#232)
This appears in so many of the test262.
2017-01-16 12:53:39 -05:00
Brian Ng d9ea466cd3 Fix FunctionExpression parens issues (#250) 2017-01-16 12:52:55 -05:00
Brian Ng 86c65d1f81 Fix missing parenthesis for typeof and arrow functions (#249) 2017-01-16 09:08:46 -08:00
Brian Ng 1c8414e894 Fix empty export with from clause (#248) 2017-01-16 08:58:23 -08:00
Christopher Chedeau 74bc9e7a4d Add newline for empty blocks {} (#205)
I find it weird to put `{}` together. So I figured I would change it to have an empty line and ask for feedback :)

![image](https://cloud.githubusercontent.com/assets/197597/21739279/062adc80-d44c-11e6-8bb7-5e0768f3ddde.png)

Beware: most of the test cases are not representative of real code, you almost never define blocks with no content in practice.
2017-01-16 11:31:32 -05:00
Christopher Chedeau c9af5a6c3b Escape strings using jsesc (#229)
The current implementation with `JSON.stringify()` is clever but unfortunately generates incorrect JavaScript. Using `jsesc` seems like a better and safer option. https://github.com/mathiasbynens/jsesc It doesn't have any dependencies and is pretty small.

I opted for escaping all the non ascii characters, so we don't display emojis anymore. I don't think that the world is ready yet for having random unicode characters inside of source files, there still are so many parts of the toolchain that breaks with them. If we want to revert back on this decision, there's a `minimal` option on jsesc which only escapes values that need to in order to generate valid JavaScript file (assuming the encoding of the file is set to utf8).

Also, while working on React Native, we've seen that there is an optimization inside of jsc for js files that are all ascii: it doesn't do a copy for the conversion to ucs16.

Fixes #163
2017-01-16 11:03:59 -05:00
Brian Ng b1138bdfd9 Fix parens issue with nested UrnaryExpressions (#237)
* Fix parens issue with nested UrnaryExpressions

* special case + and -
2017-01-16 07:51:16 -08:00
Brian Ng 470f80c17a Fix issue with ArrowFunctionExpression parens (#236) 2017-01-15 22:42:42 -08:00
Brian Ng 340a39b414 Fix cases of missing parens with NewExpression (#230) 2017-01-15 23:56:40 -05:00
Christopher Chedeau 0e1afd6312 Fix empty exports (#225)
```js
export {};
```

was printed as

```js
export
```

which is invalid.

This was discovered by #223
2017-01-15 23:53:41 -05:00
Christopher Chedeau c5d7619ad6 Remove faulty location check on template literals that throws in Nuclide (#218)
There's a handful of files inside of Nuclide that throw exceptions because an assertion is raised.

```
{ AssertionError: ']' === '`'
    at fixTemplateLiteral (/Users/vjeux/random/prettier/src/util.js:105:10)
    at Object.util.fixFaultyLocations (/Users/vjeux/random/prettier/src/util.js:45:5)
    at getSortedChildNodes (/Users/vjeux/random/prettier/src/comments.js:25:8)
    at getSortedChildNodes (/Users/vjeux/random/prettier/src/comments.js:61:5)
    at decorateComment (/Users/vjeux/random/prettier/src/comments.js:71:20)
    at decorateComment (/Users/vjeux/random/prettier/src/comments.js:85:7)
    at decorateComment (/Users/vjeux/random/prettier/src/comments.js:85:7)
    at decorateComment (/Users/vjeux/random/prettier/src/comments.js:85:7)
    at decorateComment (/Users/vjeux/random/prettier/src/comments.js:85:7)
    at /Users/vjeux/random/prettier/src/comments.js:129:5
```

When trying https://github.com/facebook/nuclide/blob/master/pkg/nuclide-task-runner/lib/main.js#L174

It throws in the fixTemplateLiteral method.

That method was added to fix https://github.com/benjamn/recast/issues/216 more than a year ago

```js
var x = {
  y: () => Relay.QL`
    query {
      ${foo},
      field,
    }
  `
};
```

I've checked (and added a test) and it now parses and prints correctly without that method. So it should be safe to remove.
2017-01-15 23:46:05 -05:00
Christopher Chedeau a4695b16f6 Last argument expansion works for arrow functions that return JSX (#211)
* Last argument expansion works for arrow functions that return JSX

Fixes #195

* Fixes #130
2017-01-15 00:04:50 -05:00
Christopher Chedeau b9d2d1aac5 Fix comma when an arrow function with no arguments breaks (#210)
Fixes #118
2017-01-14 23:55:38 -05:00
Christopher Chedeau 15cc3bb778 Fix key quotes omission for flow parser (#203)
```js
echo 'var { "key": val } = 1;' | ./bin/prettier.js --stdin --flow-parser
var { key: val } = 1;
```
2017-01-14 23:40:26 -05:00
Christopher Chedeau fe959631c1 Fix directives printing for empty functions (#199)
We were not printing the directives if the body of the function was empty in babylon. Also, we were printing way too many \n

```js
echo "function fn() { 'use strict'; }" | ./bin/prettier.js --stdin
function fn() {
  "use strict";
}
```

```js
echo "function fn() { 'use strict'; }" | ./bin/prettier.js --stdin --flow-parser
function fn() {
  "use strict";
}
```
2017-01-14 23:39:41 -05:00
Christopher Chedeau fe72aecce9 Fix parenthesis for UpdateExpression (#198)
```js
(this.x++).toString()
```

no longer drops the parenthesis
2017-01-14 23:37:57 -05:00
Benjamin Tan f70c9ec6d1 Don't break to new line if logical/loop statements are without brackets. (#194)
Closes #14.
2017-01-14 23:37:13 -05:00
Benjamin Tan 3f31a87da1 Remove legacy Recast code and simplify API. (#191) 2017-01-14 23:25:30 -05:00
Christopher Chedeau 281417ac1d Fix await parenthesis (#185)
This is the first time I'm adding something inside of fast-path so I'm not sure if it's correct, but it seems more correct than before!

Fixes #164
2017-01-14 23:12:17 -05:00
Christopher Chedeau d8c51483fc Fix DeclareInterface (#182)
DeclareInterface (flow) and InterfaceDeclaration (babylon) are the same type so should behave the same way. I am using the same `declare` trick where I only add it if you are inside of a `declare module` block.
2017-01-13 23:15:30 -05:00
Christopher Chedeau 3134b1c86c Make `declare type` consistent between babylon and flow (#183)
Flow doesn't have a different ast node for `type` and `declare type`. Let's always use the heuristic to be inside of a `declare module` for both ast. This way more snapshot tests are passing between the two parsers.
2017-01-13 23:14:32 -05:00
Christopher Chedeau ca230c2f2f Fix exponent in babylon (#181)
The type is NumericLiteral instead of Literal
2017-01-13 23:12:21 -05:00
Christopher Chedeau b9a3e0650a Fix windows line-endings (#177)
The search for an empty line incorrectly does +1 which happens to be skipping a `\n`, but in case of windows line endings it skips the `\r` but sees a `\n` afterwards and incorrectly assumes that it is a empty line.

This doesn't change the behavior of doing +1 when there's not a line ending. Making it correct actually triggers a bunch of changes, where half of them are better and half of them regressions. So I'm going to send another pull request to fix that case.
2017-01-13 23:07:09 -05:00
Christopher Chedeau 23e6184309 Do not advance for forward skipSpaces (#176)
For backward, we should go one step back, but for forward we are already in the correct place. It doesn't change any tests.
2017-01-13 23:00:36 -05:00
Christopher Chedeau ca471088e6 Fix `[(0)]` (#179)
Another issue where babylon and flow ast are different. In babylon, it is NumericLiteral but flow is Literal. All the tests are running on flow so were working correctly, but the default in the command line is to use babylon, so people report bugs with it.
2017-01-13 22:59:36 -05:00
James Long 3af7da5748 Reprint all the files! 2017-01-13 15:03:53 -05:00
James Long 6be89286bb Wrap ForStatement in a block for const decls (#172) 2017-01-13 14:57:46 -05:00
Alex Rattray 4fe16bda4d Multiline JSX opening tag breaks children out too (for #73) 2017-01-13 14:22:49 -05:00
Alex Rattray 2e1e6eece2 JSX maintains spaces that matter (fixes #30 and thus part of #73) 2017-01-13 14:22:49 -05:00
Alex Rattray b09a02084f Break JSXOpeningElement between attributes (fixes #15) 2017-01-13 14:22:49 -05:00
Alex Rattray d91a28ef81 Wrap Stateless JSX Arrow Functions and Assignment in Parens (fixes part of #73) 2017-01-13 14:22:49 -05:00
James Long 31a07feb84 Remove leftover `arrowParensAlways` option (#171) 2017-01-13 14:18:42 -05:00
Travis Jefferson 0b70a0f2a3 Numeric literal callees should keep parens (#141)
* Numeric literal callees should keep parens

* Remove isNumber check
2017-01-13 14:01:21 -05:00
Christopher Chedeau 958ea215a6 Add trailing comma support for multiline exports (#168)
```
echo "export { aaaaaaaa, bbbbbb, cccccc, dddddddd, eeeeeee, fffffffff, ggggggggg } from 'vjeux';" | ./bin/prettier.js --stdin --trailing-comma
export {
  aaaaaaaa,
  bbbbbb,
  cccccc,
  dddddddd,
  eeeeeee,
  fffffffff,
  ggggggggg,
} from "vjeux";
```
2017-01-13 13:00:46 -05:00
Christopher Chedeau 3dcf46c77c Do not put spaces on empty for loop (#169)
```js
for (;;) {
```

instead of

```js
for (; ; ) {
```
2017-01-13 13:00:32 -05:00
Christopher Chedeau 8e0f97e410 Break multiline imports (#167)
Follows the same pattern as https://github.com/jlongster/prettier/pull/156/files

```js
echo "import { aaaaaaaa, bbbbbb, cccccc, dddddddd, eeeeeee, fffffffff, ggggggggg } from 'vjeux';" | ./bin/prettier.js --stdin
import {
  aaaaaaaa,
  bbbbbb,
  cccccc,
  dddddddd,
  eeeeeee,
  fffffffff,
  ggggggggg
} from "vjeux";
```
2017-01-13 12:59:33 -05:00
James Long fb9c1e8098 Fix misprinting of computed properties in method chains. (#157)
* Fix misprinting of computed properties in method chains.

Closes #23, #94.

* Fix snapshot conflict
2017-01-12 15:06:44 -05:00
James Long aab300844f Use group instead of conditionalGroup 2017-01-12 14:53:12 -05:00
Benjamin Tan 1549936e68 Break long `exports` into multiple lines.
Ref #19.
2017-01-12 14:38:22 -05:00
James Long bbe2524dab Merge pull request #134 from vjeux/generics
Support method generics on babylon parser
2017-01-12 13:50:10 -05:00
Christopher Chedeau 291440b730 Support method generics on babylon parser
This is working on the flow parser but not babylon

```js
echo 'class C<T> { submit<T>() { } }' | ./bin/prettier.js --stdin
class C<T> {
  submit<T>() {}
}
```
2017-01-12 07:48:26 -08:00
Christopher Chedeau afca3d7e7a Minimize string escapes
If there you are opting in for double quote but there's a string with a double quote in it, it's better to swap to a single quote to avoid having too many `\`. Note that if there are both single and double quotes in the string, we should use the default string instead.

Fixes #139
2017-01-12 07:44:16 -08:00
James Long d25881530f Merge pull request #126 from vjeux/jsx_quotes
Always use double quotes for JSX and properly escape
2017-01-12 10:30:42 -05:00
James Long 809aabc3bd Merge pull request #133 from vjeux/generic_babylon
Support type annotation for rest argument on babylon parser
2017-01-12 10:28:57 -05:00
James Long 1ccf6b0344 Merge pull request #90 from bakkot/property-names
Fix #79: omit unnecessary quotes in property names
2017-01-12 09:11:36 -05:00
Christopher Chedeau 35fb28bef2 Support type annotation for rest argument on babylon parser
This is working on the flow parser but not babylon

```js
echo 'function f(...flags: Array<boolean>) {}' | ./bin/prettier.js --stdin
function f(...flags: Array<boolean>) {}
```
2017-01-11 15:05:28 -08:00
Christopher Chedeau a6cdede9f6 Always use double quotes for JSX and properly escape
JSX quotes are unfortunately using html escaping. Also, we should disregard the single-quote option for JSX quotes as we always want double quotes.
2017-01-11 11:40:24 -08:00
Kevin Gibbons 18f54005f6 Do not unquote string properties 2017-01-11 09:31:34 -08:00
Benjamin Tan 24c3af8821 Remove trailing whitespace in broken arrow function expressions.
Closes #103.
2017-01-11 23:28:13 +08:00
James Long c2458e7dc9 Merge pull request #106 from demoneaux/fix-directives-newlines
Fix misprinting of directives.
2017-01-11 10:20:09 -05:00
James Long 944659194b Merge pull request #105 from demoneaux/fix-eof
Add newline to EOF.
2017-01-11 10:15:15 -05:00
Benjamin Tan 030a70fd38 Fix misprinting of directives.
Closes #29.
2017-01-11 22:47:22 +08:00
Benjamin Tan 03414d64cc Add newline to EOF.
Closes #55.
2017-01-11 22:39:32 +08:00
Benjamin Tan d56365dd54 Add semicolons to `export` declarations.
Closes #22.
2017-01-11 20:43:27 +08:00
Kevin Gibbons be8f65d23e Format property names consistently 2017-01-10 22:29:54 -08:00
James Long 10a8cd9122 Merge pull request #45 from danharper/fix38
Print Flow types with no name (fixes #38)
2017-01-10 23:51:42 -05:00
James Long 34dc37a816 Merge pull request #67 from jmorrell/flow-type-declarations
Make union types pretty again
2017-01-10 23:38:27 -05:00
Dan Harper 7c21dd037f Fix import & export bracket spacing (fixes #24) 2017-01-11 00:32:57 +00:00
James Long 3f949907a0 Merge pull request #72 from michaelficarra/GH-71
fixes #71: don't indent block statements which are children of case clauses
2017-01-10 18:56:50 -05:00
James Long d2d6def9be Revert "fixes #49: omit new parens when it has no arguments"
This reverts commit b5392f9468.
2017-01-10 18:53:03 -05:00
Michael Ficarra 0461b3e6cd fixes #71: don't indent block stmts which are children of case clauses 2017-01-10 15:26:12 -08:00
James Long e3b41dd6ca Merge pull request #57 from michaelficarra/GH-56
fixes #56: indent cases inside switch statements
2017-01-10 17:49:46 -05:00
Dan Harper 867b829965 Print Flow types with no name (fixes #38) 2017-01-10 22:49:25 +00:00
James Long 321bd6a9fa Allow block-less arrow function expression to break (fixes #61) 2017-01-10 16:46:33 -05:00
Jeremy Morrell 9213d5ad7f First attempt at making union types prettier 2017-01-10 18:31:29 -03:00
James Long 4825e56227 Allow multiple nested arrow functions to be expanded as last call arg (fixes #65) 2017-01-10 16:20:24 -05:00
James Long c904281027 Remove use of `fromString(...).join` in a few places (fixes #52) 2017-01-10 15:28:28 -05:00
Michael Ficarra fc521c4d03 fixes #56: indent cases inside switch statements 2017-01-10 12:03:36 -08:00
Michael Ficarra b5392f9468 fixes #49: omit new parens when it has no arguments 2017-01-10 11:14:39 -08:00
James Long 4abb8ce544 Support back to node v4 2017-01-10 12:18:22 -05:00
James Long a0edc2a520 Document more CLI flags in usage text 2017-01-09 23:22:58 -05:00
James Long a4643f1bae Add special case for comment at top of file; regenerate snapshots 2017-01-09 21:49:26 -05:00
James Long 74fc539e1a Fix usage with the Flow parser 2017-01-09 21:24:42 -05:00
James Long 27af6be07a Apply bracketSpacing option to array literals 2017-01-09 20:58:51 -05:00
James Long 5c53a2d59c Use babylon directly and convert recast's comment algorith to use our own API 2017-01-09 17:37:45 -05:00
James Long 7ad69b05ca Tweak JSX attributes and fix bug with function params 2017-01-09 14:28:23 -05:00
James Long f40f5f11d6 Add space before self-closing a JSXElement 2017-01-09 14:16:28 -05:00
James Long 892d070313 Only allow ArrowFunctionExpression types to break themselves in CallExpression's if they using a block 2017-01-09 14:01:14 -05:00
James Long 994432c193 Improve printing of comments 2017-01-09 13:47:02 -05:00
James Long 542c0ee7b9 Reprint pp.js and printer.js 2017-01-09 12:09:04 -05:00
James Long aed3c1af71 Handle curly brackets in SwitchCase types 2017-01-09 12:07:39 -05:00
James Long 6b582f808c Don't prioritize breaking on last arg if it's a CallExpression 2017-01-09 11:58:47 -05:00
James Long bcd44b4368 Keep blank lines from original source 2017-01-09 09:46:09 -05:00
James Long 8a5f3d1b10 Merge pull request #4 from jlongster/call-chain
Initial attempt at chaining call expressions
2017-01-08 14:44:58 -05:00
James Long c10681d148 Pull out special chain printing into utility function 2017-01-08 14:44:44 -05:00
James Long fe4484d2e3 Update call/member expression chaining heuristic to account for NewExpression's 2017-01-08 14:00:41 -05:00
James Long d5ab6ab921 Detect chained call expressions and format them specifically 2017-01-08 13:56:57 -05:00
Christopher Chedeau c5ff571c6d Fix missing option argument 2017-01-06 19:56:30 -08:00
James Long 9c72530589 Reduce duplicate code for printing intersection & union types 2017-01-05 15:11:40 -05:00
James Long 5c39dc02e6 Improve intersection and union type annotation 2017-01-05 14:43:05 -05:00
James Long 7b0ec6d935 Break ternary ops across newlines if needed 2017-01-05 12:32:56 -05:00
James Long b5ae965274 Reprint pp.js 2017-01-05 12:21:57 -05:00
James Long 0d4d21cc68 Print trailing commas everywhere if enabled 2017-01-05 12:19:30 -05:00
James Long fcd5436b38 Improve if/else printing and other clauses 2017-01-05 12:10:14 -05:00
James Long fc186c8df8 Add option for trailing commas in objects 2017-01-05 11:36:41 -05:00
James Long 9596695a12 Rename quotes config option to 2017-01-05 10:01:43 -05:00
James Long f1feb24dff Reprint printer.js 2017-01-04 22:27:25 -05:00
James Long 835befebf5 Always output comment newlines, fix edge case with function param output 2017-01-04 22:26:46 -05:00
James Long 67e2f6d482 Simplify how options are normalized (fixes default options) 2017-01-04 20:45:28 -05:00
James Long 599b4311bb Allow single quotes with --single-quotes option 2017-01-04 17:32:05 -05:00
James Long b550f1d088 Use , to separate type fields instead of ; 2017-01-04 17:26:44 -05:00
James Long 8326963f2d Add option to include spaces inside object/array literals, default to false 2017-01-04 17:23:07 -05:00
James Long 98fef67b4e Fix a bug with expanding function args by passing group opts properly 2017-01-04 17:08:28 -05:00
James Long 898009ba66 Consistently print function parameters the correct way 2017-01-04 16:52:49 -05:00
James Long 588c8ce7cd Add `conditionalGroup` to allow manually specifying multiple representations of a document; use it to support expanding last parameter of functions 2017-01-04 15:24:10 -05:00
James Long fa16988401 If function declaration is too long, break all args on separate lines; also fix small bug in output cleansing 2017-01-01 20:33:53 -05:00
James Long de4d7ac799 Reprint printer.js 2016-12-31 14:38:58 -05:00
James Long 5efa13a10c Never print blank lines with spaces 2016-12-31 14:38:33 -05:00
James Long a9d06355ee Fix spacing algorithm 2016-12-30 23:10:22 -05:00
James Long 7451255906 Bootstrapped! Format the printer with the printer itself 2016-12-30 23:03:22 -05:00
James Long c9e24eb477 Add spaces around certain statements, add --write option, and more 2016-12-30 23:01:07 -05:00
James Long 7ea2348b03 Various fixes with destructuring default, JSX, and more; all tests pass! 2016-12-30 17:00:11 -05:00
James Long 32d4200f60 Wrap class expressions in parens if needed 2016-12-30 14:25:52 -05:00
James Long 4dfaf9da98 Fix a few parens detection and more predicates 2016-12-30 14:10:52 -05:00
James Long ed57110ef5 Add type parameters on anon functions 2016-12-30 13:41:45 -05:00
James Long e972a7f0b6 Fix object and predicate annotations 2016-12-30 13:32:43 -05:00
James Long 6715abca76 Tweak variable declaration printing 2016-12-30 11:56:42 -05:00
James Long 73755a686d Fix type annotation for optional function type properties 2016-12-30 00:08:03 -05:00
James Long 11a01552a4 Lots of bug fixes (will do smaller commits from now on) 2016-12-30 00:01:44 -05:00
James Long 88dc2681f6 Make all tests pass the crash test and fix a few more bugs 2016-12-27 21:40:04 -05:00
James Long 599e5821c1 Optimize jest testing and implement more fixes 2016-12-27 13:28:04 -05:00
James Long 9b4535e9f8 Merge in forked recast printer that uses Wadler's algorithm 2016-12-23 13:38:10 -05:00