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