Commit Graph

386 Commits (master)

Author SHA1 Message Date
Ika 49e2f77bff
refactor: extract options-normalizer/validator (#5020)
- Uses [`vnopts`](https://github.com/ikatyang/vnopts#readme)
- This way it should be easier to support language-specific options (https://github.com/prettier/prettier/pull/4798#issuecomment-407258477) and map the common options to language-specific options using [`forward`](https://github.com/ikatyang/vnopts#forward), e.g. `singleQuote: true` -> `"javascript/singleQuote": "js"`, `singleQuote: false` -> `"javascript/singleQuote": "none"`.
2018-08-31 11:26:07 +08:00
Ika 82a12a58a8
fix(config): better error message for unsupported extension (#4969) 2018-08-11 16:35:18 +08:00
Ika 26fd292ece Bump Prettier dependency to 1.14.2 2018-08-09 11:05:58 +08:00
Ika 3842cbb118
fix(typescript): use the first error when both failed (#4947) 2018-08-09 10:21:00 +08:00
Ika 4fb2070244 Bump Prettier dependency to 1.14.1 2018-08-09 00:38:53 +08:00
Brian Ng 1391891ef6 Print ObjectTypeInternalSlot with both flow/babel parsers (#4869)
* Print ObjectTypeInternalSlot with both flow/babel parsers

* chore: update to flow-parser@0.78.0

* test: update snapshot
2018-08-08 09:21:39 -06:00
Ika 308863e061
fix(typescript): no invalid output for ImportType in TypeReference (#4939) 2018-08-07 18:53:11 +08:00
Jorge Gonzalez 7d78ce68ef feat(config): support TOML configuration files (#4877)
* Add initial support for TOML in configuration files

* Missed brace

* Fix snapshots

* refactor: move loadToml to utils

* Use @iarna/toml

* Add tests for loadToml

* Fix test for CI

* Remove jest-extended

* Create snapshot for load-toml

* Add feat to docs

* lint docs

* Use @iarna/toml/parse-string

* Change path string
2018-08-03 06:27:19 -04:00
Ika 42ba638f37
fix(yaml): update parser (#4931)
* test: add tests

* fix(yaml): update parser
2018-08-03 15:10:26 +08:00
Brian Ng 1597578b05
Bump babel-parser (#4910) 2018-08-02 22:19:21 -05:00
Ika b6077e175e
fix(yaml): end comment in nested mapping (#4918)
* test: add tests

* fix(yaml): end comment in nested mapping
2018-08-02 22:38:16 +08:00
Ika 440ab4f60b
refactor: upgrade to cosmiconfig@5 (#4899)
* refactor: upgrade to cosmiconfig@5

* fix: use custom require
2018-07-29 16:57:36 +08:00
Ika 514fcb835a chore: bump Prettier dependency to 1.14.0 2018-07-29 15:44:21 +08:00
Ika 1c33224117
fix(typescript): support jsx spread child (#4885)
* fix(typescript): support jsx spread child

* chore(deps): update to use typescript-eslint-parser@17.0.0
2018-07-26 22:13:32 +08:00
Ika cb7fe00863
fix(yaml): support end comments (#4854) 2018-07-18 09:37:53 +08:00
Ika b1c0c8c8d6
refactor(typescript): remove unnecessary experimental types (#4819)
Ref: eslint/typescript-eslint-parser#429
2018-07-10 10:05:31 +08:00
Jed Fox dc362c212d
Report test summaries to CircleCI (#4704)
* Report test summaries to CircleCI

* Don’t run jest-junit on Node <6

(it uses default function parameters)

* Address @lydell’s comment

* Use @duailibe’s suggestion

* 🔥 `jest-junit` key in production package.json

* Move config to jest.config.js
2018-07-07 12:11:04 -04:00
Ika 2271992446
feat(json): add jsonc to aliases and use it to find parser in markdown embed (#4734) 2018-07-07 20:46:34 +08:00
Simen Bekkhus e25021711d Upgrade to Jest 23 (#4809) 2018-07-04 16:54:39 -03:00
Ika 432c9d7d04
feat(yaml): support proseWrap (#4742)
- support `proseWrap` in `yaml`
- move `proseWrap` to `commonOptions`
- update to `yaml@1.0.0-rc.4` and `yaml-unist-parser@1.0.0-rc.1`
2018-07-04 00:28:47 +08:00
Simen Bekkhus 51b7c02e12 Upgrade jest to 22 (#4782)
* chore: upgrade Jest

* chore: update snapshots

* chore: lock down babel dependency using invalid syntax

* 2 args to test.skip

* use jest 22 for now

* Revert "2 args to test.skip"

This reverts commit 691fdc3f99e320f2303958f2b503f7b4c93fa455.

* remove snapshot name from matcher

* fix standalone tests skips
2018-07-03 03:06:29 -03:00
Ivan Babak b9fb113b3b feat(benchmark): add options to measure performance (#4776) (#4789)
- `--debug-benchmark` uses `benchmark` module to produce statistically significant time measurements.
- `--debug-repeat` uses a naive loop and measures just the average run time, but useful for profiling to highlight hot functions.
2018-07-01 19:49:16 -07:00
Simen Bekkhus d450882289 chore: dedupe dependencies in lockfile (#4781)
I had this lying in my tree when I looked at maybe upgrading Jest. So why not open up a PR with it 🙂 

This is `yarn-tools fix-duplicates` followed by `yarn`.

https://www.npmjs.com/package/yarn-tools
2018-06-30 20:13:26 +08:00
Ika 50d242d085
feat(typescript): support TSOptionalType and TSRestType (#4757)
Ref: Microsoft/TypeScript#24897
2018-06-30 09:10:56 +08:00
Ika e10c31a333
fix(typescript): update typescript-eslint-parser (#4762) 2018-06-29 19:27:21 +08:00
Lucas Duailibe e765d31f8f Release 1.13.7 2018-06-28 16:26:15 -03:00
Ika 0b659b898d
feat: update linguist languages (#4741)
Context: https://github.com/prettier/prettier/pull/4734#issue-196702272

Languages should be easy to maintain now.
2018-06-28 08:24:02 +08:00
Lucas Duailibe 1baddf27f2 Bump Prettier dependency to 1.13.6 2018-06-25 10:59:37 -03:00
Ika 652628b6c9 chore: update lockfile
reflect changes in #4733
2018-06-23 15:26:50 +08:00
Ika f53b5b8323
fix(options): inferParser for standalone (#4721) 2018-06-22 12:43:44 +08:00
Rubén Norte cbef0105e9 Upgrade flow-parser to 0.75.0 (#4727)
* Upgrade flow-parser to 0.75.0

* Added failing test for optional catch binding and flow-parser@0.74.0
2018-06-21 10:50:54 -07:00
Ika dcf44ffbdc
feat: support YAML (#4563)
* feat: support YAML

* fix: do not indent sequence in mappingValue

* docs: add yaml to index.md

* fix: reduce `SyntaxError: Node#parse consumed no characters`

* chore: remove old-build and new-worker.js

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* fix: no space after `<<`

* fix: add yaml to standalone test

* test: add tests

* fix: next empty line in flow collection

* fix: tabs are not allowed
http://yaml.org/spec/1.2/spec.html#space/indentation/

* fix: update parser

* feat: rewrite the mappingItem logic
* feat: indent sequence in mapping
* feat(doc): add ifBreak#groupId and group#id

* chore: fix node 4

* chore: add tools_yaml.svg

* chore: remove resolved TODO

* refactor: remove unnecessary workaround

* chore(worker): importScriptOnce

* chore(build): rename with babelPlugins

* make it rollup compatible

* feat: support singleQuote

* refactor
2018-06-21 10:29:42 +08:00
Lucas Duailibe 9ec1da1ad1
[internal] Cache build results (#4693) 2018-06-18 15:16:40 -03:00
Lucas Duailibe 78ac229956
Transpile webpack generated bundles (#4689) 2018-06-13 17:23:33 -03:00
Brian Ng 3e0dceda99
flow-parser@0.74.0 (#4649) 2018-06-09 17:03:50 -05:00
Ika 98bfd03d93
feat(typescript): support unknown type (#4625) 2018-06-10 00:12:30 +08:00
Lucas Duailibe 6d42fd12e4 Bump Prettier dependency to 1.13.5 2018-06-08 15:06:04 -03:00
Ika f27f6c525b
fix(typescript): preserve decorator on interface (#4632) 2018-06-05 00:08:24 +08:00
Ika ae6abe4d8c chore: bump own prettier to 1.13.4 2018-06-01 20:02:28 +08:00
Lucas Duailibe 16da7d3a76 Bump own Prettier to 1.13.3 2018-05-30 15:04:20 -03:00
Lucas Duailibe 68f594414e Bump own Prettier to 1.13.2 2018-05-29 09:49:47 -03:00
Lucas Duailibe 9da80415f4 Bump own prettier dependency 2018-05-27 15:22:34 -03:00
Brian Ng d20d9c160e
Switch to @babel/parser (#4544)
We landed a change that added a new `InterpreterDirective` AST node type for hashbangs, and no longer add it as a comment/leadingComment.

Ref: https://github.com/babel/babel/pull/7928

I mimicked what we do in `@babel/generator` here, since I found it better than trying to add comments to the ast in `parser-include-shebang.js`). Definitely open to a better/cleaner option though!

Note: I'll follow this up with enabling tests for https://github.com/prettier/prettier/pull/4543 and https://github.com/prettier/prettier/pull/4540 once they land too.
2018-05-25 11:27:41 -05:00
Lucas Duailibe 174a7736c1
[build] Always transpile everything (#4548) 2018-05-25 12:47:01 -03:00
Brian Ng e42db35427
Add support for flow inline interfaces (#4543)
Flow commit: 4f93f3adb7

Babel commit: https://github.com/babel/babel/pull/7973

Will follow up w/ flow team on making `InterfaceType` -> `InterfaceTypeAnnotation`, since it seems a bit inconsistent.
2018-05-25 09:17:43 -05:00
Christopher Chedeau 8f141bfafe
Update babylon & flow (#4536)
* Support new node types for optionals

* Update babylon

* Fix decorator tests

* fix manual errors

* Update flow

* pretty print

* enable option for flow to support ??

* fix AST_COMPARE=1

* fix lint and explicitly test 1_2_3 syntax for flow
2018-05-24 13:06:33 -07:00
Lucas Duailibe 52a2a46b3c
New build system (#4449) 2018-05-24 15:30:45 -03:00
Lucas Duailibe 983202413c
Refactor frontmatter handling (#4482) 2018-05-14 22:17:15 -03:00
Alexander Kachkaev 7345a38e64 Fix plugin API in globally installed Prettier and introduce optional --plugin-search-dir (#4192)
* Fix plugin API in globally installed Prettier and introduce optional --plugin-search-dir

* Use find-parent-dir instead of find-up and test autoloading (with mocked fn)

* Add two test cases where --plugin-search-dir is not .

* Do not mutate pluginSearchDirs argument in load-plugins.js

* Do not test automatic plugin resolution as mocking of "find-parent-dir" does not work due to rollup

* Document --plugin-search-dir / pluginSearchDirs and improve spacing

* Address @ikatyang's review comments

* Fix require path for third-party

* Undo alphabetic sorting of third-party scripts
2018-05-09 19:17:12 +08:00
Elias Meire 5b7ebb18ba Fix: Always preserve frontmatter, remove dependency (#4392)
* Fix: Always preserve frontmatter, remove dependency

* Move correct test to correct filename

* Add test for malformed frontmatter, finetune regex

* Use other malformed test case

* Update yarn.lock
2018-04-28 08:53:30 -03:00
Ika 643e2a83d6 feat(typescript): support TaggedTemplateExpression typeParameters (#4353)
* test: add tests

* feat(typescript): support TaggedTemplateExpression typeParameters

* fix(playground): `buffer is not defined` in `--parser typescript`

* chore(deps): update typescript-eslint-parser
2018-04-24 08:45:06 -05:00
Brian Ng 7cb6790ce0
Merge pull request #4326 from existentialism/flow70
Bump flow to 0.70
2018-04-18 17:04:14 -05:00
Stephen Scott ad318f6f36 1.12.1 2018-04-16 20:45:29 -06:00
Brian Ng e22ec0b9b9
Bump flow to 0.70 2018-04-16 20:53:07 -05:00
Suchipi Izumi bdc5e0073d Bump own prettier dependency to 1.12.0 2018-04-11 22:39:13 -06:00
Lucas Duailibe 46c8a4cd9d
Move sw-toolbox to `website` dependencies (#4297) 2018-04-11 11:38:48 -03:00
Christopher Chedeau 7819a8f010
[flow] Upgrade flow to 0.69 and enable ?. support (#4296)
Flow now support ?. so this PR enables it in prettier
2018-04-10 18:03:34 -07:00
Evilebot Tnawi d676188dbb
chore(deps): update `html-tag-names` package (#4242) 2018-04-02 16:25:29 +03:00
Evilebot Tnawi 76cb653347
chore: update `postcss-scss` and `postcss-less` (#4237) 2018-04-02 12:50:48 +03:00
Evilebot Tnawi f2f2390114
fix: inline comments in lists and maps (#4205) 2018-03-31 17:18:23 +03:00
Rui Araújo 9da8752585 Allow new interface style for GraphQL. (#4012)
* Allow new interface style for GraphQL.

This is a breaking change since it will upgrade the old style to the new one.

Closes #3600.

* Allow old interface style.

When in present of mixed style, it updates to the new one.
2018-03-27 00:52:57 -06:00
Wang Zhongliang 67277f7477 feat(typescript): support TSMinusToken 2018-03-16 10:46:12 +08:00
Lucas Duailibe bb1c354453 Update yarn.lock 2018-03-08 10:44:30 -03:00
Lipis 6fea2f4745
chore: Upgrade some dependencies (#4104) 2018-03-05 21:52:26 +02:00
Evilebot Tnawi 19d7d881a7
chore: update `postcss-scss` to latest version (#4084) 2018-03-01 21:00:51 +03:00
Stephen Scott 6f6d974d27 Bump own prettier dependency version to 1.11.1 2018-02-28 15:26:27 -07:00
suchipi 74a132c4ba
Bump own prettier dependency version to 1.11.0 (#4058) 2018-02-26 22:03:56 -07:00
Zhongliang Wang d18da53e87 feat(typescript): Support conditional types (#4007)
* feat(typescript): support for conditonal types

* refactor(js): reuse conditional expression logic

* chore(typescript): update snapshot for typescript conditional type test suite

* chore(js): make code support Node 4

* chore(js): rename utility functions

* chore(js): add comments for formatTernaryOperator

* fix(ts): support infer keyword

* chore(js): new line

* chore(js): improve readablity a little bit
2018-02-23 12:34:23 -07:00
Ika 8f6a32853c
feat(typescript): support definite assignment (`!:`) (#4020) 2018-02-22 01:40:57 +08:00
Ika 4a4bd2faed
fix(typescript): support `unique symbol` (#3967)
* test(typescript): add failing test

* chore(deps): update typescript-eslint-parser to v13.0.0

* fix(typescript): support `unique symbol`
2018-02-14 01:03:53 +08:00
Evilebot Tnawi 17c0f9bfe1
feat(css): lowercase html tags (#3954) 2018-02-13 18:41:55 +03:00
Evilebot Tnawi c30d28003b
chore(css): update `postcss-values-parser` to latest version (#3960) 2018-02-12 20:46:54 +03:00
Lucas Azzola f87cbcf76e
Bump jest-docblock to 22.2.2 (#3947) 2018-02-11 17:42:08 +11:00
Christopher Chedeau 9ba0d69cb9
Upgrade flow to 0.64 (#3899)
* Upgrade flow to 0.64

This also enables spread operator on jsx on the flow parser:

```js
<div>{...list}</div>
```

I had no idea it was even a thing.

I had to comment out a flow test that no longer parses, but it's no longer in the flow repo and the comment said that it shouldn't be working anyway so I don't think it's going to be a problem.

* Fix build script
2018-02-06 09:01:58 -08:00
Evilebot Tnawi f5e74cd70a
fix(css): at rules improve formatting and tests (#3828) 2018-02-02 18:06:47 +03:00
Ika 84c603623d
feat: support external options (#3775)
* refactor: wrap

* refactor: replace

* refactor: replace

* refactor: replace

* refactor: extract

* refactor: logger

* refactor

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* feat(support): add `showInternal` option

* refactor: use internal

* refactor

* refactor: extract

* refactor: extract

* refactor

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: reorder

* refactor: remove unnecessary

* refactor: reorder

* refactor: move

* refactor

* refactor

* refactor

* refactor: remove unnecessary

* feat: external options from CLI

* refactor: push/pop plugins

* feat: external options from config file

* refactor: remove unnecessary

* refactor

* refactor

* refactor

* fix: use `json-stable-stringify`

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: move

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: move

* refactor: extract

* docs: add comments

* refactor: sort

* refactor: sort

* refactor: rename

* refactor: remove unnecessary

* style: remove trailing whitespace
2018-01-28 00:24:25 +08:00
Evilebot Tnawi a3bf378259
fix: handle YAML front matter block (#3802) 2018-01-24 19:44:09 +03:00
Ika 08b9e07207
fix(markdown): update remark-parse to v5.0.0 (#3780)
* fix(markdown): update remark-parse to v5.0.0

* test(markdown): ensure links with entities printed correctly

* test(markdown): ensure lists  interrupted by headings
2018-01-21 12:31:30 +08:00
Ika dc26445e51
refactor(options): use supportOptions to generate CLI options (#3622)
* refactor(cli-constant): use supportOptions

* refactor(options): use supportOptions

* refactor(cli-util): use supportOptions

* fix: do not infer parser in multiparser

* chore: remove unnecessary package

* chore: trigger another travis build

* test: add kebab-case test to ensure no regression

* test: update snapshots
2018-01-18 15:26:27 +08:00
Lucas Azzola dd78f31aaf
Run production tests on npm package (#3730)
* Run production tests on npm package

* Put back fast finish
2018-01-13 03:19:20 +11:00
Lucas Duailibe d0d5845af1 Bump prettier's prettier to 1.10.2 2018-01-11 00:04:30 -02:00
Lucas Azzola a10418ee80
Bump Prettier to 1.10.1 (#3699)
* Bump Prettier to 1.10.1

* Fix relative paths
2018-01-11 01:13:09 +11:00
Lucas Azzola e5d6a4704f
Automatically load plugins from package.json (#3624)
* Automatically load plugins from package.json

* Fix build by adding json extension

* Fixup misuse of options argument

* Rewire graceful-fs to fs

* Document graceful-fs issue

* Alias graceful-fs to fs in Rollup
2018-01-05 21:09:51 +11:00
Christopher Chedeau 58e5536741
Update GraphQL parser (#3605)
* Update GraphQL parser

Fixes #3601

This adds support for
- description as strings
- extending all the possible types
- block strings
- allow removing {} if there's no implementation for all graphql types

This is a breaking change but shouldn't be a big issue.
- Empty types are no longer allowed (there's an option to enable it but it hasn't been released yet). The fix is to remove `{}`

Something that hasn't been changed because not released:
- Doesn't support the new `&` separator for implementing multiple interfaces

A bug has been fixed:
- Now properly prints @directives for unions.

* Properly handle triple quotes
2017-12-31 16:45:06 +01:00
Ika 6c0dd74518 feat(support-info): add `options` field (#3433)
* refactor: rename supportTable with supportLanguages

* refactor: use `dedent`

* test: reduce unnecessary data

* feat(support-info): add `options` field

* add `showDeprecated` option
* add `showUnreleased` option

* test: snapshot diff

* fix(support): add missing `since`

* fix: add missing `category`

* refactor: use template tag

* fix: `trailingComma:true` should redirect to `trailingComma:es5`

* refactor: reorder parser

* refactor: fix linting

* refactor: move options

* refactor: move options to printers
2017-12-31 15:34:37 +11:00
Robert Webb 833666a394 Support handlebars (#3534)
* feat(glimmer): initial HTML/Handlebars/Glimmer support

* feat(glimmer): support un-escaped mustache expressions

* fix(glimmer): add 'as |foo|' syntax

* fix(glimmer): support {{foo bar}} syntax

* feat(glimmer): implement all AST types

* feat(glimmer): implement if/else if/else

* test(glimmer): ignore leading/trailing whitespace from AST_COMPARE

* fix(glimmer): do not use trailing slash for void self-closing elements

* chore(build): disable html tests until we can sort out the glimmer dependency

* feat(html): complete rebase on parse5 addition

* Prettier Support For Glimmer VM/Handlebars

Polished Support for Sub Expressions
Added test cases for glimmer primitives
Added support for concat statements
Attempted to make element nodes work
Attempted block statements
Element Nodes are OK
Added support for block elements that are not else-if related
Added support for Else/If
Cleaning up
Rebase
Switch node 4 syntax
Update build

* Removed dead code/partials

* Added new lines to end of test files.

* Rebase after plugin change

* Added ignores to code coverage
2017-12-29 18:14:31 +01:00
Lucas Azzola 84dd11e875
Bump TypeScript to 2.7-insiders (#3580)
* Bump TypeScript to 2.7-insiders

* Update yarn.lock
2017-12-27 09:06:59 +11:00
Joseph Frazier 7b211eab24 editorconfig: Only search for .editorconfig up to the VCS directory (#3559)
* editorconfig: Only search for .editorconfig up to $PWD

This addresses https://github.com/prettier/prettier/issues/3558

I'm not sure if this is the best way to find the "project root", but it
seems better than before.

* editorconfig: Search for `.editorconfig` up to the VCS directory

This uses [find-project-root] to find the nearest directory containing `.git` or `.hg`

See here for context: https://github.com/prettier/prettier/pull/3559#issuecomment-353756948

[find-project-root]: https://github.com/kirstein/find-project-root

* editorconfig: Add test for finding VCS directory

It's a little hacky in that the .hg file isn't really a Mercurial
repository, but it's enough to illustrate the intent. See here for
context: https://github.com/prettier/prettier/pull/3559#issuecomment-353857109
2017-12-26 18:16:09 +11:00
Lucas Azzola 4c9d4061da
Prettier Plugin API (#3536)
* Move files around in preparation for refactor

* Update paths in build script

* Extract generic printing logic from the JavaScript printer

* Conform printer API

* Fixup decorator handling

* Fix multiparser

* Create plugin entry for markdown

* Create plugin entry for javascript/typescript

* Create plugin entry for html

* Create plugin entry for graphql

* Create plugin entry for css/less/scss

* Move JSON to JS plugin entry

* Integrate plugins into getSupportInfo()

* Move astFormat to parser definition

* Move util to common

* Implement parser loading

* remark -> mdast

* Rename cli/cli -> cli/index

* Rename builder -> doc package, fix printer resolution

* Fix doc shape assumption in CSS-in-JS logic

* Fix third-party.js prod resolution

* Fixup build-docs script

* Distribute multiparser code

* Remove requirement to forward options

* Flatten closure

* Remove debug directory

* Expose doc

* Add external plugins

* Pass options to loadPlugins

* Export getParsers

* Pin resolve version

* Use getSupportInfo in Markdown embed

* Document plugin API

* Update build-docs

* Add CLI for plugins

* Lint docs

* Fixup build.js

* Add vue language

* Fixup multiparser for vue

* Upgrade rollup and rollup-plugin-commonjs

* Fixup third-party build

* Change AST format in docs
2017-12-26 12:23:50 +11:00
Simen Bekkhus 36727421c2 chore: use scoped babel package (#3529) 2017-12-20 19:36:33 +11:00
Lucas Azzola 5e81e75601
Add plugin:prettier/recommended (#3508)
* Add plugin:prettier/recommended

* Revert eslint-plugin-prettier docs changes
2017-12-18 08:39:31 +11:00
James Henry 5feb76f13f Update tsep to v11 and update snapshot (#3471)
* Update tsep to v11 and update snapshot

* Remove unneeded TSNamespaceFunctionDeclaration
2017-12-14 17:44:59 +11:00
Lucas Duailibe 4090bd6303 Update prettier's prettier to 1.9.2 2017-12-12 01:55:44 -02:00
James Henry dc91108453 Update tsep and apply breaking changes (#3455) 2017-12-12 01:20:54 -02:00
Joseph Frazier 4f24892e53 Treat absent .editorconfig correctly (#3439)
This fixes https://github.com/prettier/prettier/issues/3432, I think.
2017-12-08 09:03:49 +11:00
Lucas Duailibe 36c6e8368f
Bump prettier to 1.9.1 (#3416) 2017-12-05 21:56:49 -02:00
Lucas Duailibe c34608f8ed
Bump editorconfig-to-prettier (#3412) 2017-12-05 19:01:48 -02:00
Lucas Azzola c7c1d2e7a4 Upgrade Prettier to Prettier 1.9 (#3395)
* Upgrade to prettier@1.9.0

* Run eslint --fix

* Run prettylint --fix

* Fix playground with editorconfig script
2017-12-05 08:14:03 -02:00
Joseph Frazier cecf0657a5 Re-add EditorConfig support (undo #3213) (#3255)
* Revert "Revert "Respect EditorConfig settings" (#3213)"

This reverts commit d2241fc0d5.

* Comment out EditorConfig docs

See https://github.com/prettier/prettier/pull/3213#issuecomment-343009769

* editorconfig: Support `indent_size = 0`

See https://github.com/prettier/prettier/pull/2760#discussion_r137447715
and c38b84c42a

* Revert "Comment out EditorConfig docs"

This reverts commit ddfa529c55cac4853a1e76e00c8b5e3ef158c01f.

* Mark EditorConfig functionality as v1.9.0+

See https://github.com/prettier/prettier/pull/3255#discussion_r150432508

* editorconfig: Upgrade editorconfig-to-prettier to 0.0.4

* editorconfig: Only enable for CLI, by default

https://github.com/prettier/prettier/pull/3255#issuecomment-348420546

* editorconfig: Add tests confirming that editorconfig is ignored by default in the API

https://github.com/prettier/prettier/pull/3255#issuecomment-348420546

* editorconfig: Add/fix CLI option parsing

* editorconfig: Move docs from configuration.md to options.md

* editorconfig: Add `oppositeDescription` to show docs for `--no-editorconfig`

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154542792

* editorconfig: Update test snapshots

* editorconfig: Remove unnecessary options parsing code

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154544560

* editorconfig: Move docs from options.md to api.md and cli.md

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154545979

* resolveConfig: return null if both .prettierrc and .editorconfig are missing

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154574613

* Don't add now-failing tests

The way these tests work, both `tests_integration/cli/config/.prettierrc`
and `.prettierrc` apply to `tests_integration/cli/config/editorconfig/file.shouldnotexist`,
so the test wouldn't work even on master. Here's a way to confirm that:

```js
const path = require('path')
const assert = require('assert')
const prettier = require('./')

const file = './tests_integration/cli/config/editorconfig/file.shouldnotexist'
console.log(prettier.resolveConfig.sync(file))
assert(prettier.resolveConfig.sync(file) === null)
```
2017-12-05 09:28:27 +11:00
Lipis 475b2ab630 chore: Update packages to the latest patches (#3377) 2017-12-04 13:28:56 -07:00
Brian Ng d52d721cd1 Bump babylon to 7.0.0-beta.33 (#3372) 2017-12-02 09:39:10 +11:00
Lucas Duailibe b2cca7eacc
Add support for JSX fragments (#3237) 2017-11-30 00:09:45 -03:00
Lucas Duailibe a778667a4f Bump typescript-eslint-parser 2017-11-29 18:27:19 -03:00
Lucas Duailibe d8f54b0f13 Use released version instead of insiders 2017-11-28 10:06:28 -03:00
Lucas Duailibe 2953ad0d03 Bump versions 2017-11-26 23:23:09 -03:00
Lucas Duailibe f9f056612f
Update flow to 0.59.0 (#3238) 2017-11-26 23:14:45 -03:00
Ika 76efb33e75 chore: setup markdown formatting (#3224)
* chore(deps): upgrade prettier to v1.8.2

* chore: setup lint-docs script

* docs: add `<!-- prettier-ignore -->`s

* docs: format docs

* Revert "docs: format docs"

This reverts commit 6dba903987dddc498cb589ca311905f25b6aee53.

* chore(prettierrc): set `--no-prose-wrap`

* docs: format docs

* Revert "docs: format docs"

This reverts commit 139bd744b6921916be8fac4fa3bab83bae5d12df.

* docs: tweak

* docs: format docs

* chore: rename .prettierrc

* chore: rename back to .prettierrc

* chore: split out third-party

* refactor: fix linting

* chore: do not split out third-party on website
2017-11-22 22:27:40 +11:00
Ika d08df0b221
fix(markdown): handle punctuation variants (#3254)
* fix(markdown): handle punctuation variants

* docs: add comment
2017-11-13 00:09:04 +08:00
Lucas Azzola d2241fc0d5
Revert "Respect EditorConfig settings" (#3213)
* Revert "Respect EditorConfig settings (#2760)"

This reverts commit 8f58ca0f48.
2017-11-09 11:38:58 +11:00
Joseph Frazier 8f58ca0f48
Respect EditorConfig settings (#2760)
This fixes https://github.com/prettier/prettier/issues/42.
It adds support for .editorconfig's `indent_style`, `indent_size`, `tab_width`,
and `max_line_length` properties.

It doesn't support the `end_of_line` property as described in
https://github.com/prettier/prettier/issues/42#issuecomment-327073326,
but that could be added later. The same goes for `quote_type`
(https://github.com/prettier/prettier-atom/issues/293#issue-267288335).

* Make test .prettierrc not set config for all file extensions

This makes it easier to keep tests isolated.
2017-11-08 14:30:28 -05:00
Ika 76ee59a191
chore(deps): update prettier to 1.8.0 (#3167)
* chore(deps): update prettier to 1.8.0

* refactor: fix linting
2017-11-07 16:42:38 +08:00
Lucas Azzola 71a5533c4e
Move all docs to website (#3139)
* Sync README -> docs/options.md

* Sync README -> docs/*.md

* Misc fixups

* Remove markdown-toc

* Remove insert-pragma from ToC

* Never again!

* Move all docs to ./docs

* Remove yarn toc

* Fix inter-doc links

* Fix links in footer

* Clean up README.md

* Add basic description to README.md

* Use flat badges

* Move editor guides to website

* Improve prettier-ignore docs

* Fixup bad find/replace

* Add JSON to README

* Fix custom parser API link

* Fixup GitHub centering, add downloads badge

* Add 1.8 docs

* docs(website): mention markdown on homepage (#1)

* Add intro

* Add watching-files.md

* Fix markdown syntax highlighting

* Switch back to .md links
2017-11-07 14:39:07 +11:00
Ika 1d4848b37c chore(deps): upgrade patch-level dependencies (#3153)
* chore(deps): update jest-docblock to 21.3.0-beta.7

* chore(deps): upgrade patch-level dependencies

* test: update snapshot
2017-11-07 00:38:37 +11:00
Brian Ng d90aec1a1d Add test for nested ternary with arrow func (#3039) 2017-10-16 09:09:57 +11:00
Ika c27cc7ff45 feat(markdown): support CJK and emoji (#3026)
* refactor: extract `splitText`

* fix: respcet CJK width in table

* test: add failing test

* fix: support emoji

* test: add failing test

* feat: support CJK character

* feat: enable adding whitespace between non-CJK/CJK-character by default

* fix: do not print softline at node that is sensitive to its identifier

* fix: treat full-width whitespace as CJK punctuation

* disallow leading/trailing full-width whitespace

* feat: remove `--split-cjk-text` option and enable it by default

* refactor: simplify regex and remove unnecessary `g` flag
2017-10-14 23:57:31 -05:00
Ika f009a96ae4 fix(doc-printer): use `string-width` (#3015)
* refactor(doc-printer): use `string-width`

* test: add test case
2017-10-12 02:27:02 -05:00
Ika 9f6f3e7355 feat: support markdown (#2943)
* feat(markdown): inital implementation

* feat(markdown): support strong

* fix: add missing default value

* feat(markdown): support inlineCode

* feat: support delete

* feat: support link

* feat: support image

* feat: support blockquote

* feat: support heading

* feat: support code

* feat: support yaml

* feat: support html

* feat: support list

* feat: support thematicBreak

* feat: support table

* feat: support linkReference

* feat: support imageReference

* feat: support definition

* feat: support footnote

* feat: support footnoteReference

* feat: support footnoteDefinition

* test(cli): update snapshots

* refactor: extract SINGLE_LINE_NODE_TYPES

* refactor: printChildren

* fix: correct newlines

* test: add trailing newline

* fix: blockquote formatting

* fix: node types

* fix: break line correctly

* fix: remove unnecessary properties to make AST_COMPARE happy

* fix: escape `|` in tableCell content

* fix: unexpected line break

* fix: ast difference from loose list

* fix: html break lines

* refactor: fix linting

* fix: normalize ast

* fix: escape specific chars

* test: add more tests

* fix: build markdown parser

* chore: remove unnecessary *.log

* fix: escape html entity

* feat: support prettier-ignore

* fix: line break for non-loose listItem

* feat: support formatting `code` based on `lang`

* fix: add `jsx` and `tsx`

* fix: use multiparser

* refactor: fix linting

* test: update test case 😉

* feat: switch to `_` style emphasis

* fix: sequence list should use different prefix

* test: add tests

* fix: do not print additional new line after `prettier-ignore`

* fix(list): enforce `1.` to avoid unnecessary git diff

* feat: enable `commonmark` option

* feat: support `break`
* fix: escape backslash
* refactor: escape html entity using backslash

* fix: respect autolink-style link

* feat: support md`...` and markdown`...`

* docs: replace ands with commas

* fix: respect indented code block

* fix: respect html entity

* docs: add docs for modified MDAST

* fix: inlineCode is breakline-able

* feat: support backtick in inlineCode

* feat: support a-lot-of-backtick in fenced code block

* feat: use `~~~`-style code block in js template

* fix: respect escaped chars

* fix: use `*`-style emphasis for invalid `_`-style output

* test: add test cases

* fix: use `- - -`-style thematicBreak to avoid conflict with yaml

* fix: remain the same content for linkReference identifier

* fix: `inlineCode` gap can be a line break

* fix: `html` should not print trailing spaces if it's in root

* refactor: fix typo

* fix: wrap `definition`'s url if there's whitespace

* fix: remove unnecessary whitespace at the end of paragraph

* fix: fix: remove unnecessary whitespace at the start of paragraph

* fix: setence children length is possible 0

* fix: support continuous ordered list

* fix: do not print addtional hardline after loose list

* fix: use double-backtick style for single-backtick value in inlineCode

* fix: support nested emphasis

* fix: support space-url in link/image

* fix: escape `)` in link/image url

* fix: support single-quote in link/image/definition title

* fix: respect alt in image/imageReference

* fix: use `*`-style thematicBreak in list

* fix: loose/tight list linebreaks

* fix: print third linebreak before indented code block with a tight list in the previous

* test: move bug cases

* fix: remove unnecessary linebreaks

* refactor: fix typo
2017-10-12 09:46:44 +11:00
Ika f7907b9282 fix(doc-printer): respect CJK width (#3003)
* test: add failing test

* fix(doc-printer): respect CJK width
2017-10-11 00:32:45 -05:00
Marshall Bowers 445f51709e Fix indentation for JSDoc comments (#2470)
* Fix TypeScript comment snapshot

* Add failing test for TypeScript method comments

* Remove trailing space in comment

* Add snapshot for comment with many lines

* Add TODO marking potential location for comment re-indentation

* Update snapshot

* Indent comments based on the parent node

* Only adjust indentation if the comment looks like a JSDoc comment

* Only strip leading spaces when adjusting comment indentation

* Update snapshot

* Add test to show incorrect indentation based on parent node

* Update snapshot

* Update snapshot

* Update comment indentation to not rely on the parent node

* Extract code for getting the indent size

* Add test where the parent indentation changes as well

* Fix lint warning regarding lexical declarations within case block

* Update lockfile

* Update snapshot

* Add test case for block comment inside of a method

* Replace spread operator with `concat`

* Use `align` instead of `addAlignmentToDoc`

* Add test for mismatched indentation within JSDoc comment

* Always add a leading space to subsequent lines in a JSDoc comment

* Refactor JSDoc comment printing into a separate function

* Remove unneeded `align`

* Replace `forEach` with `map` for better style

* Only `trimLeft` when the end comment token is on the last line of the comment

* Remove unneeded `docBuilders`

* Add tests for JSDoc comments in JSX

* Update snapshots
2017-10-08 20:34:24 +11:00
Jake 50f3e646c7 Add option to insert @format to first docblock if absent (#2865)
* Add option to insert @format pragma if absent

prependPragma --> insertPragma

add tst dir, move stripBom, add to README, update snapshots

remove noise from test + update snapshots

use jest@test new functions, update docs, rerun snapshots

fix accidental upgrade to jest@test

update jest-docblock again to latest with strip()

updated snapshot

* updated snapshots

* revert jest dep change

* apply a trim to parsed comments

* remove empty object

* Revert "apply a trim to parsed comments"

This reverts commit 467f71ce5f4b4f8a1b5c4474ee0484bc96c92141.

* rerun snapshots with proper jest version

* pin jest-docblock to latest @test release

* comment out docs for new feature from readme

* remove leading newlines

* ensure blank line between docblock and rest of file

* remove backtick string
2017-10-06 19:37:14 +11:00
Ika d9737e6ffa test: fix snapshots (#2957)
* test: trigger test to check its status

* test: update snapshots

* refactor: use strip-ansi
2017-10-02 19:56:34 +02:00
Ika 26254ece0f chore(deps): pin dependencies (#2953) 2017-10-02 17:58:21 +02:00
Ika c7f9bb5731 chore(deps): update cosmiconfig to v3.1.0 (#2952) 2017-10-02 13:01:32 +11:00
Lucas Azzola 3329ee022f Upgrade prettier to 1.7.3 (#2940) 2017-09-30 14:28:53 +02:00
Simon Lydell 51d123b3f1 Update postcss-values-parser (#2928)
My PR has been merged and released to npm, so no need to depend on my
fork anymore.
2017-09-28 19:59:14 +02:00
Stephen Scott c2bc33b3ad 1.7.1 2017-09-27 11:00:29 -06:00
Lucas Azzola f77e471b0c Upgrade to ts2.5.3-insiders (#2842) 2017-09-27 15:43:17 +10:00
Ika 70f5165bb1 fix(typescript): allow symbol type (#2899) 2017-09-26 12:34:31 +10:00
Ika 4435ecbc7b fix(cli): validate options for every `config-precedence` (#2894)
* fix(cli): validate options for every `config-precedence`

* refactor: use camelcase

* refactor: reduce duplicate code

* refactor: rename function

* refactor: rename parameter
2017-09-25 21:04:25 +02:00
Ika 184e368a9a feat: support detailed `--help` (#2847)
* feat: support detailed --help

* refactor: put alias first, separate with comma

* feat: support detailed --help for --no-option

* docs: add missing type

* docs: remove `This requires node 8 or a transform`

* docs: remove config-precedence's choice descriptions in option.description

* docs: replace `option-name` with `flag`

* docs: update docs for `choices`

* docs: update `help` description

* docs: update error message

* docs: replace `undocumented` with empty string

* refactor: extract `getOptionDefaultValue`

* refactor: dynamically generate `defaults to ...`

* refactor: extract `getOptionWithLevenSuggestion`

* refactor: extract `createChoiceUsages`

* refactor: remove `optionTitleName`

* test: add `--help` tests for all options

* fix: handle `--help --help`

* feat: support `--help <alias>`

* refactor: use `flattenArray`

* feat: handle `--help <unknown>`

* docs: add description for `semi`, `color` and `bracket-spacing`

* fix: remove unnecessary option in `--help`
2017-09-21 07:54:13 +02:00
Daniel Tschinder eb776b7635 Update cosmiconfig to 3.0.1 to avoid memory leak (#2848) 2017-09-18 09:09:07 +10:00
Lucas Azzola 48899289da Upgrade cosmiconfig to v3, remove hardcoded combinatoric problem (#2843)
* Upgrade cosmiconfig to v3, remove hardcoded combinatoric problem

* Fix indendation change from 1.7

* Ensure default value for useCache is true

* Pin mem version
2017-09-16 20:24:08 +10:00
Joseph Frazier 2c59fb2f07 Upgrade prettier dependency to 1.7.0, fix lint (#2821) 2017-09-15 15:49:55 -04:00
Brian Ng 5bd8ca472b Bump Babylon (#2831) 2017-09-15 17:26:35 +02:00
Simon Lydell 1be06af923 Merge pull request #2814 from ikatyang/chore/jest-21
chore(deps): update jest-* to v21.1.0
2017-09-14 13:21:50 +02:00
Ika c100911bbc chore(deps): pin cosmiconfig (#2815) 2017-09-14 19:10:55 +08:00
ikatyang 6f9da6441c chore(deps): update jest-* to v21.1.0 2017-09-14 13:13:03 +08:00
Will Binns-Smith d5e5d66407 Add option to require @prettier or @format pragma (#2772)
* Add option to require @prettier or @format pragma

Fixes #2397.

Inspired by `eslint-plugin-prettier` and the discussion in #2397, this
implements requiring a special comment pragma to be present in a file's
first comment in order to be formatted.

This will help large codebases gradually transition to prettier over
time without tons of churn or large code reviews.

I implemented this as a standard prettier "option", not just a typical
`argv` flag, as it is relevant in both the cli and the api. This way it
can be provided programmatically, on the command line, or standardized
in a prettierrc file so like the style options, every user can use this
setting consistently and only apply prettier to relevant files, no
mattier their editor integration.

This requires the pragma begin with `@` (in fact it's inserted if the
user doesn't provide it). Currently the usage implies it must be
"prettier" or "format", but it can technically be any value other than
"none", which is similar to the `trailingCommas` option.

cc @vjeux

* Don't quote anything in runPrettier; this is usually handled by a shell

* Make --require-pragma a boolean option

* Use jest-docblock to find pragmas without parsing the ast

* Clarify docs

* includes -> indexOf

* Move test out of integration
2017-09-13 09:03:18 -07:00
James Henry 9c4ec68afd Fix: TypeScript never keyword (fixes #2718) (#2756) 2017-09-05 11:37:22 -07:00
Ika c1707cf40c chore(deps): remove `cross-spawn` (#2739) 2017-09-03 16:10:58 +02:00
Joseph Frazier a9520d31b1 Upgrade chalk to v2.1.0 (#2732)
This fixes a warning when installing prettier from github:

    warning prettier > chalk@2.0.1: Please upgrade to Chalk 2.1.0 - template literals in this version (2.0.1) are quite buggy.
2017-09-03 14:18:27 +10:00
Joseph Frazier b50946f59b Fix cosmiconfig dependency branch (#2731)
The `3.0` branch was [merged] and [deleted],
so we should use the default branch now.

[merged]: https://github.com/davidtheclark/cosmiconfig/pull/78#event-1232367869
[deleted]: https://github.com/davidtheclark/cosmiconfig/pull/78#event-1232367884
2017-09-03 10:47:28 +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
Levi Thomason 828a7b8f0d docs(readme): add and sort cli options (#2700)
* chore(build): auto generate toc

* docs(readme): add and sort cli options

* refactor(build): move toc to seperate task
2017-08-29 13:39:49 -07:00
Brian Ng 8bb8eaf941 Bump babylon to 7.0.0-beta.22 (#2687) 2017-08-29 09:11:32 +10:00
Joseph Frazier 82ad911ddc Upgrade prettier dependency to v1.6.0, fix lint (#2681) 2017-08-28 12:22:51 -07:00
Lucas Azzola 1e2da6c727 Support TypeScript 2.5 RC (#2672) 2017-08-26 05:36:50 -07:00
Simon Lydell 302d1d89cb Switch to postcss-values-parser with support for exponential notation 2017-08-22 18:50:10 +02:00
James Henry 23e0e90779 Update tsep and account for AST differences (#2647) 2017-08-21 12:27:35 -07:00
James Henry 5c539b06a4 Update: tsep version upgrade and changes to TS enum structure (#2641) 2017-08-19 11:10:38 -07: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
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