Commit Graph

3127 Commits (2e2368f5d7db2d74c4c4b0242055a8dbb2a55398)

Author SHA1 Message Date
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
James Long 7f80d8dbff Add note about Sublime Test github issue in readme 2017-01-14 23:21:58 -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
James Long 60c0b52fed Update live editor to 0.0.7 2017-01-13 23:33:38 -05:00
James Long e447971612 v0.0.7 2017-01-13 23:27:49 -05:00
Christopher Chedeau 6f5df0e2b6 Change test to workaround babylon bug (#184)
Babylon has a bug where it doesn't escape DirectiveLiteral properly. Except for `'use strict';`, this never happens in real world code, so let's put strings in a array in order to workaround this bug and have the same output on both parsers.

https://github.com/babel/babylon/issues/289
2017-01-13 23:17:02 -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
Kent C. Dodds f49111c87c add license to package.json (#178)
Because right now it doesn't show any license on
[the npm page](https://www.npmjs.com/package/prettier).

Also, it's causing my [DependencyCI](https://dependencyci.com/github/kentcdodds/prettier-eslint/builds/5)
build to fail 😅
2017-01-13 23:11:03 -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
Mikael Brevik cbabefdb0f Adds various prettier-browser changes (#175)
* Adds link to GH repo in title

* Adds popular keybindings (subl) to editor

* Changes theme to base16-dark to fit better with body bg
2017-01-13 17:14:48 -05:00
James Long 3713408871 Update live editor to 0.0.6 2017-01-13 15:40:22 -05:00
James Long 4ffdb0c43f Improve CHANGELOG format again 2017-01-13 15:13:30 -05:00
James Long 2ab030b1d2 Fix CHANGELOG format 2017-01-13 15:10:21 -05:00
James Long 7e3161096b v0.0.6 2017-01-13 15:09:37 -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
Vu Tran b429b2443c include index.js in format:all script (#132) 2017-01-13 14:23:07 -05:00
Alex Rattray 47102bc3ef Add regression tests for long JSX Expression contents 2017-01-13 14:22:49 -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 df99ae56b0 Add test for shebang and move to index.js (#170)
When looking into adding a test, I realized that the logic was inside of bin/prettier.js and therefore only applying to the cli. Moving it to index.js and adding a test so that it's more robust :)
2017-01-13 13:39:07 -05:00
Rogelio Guzman ec5b0f7c76 Fix for Node 4 2017-01-13 13:25:13 -05:00
Rogelio Guzman 4ebccef79d Add tests for trailingComma option 2017-01-13 13:25:13 -05:00
Rogelio Guzman 63c87b6cd0 Add tests for tabWiths option 2017-01-13 13:25:13 -05:00
Rogelio Guzman 7f9655e186 Add tests for quotes option 2017-01-13 13:25:13 -05:00
Rogelio Guzman e54b9806a3 Add tests for bracketSpacing option 2017-01-13 13:25:13 -05:00
Rogelio Guzman 3e0ac6c18e Update run_spec to support options 2017-01-13 13:25:13 -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
Jamie Webb ecb26b3432 treat shebang outside of parsing (#137)
* treat shebang outside of parsing

* use less costly indexOf and reuse format function

* avoid reprinting new line and potential double space at start

* move options back to format function
2017-01-13 12:57:27 -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 ab37f7fd02 Merge pull request #156 from jlongster/break-imports-exports
Break long `exports` into multiple lines.
2017-01-12 15:00:00 -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
James Long a1d9d2a02f Merge pull request #142 from vjeux/minimize_quotes
Minimize string escapes
2017-01-12 13:39:17 -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