Commit Graph

386 Commits (master)

Author SHA1 Message Date
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
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
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 b7fa01af17 Enable code coverage in CI (#2497)
* Enable code coverage in CI

* Disable codecov comment

* Ignore some statements from coverage reports
2017-07-16 21:49:37 +10:00
James Henry ee822f99b9 Update tsep and add test for destructuring assignment (#2443)
Fixes #2229
2017-07-11 09:11:18 +10:00
Lucas Azzola dcccfed366 Implement cosmiconfig for workspace configuration (#2434)
* Implement cosmiconfig

* Add resolveOptions API and extname support

* Add --resolve-config and --config, rename resolveOptions to resolveConfig

* Move color to top-level CLI options

* Fix unknown param warning

* Change from {} to null when no config is found

* Change override API to emulate eslint

* Add test for eslint-style overrides

* Delete overrides from resolveConfig
2017-07-10 22:26:36 +10:00
Simen Bekkhus 1b4846b67d Format prettier with newer prettier (#2431) 2017-07-08 14:07:39 +02:00
Simen Bekkhus 3e184d8f37 Upgrade chalk (#2432) 2017-07-08 14:07:03 +02:00
Joseph Frazier 8fcd667200 Update yarn.lock 2017-07-05 10:44:14 -04:00
Joseph Frazier ead0bc0a9c Use eslint-plugin-import to detect devDependencies used in production (#2387)
This solves the same problem as https://github.com/prettier/prettier/pull/2386,
but at lint-time, rather than only on Travis.
2017-07-04 17:53:45 +02:00
Lucas Azzola 65bbbaec58 Add content to website (#2377)
* Add content to website

* Fix linting error

* Cleanup, extract content to JSON files
2017-07-03 12:48:05 +02:00
Frank Li 80f38ce75b Website (#2241)
* initial docusaurus set-up

* Delete why-prettier.md

* Update README.md

* Update Docusaurus structure

* Update package.json

* Update siteConfig.js

* Remove ~ files

* chore(website): update build script

* Add redirect script

* Get eslint working on website

* Fix to allow for baseUrl of '/'

* Update docusaurus version

* Update README.md

* Change redirect script to use baseUrl of '/'

* Fix index.js formatting

* Load redirect script

* General cleanup

* Add projects using prettier
* Update service worker to just scope to playground
* Reduce link repeatition
* Link "Try it out" button to /playground/
* Make header of playground approximately same as main site
* Remove .html from URLs (e.g. users.html -> users/)
* Link Gitter Chat

* Add circleci.yml

* Only run builds on master

* Do deployment using Travis
2017-07-02 10:14:24 +10:00
Simon Lydell 20a0723fc1 Convert build.sh into build.js using shelljs
For better cross platform compatibility.
2017-06-28 22:34:59 +02:00
Simon Lydell ba51d2dfa8 Enable linting of build scripts 2017-06-28 21:37:33 +02:00
Christopher Chedeau 6f4eade422 Go back to babylon beta 13 (#2289)
Fixes #2286
2017-06-27 11:51:23 -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
Brian Ng 7cef77433a Bump babylon version (#2205) 2017-06-20 08:36:14 -07: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
Lucas Azzola 82a0bb5c5e fix(typescript): upgrade tsep, fixes #2143 (#2183) 2017-06-17 17:10:22 -10: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
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
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 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
Christopher Chedeau abfdbe1896 Upgrade typescript to 2.4 (#2120)
Fixes #2117
2017-06-13 09:47:40 -07:00
Lucas Azzola d00956d51d feat(html): add parse5/htmlparser2 printer (#2083) 2017-06-09 19:22:59 -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
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
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
James Henry 5f5980b217 Revert to official tsep and bump TS to 2.3.4 (#1972) 2017-06-05 22:15:00 +10:00
Christopher Chedeau 2b6c1cd27e Update typescript-eslint (#1924)
This applies https://github.com/eslint/typescript-eslint-parser/pull/308 and https://github.com/eslint/typescript-eslint-parser/pull/303 to fix issues on prettier.

Fixes #1870
2017-06-02 16:19:15 -07:00
Simen Bekkhus 584bf4ecbf Upgrade babel code frame (#1902)
* Upgrade babel code frame

* Get better marker for parsing errors in postcss-values-parser
2017-06-02 14:11:05 -07:00
Simen Bekkhus 862a2d610c Used published version of uglify-es (#1897) 2017-06-02 13:46:13 -07:00
Joseph Frazier 26e829b987 Upgrade prettier to v1.4.0, fix lint issues (#1888) 2017-06-02 11:48:43 -07:00
Lucas Azzola 38eec13a03 TypeScript: temp fix for missing readonly keyword (#1865)
* fix(typescript): temp fix for missing readonly keyword, fixes #1845

* fix(typescript): use non-master commit from tsep
2017-06-02 08:09:24 -07:00
Christopher Chedeau fdce975e5d Move all the dependencies to dev dependencies and --exact (#1850)
Since we are now bundling all the dependencies, we can have prettier be dependency-free on npm <3
2017-06-01 20:38:25 -07:00
Christopher Chedeau f4296550db Introduce Webpack 2 to fix postcss bundling (#1836)
It turns out rollup doesn't use the same algorithm for bundling commonjs files when there are cycles as node, which breaks postcss: https://twitter.com/Rich_Harris/status/869021144191561729. Webpack works just fine with it.

This sucks to have this rollup/webpack frankenstein but I really want to be able to release and don't really want to spend yet another day or two trying to make it work well.
2017-05-31 11:59:33 -07:00
James Henry 920ceea77e Update tsep to latest master, reenable abstract interface test (#1795) 2017-05-29 23:26:53 +10:00
Christopher Chedeau 05b921efdd Build the dist/ with rollup (#1794) 2017-05-28 21:49:41 -07:00
Christopher Chedeau 5a828bedd1 Update eslint-typescript again (#1791)
Now fixes more issues ;)
2017-05-28 16:05:07 -07:00
Christopher Chedeau 97775dc94c Add support for SCSS (#1790)
We use a heuristic to figure out if it's a SCSS or Less file. And if it doesn't work, we try again with the other one. We do the same for JSX and TypeScript.

Fixes #1784
2017-05-28 15:01:47 -07:00
Christopher Chedeau 882b712c5f Update typescript-eslint (#1787)
It improves a few things.
2017-05-28 13:18:29 -07:00
Lucas Azzola e270032d37 chore(typescript): upgrade typescript-eslint-parser to 992f1fa (fixes #1769) (#1785) 2017-05-28 08:05:33 -07:00
Christopher Chedeau f3823276eb Enable loose mode for postcss-values-parser (#1766)
Fixes https://github.com/shellscape/postcss-values-parser/issues/29
2017-05-27 11:15:05 -07:00
Simen Bekkhus 06806068f6 Dedupe typescript-eslint-parser in yarn.lock (#1739) 2017-05-26 07:47:45 -07:00
Christopher Chedeau 5e0fa00725 Upgrade typescript-eslint to 31ad3c (#1738)
Fixes #1737
2017-05-25 19:04:15 -07:00
Christopher Chedeau 2e92e4e17d Update to flow 0.47 (#1736)
Fixes #1469
Fixes #1457
Fixes #425
2017-05-25 17:00:36 -07:00
Christopher Chedeau 78ba808322 Initial CSS support (#1636)
I wanted to see how hard it would be to add support for CSS inside of prettier. Turns out, it's not that hard. I spent a few hours printing post-css values and getting all the stylefmt unit tests to not throw.
2017-05-24 10:52:12 -07:00
Michał Pierzchała 7a0df958dc Ignore node_modules when running prettier from CLI (#1683)
* Ignore node_modules by default

* Add integration test suite for --with-node-modules CLI arg

* Refactor tests to snapshots

* Disable eslint for purposely faulty files

* Fix node 4

* Fix prettier

* Gitignore only top-level node_modules
2017-05-23 14:19:04 -07:00
Brian Ng d608b7ba28 Bump Babylon and enable additional tests (#1668) 2017-05-22 15:31:53 -07:00
Joseph Frazier fa8408b53f Upgrade typescript parser, fix and run AST tests on Travis (#1657)
* Run `yarn` to update yarn.lock

* Upgrade typescript-eslint-parser, use JSXText instead of Literal for strings inside JSXElement

https://github.com/eslint/typescript-eslint-parser/pull/272 was merged,
so this fixes https://github.com/prettier/prettier/issues/1558

See here for more info about the new TSQualifiedName node type:
3491b4b73a

* Run AST comparison tests on Travis
2017-05-21 14:16:24 -07:00
Joseph Frazier d7aaaee0dd Add `lint` script, run it on Travis, prettify source code (#1634)
* Add `lint` script with eslint-plugin-prettier, use it in `format:all`

See https://github.com/prettier/prettier/pull/1634#issuecomment-302945967

* Run `lint` script on Travis

* Run Prettier on its own source code

This was done with

    npm run format:all
2017-05-21 11:00:16 -07:00
Danny Martini e1fdf78863 upgrade typescript-elint-parser and enable most ts tests again (#1649) 2017-05-21 07:53:00 -07:00
Danny Martini 2c76bfe1e1 update typescript parser (#1578)
* update eslint-parser-typescript

* fix comment parsing

* disable all failing tests

* fix TSInterfaceDeclaration

* fix #1537

* only disable typescript tests for tests/function
2017-05-10 14:11:50 -07:00
Simen Bekkhus ed24bff251 Upgrade jest (#1534)
* Upgrade jest

* yarn upgrade
2017-05-06 07:40:40 -07:00
Danny Arnold 423cb11d9d update yarn.lock (#1471)
package.json and yarn.lock are out of sync
2017-05-01 09:36:48 -07:00
Christopher Chedeau 3161bd0787 Upgrade flow parser to 0.45 (#1447)
This fixes all the unicode issues and spacing between elements in array.

Fixes #1336
Fixes #1427
Fixes #770
2017-04-27 14:59:18 -07:00
Jan Kassens b82220b20f Prittier printing of snapshots (#1190)
This uses a custom snapshot serializer to reduce escaping in snapshot files and
make them easier to read.

Snapshot serializers are documented here:
https://facebook.github.io/jest/docs/configuration.html#snapshotserializers-array-string
2017-04-12 13:41:51 -07:00
Simon Lydell dc93bdc983 Sync the Flow tests (#1163)
* Extract custom tests from tests/flow/

Approach:

1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
   - It was easy to see which deletions were due to changes in the tests
     due to updates in the flow repo.
   - For the rest of the deletions, I used `git blame` to verify that
     they had been added by us since the flow tests were copied over.

This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.

* Add a script for syncing the flow tests

* Sync the flow tests
2017-04-08 07:52:38 -07:00
Christopher Chedeau 1578e180f4 Add support for flow type spread in .43 and babylon beta8 (#1064)
Fixes https://twitter.com/ryyppy/status/844116626467438592
2017-04-04 14:52:16 -07:00
Brian Ng d9a4efcc35 Bump babylon to 7.0.0-beta.8 (#1118)
* Bump babylon version

* Enable flow predicate tests in babylon
2017-04-04 14:21:56 -07:00
Christopher Chedeau 569791a57a Update babylon to 7.0.0-beta.4 (#1047)
Fixes #700
2017-03-20 12:46:31 -04:00
Christopher Chedeau b012f7531e Fix comments inside of ObjectPattern (#1045)
ast-types was missing a type, I sent a PR on ast-type ( https://github.com/benjamn/ast-types/pull/211 ) which was merged and released (thanks @benjamn for being super quick!). So I'm upgrading ast-types and add the test in this PR.

Fixes #1007
2017-03-20 12:42:07 -04:00
Christopher Chedeau f656db7728 update-yarn-lock 2017-03-19 08:54:17 -07:00
James Henry 72456bf06f [WIP] TypeScript Parser (#915)
* WIP immediate feedback

* typescript parser is drop-in replacement for flow parser

* Add new TypeScript Parser snapshots where drop-in replacement possible

* Snapshot updates after rebasing

* Remove unnecessary stripping of properties on TypeScript parser AST

* Remove annotated issues

* Move TS dependencies to dev for now
2017-03-08 13:18:13 -08:00
Christopher Chedeau 1b9234a8c4 Update flow to 0.40 (#808)
This fixes the bug with comments swapped between `/*` and `//`

Fixes #755
2017-02-24 15:46:20 -08:00
Brian Ng 543e62cd31 Revert babylon bump (#792) 2017-02-23 09:00:57 -08:00
Brian Ng 211deb527e Bump babylon & add test for async func decl (#790)
* Add test for async function declaration

* Bump babylon version
2017-02-23 09:32:20 -05:00
Rogelio Guzman e039ca888a Upgrade to Jest 19.0.1 (#779) 2017-02-22 10:28:17 -08:00
Rogelio Guzman d45e157563 Upgrade to Jest 19 (#762)
* Upgrade to Jest 19

* Use exact versions for Jest
2017-02-21 13:59:19 -08:00
Umidbek Karimov 97fd8a8d81 Log filename with [update] or [ignore] flags during `--write` process. (#584)
* Make `--write` logs more informative.

* Add format duration to logs.

* Use colors instead of [ignore] and [update] labels.

* Remove `colors` dependency.

* Use `chalk` to colorize logs.

* Print filename before `format` and add duration info later.

* Print filename before read error.
2017-02-07 14:03:48 -05:00
James Long f8f0b340e0 Update lockfile 2017-01-24 18:18:36 -05:00
Michał Pierzchała 66fe2f78fa Validate user-provided config with jest-validate (#301)
* Validate user-provided config with jest-validate

* Don't use object shorthand

* Update jest-validate to 18.2

* Fix Node4 destructuring from require

* Make use of jest-validate for deprecation message

* Remove chalk reference
2017-01-23 16:33:58 -05:00
Christopher Chedeau 93c8270eee Update yarn.lock 2017-01-23 09:16:47 -08:00
Simon Lydell bb1884320b Use babel-code-frame for syntax errors (#367)
* Use babel-code-frame for syntax errors

* Support the `--color` option more explicitly

* Update rollup config to handle babel-code-frame

* Use exact dependencies
2017-01-23 09:10:51 -08:00
Simon Lydell 6b3d3bc066 Add glob support to the CLI (#363)
* Add glob support to the CLI

Fixes #145. Fixes #362.

* Update README.md regarding globs

* Use exact dependency for glob
2017-01-23 10:37:57 -05:00
Henry Zhu 237e6f44bc Use a Symbol instead of the private dep (#359) 2017-01-20 15:55:24 -08:00
Christopher Chedeau e4b5aaade2 Fix docs (#307)
It doesn't compile cleanly anymore:
- esutils checks for Buffer.isBuffer without ensuring that Buffer exists.
- for version, we require a json file, need a rollup extension for that.

I no longer hardcode the version number.

Note: we need to merge this pull request after we have done the release so that the version number is correct and need to rebuild the minified version in a subsequent commit.
2017-01-18 14:24:42 -08:00
Christopher Chedeau fadbbeb4ea Use exact versions in package.json (#291) 2017-01-18 12:48:04 -05:00
Christopher Chedeau 60af75b37b Update flow-parser to 0.38 (#290) 2017-01-18 12:35:42 -05:00
James Long 3713408871 Update live editor to 0.0.6 2017-01-13 15:40:22 -05:00
Henry Zhu 1b5c7b3a03 remove recast (not used) 2017-01-11 14:32:33 -05:00
Henry Zhu eabc4005ce update yarn.lock 2017-01-11 14:30:23 -05:00
Mateusz Zatorski ccf6f846f0 add travis config and add yarn support 2017-01-11 15:52:51 +00:00