Commit Graph

80 Commits (3666411bd5ebb0feb257d23f484721719881e4e6)

Author SHA1 Message Date
Lucas Duailibe d013983d8a
Always expand first argument if the second argument is also a call expression (#4657) 2018-06-08 15:16:12 -03:00
Lucas Duailibe cb1c52ad08
Break JSX in arrow functions in JSX expressions (#4601) 2018-06-08 15:15:50 -03:00
Lucas Duailibe a4da6e6c8e
Inline _ or $ in the root of a method chain (#4621) 2018-06-01 12:51:06 -03:00
Ika 8abbc5d4b0
fix(javascript): regression for `hasOwnProperty` (#4603) 2018-05-31 00:39:39 +08:00
Lucas Duailibe a6db391556
Short rule should only apply to the first identifier (#4575) 2018-05-27 21:52:42 -03:00
Kevin Donnelly 16a84e88d6 Improve format when passing ts arrow function with return type as an argument (#4228)
* Add various tests for ts type annotated function properties.

* Improve format when passing ts arrow function with return type

* Add test for case from #2581.
2018-05-27 20:39:08 -03:00
Lucas Azzola b0cb63a7bb
Use destructuring for imports (#4554)
* Use destructuring for imports

* Clean up integration tests

* Use moduleNameMapper for require_prettier
2018-05-27 21:36:12 +10:00
Brian Ng fda7bf59f4
Add support for Flow's proto modifier syntax (#4551)
Flow commit: eb815be907

Babel PR: https://github.com/babel/babel/pull/7978
2018-05-25 17:23:17 -05:00
Brian Ng d20d9c160e
Switch to @babel/parser (#4544)
We landed a change that added a new `InterpreterDirective` AST node type for hashbangs, and no longer add it as a comment/leadingComment.

Ref: https://github.com/babel/babel/pull/7928

I mimicked what we do in `@babel/generator` here, since I found it better than trying to add comments to the ast in `parser-include-shebang.js`). Definitely open to a better/cleaner option though!

Note: I'll follow this up with enabling tests for https://github.com/prettier/prettier/pull/4543 and https://github.com/prettier/prettier/pull/4540 once they land too.
2018-05-25 11:27:41 -05:00
Brian Ng e42db35427
Add support for flow inline interfaces (#4543)
Flow commit: 4f93f3adb7

Babel commit: https://github.com/babel/babel/pull/7973

Will follow up w/ flow team on making `InterfaceType` -> `InterfaceTypeAnnotation`, since it seems a bit inconsistent.
2018-05-25 09:17:43 -05:00
Brian Ng 61b39749a1
Add support for flow explicit type arguments (#4540)
Fixes #4489.

Babylon support landed in `beta.48` just now but requires a few other fixture changes, so I'm going to follow this up with another PR.
2018-05-25 08:55:39 -05:00
Lucas Duailibe c2202efd54
Do not remove parens for ?. operator (#4542) 2018-05-24 23:27:49 -03:00
Christopher Chedeau 8f141bfafe
Update babylon & flow (#4536)
* Support new node types for optionals

* Update babylon

* Fix decorator tests

* fix manual errors

* Update flow

* pretty print

* enable option for flow to support ??

* fix AST_COMPARE=1

* fix lint and explicitly test 1_2_3 syntax for flow
2018-05-24 13:06:33 -07:00
Ika 553e9bb1ac
fix(typescript): preserve quoted class property (#4517) 2018-05-21 18:57:30 +08:00
Lucas Duailibe ea01781d8c
Only break chains with short names if inside ExpressionStatement (#4505) 2018-05-18 21:44:15 -03:00
Georgii Dolzhykov c6e8177282 Inline AngularJS tests that use `inject` (#4495)
* Inline AngularJS tests that use `inject`

See https://docs.angularjs.org/guide/unit-testing#using-beforeall- for a code example.

* More meaningful function name, minor refactoring

* Linting

* Minor regexp improvement

* address review comments
2018-05-17 12:09:20 -03:00
Brian Ng 857c55bd61
Keep parens around do-expressions inside ExpressionStatement (#4479) 2018-05-15 11:41:17 -05:00
Soo Jae Hwang ee96e97c77 Fix: Group long name method in bind expressions (#4447)
* Fix: Group long name method in bind expressions

* Add test for short name method in bind expressions
2018-05-09 10:42:16 -06:00
Nicolò Ribaudo ab452ddc38 Fix: Correctly break class prperties initializer. (#4442) 2018-05-08 20:35:49 -04:00
Ika 3fe790d4b7
refactor: fix linting 2018-05-08 12:42:02 +08:00
Ika 76a5f3c7b6
fix(typescript): add missing `qualifier` and `typeof` in TSImportType (#4438) 2018-05-08 12:35:12 +08:00
Kevin Donnelly c6e7c1966e Improve formatting of TS casts with generics and unions (#4219)
* Add tests showing existing behavior of various TS casts.

* Improve formatting of TS casts with generics and unions.

By adding a soft break between the cast and the expression. Also
includes wrapping parentheses for clarity as suggested in #4171.

Avoids changing behavior at all though if casting an array or object
literal because those already have good behavior where the array or
object literal breaks before the cast does so including them would just
result in a pointless extra layer of parentheses that would add no
clarity.

* Update tests in prepation for updating long cast format.

* Update so nested breaks inside type cast are indented.

* Add tests where expression being cast is too long itself.

* Update cast formatting to only sometimes break after cast.

Specifically it will break after the cast if that makes the cast itself
fit on a single line. If the cast itself won't fit on a single line then
the expression being cast will be placed directly after the `>` at the
end of the cast.
2018-05-07 22:26:01 -06:00
Suchipi ed18f9f7d7
Add heuristic to format functional composition more nicely (#4431)
* Add heuristic to format functional composition more nicely

* Regex -> array

* Use object instead of array for faster lookup

* Remove empty lines

* Add redux connect

Also add comments for libraries
2018-05-07 21:46:30 -06:00
Ika cc4392e5c0
feat(typescript): support TSImportType (#4429)
* feat(typescript): support TSImportType

* test: add singleQuote test
2018-05-07 07:57:57 +08:00
Ika 7e81a613b5
feat(javascript): support jest-each template string (#4423)
* feat(javascript): support jest-each

* test: add trailing newline

* fix: there can be no trailing newline

* refactor: simplify regex

* refactor: Array.from

* refactor

* fix: print quasis safely
2018-05-06 14:52:34 +08:00
Lucas Duailibe 5776c8405a
Fix TSMappedType comments (#4418) 2018-05-05 15:43:53 -03:00
Lucas Duailibe 8e1b60e943
Fix trailing JSDoc comments with trailing regular comments (#4414) 2018-05-04 10:15:30 -03:00
Lucas Duailibe 32900842e3
Apply destructuring rules in functions to catch param (#4385) 2018-05-01 10:24:46 -03:00
Ika 289b98c125
feat(json): enforce StringLiteral-style property key (#4371)
* test: add tests

* feat(json): enforce StringLiteral-style property key
2018-04-26 00:00:07 +08:00
Ika 6a17474e37 feat(typescript): support generic JSX element (#4268)
* feat(typescript): support generic JSX element

* fix(playground): `buffer is not defined` in `--parser typescript`

* chore(deps): update typescript-eslint-parser
2018-04-24 08:45:31 -05:00
Ika 643e2a83d6 feat(typescript): support TaggedTemplateExpression typeParameters (#4353)
* test: add tests

* feat(typescript): support TaggedTemplateExpression typeParameters

* fix(playground): `buffer is not defined` in `--parser typescript`

* chore(deps): update typescript-eslint-parser
2018-04-24 08:45:06 -05:00
Adam Pearce 09ac476a32 Nicer line wrapping for d3 (#4285)
* d3 counts as a constructor

* adds test

* Tweak wording

* docs: fix linting

* updates test

* no $ special case

* renames function

* shorter function name

* removes trailing white space
2018-04-24 06:54:45 -04:00
Mike Grip 4c464133ac feat: adding plugin ability for isBlockComment (#4347)
* adding plugin ability for isBlockComment

* refactor to remove private util def

* remove old fn def
2018-04-19 13:31:08 -07:00
Brian Ng 7cb6790ce0
Merge pull request #4326 from existentialism/flow70
Bump flow to 0.70
2018-04-18 17:04:14 -05:00
Brian Ng 7ab3e94fbb
Ensure mixins before implements 2018-04-16 21:28:56 -05:00
Christopher Chedeau 02a1db8c9f
[flow] Fix union indent inside of function param with a name (#4325)
Fixes #4323

See #4323 for all the context
2018-04-16 18:47:05 -07:00
Ika 8e8a8d50cf
refactor(doc-utils): move `rawText` to printer-estree (#4309) 2018-04-14 00:05:00 +08:00
Suchipi Izumi bdc5e0073d Bump own prettier dependency to 1.12.0 2018-04-11 22:39:13 -06:00
Jed Fox 63a2ded4c9
Never print a semicolon after `export default interface Foo {}` (#4128)
* Never print a semicolon after `export default interface Foo {}`

* Add test
2018-04-11 06:38:02 -04:00
Lucas Duailibe 57bc700602
Stop marking all comments in named exports as leading comments (#4292) 2018-04-10 17:05:49 -03:00
Aakansha Doshi 6794a14554 Inline Angular async tests and beforeEach, etc. (#4241)
* fix #3791 and refactor isTestCall

* typo

* remove default value

* add safe check if parent exists

* add spec

* better comment
2018-04-11 00:06:42 +08:00
Lucas Duailibe 18aaee594f
Break object destructuring with nested destructuring (#4267) 2018-04-06 11:57:37 -03:00
Lucas Duailibe fa089f5bb6 If consequent is a block statement, treat as trailing comment 2018-04-05 17:22:10 -03:00
Lucas Duailibe 88489a9afe Handle comments before `else` 2018-04-05 16:06:18 -03:00
Lucas Duailibe e17bb5e947 Break nested ternaries (#4120) 2018-04-04 18:50:15 -06:00
Lucas Azzola e03e4d6d40
Move needsParens to a language-specific file (#4201) 2018-03-25 18:35:32 +11:00
Christopher Chedeau adf6d1849d
Remove outdated comment (#4190)
We now always return a conditional group.
2018-03-21 14:38:51 -07:00
Brian Ng 4553b88bd4
Merge pull request #4156 from Cryrivers/master
feat(typescript): support TSMinusToken and TSPlusToken
2018-03-21 09:06:06 -05:00
Mike Grip d9ee183f5b feat: enable plugin-specific comment functionality (#4182)
* feat: enable plugin-specific comment functionality

This change enables language plugins to provide their own "handleComment" function. To do so, we're exposing the addLeadingComment, addTrailingComment, and addDangling comment functions which attach comment nodes correctly in the ast which will get handled by prettier core when printing.

* moving js comment functionality to plugin
2018-03-20 18:39:28 -07:00
Evilebot Tnawi 31530259a1 feat: indent in discriminant switch (#4165) 2018-03-19 23:50:24 +11:00