Lucas Azzola
02639da9a9
Improve coverage and remove some dead code ( #2504 )
...
* Improve test coverage
* Clean up some un-used code
* Lower patch requirements on codecov
2017-07-17 23:31:42 +10:00
Lucas Azzola
d62d1c5c56
Preserve parens with keyof, enforce parens with arrows with type params ( #2503 )
...
* Force parens around argument of simple arrow function if type annotation is present
* Preserve parens inside keyof operator
2017-07-17 13:32:33 +02:00
Lucas Azzola
71b2004391
Cleanup unused nodes, and turn on importMeta babylon plugin ( #2498 )
...
* Cleanup unused AST nodes
* Add tests for JSXNamespacedName
* Turn on importMeta babylon plugin
* Add tests for DeclareTypeAlias
* Add back TS*Keyword nodes, fix TS optional destructuring
2017-07-16 23:59:49 +10:00
Lucas Azzola
188c466cd5
Don't call shouldHugType for function arguments, fixes #2458 ( #2496 )
2017-07-16 11:53:01 +02:00
Lucas Azzola
028d9e0ea7
Improve bind expression formatting ( #2493 )
...
* Improve bind expression formatting, fixes #1400
* Fix parenthesis with bind expressions, fixes #1446
2017-07-16 11:47:06 +02:00
Lucas Azzola
00d9aa208e
Trim trailing whitespace from comments, closes #2422 ( #2494 )
2017-07-16 17:45:27 +10:00
Lucas Azzola
bac9658687
Flatten x & y & z, and x ^ y ^ z, fixes #2445 ( #2490 )
2017-07-15 12:54:33 +02:00
Lucas Azzola
b9b3da6ee9
Implement prettier-ignore inside JSX ( #2487 )
...
* Implement prettier-ignore inside JSX, closes #2467
* Re-enable babylon and typescript verification
2017-07-15 20:21:43 +10:00
Stephen Scott
3ed2bae1b4
Improve JSX ternary formatting
...
* Now JSX-mode ternaries only break if they need to.
* Only the outermost ternary in a chain of JSX-mode ternaries will become a group.
* We don't wrap null in parens when breaking JSX-mode ternaries.
This commit also improves the test coverage and explanation in tests/jsx/conditional-expression.js.
2017-07-13 10:21:58 -06:00
Stephen Scott
757037948a
Improve JSX Formatting
...
* Arrow Function Expressions returning JSX will now add parens when the JSX breaks
* Conditional expressions within (or containing) JSX are formatted in a more natural way (for JSX), especiall when chained
* JSX in logical expressions (|| or &&) is always wrapped in parens
Fixes #2208
2017-07-13 10:20:42 -06:00
John Backus
1691b85322
Fix <this.Component /> ( #2472 )
...
This is a workaround while waiting on
https://github.com/eslint/typescript-eslint-parser/issues/337 .
Fixes #2471
2017-07-13 17:21:46 +10:00
Alex Rattray
ef91e28434
Merge pull request #2442 from karl/jsx-inline-single-expression
...
Allow single expressions in JSX to be inline
2017-07-12 21:32:48 -07:00
James Henry
ee822f99b9
Update tsep and add test for destructuring assignment ( #2443 )
...
Fixes #2229
2017-07-11 09:11:18 +10:00
Karl O'Keeffe
5e76ea7bdd
Allow single expressions in JSX to be inline
2017-07-10 20:02:30 +01:00
Lucas Azzola
b25935d7a3
TypeScript: allow type assertions to hug ( #2439 )
...
* TypeScript: allow type assertions to hug, fixes #2437
* Update snapshots
2017-07-10 22:37:43 +10:00
Lucas Azzola
4a320a9332
Add supervisory parens for bitwise operations ( #2429 )
...
* Add supervisory parens for bitwise operations, fixes #2424
* Flatten x | y | z
2017-07-08 17:31:28 +10:00
Lucas Azzola
7e96e01fba
Add more supervisory parens, closes #187 ( #2423 )
2017-07-07 15:57:17 +02:00
Lucas Azzola
8bbbc3a6f3
Remove parens for type assertions in binary expressions, fixes #2416 ( #2419 )
2017-07-07 13:02:43 +02:00
Lucas Azzola
82b80b3c79
Trim whitespace in descendant combinator, fixes #2410 ( #2411 )
...
* Trim whitespace in descendant combinator, fixes #2410
* Permit whitespace changes in clean-ast.js
2017-07-06 13:55:34 +02:00
Dan Wang
86c88ff278
Print TypeParameter even when unary function type ( #2406 )
2017-07-06 19:13:30 +10:00
Kevin Gibbons
28b3a4b925
Break sequence expressions ( #2388 )
...
* Add SequenceExpression tests
* Clean up printing of SequenceExpressions
* Remove test and lint
2017-07-04 22:50:57 +02:00
Karl O'Keeffe
06ae32ddce
Ensure there is a line break after leading JSX white space ( #2348 )
2017-07-03 12:43:10 +02:00
Lucas Azzola
6f9824778d
Strip BOM before parsing, fixes #2362 ( #2373 )
2017-07-01 18:11:13 +02:00
Jarda Snajdr
3f6a232cea
Fix indentation of a do-while condition ( #2359 )
...
Fixes #2353 . Use the same printing code for both `WhileStatement` and `DoWhileStatement`.
Fix calculation of `isInsideParenthesis` when printing a `LogicalExpression`. There is
no such thing as `DoStatement` -- it should be `DoWhileStatement`.
2017-06-29 15:46:25 -07:00
Simone Picciani
85e0bffa7d
Removed injectGlobal and keyframes ( #2342 )
2017-06-28 16:03:33 -07:00
Simone Picciani
067a0137bd
Add support for css, keyframes and injectGlobal keywords ( #2337 )
...
* styled components now support css keyword
* added support also for keyframes
* added comment to reflect the new keywords
* modified comment
* ignore css and keyframes when testing ast manipulations
* added also injectGlobal
2017-06-28 14:31:27 -07:00
Joseph Frazier
175cde1dc5
Force trailingComma option to "none" when parser is JSON ( #2335 )
...
* Run JSON tests with `trailingComma: "all"`
* Add test of `parser: 'json', trailingComma: 'all'` with non-.json extension
See https://github.com/prettier/prettier/issues/2308#issuecomment-311707801
* Force trailingComma option to "none" when parser is JSON
This fixes https://github.com/prettier/prettier/issues/2308
2017-06-28 09:29:47 -07:00
Joseph Frazier
8e37fd76e9
Add support for range-formatting GraphQL ( #2319 )
...
* Add test for range-formatting GraphQL
See https://github.com/prettier/prettier/issues/2296#issue-238985580
* Pass test for range-formatting GraphQL
See https://facebook.github.io/graphql/#sec-Appendix-Grammar-Summary.Query-Document
This fixes https://github.com/prettier/prettier/issues/2296
* Consider *Definition GraphQL nodes to be formattable
See https://github.com/prettier/prettier/pull/2319#discussion_r124569400
2017-06-28 09:21:11 -07:00
Lucas Azzola
678964b8de
fix(typescript): don't add namespace keyword to global declaration, fixes #2327 ( #2329 )
2017-06-28 07:53:10 -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
ee07ff5870
Fix master
2017-06-27 18:33:23 -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
850d51a033
Tweak name
2017-06-27 17:30:13 -07:00
Joseph Frazier
b47c0b4e04
Allow formatting ranges of JSON ( #2298 )
...
* Add test for https://github.com/prettier/prettier/issues/2297
* Add JSON types to isSourceElement()
See https://github.com/prettier/prettier/issues/2297
* Avoid expanding format range when possible
This fixes https://github.com/prettier/prettier/issues/2297
* Move JSON range test into tests/range_json
This is so that the AST_COMPARE=1 tests don't try to parse JSON with Flow.
* Check parser in isSourceElement()
Otherwise JSON formatting would format weird things inside of JS.
See https://github.com/prettier/prettier/pull/2298#discussion_r124407056
* Use arrow functions instead of .bind()
See https://github.com/prettier/prettier/pull/2298#discussion_r124409783
* Add test of range-formatting JSON identifier
See https://github.com/prettier/prettier/pull/2298/files#r124410750
* Allow range-formatting JSON identifier
See https://github.com/prettier/prettier/pull/2298/files#r124410750
* Fix lint
2017-06-27 16:04:42 -07:00
Joseph Frazier
5f063ab168
Fix locEnd() for postcss parser ( #2295 )
...
* Fix locEnd() for postcss parser
`node.source` doesn't have an `end`, but `node.nodes[-1].source` does.
Fixes https://github.com/prettier/prettier/issues/2267
* Add regression test for https://github.com/prettier/prettier/issues/2267
See https://github.com/prettier/prettier/pull/2295#issuecomment-311484343
* Make locEnd() postcss fix more focused
This passes the tests again.
* Use getLast() instead of .slice()
See https://github.com/prettier/prettier/pull/2295#discussion_r124398553
* Move CSS range test into tests/range_css
This is so that the AST_COMPARE=1 tests don't try to parse CSS with Flow.
2017-06-27 15:12:22 -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