Simon Lydell
133303f47a
Ignore some things in coverage ( #2741 )
...
- If statements for old deprecated stuff.
- "This should never happen" (and never happens in the tests) code paths.
2017-09-03 13:40:44 -07:00
Simon Lydell
368522cf33
Normalize CSS case ( #2736 )
...
Fixes #2653 .
2017-09-03 21:22:28 +02:00
Simon Lydell
fd025a855e
Merge pull request #2738 from ikatyang/test/more-cli-tests
...
test(integration): add more tests
2017-09-03 16:24:44 +02:00
Simon Lydell
f903ae45ed
Make run-external-typescript-tests.js cross-platform ( #2737 )
...
The old version had quite a bit of code related to grouping errors,
showing the number of errors per group and saving the groups of errors
to different files. However, now there are only 12 bad tests so I didn't
bother porting that logic to the new version. Instead, the errors a
simply printed to stdout.
2017-09-03 15:59:19 +02:00
ikatyang
8f423c1071
fix: globby.sync should be in try..catch block
2017-09-03 21:32:12 +08:00
Ika
c4e5463514
refactor(cli): separate files and make it pure as possible ( #2730 )
...
* refactor(bin): resolveConfig
* refactor(bin): getOptionsForFile
* refactor(bin): remove `mapSeries`
* refactor: move content from bin to src/cli
* refactor: wrap content with function
* refactor: move constants to another file
* refactor: move utils to another file
* refactor: move functions
* refactor: extract functions
* refactor: remove unnecessary variable
* refactor: move `src/cli` to `src` with prefix `cli`
* refactor: use template literal
* refactor: remove unnecessary variable
* refactor: extract `listDifferent`
* refactor: extract `format`
* refactor: change error message `Invalid configuration:`
* refactor: bind args with argv
* refactor: extract `getOptionsForFile`
* refactor: extract `formatStdin`
* refactor: extract `eachFilename`
* refactor: extract `formatFiles`
* refactor: remove unnecessary export
* refactor: use `globby.sync()`
* refactor: add `runPrettier.sync()` helper
* refactor: fix linting
* refactor: mock `process.argv`
* chore: use `--forceExit` to avoid process hanging
* refactor: mock `get-stream`
* refactor: remove unnecessary stuff
* refactor: fix linting
* refactor: wrap `run` with `try..catch.finally`
* refactor: restore `process.exitCode` after testing
2017-09-03 19:21:06 +10:00
Ika
088aa71b07
feat(resolve-config): add .sync() method ( #2722 )
...
* feat(resolve-config): add `sync` option
* docs(readme): add `sync` option
* fix(clearCache): always clear both
* chore(deps): switch to 3.0 branch
* feat: replace `sync` option with `.sync()`
* docs(readme): update `.sync()`
2017-09-01 20:17:07 +10:00
Christian Wesselhoeft
87401de0a5
Handle +/- before numbers in CSS ( #2713 )
...
* src/util: Fix negative number handling
* src/util: Handle decimal numbers with leading plus sign
* src/util: Handle sign symbols before numbers in scientific notation
2017-08-30 20:26:11 +02:00
Brian Ng
9533c17827
Fix printing declare modifier for TS enum ( #2711 )
2017-08-30 08:14:26 -07:00
Brian Ng
123bc5d5ff
Ensure parens around LogicalExpression inside ExperimentalSpreadProperty ( #2710 )
2017-08-30 08:10:36 -07:00
Simon Lydell
63835d1ccb
Fix config file finding when using stdin ( #2692 )
...
Fixes #2689
2017-08-29 08:58:08 +02:00
James Henry
987b931215
Fix: Union type with type params regression ( #2688 )
2017-08-28 18:37:12 -07:00
Joseph Frazier
82ad911ddc
Upgrade prettier dependency to v1.6.0, fix lint ( #2681 )
2017-08-28 12:22:51 -07:00
Lucas Azzola
2e828de76f
Print 3 or more chained calls on multiple lines ( #2673 )
2017-08-27 09:44:44 -07:00
Lucas Azzola
dd84559991
Merge computed MemberExpression in member chain ( #2670 )
2017-08-26 05:35:05 -07:00
Christopher Chedeau
0d38136115
Put parenthesis after return when jsx is prettier-ignored ( #2665 )
2017-08-24 19:29:05 -07:00
Christopher Chedeau
0ee74a8d25
Do not swallow prettier-ignore comments ( #2664 )
2017-08-24 18:57:01 -07:00
Christopher Chedeau
f7bd74ed98
Fix fatal with empty jsx ( #2663 )
2017-08-24 18:02:44 -07:00
Christopher Chedeau
ab91f6f8be
Fix interleaved comments in class decorators ( #2661 )
...
I wrote this fix a while ago but it conflicted with the class heuristic, now that #2660 fixes it, we can ship this one as well!
Fixes #1460
Fixes #2507
2017-08-24 16:04:02 -07:00
Christopher Chedeau
05b4422e4f
Better fix for class comments ( #2660 )
...
We used to be very naive and just push all the comments at the top of the class, but it's very brute force (and breaks some flow annotations inside of fb) so we can do better :)
2017-08-24 15:45:28 -07:00
Simon Lydell
e5f84467b7
Normalize numbers in CSS like JS
...
Unlike JS, `1.0` is also normalized to `1`.
2017-08-22 18:50:10 +02:00
Simon Lydell
5f95e68913
Quote unquoted CSS attribute values in selectors ( #2644 )
2017-08-22 09:45:15 -07:00
Simon Lydell
876dfe6398
Work around issue #2584 ( #2652 )
...
parser-postcss parses `@import` at-rules specially, and unfortunately
buggily. This monkey-patches parser-postcss to parse all at-rules the
same way.
Fixes #2584 .
postcss-less bug: https://github.com/shellscape/postcss-less/issues/88
2017-08-22 09:44:25 -07:00
Simon Lydell
3e924474cd
Print sub-nodes of @import in Less ( #2646 )
...
Fixes part of #2584 .
2017-08-21 12:28:22 -07:00
James Henry
23e0e90779
Update tsep and account for AST differences ( #2647 )
2017-08-21 12:27:35 -07:00
jackyho112
b77b1c82a7
Strip away unnecessary quotes in keys in type objects and interfaces ( #2643 )
...
* Use printPropertyKey function to print keys in object type property in TS and Flow
* Remove flow test modification
* Add tests for new object key cases
* Add new test file
* Fix some styles
2017-08-21 20:08:38 +10:00
James Henry
5c539b06a4
Update: tsep version upgrade and changes to TS enum structure ( #2641 )
2017-08-19 11:10:38 -07:00
Simon Lydell
9e16dbbde7
Adjust some more quotes in CSS
2017-08-17 08:59:56 +02:00
Simon Lydell
c198c33700
Merge pull request #2624 from lydell/css-strings
...
Normalize quotes in CSS like in JS
2017-08-15 16:07:06 +02:00
Simon Lydell
b286ed171e
Fix AST_COMPARE for CSS strings
2017-08-15 07:58:19 +02:00
Simon Lydell
4979f58c15
Normalize quotes in CSS like in JS
2017-08-14 09:14:57 +02:00
Lucas Azzola
0b9fbf940f
Support styled.div.attr({})... ( #2619 )
2017-08-13 13:52:24 +10:00
Lucas Azzola
ec85cf0f0a
Do not accept declare on previous line ( #2618 )
2017-08-13 13:47:48 +10:00
Dmitry Korlas
f738a214d3
fix cut off line-break in scss between comment and followed @else ( #2600 )
...
* fix cut off line-break in scss between comment and followed @else
* fix cut off line-break in scss between comment and followed @else (CR fixes)
2017-08-08 12:07:47 +10:00
Lucas Azzola
e378f5e9ba
Implement proposal-optional-chaining ( #2572 )
...
* Implement proposal-optional-chaining
Closes #2568
* Refactor optional token printing
2017-08-03 17:38:02 +10:00
Brian Ng
1701f4a0d5
Print declare for TSInterfaceDeclaration ( #2574 )
2017-08-02 00:00:01 +10:00
Brian Ng
4c335cae0a
Add support for printing optional catch binding ( #2570 )
2017-07-31 14:40:14 -06:00
Lucas Azzola
58edd0d3f3
Keep parens around FunctionTypeAnnotation inside ArrayTypeAnnotation ( #2561 )
...
Without this, this:
const actionArray: (() => void)[] = [];
is formatted as:
const actionArray: () => void[] = [];
Fixes #2559
2017-07-30 00:50:38 +10:00
Lucas Azzola
af6b020f7e
Support styled-components with existing component ( #2552 )
...
Supports the syntax:
```js
styled(ExistingComponent)`
css: property;
`;
```
Fixes #2545
2017-07-28 19:04:17 +10:00
Lucas Azzola
3eed1933e1
Don't pass config path through to cosmiconfig ( #2547 )
2017-07-27 21:59:57 +10:00
Brian Ng
24e1aec306
Add support for flow opaque types ( #2543 )
2017-07-25 19:47:54 -07:00
Brian Ng
60f5836b37
Add support for flow export type star ( #2542 )
2017-07-26 09:00:20 +10:00
Yang Su
26842e4d69
Handle closure compiler type cast syntax correctly ( #2484 )
...
* Handle closure compiler type cast syntax correctly
Fixes https://github.com/prettier/prettier/issues/1445
* Move closure type cast detection to needParens in fast-path.js
* every => some and added additional check for leading comment
2017-07-25 11:21:25 +10:00
Lucas Azzola
a666a29aa3
Print semi after DeclareFunction, fixes #2534 ( #2536 )
2017-07-24 21:55:16 +10:00
Joseph Frazier
a78d1389f6
Use babylon.parseExpression for JSON ( #2476 )
...
* Add comments showing parser arguments
Since this is how they are invoked, the comments make it easier to maintain.
* Use babylon.parseExpression for JSON
See https://github.com/prettier/prettier/issues/2378#issuecomment-314600778
Note that this doesn't yet print comments:
echo '{/*comment*/"K":"V"}' | ./bin/prettier.js --parser json
* Remove parser-json.js
This reduces duplicate code in the built package.
See https://github.com/prettier/prettier/pull/2476#pullrequestreview-50181398
* Add test with block comment in JSON
* Fix test with block comment in JSON
* Add test with line comment in JSON
* Don't build now-redundant parser-json.js
2017-07-24 11:43:49 +10:00
Lucas Azzola
4a0e9475df
Print parens around type assertion as LHS in assignment, fixes #2521 ( #2525 )
2017-07-20 23:16:15 +10:00
James Henry
1c9962df67
Update tsep and account for TSTypeReference change ( #2520 )
...
* Update tsep and account for TSTypeReference change
* Check TSTypeReference in shouldHugType
2017-07-20 12:54:43 +02:00
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