Commit Graph

1439 Commits (dd84559991f6a5a5ac58ff70dd05c0c4b5018e11)

Author SHA1 Message Date
Karl O'Keeffe 04c41f6758 Fix up empty JSX element detection (#2220) 2017-06-21 13:48:02 -07:00
Lucas Azzola e78e07e2ad refactor(multiparser): move css expression doc printing to transformCssDoc (#2214) 2017-06-21 13:41:24 -07:00
Christopher Chedeau 767138ce6c Remove node 6 from the test matrix
It has never caught any issue in practice and is making the whole test suite consume 1/3 more cpu as a result.
2017-06-21 13:39:45 -07:00
Joe Critchley 5c61036fab Added definition of 'style' to README (#2221) 2017-06-21 13:34:34 -07:00
Christopher Chedeau 313519d8ae Allow long media rules to break (#2219)
Fixes #2198
2017-06-21 13:02:16 -07:00
Simon Lydell e8fb9bddf7 Fix type in README.md 2017-06-21 20:12:18 +02:00
Christopher Chedeau 810ed8857c Update README.md 2017-06-21 10:44:53 -07:00
Simon Fridlund 0fbf23c1ee Turn off trailing comma for json (#2216) 2017-06-21 09:04:39 -07:00
Joseph Frazier 785970a265 Use eslint-friendly-formatter to make errors clickable (#2200)
This changes the eslint error formatting from:

    /Users/josephfrazier/workspace/prettier/src/printer-postcss.js
      3:31  error  Insert `;`  prettier/prettier

to:

    ✘  prettier/prettier  Insert `;`
    src/printer-postcss.js:3:31
    const util = require("./util")
                                   ^

which makes them clickable in terminals like iTerm2 and Guake. See
[eslint-friendly-formatter] for details.

[eslint-friendly-formatter]: https://github.com/royriojas/eslint-friendly-formatter
2017-06-20 18:38:33 -07:00
Simon Fridlund b0a790017b Turn allowImportExportEverywhere on (#2207)
This allows prettier to be used in environments which supports nested import statments, Meteor for example.
2017-06-20 14:42:58 -07:00
Brian Ng 7cef77433a Bump babylon version (#2205) 2017-06-20 08:36:14 -07:00
Lucas Azzola 43521565e7 CSS: lowercase hex colors, closes #2139 (#2203) 2017-06-20 23:07:31 +10:00
suǝʞǝǝpʇ 16db5971f0 Fix css-modules composes breaking with long line width (#2190)
* fix(css): css-modules composes breaking

* refactor(css): to use removeLines in case of composes
2017-06-18 23:41:10 -10:00
Joseph Frazier 3769cbe5bb Fix typos in ./editors/vim/README.md 2017-06-18 18:06:20 -04:00
Jon Wong 1511609c01 Support for printing GraphQL comments (#2187)
* save point

* prettier

* Reverting change to check SOF and EOF

* Removing console.log

* Fixing grouping

* Adding comment output

* Basic comments

* Printing comments

* Getting comments to work

* Adding in basic handling of graphql comments

* Removing parser normalization (i assume it'll be added with language support)

* Lint error

* Reverting special cases

* Dealing with off-by-one error
2017-06-18 07:37:52 -10:00
Lucas Azzola eccb17495a Website: speed up load time, enable service worker (#2172)
* feat(website): speed up website load 💥

* chore(package): fix bad merge
2017-06-18 20:25:27 +10:00
EddiG 4106a69b6d Improvements in Vim Prettier manual (#2188)
* Fix incorrect command in Vim Prettier manual

* Make clarification in command description in Vim Prettier manual
2017-06-18 10:21:44 +02:00
Lucas Azzola 58413cde3e docs(readme): use unordered lists in options section 2017-06-18 15:41:22 +10:00
Lucas Azzola af90402aab docs(readme): join API and CLI columns to prevent overflow 2017-06-18 15:25:24 +10:00
Lucas Azzola 21f913cb6e CLI: ignore node_modules with ./**-style glob, fixes #2110 (#2185) 2017-06-18 14:35:42 +10:00
Lucas Azzola 82a0bb5c5e fix(typescript): upgrade tsep, fixes #2143 (#2183) 2017-06-17 17:10:22 -10:00
Joseph Frazier 69808cebfb Format JSON literals like object literals (#2181)
* Format JSON literals like object literals

Following up on commit a42db30 (https://github.com/prettier/prettier/issues/2173),
this change makes it so that literals in JSON files are formatted as
they would be in an object literal. This normalizes trailing zeroes,
exponential notation, unnecessarily escaped characters, etc.

It works by using babylon to parse literals as expressions, and putting
the result in the AST instead of a `json-literal` node. Since JSON
string literals have to be double-quoted, there's a new
`__prettier__isJson` flag on each node, which is used by the printer to
force double-quotes.

* json: Check options.parser when formatting StringLiteral

This is instead of having a custom AST property. See
https://github.com/prettier/prettier/pull/2181#discussion_r122578251

* multiparser: Use babylon.parseExpression

See https://github.com/prettier/prettier/pull/2181#discussion_r122578354

* json: Don't split result AST node into two

See https://github.com/prettier/prettier/pull/2181#discussion_r122578499

* json: Don't use babylon parser to build expression nodes

See https://github.com/prettier/prettier/pull/2181#discussion_r122579052

* Revert "multiparser: Use babylon.parseExpression"

This reverts commit 3d7a4362880d39fac0cea88b5d0186a29538cf6f.

* Remove unused parameter from babylon parser

* json: Remove unused constructorTypes
2017-06-17 20:49:22 -04:00
Joseph Frazier 532ac0d3f8 Build/test dist/ on Travis (#2176)
This helps us keep track of whether or not the dist/ build actually
works (see https://github.com/prettier/prettier/pull/2174). Note that
the dist/ jobs are allowed to fail, and do not affect overall build
time, so they shouldn't slow anything down (see
https://blog.travis-ci.com/2013-11-27-fast-finishing-builds/).
2017-06-17 13:37:51 -10:00
Joseph Frazier 33a1c713d5 Dedupe copy/pasted code in build.sh (#2179) 2017-06-17 11:39:30 -10:00
Joseph Frazier d46b778dba Add json parser to dist/ build (#2178)
This fixes the build, as shown by:

    yarn build
    yarn test --prod -- tests/json/
2017-06-17 17:09:48 -04:00
Joseph Frazier a42db30946 Add JSON support (#2173)
* Add JSON support

This fixes https://github.com/prettier/prettier/issues/1973 by using
[json-to-ast] to parse JSON, then converting the AST into a
mostly-Babylon AST, so as to piggyback on the existing printer logic.

Identifiers and literals are currently printed verbatim from the input,
but this could be improved upon later (at least for literals, not sure
about identifiers).

[json-to-ast]: https://github.com/vtrushin/json-to-ast

* Rename `json-to-ast` parser to `json`

See https://github.com/prettier/prettier/pull/2173#discussion_r122574644

* json: Use createError to have a pretty error

See https://github.com/prettier/prettier/pull/2173#discussion_r122574748

* json: Transform AST without mutations

See https://github.com/prettier/prettier/pull/2173#discussion_r122574690
2017-06-17 10:36:42 -10:00
Joseph Frazier 59a294fcc9 Fix dist/ build by upgrading typescript to nightly (#2174)
Before, this error happened upon `yarn build`:

    🚨   (commonjs plugin) Binding arguments in strict mode (49161:16) in /Users/josephfrazier/workspace/prettier/node_modules/typescript/lib/typescript.js
2017-06-17 09:00:21 -10:00
Joseph Frazier fe8cc68e56 Fix dist/ build on machines that don't support `sed -i ''` (#2175)
Here's an example of the error that happens upon `yarn build`:

    sed: can't read : No such file or directory
2017-06-17 08:59:45 -10:00
Iaroslav Voloshchuk 89971285e4 Move devDependencies to dependencies (#2124)
fixes https://github.com/prettier/prettier/issues/2121

* move runtime deps to npm deps

* Fix (dev)dependencies

See https://github.com/prettier/prettier/pull/2124#discussion_r121795774

* Remove dependencies from dist/package.json

See https://github.com/prettier/prettier/pull/2124#issuecomment-308259138
2017-06-17 10:36:50 -04:00
Lucas Azzola bff28023b3 Comments: attach method name comments with estree parsers, fixes #2141 (#2170) 2017-06-17 22:22:39 +10:00
Lucas Azzola c669a1db72 TypeScript: group function params in call/construct signatures, fixes #2163 (#2169) 2017-06-17 12:09:18 +10:00
Stephen Wan a005211c96 Fix extra semicolon in ambient typescript declaration emit (#2165) (#2167)
* fix(typescript): add failing ambient declaration test

* fix(typescript): fix failing test case for ambient function exports
2017-06-16 08:20:59 -10:00
Lucas Azzola 7e60d70f97 fix(typescript): always break interfaces onto multiple lines, fixes #2159 (#2161) 2017-06-15 14:34:54 -10:00
Joseph Frazier aedc6d4269 Add integration test of invalid syntax (#2160) 2017-06-16 09:10:39 +10:00
James Henry d8f29d2d5b Update tsep (#2153)
* [WIP] Update tsep

* Fix TypeParameter union parens
2017-06-15 08:55:23 -10:00
James Henry 0410949984 Lock tsep to specific commit (#2152) 2017-06-15 22:45:38 +10:00
Lucas Azzola 9e7b02d50e Print {} in import if it's in the source, fixes #2145 (#2150) 2017-06-15 20:19:01 +10:00
Joseph Frazier cb44125a21 Let `prettier --stdin` work with keyboard input (#2147)
This uses [get-stream] instead of [get-stdin], since the latter just
gives an empty string if process.stdin is a TTY
(see https://github.com/sindresorhus/get-stdin/issues/21)

[get-stream]: https://github.com/sindresorhus/get-stream
[get-stdin]: https://github.com/sindresorhus/get-stdin
2017-06-15 09:57:29 +10:00
Joseph Frazier 3bbfa97152 Check exit codes in integration tests (#2148) 2017-06-15 09:56:48 +10:00
Lucas Azzola a2328edced TypeScript: keep parens around with yield/await non-null assertion, fixes #2137 (#2149) 2017-06-15 09:34:12 +10:00
James Henry 3726067923 Override tsep loggerFn with noop (#2144)
* Override tsep loggerFn with noop

* Extra function to keep Vjeux happy :P
2017-06-14 14:53:05 -07:00
Joseph Frazier f361910036 Upgrade dependencies (#2140)
Among other things, this upgrades fsevents from 1.1.1 to 1.1.2, which
eliminates a `yarn` warning on OSX machines running Node.js 8. See here
for details: https://github.com/strongloop/fsevents/issues/170
2017-06-14 14:29:35 -07:00
Joseph Frazier 48bbd9cb6b Don't insert a cursor placeholder for a value-less path (#2136)
* Test that no cursor placeholder is inserted for a value-less path

This was taken from https://github.com/prettier/prettier/issues/2131

* Don't insert a cursor placeholder for a value-less path

This fixes https://github.com/prettier/prettier/issues/2131
2017-06-14 09:05:06 -07:00
Lucas Azzola b7e1c366e0 Vue: pretty-print binding syntax (#2108)
* feat(vue): pretty-print :class attributes

* feat(vue): switch to brand new custom parser API! 🎉

* refactor(vue): move AST manipulation to post-parse
2017-06-14 22:33:15 +10:00
James Henry 9b772cb4fd Add test for comment in TypeScript type parameters (#2132) 2017-06-14 20:10:03 +10:00
George Chung 68550450b6 Typo fix (#2134) 2017-06-14 20:08:32 +10:00
Christopher Chedeau abfdbe1896 Upgrade typescript to 2.4 (#2120)
Fixes #2117
2017-06-13 09:47:40 -07:00
Rodrigo Pombo 8dd0cb2a05 Format CSS in template literals with expressions (#2102)
* Add support for styled-jsx with expressions

* Lint

* Fix require for Node 4

* Re-create template-literal document when replacing placeholders

* Add support for styled-components with expressions

* Fix merge

* Move css library detection to functions
2017-06-13 09:45:16 -07:00
Lucas Azzola 40c41f232f Website: usability improvements (#2118)
* feat(website): use worker thread for formatting

* Create index.html

Remove step=5
2017-06-13 09:20:13 -07:00
Christopher Chedeau e69d0fe5fb Create why-prettier.md 2017-06-12 21:00:04 -07:00