Commit Graph

1152 Commits (f702c2c61484241f1d0ca33a6603dcdcc0102256)

Author SHA1 Message Date
Christopher Chedeau f702c2c614 1.4.3
* Fix support for node 4 (#1988)
* Fix website on iOS Safari (#1970)

Formatting change:
* Position JSX whitespace (`{" "}`) at the end of lines (#1964)

Lots of small fixes, mainly for TypeScript.
2017-06-07 15:48:34 -07:00
Martin V 820e39b2b3 Clean up build script, add Babel for docs js bundles (#1970)
* Clean up build script, add Babel for docs js bundles

* Update package.json
2017-06-07 15:20:48 -07:00
Christopher Chedeau 924363193b Check if the next group has comments (#2040)
Fixes #1958
Fixes #1959
2017-06-07 15:20:11 -07:00
Christopher Chedeau 1edb1f261b Include typeAnnotation inside of node location (#2039)
We should remove this hack once https://github.com/eslint/typescript-eslint-parser/issues/314 lands

Fixes #1946
2017-06-07 15:05:46 -07:00
Christopher Chedeau 42b0368e3d Fix decorator comments for export class (#2038)
We need to do the same location trick for export class unfortunately.

Fixes #1956
2017-06-07 14:55:55 -07:00
Christopher Chedeau b730f4eccf Add group around TSMethodSignature (#2037)
This ensures that the comment size is not taken into account during measurement

Fixes #1976
2017-06-07 14:20:55 -07:00
Christopher Chedeau 09f147decd Do not throw for unprinted comments inside of JSX (#2036)
Fixes #1990
2017-06-07 12:57:03 -07:00
Christopher Chedeau ccda4c7115 Break decorator before content (#2032)
Fixes #1996
2017-06-07 12:40:47 -07:00
Christopher Chedeau e16478ef80 Fix less &:extends when parsed with scss (#2034)
This is the only breakage that people ever reported with CSS so I'm happy adding one edge case like this.

Fixes #1967
2017-06-07 12:40:36 -07:00
Christopher Chedeau cabae6d877 Fix parenthesis for call expression inside of member expression inside of new (#2035)
Fixes #2033
2017-06-07 12:40:27 -07:00
Christopher Chedeau c7cacf0529 Break if string | null (#2028)
We were a bit too aggressive around the `| null` heuristic.

Fixes #2002
2017-06-07 11:51:32 -07:00
Christopher Chedeau c9c8512170 Only prevent lone `set` if there's no type annotations (#2026)
If there are, it's not ambiguous.

Fixes #2023
2017-06-07 11:51:25 -07:00
Christopher Chedeau 5ba0b0ec87 Add semi for functions without body (#2025)
We don't need to be overly restrictive and should add the semi if there's no body

Fixes #2003
2017-06-07 11:51:17 -07:00
Christopher Chedeau 57b3fe8a50 Update commands.md 2017-06-07 11:43:06 -07:00
Christopher Chedeau e1ebbff001 Update commands.md 2017-06-07 11:42:31 -07:00
Christopher Chedeau 9d4fabd691 Pretty printer commands.js 2017-06-07 11:17:04 -07:00
Alexandre BODIN 8ec1b40961 GraphQL: Add support for union types (#2014) 2017-06-07 10:33:46 -07:00
Eugene Korbut 0222d8eefe Update README for emacs integration link (#2024) 2017-06-07 09:21:17 -07:00
Sashko Stubailo 0583fd4ce6 Add alias and null value (#2017)
Add kitchen sink test case
2017-06-06 18:06:15 -07:00
Joseph Frazier 1f3665fba0 Upgrade prettier to v1.4.2, fix lint issues (#2018)
This corrects the regressions seen in commit
26e829b (https://github.com/prettier/prettier/pull/1888)
2017-06-06 18:05:22 -07:00
Joseph Frazier f261ad4efb Add .yarnrc to use exact versions (#2016)
Now, `yarn add` and `yarn upgrade` will write exact versions to
package.json and yarn.lock.

See commit fadbbeb (https://github.com/prettier/prettier/pull/291)
2017-06-06 18:04:52 -07:00
Sashko Stubailo 88f962beee Add support for GraphQL directies (#2015) 2017-06-06 17:42:47 -07:00
Joseph Frazier 552ceb30e8 Allow --debug-check to work with stdin (#2013)
* Allow --debug-check to work with stdin

This makes it easier to quickly test formatting code snippets with e.g.

    pbpaste | prettier --debug-check

Before, the following would happen:

    $ pbpaste | prettier --debug-check
    stdin: TypeError: Invalid data, chunk must be a string or buffer, not undefined
        at WriteStream.Socket.write (net.js:693:11)
        at writeOutput (/Users/josephfrazier/workspace/prettier/bin/prettier.js:375:18)
        at getStdin.then.input (/Users/josephfrazier/workspace/prettier/bin/prettier.js:275:7)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:169:7)
    $

Now, it looks like this:

    $ pbpaste | prettier --debug-check
    (stdin)
    $

* Test that --debug-check still prints filenames

See https://github.com/prettier/prettier/pull/2013#discussion_r120499306
2017-06-06 16:10:24 -07:00
Joseph Frazier b20437ad13 Use printStatementSequence() to print SwitchCase consequent (#2011)
I noticed the duplicated code while working on commit 0cfd772
(https://github.com/prettier/prettier/pull/2008)
2017-06-06 14:58:20 -07:00
Joseph Frazier 0cfd772fd2 Protect SwitchCase statements from ASI (#2008)
* Add no-semi test with SequenceExpression

Adapted from https://github.com/prettier/prettier/issues/2006

* Protect SequenceExpressions from ASI

Fixes https://github.com/prettier/prettier/issues/2006

* Add test for ASI protection of SequenceExpression outside SwitchCase

See https://github.com/prettier/prettier/pull/2008#issuecomment-306614217

* Revert "Protect SequenceExpressions from ASI"

This reverts commit ca644fad8072c90a977ad8a2f29674bc72f679e8.

* Protect SwitchCase statements from ASI

See https://github.com/prettier/prettier/pull/2008#issuecomment-306614217

Fixes https://github.com/prettier/prettier/issues/2006
2017-06-06 14:28:51 -07:00
Sashko Stubailo 7c051804a8 Add support for GraphQL object values (#2010) 2017-06-06 14:28:15 -07:00
Sashko Stubailo c441f87fc0 Add GraphQL fragment support (#2005) 2017-06-06 12:35:40 -07:00
Rodrigo Pombo d4774edd03 Parse CSS in template literals (styled-jsx) (#1984)
* Add basic styled-jsx parsing

* Use eval("require")

* Remove template literal raw and cooked values when it contains CSS

* Set postcss parser to options and group subtree parts

* Gracefully give up TemplateLiteral formatting when it fails
2017-06-06 08:28:13 -07:00
Sashko Stubailo 6d00644c78 Add GraphQL variable definition support (#1995) 2017-06-06 08:26:04 -07:00
Philipp Spieß d679f235ed Also infer parser when using `--list-different` (#1997)
* Also infer parser when using `--list-different`

* Add integration tests for parser inference
2017-06-06 08:24:56 -07:00
Daniel Tschinder df7311a7f3 Add parens around all string literals at top level (#1999) 2017-06-06 08:24:13 -07:00
Sashko Stubailo c80e82c7d7 Add support for list values (#1994)
Run the linter
2017-06-05 23:45:15 -07:00
Christopher Chedeau c46a20c8c1 re-run tests 2017-06-05 22:26:35 -07:00
Sashko Stubailo df08dc4a56 Add support for arguments with soft line break (#1993) 2017-06-05 22:25:12 -07:00
Sashko Stubailo 8cb259eac7 GraphQL: Add support for printing operation names (#1992)
* Add support for printing GraphQL operation names

* Remove extra empty line at the end
2017-06-05 22:24:01 -07:00
Sashko Stubailo 76c5733b55 GraphQL: Add support for formatting fields in selection sets (#1991)
* GraphQL: Add support for formatting fields in selection sets

(Doesn't yet handle arguments or directives)

* Remove extra space
2017-06-05 22:23:03 -07:00
Joseph Frazier c863cbeac8 Translate cursor relative to nearest node, not SourceElement (#1989)
* Add test demonstrating SourceElement-relative cursor translation

See https://github.com/prettier/prettier/issues/1981#issuecomment-306326739

* Translate cursor relative to nearest node, not SourceElement

This partially address https://github.com/prettier/prettier/issues/1981

See https://github.com/prettier/prettier/issues/1981#issuecomment-306326739

* Add test demonstrating incorrect cursor translation

Since the `cursorOffset` option (introduced in #1637) works by tracking
the cursor position relative to an AST node (rather than a CST token),
it can produce incorrect results.

See https://github.com/prettier/prettier/issues/1981
2017-06-05 18:51:53 -07:00
Carl von Buelow 19bd2a3f7c Add "use strict" to fix SyntaxError on Node@4 (#1988) 2017-06-05 18:27:55 -07:00
Joseph Frazier d9e4d8f1b8 Remove unnecessary 'else' after 'return' (#1987)
As mentioned in at the end of
https://github.com/prettier/prettier/pull/1983/files#r120222081
2017-06-05 15:12:59 -07:00
Karl O'Keeffe 73432c2ce7 Position JSX whitespace (`{" "}`) at the end of lines (#1964)
* Position JSX whitespace at the end of lines

Currently we place JSX whitespace at the beginning of lines.

* Use `isLiteral` when determining JSX whitespace
2017-06-05 21:52:54 +01:00
Jon Wong e33d6773d6 Adding support for `graphql` (#1982)
* Initial GraphQL implementation

This is the bare minimum amount of code to make graphql work. Turns out it's pretty easy to add support for other languages :)

* Fixing support for `graphql` parsing

There was a few structural changes with the addition of CSS and Typescript that we had to take into account.

* Fixing file glob, adding `graphql` to yarn.lock

* Removing extraneous file

* Adding `graphql` parser, style changes

* Splitting out graphql printer

* Removing merge conflict

* Fixing yarn.lock

* Addressing code review, using `createError`

* Adding release config

* Using exact version

* Removing destructuring
2017-06-05 12:34:08 -07:00
Lucas Azzola 31ab3b6036 feat(css): split postcss printer into separate file (#1969) 2017-06-05 07:28:38 -07:00
James Henry 5f5980b217 Revert to official tsep and bump TS to 2.3.4 (#1972) 2017-06-05 22:15:00 +10:00
tdeschryver 4291a8cedc Update single quote option in README (#1952)
* chore: add single quote note in readme

* chore: change readme text to quote format behaviour
2017-06-04 14:41:57 -07:00
Lucas Azzola 642ac7e230 fix(typescript): print semi in class index signatures, fixes #1960 (#1961) 2017-06-04 07:21:33 -07:00
Christian Hamburger Grøngaard 41688901f2 Make README more JavaScript agnostic (#1955)
- Prettier has grown into a more general tool.
2017-06-04 21:24:18 +10:00
Lucas Azzola fed9f0f4eb Mention TypeScript and CSS in the README (#1950)
* Mention TypeScript and CSS in the README.
* Collapse the table of contents with `<details>` tag.
* Clarifies the `--parser` option.
2017-06-03 20:03:30 -07:00
Christian Hamburger Grøngaard e0682a9558 Miscellaneous minor README fixes (#1943)
* Refer to "line length" instead of "line width"

- It's consistent with what it has been called in the section so far.

* Add missing punctuation

* Remove needless "just"s

- It's less condescending to a reader who doesn't know how to
"just" do these things.
2017-06-03 11:49:15 -07:00
Christopher Chedeau 86febfe797 1.4.2 2017-06-03 08:54:22 -07:00
Lucas Azzola 6697122e28 fix(decorators): do not inline methods with decorators with babylon, fixes #1933 (#1934) 2017-06-03 05:24:24 -07:00