Christopher Chedeau
0d38136115
Put parenthesis after return when jsx is prettier-ignored ( #2665 )
2017-08-24 19:29:05 -07:00
Christopher Chedeau
0ee74a8d25
Do not swallow prettier-ignore comments ( #2664 )
2017-08-24 18:57:01 -07:00
Christopher Chedeau
f7bd74ed98
Fix fatal with empty jsx ( #2663 )
2017-08-24 18:02:44 -07:00
Christopher Chedeau
ab91f6f8be
Fix interleaved comments in class decorators ( #2661 )
...
I wrote this fix a while ago but it conflicted with the class heuristic, now that #2660 fixes it, we can ship this one as well!
Fixes #1460
Fixes #2507
2017-08-24 16:04:02 -07:00
Christopher Chedeau
05b4422e4f
Better fix for class comments ( #2660 )
...
We used to be very naive and just push all the comments at the top of the class, but it's very brute force (and breaks some flow annotations inside of fb) so we can do better :)
2017-08-24 15:45:28 -07:00
Christopher Chedeau
b231948a36
GraphQL: Print directives for field declarations ( #2317 )
2017-06-27 20:22:03 -07:00
Christopher Chedeau
45c8e40d8a
GraphQL: Implement schema ( #2316 )
2017-06-27 20:15:55 -07:00
Christopher Chedeau
019beb54e5
GraphQL: Fix directives separator ( #2315 )
...
I couldn't figure out what the separator was, I tried `,`, `on` but none of them worked. Turns out it is `|`!
2017-06-27 19:58:38 -07:00
Christopher Chedeau
14caabd635
GraphQL: Print arguments for FieldDefinition ( #2314 )
2017-06-27 19:49:59 -07:00
Christopher Chedeau
bbf8f76823
GraphQL: Implement scalar ( #2313 )
2017-06-27 19:34:25 -07:00
Christopher Chedeau
0a2a099efe
GraphQL: Implement interface ( #2312 )
2017-06-27 19:30:58 -07:00
Christopher Chedeau
8e31088761
GraphQL: Implement input ( #2311 )
2017-06-27 19:27:02 -07:00
Christopher Chedeau
b63e1c2dd7
GraphQL: Implement Enum ( #2310 )
2017-06-27 19:20:53 -07:00
Christopher Chedeau
51c7503dae
GraphQL: Implement DirectiveDefinition ( #2309 )
2017-06-27 19:10:07 -07:00
Christopher Chedeau
fbf4c3a952
GraphQL: Support object definition implements ( #2307 )
2017-06-27 18:51:56 -07:00
Christopher Chedeau
af309e3acd
Add support for GraphQL TypeExtensionDefinition ( #2306 )
2017-06-27 18:26:43 -07:00
Christopher Chedeau
f96fe1ea5e
Initial support for GraphQL ObjectTypeDefinition ( #2305 )
...
It appears in some files inside of fb codebase
2017-06-27 18:22:04 -07:00
Christopher Chedeau
189027c7d3
GraphQL: Use spaces instead of commas ( #2303 )
...
"Daniel Schafer: Yeah, that's definitely what I'd describe as the canonical style; anytime you have two "things" on a line, use commas, but if you have a newline it's not needed."
2017-06-27 18:13:07 -07:00
Christopher Chedeau
4d46a3975b
GraphQL: Remove circular dependency in ast ( #2304 )
...
The tokens are attached to the location via the prototype (so they are not visible when you JSON.stringify) but the various places where we traverse the ast see them. It causes stack overflows and comments that are not printed because they are attached to tokens instead of real nodes.
Fixes #2302
2017-06-27 18:12:30 -07:00
Christopher Chedeau
6f4eade422
Go back to babylon beta 13 ( #2289 )
...
Fixes #2286
2017-06-27 11:51:23 -07:00
Christopher Chedeau
073a2071a8
Inline import('x') to avoid having trailing , ( #2288 )
...
Fixes #2287
2017-06-27 11:40:20 -07:00
Christopher Chedeau
803b7ff6b9
Add \n at the end of .graphql files ( #2285 )
...
We need to use the same hack as CSS unfortunately.
Fixes #2275
2017-06-27 09:49:15 -07:00
Christopher Chedeau
1e48f34ac8
Copy README.md to the dist/ folder ( #2284 )
...
Fixes #2275
2017-06-27 09:48:06 -07:00
Christopher Chedeau
e707bdd52f
Print comments attached to {' '} ( #2283 )
...
We had two occurrences on fb codebase where people attached comments on `{' '}` which would be swallowed. Instead of dropping the comments, let's make the algorithm a bit less naive.
2017-06-27 09:35:03 -07:00
Christopher Chedeau
6017ac13c7
Create CNAME
2017-06-27 07:43:54 -07:00
Christopher Chedeau
9a55f5b2d6
Fix unstable arrow comments ( #2262 )
...
It outputted which is completely wrong
```js
<FlatList
renderItem={info => <span>{info.item.widget.missingProp // $FlowExpectedError - bad widgetCount type 6, should be Object
}</span>}
/>;
```
2017-06-25 12:30:09 +10:00
Christopher Chedeau
f71fcd0b65
Fix variance location ( #2261 )
...
Turns out when we refactored for TS, we moved it before "static" and it no longer parses. Oops.
2017-06-25 11:46:29 +10:00
Christopher Chedeau
38d4661ba9
Forward originalText in multiparser ( #2260 )
...
If we don't, all the places where we read from the original text (mostly comments) are reading into random places.
Fixes #2258
2017-06-24 17:54:09 -07:00
Christopher Chedeau
8def8e13b0
Add caching for printing ( #2259 )
...
* Add caching for printing
For printing the last argument expansion, we need to print the same node a bit differently with a flag. It's not easy to re-print just the node that is different so we end up printing all the sub-tree twice. Since it is often nested, it means that we run into an exponential complexity.
I finally found a simple solution: we can use a Map to store the nodes and their printed values. It is really cheap to do so (I can't notice a time difference with or without on normal code) and allows us to stop going through the two sub-trees in the bad case.
Fixes #1250
* Update printer.js
2017-06-24 14:01:02 -07:00
Christopher Chedeau
6663bab8a3
Support trailing commas for function calls ( #2257 )
2017-06-24 12:23:34 -07:00
Christopher Chedeau
cc85769231
Add support for --trailing-comma for GraphQL ( #2254 )
...
Fixes #2251
2017-06-24 11:20:45 -07:00
Christopher Chedeau
b464189fb4
Add .graphql detection ( #2256 )
...
Test Plan:
create a `test.graphql` file that has some graphql content
```js
fragment Visit on HighlightedVisit
@argumentDefinitions(
count: {type: "Int", defaultValue: 20}
) {
name
}
```
```
./bin/prettier.js test.graphql
```
make sure it doesn't syntax error because it's parsing it as js.
2017-06-24 11:14:36 -07:00
Christopher Chedeau
59b3a9bc56
Add support for --no-bracket-spacing for GraphQL ( #2255 )
...
Fixes #2252
2017-06-24 11:06:56 -07:00
Christopher Chedeau
2f96357884
Attach comments in multiparser ( #2253 )
...
Otherwise it doesn't print comments :(
2017-06-24 11:06:50 -07:00
Christopher Chedeau
811885d635
Delete webpack.config.js
2017-06-24 08:32:54 -07:00
Christopher Chedeau
39954f7951
Handle conditions inside of a ternary ( #2228 )
...
Fixes #2122
2017-06-21 18:17:30 -07:00
Christopher Chedeau
ec1b672bbf
Don't indent + in object value ( #2227 )
...
This is a "regression" from when we started using the same heuristic for `=` and `:`
Fixes #2129
2017-06-21 15:58:12 -07:00
Christopher Chedeau
c36dd48339
First try scss when there's an @import with comma ( #2225 )
...
It's annoying that the less parser is so lenient that it drops things instead of throwing :(
Fixes #2125
2017-06-21 15:45:55 -07:00
Christopher Chedeau
aac0d1dda0
Support inline template for new calls ( #2222 )
...
I merged the implementation of new and call expressions in this PR.
Fixes #2215
2017-06-21 15:45:44 -07:00
Christopher Chedeau
08060e7c94
Use fill for CSS values ( #2224 )
...
This looks less weird to have them flow as they fit than breaking on every single line.
Fixes #2213
2017-06-21 15:13:51 -07:00
Christopher Chedeau
767138ce6c
Remove node 6 from the test matrix
...
It has never caught any issue in practice and is making the whole test suite consume 1/3 more cpu as a result.
2017-06-21 13:39:45 -07:00
Christopher Chedeau
313519d8ae
Allow long media rules to break ( #2219 )
...
Fixes #2198
2017-06-21 13:02:16 -07:00
Christopher Chedeau
810ed8857c
Update README.md
2017-06-21 10:44:53 -07:00
Christopher Chedeau
abfdbe1896
Upgrade typescript to 2.4 ( #2120 )
...
Fixes #2117
2017-06-13 09:47:40 -07:00
Christopher Chedeau
e69d0fe5fb
Create why-prettier.md
2017-06-12 21:00:04 -07:00
Christopher Chedeau
0877612e68
Create README.md
2017-06-12 20:00:42 -07:00
Christopher Chedeau
62b9e29af5
Fix comments in non strict mode ( #2114 )
...
It turns out that by returning there, we didn't go through the line `delete ast.tokens` and the comments attachment logic would attach it to a random token. It's great that this fail-safe caught this bug!
Fixes #2111
2017-06-12 09:50:51 -07:00
Christopher Chedeau
f399e90bc2
Preserve lines after directives ( #2070 )
...
Looks like we were only doing it at the top level, we should do it everywhere.
Fixes #2067
2017-06-08 17:10:01 -07:00
Christopher Chedeau
d062961ccf
Create README.md
2017-06-08 16:57:26 -07:00
Christopher Chedeau
939734b75e
Use ifBreak instead of shouldBreak ( #2063 )
...
shouldBreak is only a heuristic to enforce a break, if it breaks "naturally", then it won't be applied.
Fixes #2055
2017-06-08 11:47:49 -07:00
Christopher Chedeau
883e637fa9
Support the Keyword type ( #2056 )
...
This is an issue in https://github.com/eslint/typescript-eslint-parser/issues/315
Fixes #2049
2017-06-08 09:25:28 -07:00
Christopher Chedeau
924363193b
Check if the next group has comments ( #2040 )
...
Fixes #1958
Fixes #1959
2017-06-07 15:20:11 -07:00
Christopher Chedeau
1edb1f261b
Include typeAnnotation inside of node location ( #2039 )
...
We should remove this hack once https://github.com/eslint/typescript-eslint-parser/issues/314 lands
Fixes #1946
2017-06-07 15:05:46 -07:00
Christopher Chedeau
42b0368e3d
Fix decorator comments for export class ( #2038 )
...
We need to do the same location trick for export class unfortunately.
Fixes #1956
2017-06-07 14:55:55 -07:00
Christopher Chedeau
b730f4eccf
Add group around TSMethodSignature ( #2037 )
...
This ensures that the comment size is not taken into account during measurement
Fixes #1976
2017-06-07 14:20:55 -07:00
Christopher Chedeau
09f147decd
Do not throw for unprinted comments inside of JSX ( #2036 )
...
Fixes #1990
2017-06-07 12:57:03 -07:00
Christopher Chedeau
ccda4c7115
Break decorator before content ( #2032 )
...
Fixes #1996
2017-06-07 12:40:47 -07:00
Christopher Chedeau
e16478ef80
Fix less &:extends when parsed with scss ( #2034 )
...
This is the only breakage that people ever reported with CSS so I'm happy adding one edge case like this.
Fixes #1967
2017-06-07 12:40:36 -07:00
Christopher Chedeau
cabae6d877
Fix parenthesis for call expression inside of member expression inside of new ( #2035 )
...
Fixes #2033
2017-06-07 12:40:27 -07:00
Christopher Chedeau
c7cacf0529
Break if string | null ( #2028 )
...
We were a bit too aggressive around the `| null` heuristic.
Fixes #2002
2017-06-07 11:51:32 -07:00
Christopher Chedeau
c9c8512170
Only prevent lone set if there's no type annotations ( #2026 )
...
If there are, it's not ambiguous.
Fixes #2023
2017-06-07 11:51:25 -07:00
Christopher Chedeau
5ba0b0ec87
Add semi for functions without body ( #2025 )
...
We don't need to be overly restrictive and should add the semi if there's no body
Fixes #2003
2017-06-07 11:51:17 -07:00
Christopher Chedeau
57b3fe8a50
Update commands.md
2017-06-07 11:43:06 -07:00
Christopher Chedeau
e1ebbff001
Update commands.md
2017-06-07 11:42:31 -07:00
Christopher Chedeau
9d4fabd691
Pretty printer commands.js
2017-06-07 11:17:04 -07:00
Christopher Chedeau
3d175cc305
Remove eval for npm release ( #1925 )
...
Fixes #1895
2017-06-02 16:19:26 -07:00
Christopher Chedeau
2b6c1cd27e
Update typescript-eslint ( #1924 )
...
This applies https://github.com/eslint/typescript-eslint-parser/pull/308 and https://github.com/eslint/typescript-eslint-parser/pull/303 to fix issues on prettier.
Fixes #1870
2017-06-02 16:19:15 -07:00
Christopher Chedeau
dae7203be6
Fix As parenthesis for real ( #1923 )
...
Instead of doing it inside of object, we need to have them use the existing mechanism that checks if the left-most character is a paren.
2017-06-02 16:08:45 -07:00
Christopher Chedeau
3264da9cab
Fix leading comment ( #1920 )
...
It turns out that leading comment is attached to the CallExpression which is the last one and not the first one if they fit in a single line, so we want to not check that one.
Fixes #1892
2017-06-02 15:50:43 -07:00
Christopher Chedeau
323d64fb84
Port intersection inlining logic to TypeScript ( #1919 )
...
Fixes #1880
2017-06-02 15:40:33 -07:00
Christopher Chedeau
0d239477cb
Use semi-colon for object separator ( #1918 )
...
Looks like the convention for typescript separator is `;` whereas for flow it's `,`. Let's migrate to that.
Fixes #1896
Fixes #1879
Fixes #1874
2017-06-02 15:32:51 -07:00
Christopher Chedeau
620119d9d4
Fix --debug-check ( #1916 )
...
This got broken with the cursor commit.
cc @josephfrazier, would be nice to add some end to end test here :)
2017-06-02 15:10:08 -07:00
Christopher Chedeau
74f0d3979b
Add parenthesis for yield and await inside of as ( #1915 )
...
Fixes #1913
2017-06-02 15:10:02 -07:00
Christopher Chedeau
2f9ea794db
Always expand enums ( #1914 )
...
We do the same for classes, and it's usually written that way even if it fits in one line, even in the TS docs: https://www.typescriptlang.org/docs/handbook/enums.html
Fixes #1873
2017-06-02 15:09:55 -07:00
Christopher Chedeau
a255977009
Do not make variable multilines inside of for loop ( #1912 )
...
Fixes #1876
2017-06-02 15:00:16 -07:00
Christopher Chedeau
e58dd2bf0b
Add semi for ts function declarations without body ( #1911 )
...
Fixes #1891
2017-06-02 14:49:37 -07:00
Christopher Chedeau
6933d16125
Inline decorators with no arguments ( #1910 )
...
Fixes #1898
2017-06-02 14:40:39 -07:00
Christopher Chedeau
0e35d3758a
Fix <this.x /> ( #1886 )
...
Would be nice to get it properly handled in https://github.com/eslint/typescript-eslint-parser/issues/307
Fixes #1877
2017-06-02 14:27:27 -07:00
Christopher Chedeau
74f7f96fe4
Move accessibility before static ( #1908 )
...
I looked through all the places where we display accessibility and all of them now have a consistent way of printing all those modifiers.
Fixes #1877
2017-06-02 14:27:19 -07:00
Christopher Chedeau
02c48d284e
Fix strictEqual throwing ( #1909 )
...
I looked at what is being called with assert and couldn't find anything but `ok` and `strictEqual`.
Fixes #1903
2017-06-02 14:27:03 -07:00
Christopher Chedeau
faf2ac5f9e
Hack to get export default work ( #1866 )
...
Fixes #1854
2017-06-02 08:12:03 -07:00
Christopher Chedeau
bc4075ac65
Add parenthesis around object inside of as ( #1852 )
...
Fixes #1851
2017-06-01 21:10:05 -07:00
Christopher Chedeau
fdce975e5d
Move all the dependencies to dev dependencies and --exact ( #1850 )
...
Since we are now bundling all the dependencies, we can have prettier be dependency-free on npm <3
2017-06-01 20:38:25 -07:00
Christopher Chedeau
3f8c4d6974
Fix yet another form of class with the same ast ( #1849 )
...
Fixes #1847
2017-06-01 19:02:15 -07:00
Christopher Chedeau
d55640087e
Fix building docs ( #1838 )
...
The hackiness continues! I'm now bundling an existing bundle again in order for it to get exported as a global variable :p There's likely a better solution, but it kind of works.
Because I have to regenerate the docs, I just tagged it as 1.4.0-beta and added typescript and postcss in there.
2017-05-31 13:37:35 -07:00
Christopher Chedeau
f4296550db
Introduce Webpack 2 to fix postcss bundling ( #1836 )
...
It turns out rollup doesn't use the same algorithm for bundling commonjs files when there are cycles as node, which breaks postcss: https://twitter.com/Rich_Harris/status/869021144191561729 . Webpack works just fine with it.
This sucks to have this rollup/webpack frankenstein but I really want to be able to release and don't really want to spend yet another day or two trying to make it work well.
2017-05-31 11:59:33 -07:00
Christopher Chedeau
fa708d102a
Remove trailing commas for generics in TypeScript ( #1832 )
...
Fixes #1820
2017-05-31 09:22:00 -07:00
Christopher Chedeau
3097f9b2fe
Do not indent nested ternaries ( #1822 )
...
This avoids making it seems like it is indented by 4 characters instead of two. The downside is that if the condition is multi-line it's not going to be properly aligned, but I feel it's a better trade-offs. If you are doing nested ternaries, you usually have small conditions.
2017-05-30 10:08:06 -07:00
Christopher Chedeau
73ff0ef9ea
Add group around implements ( #1821 )
...
This shouldn't break if it fits in one line.
Fixes #1818
2017-05-30 09:45:07 -07:00
Christopher Chedeau
eeb8616e3c
Add parenthesis for single arg types with generics ( #1814 )
...
Fixes #1813
2017-05-29 16:59:45 -07:00
Christopher Chedeau
2ab3d6d6ac
Workaround bug with comment ending in */ ( #1810 )
...
Reported in the original repo: https://github.com/postcss/postcss-scss/issues/64
2017-05-29 13:05:20 -07:00
Christopher Chedeau
59e4e83355
Break before combinators and indent ( #1809 )
2017-05-29 12:55:14 -07:00
Christopher Chedeau
f34492d7e5
Strip leading space for first combinators ( #1807 )
2017-05-29 12:49:25 -07:00
Christopher Chedeau
27df0f81f5
Preserve space before parens ( #1806 )
2017-05-29 12:41:04 -07:00
Christopher Chedeau
dc287d32a5
Remove extra newline from empty @media ( #1802 )
2017-05-29 08:52:24 -07:00
Christopher Chedeau
c4e32f4c78
Remove double spaces in @font-face ( #1801 )
2017-05-29 08:49:51 -07:00
Christopher Chedeau
873123223f
Fix empty urls ( #1800 )
2017-05-29 08:43:19 -07:00
Christopher Chedeau
6a9e053221
Workaround a bug where the comment location is off for scss ( #1799 )
...
Workarounds https://github.com/postcss/postcss-scss/issues/63
2017-05-29 08:39:41 -07:00
Christopher Chedeau
bf5f9cc05d
Add support for media-url ( #1797 )
2017-05-29 08:20:03 -07:00
Christopher Chedeau
05b921efdd
Build the dist/ with rollup ( #1794 )
2017-05-28 21:49:41 -07:00