Commit Graph

958 Commits (01b953c580408b360ea30191db48abec937b0d5b)

Author SHA1 Message Date
Joseph Frazier 2ce6632082 Fix variable name in getParsersToVerify() (#1554)
It previously referred to an undefined variable.
2017-05-08 17:27:39 -07:00
Lucas Azzola 44934da349 feat(typescript): add fallback for JSX detection (#1551) 2017-05-08 05:57:19 -07:00
Lucas Azzola eabff629dd chore(build): update snapshot test (#1549) 2017-05-07 20:04:32 -07:00
Lucas Azzola fa27e5838c feat(typescript): add TSTypeAssertionExpression and naive TSX detection (#1545) 2017-05-07 08:09:52 -07:00
Lucas Azzola 3471ce4584 feat(typescript): print semi instead of comma in TS interface (#1548) 2017-05-07 07:39:21 -07:00
Lucas Azzola f655233ba2 fix(typescript): handle declare global syntax (#1546) 2017-05-07 03:44:41 -07:00
Lucas Azzola 5cc7878902 fix(typescript): fix a handful of ast(prettier(input)) issues (#1544) 2017-05-06 22:34:47 -07:00
Lucas Azzola 92d5a57122 fix(typescript): add TSNamespaceFunctionDeclaration to ast-types (#1543) 2017-05-06 21:33:07 -07:00
Lucas Azzola 0fa38cce33 fix(typescript): remove extraneous newline with namespace exports (#1542) 2017-05-06 20:28:49 -07:00
Lucas Azzola e22bd00815 fix(typescript): ArrowFunctionExpression needs parens in TSAsExpression (#1541) 2017-05-06 20:03:17 -07:00
Lucas Azzola 5fd9cd01de test(typescript): do not fail debug check on Literal -> Identifier (#1540) 2017-05-06 19:39:19 -07:00
Christopher Chedeau 97ea416c69 Better syntax error message for typescript (#1536)
This makes uses the fancy babylon error printer instead of just printing the message and line/column.
2017-05-06 12:44:06 -07:00
Lucas Azzola 3d45278ea7 fix(typescript): print readonly and ? tokens in TSMappedType (#1535) 2017-05-06 10:30:59 -07:00
Lucas Azzola 4629db6b0d TypeScript: improve handling of computed properties (#1532)
* fix(typescript): improve handling of computed properties

* test(typescript): add Symbol computed property test

* fix(typescript): do not print brackets for literals
2017-05-06 08:00:26 -07:00
Prathik Shetty c2bdcbe996 Include pre-commit plugin (#1493)
* Update README.md

* Update README.md

* Update README.md

* Update README.md
2017-05-06 07:59:23 -07:00
Simen Bekkhus ed24bff251 Upgrade jest (#1534)
* Upgrade jest

* yarn upgrade
2017-05-06 07:40:40 -07:00
Lucas Azzola c337c83043 fix(typescript): workaround eslint/typescript-eslint-parser#257 (#1533) 2017-05-06 06:19:33 -07:00
Lucas Azzola 11e3d8241f TypeScript: print modifiers on TSIndexSignature and TSPropertySignature (#1531)
* fix(typescript): print modifiers on TSIndexSignature

* fix(typescript): print modifiers on TSPropertySignature and reformat TSMappedType
2017-05-06 06:18:23 -07:00
Lucas Azzola 8a8a67b9fe fix(typescript): print typeArguments in TSExpressionWithTypeArguments (#1530) 2017-05-06 06:17:48 -07:00
Igor Oleinikov f51822c16d fix(TypeScript): define TSFunctionType AST node (#1529)
- fixes printing of comments inside function type node
2017-05-05 22:14:12 -07:00
Christopher Chedeau bb232d48a3 Inline chained conditionals inside of jsx attribute (#1519)
Fixes #1515
2017-05-05 21:44:50 -07:00
Christopher Chedeau c63e21b52b Do not put parens for single argument with end of line comment (#1518)
Fixes #1517
2017-05-05 21:44:42 -07:00
Christopher Chedeau 3d964b18bb Add parens around `as` (#1528)
I put it at the same place where `a in b` is handled.

Fixes #1524
2017-05-05 21:39:20 -07:00
Christopher Chedeau c8984f392a Fix TypeScript regex (#1527)
Turns out n.value is NaN for regexes in typescript, go figure. Just moving the two if statements is working to fix the issue.

Fixes #1526
2017-05-05 21:39:11 -07:00
Lucas Azzola b9a7549e47 TypeScript: correctly print nested namespaces (#1522)
* fix(typescript): correctly print nested namespaces

* test(typescript): update snapshots
2017-05-05 21:14:07 -07:00
Lucas Azzola b23c16d05d fix(typescript): print typeParameters on TSMethodSignature (#1523) 2017-05-05 21:11:13 -07:00
Lucas Azzola c689f2a0e7 Fix module block, add enum initializers and fix type parameters (#1501)
* fix(typescript): fix module block, add enum initializers and fix type parameters

* fix(typescript): use printStatementSequence for TSModuleBlock

* fix(type-params): move typeParameters out of printFunctionParams

* refactor(type-params): move typeParameters out of printArgumentList
2017-05-05 19:44:26 -07:00
Dorian Karter d3d5d57984 Use setlocal in all vim examples (#1403) 2017-05-05 09:13:08 -07:00
Paul Carduner af754adb7b Make prettier into a global minor mode that can be toggled on and off (#1496) 2017-05-05 09:10:59 -07:00
Jake Trent 3cfc37d411 Options readme (#1406)
* add options table to readme

* remove options from api usage in favor of options table

and link a few paragraphs to the options section
2017-05-05 09:10:23 -07:00
Kevin Gibbons e290514a9e Parenthesize `new F(await a)` and `x[await a]` correctly (#1513) 2017-05-05 08:10:56 -07:00
Brian Ng ccf509abb6 Fix empty line with flow union (#1511) 2017-05-04 19:06:30 -07:00
Christopher Chedeau 1a1e6fc1dd Print empty member lookup (#1506)
I have no idea if it's even valid but it threw on 8 typescript tests, now it doesn't.

```js
TypeError: Cannot read property 'type' of null
at printMemberLookup (prettier/src/printer.js:3062:16)
```
2017-05-04 11:20:52 -07:00
Danny Arnold 1fca1eeddf add TSTypeParameter to typescript ast nodes (#1508) 2017-05-04 11:20:35 -07:00
Danny Arnold 14636947b6 add TSParameterProperty to typescript ast nodes (#1507) 2017-05-04 11:19:50 -07:00
Danny Arnold c1a8ee011d add TSAbstractKeyword (#1505) 2017-05-04 09:48:24 -07:00
Christopher Chedeau bdf6050434 Do not throw on an empty file with a ; (#1503)
Fixes "TypeError: Cannot read property 'replace' of undefined"

This was discovered by #1480 and also affects non-typescript
2017-05-04 09:40:11 -07:00
Danny Arnold e6eee0467d add TSConstKeyword (#1502) 2017-05-04 09:37:00 -07:00
CodinCat b354fbd6dc Update repo link in github page (#1500) 2017-05-04 07:46:42 -07:00
Kevin Gibbons 886f70fcdf Put loop bodies on the same line when possible (#1498) 2017-05-03 15:50:48 -07:00
Christopher Chedeau 515a565a66 1.3.1 (hotfix) 2017-05-03 14:44:08 -07:00
Christopher Chedeau 8613046fd2 Respect template inline-ness (#1497)
In 1.3.0, we shipped a change that makes template literal always inlined as single arguments of a function. The problem with template literals is that they whitespace is significant so we can't change it. There are two cases:

```js
call(`
  template
  template
`);
```

and

```js
call(
  `template
   template`
);
```

If you always make the same decision to inline, you're going to be wrong for the other use case. The solution that I found that works is to figure out if there's a `\n` before the backtick `` ` ``. If that's the case, then don't inline, otherwise do. We're trying to avoid looking at the source as much as possible but this is one example where we actually don't have a choice if we want to keep the output sane.

1.3.0 made the jest codebase significantly worse because of this. The issue is that once things have been moved, this heuristic won't be able to undo it. So people need to have this fix applied before they run 1.3.0, otherwise it's going to damage their codebase unless they manually change everything back, which is a pain. So I'm going to land this as a hotfix in 1.3.1.

Fixes #1492
2017-05-03 14:35:58 -07:00
Davy Duperron 9e345c8527 Drop htmlEscapeInsideAngleBracket function in favour of raw/extra.raw from Flow/Babylon parsers (#1165)
* Make slice simpler.

* Drop htmlEscapeInsideAngleBracket function.

Use child.extra.raw (Babylon) and child.raw (Flow) to get the value instead.

* Remove unused htmlEscapeInsideAngleBracket function.

* Update test cases accordingly.

* Fix merge conflict.

* Update tests via `npm test -- -u`.

* Fix multiple consecutive spaces preservation in printJSXChildren.

* Update tests accordingly.
2017-05-03 08:47:15 -07:00
Lucas Azzola aeeaffca35 Fix handling of new keyword and call signatures and improve type parameter formatting (#1491)
* fix(typescript): fix handling of new keyword

* fix(typescript): fix handling of call signatures

* feat(typescript): share type parameter formatting with flow
2017-05-03 08:01:45 -07:00
Lucas Azzola 59b348f550 Implement TypeScript keywords, namespace functions and class heritage (#1483)
* feat(typescript): #1480: implement *Keyword, namespace function and class heritage

* feat(typescript): add type params and modifiers to interfaces

* chore(style): add squigly wings to if/else blocks

* fix(typescript): remove hardline before declare
2017-05-02 17:06:25 -07:00
Danny Arnold e8a80ca0aa fix #1484 (#1487)
* don't print colon if there is no `typeAnnotation`
* print prefix also for empty interfaces
2017-05-02 16:03:51 -07:00
Danny Arnold 5cf1659acf add TSDecorator (#1488) 2017-05-02 16:03:23 -07:00
Christopher Chedeau b481c57470 1.3.0 docs 2017-05-02 16:00:33 -07:00
Christopher Chedeau a81d5c1cd1 1.3.0 2017-05-02 13:15:15 -07:00
Christopher Chedeau 078572631f Inline template literals as arrow body (#1485)
Turns out I wrote the wrong one :(

Fixes #1465
2017-05-02 09:17:20 -07:00