Commit Graph

1003 Commits (2c62b5bebef3995737e26c32cc8d9fc7eeeb4116)

Author SHA1 Message Date
Lucas Azzola 2c62b5bebe feat(number): trim extra trailing zeroes (#1768) 2017-05-27 10:46:45 -07:00
Lucas Azzola 91bcde9859 fix(typescript): fix unstable optional method (#1770) 2017-05-27 07:24:54 -07:00
Lucas Azzola 59a760c5d8 TypeScript: fix namespace comment printing (#1765)
* fix(typescript): fix namespace comment printing

* fix(typescript): remove extra newline after comment

* chore(lint): lint changes
2017-05-26 21:30:42 -07:00
Lucas Azzola 934216d852 fix(typescript): allow parens with TSFunctionType and ignore empty specifiers (#1764) 2017-05-26 20:47:48 -07:00
Lucas Azzola b265713763 fix(typescript): handle ExperimentalSpreadOperator, optional method, and abstract interface (#1763) 2017-05-26 20:19:17 -07:00
Christopher Chedeau f66d1b05d6 Add support for insensitive attribute match (#1760)
I had no idea this existed!
2017-05-26 19:30:29 -07:00
Christopher Chedeau 1255c5c51b Ignore trailing comma from the ast (#1761)
This doesn't change the semantics
2017-05-26 19:30:21 -07:00
Christopher Chedeau 044a58bb6f Add support for value-colon (#1753) 2017-05-26 15:58:09 -07:00
Christopher Chedeau 7ad38c525e Skip params in --debug-check (#1754) 2017-05-26 15:58:00 -07:00
Christopher Chedeau 2a33309e3d Print selector-string (#1759) 2017-05-26 15:54:39 -07:00
Christopher Chedeau 4b727daa54 prettify... 2017-05-26 15:40:28 -07:00
Christopher Chedeau d71e95af6d Merge conflict :( 2017-05-26 15:30:59 -07:00
Christopher Chedeau 2007961581 Preserve stack 2017-05-26 15:29:59 -07:00
Christopher Chedeau 060ea6c0da Also add the stack for postcss errors (#1758) 2017-05-26 15:17:46 -07:00
Christopher Chedeau 4d9c67af15 Better error message for selector parsing error (#1756) 2017-05-26 14:59:46 -07:00
Christopher Chedeau 855a701309 Preserve comments for selectors (#1755) 2017-05-26 14:55:41 -07:00
Christopher Chedeau b27849def4 fix format 2017-05-26 13:54:20 -07:00
Christopher Chedeau b11b89d2af Inline url() even if unquoted (#1752) 2017-05-26 13:45:15 -07:00
Christopher Chedeau 2f6d12aaa8 Inline url('string') (#1751)
We don't want them to break even if they go beyond 80 columns
2017-05-26 13:42:32 -07:00
Simon Lydell 48d9267dd5 Fix lint error 2017-05-26 22:13:29 +02:00
Simon Lydell fe48638376 Don't pass too many arguments to functions (#1750)
Found using Flow.
2017-05-26 13:01:03 -07:00
Christopher Chedeau f9e324c4d0 Add the ability for SequenceExpression to break (#1749)
Fixes #1742
2017-05-26 12:29:00 -07:00
Christopher Chedeau 5f73ba29ed Add parens for expressions inside TSNonNullExpression (#1748)
Fixes #1695
2017-05-26 12:03:27 -07:00
Christopher Chedeau 7486756dd6 Fix master 2017-05-26 12:02:59 -07:00
Christopher Chedeau 5c462cc8e1 Remove ast-types (#1747)
Yay!
2017-05-26 11:54:43 -07:00
Christopher Chedeau 30857cd5fc Remove last call site of ast-types (#1746)
I console.log'd when it passed and ran the test suite, then uniqui-fied the results :)
2017-05-26 11:52:19 -07:00
Christopher Chedeau 27e9aed091 Remove ast-types from printer.js (#1745)
We're close to get rid of ast-types completely :)
2017-05-26 11:45:24 -07:00
Christopher Chedeau ba69e9fe22 Remove ast-types from comments traversal (#1744)
It's very annoying to have to have a static definition of the ast, we should instead just traverse the objects to discover it. We just need to make sure not to have any cycles, but it's also good for debugging anyway.

This fixed a few comments already :)
2017-05-26 11:44:32 -07:00
Christopher Chedeau 7bd951652c Cleanup fast-path (#1743)
- I want to get to a place where we don't use ast-types in order to do the traversal. This almost removes it from fast-path.
- Remove FastPath.from and copy
- Use .prototype instead of the weird Fpp
- Remove unused TODO
- Remove unused needsParen condition with a bunch of associated code
2017-05-26 10:59:12 -07:00
Simen Bekkhus 06806068f6 Dedupe typescript-eslint-parser in yarn.lock (#1739) 2017-05-26 07:47:45 -07:00
Christopher Chedeau 5e0fa00725 Upgrade typescript-eslint to 31ad3c (#1738)
Fixes #1737
2017-05-25 19:04:15 -07:00
Christopher Chedeau 2e92e4e17d Update to flow 0.47 (#1736)
Fixes #1469
Fixes #1457
Fixes #425
2017-05-25 17:00:36 -07:00
Christopher Chedeau c8f255d6d5 Port a handful of heuristics we had to work on typescript nodes as well (#1735) 2017-05-25 16:49:25 -07:00
Christopher Chedeau 267c6edaf5 Inline import type (#1729)
A long time ago I introduced the ability to break for import statements. Then, later on, we removed the ability for require to break and go over the 80 column mark. In order to be consistent, we should do the same for import statements as well.
2017-05-25 16:27:04 -07:00
Christopher Chedeau d06c46d045 Break on implements instead of extends (#1730)
There can often be something that breaks inside of `extends` so it's looking weird to break twice. It now only breaks on `implements` and make sure to put each element on its own line.

Fixes #1520
2017-05-25 16:26:56 -07:00
Christopher Chedeau ffc1b3702e Remove parenthesis for JSX inside of arrow functions (#1733)
I didn't intend for putting parenthesis there in the first place but it slept through. Since it was going to trigger a ton of changes I held up changing it, but I feel like we need to do it sooner than later otherwise we're not going to be able to do it. A lot of people writing functional components are going to be very happy about this change :)
2017-05-25 16:26:49 -07:00
Christopher Chedeau fe49650700 Inline | null and | void (#1734)
TypeScript doesn't have the concept of `?` for nullable options and instead you have to write `| null` and `| void`. This is annoying to have it use the long form, so we're now inlining them.

While working on this, I found out a few issues with the way we deal with those:
- We only align objects if the parent is a union. This means that if you have `Array<{ object }>`, the object is not aligned properly. The fix is to move the alignment logic to the union, and not the child.
- When doing so, it messes up with the comment alignment, so we have to manually handle children comment printing in the union code.

It doesn't yet fix #1727 because the hardcoded type names are different, i'll follow up in a PR.
2017-05-25 16:26:40 -07:00
Christopher Chedeau 62679f20f0 Indent conditions inside of !() (#1731)
This has been a longstanding issue and I thought it would be hard to do, but turns out it is pretty easy!

Fixes #774
2017-05-25 16:26:34 -07:00
Christopher Chedeau 198ba3c065 Force \n for multiple variable declarations (#1723)
This keeps being requested and we're not using it at Facebook, so I don't particularly care which way it should be printed. We now force multiline if there's at least one declaration with a value. We don't want to break all the variables that are just declared.

Fixes #1607
2017-05-25 16:26:26 -07:00
Christopher Chedeau 9a93822bbc Use the same breaking rules for assignment and object values (#1721)
Fixes #1417
Fixes #1604
2017-05-24 18:19:15 -07:00
Christopher Chedeau 449bc41316 Use expandLast for nested arrow functions (#1720)
We don't always want to automatically forward this option but we can always forward it to `n.body`. If it's an arrow function, it's doing the intended behavior, otherwise, it's not going to ignore it and not forward it. What we don't want is for arrow -> blockStatement -> arrow to get it, but we're good.

Fixes #1652
2017-05-24 18:19:07 -07:00
Joseph Frazier 9d7515907e Pass entire text through formatWithShebang() to format() (#1718)
* Verify shebang tests against Babylon as well as Flow/Typescript

* Pass entire text through formatWithShebang() to format()

That way, we won't have to do any arithmetic on range and cursor
locations when there is a shebang. See here for details:

https://github.com/prettier/prettier/pull/1637#issuecomment-303846507

This required changing comment printing such that comments that are
actually shebangs are just ignored.

* Add curly brace after `if`

See https://github.com/prettier/prettier/pull/1718#discussion_r118382574
2017-05-24 18:59:25 -04:00
Joseph Frazier 7344a37b5c Enforce braces after `if`/etc (#1719)
See https://github.com/prettier/prettier/pull/1718#discussion_r118382742
2017-05-24 15:57:05 -07:00
Christopher Chedeau a6068c0532 Temporary fix comments inside of flow type spread (#1716)
This is breaking on fb code. While benjamn/ast-types#221 is getting merged in ast-type, we can add it in prettier so it fixes the issue.

Fixes #1632
2017-05-24 15:21:30 -07:00
Joseph Frazier 71a39d2512 Ignore docs/prettier.min.js when searching with ag/ripgrep/sift (#1717)
This makes it easier to search through the code without getting
irrelevant results. It uses a .ignore file in order to cover at least
the three tools mentioned in the title. See the discussion here:

https://news.ycombinator.com/item?id=12568822
2017-05-24 15:21:21 -07:00
Simon Lydell 01b953c580 Saying "Coming soon" doesn't really help anyway 2017-05-24 23:06:04 +02:00
Simon Lydell 4babc032cb Make it easier to find the WebStorm guide 2017-05-24 22:59:55 +02:00
Dara Hak 1f378b9755 Replace JetBrains with WebStorm in README.md (#1715)
The links are clearly about the WebStorm IDE and JetBrains is just the company's name.
This can be confusing for users.
2017-05-24 13:33:32 -07:00
Christopher Chedeau a53c609f8f Add .flowconfig (#1711)
I have no intention of using flow to type prettier but adding this file makes Nuclide run flow and get jump to definition and some datatips for what it can infer.
2017-05-24 13:20:25 -07:00
Christopher Chedeau 58194e5375 Fix empty lines with comments between switch cases (#1709)
The function isPreviousLineEmpty comment doesn't skip comments (on purpose, see comment above that method :P) so the detection is messed up. Turns out, it's easier to just use isNextLineEmpty like everywhere else.

Fixes #1708
2017-05-24 13:20:05 -07:00