Commit Graph

1522 Commits (82257bc091b7d2ec0d4bfb36e3ea3a9329680cba)

Author SHA1 Message Date
Suchipi cb5e1db4a5
Revert "Ternary Operators in JSX Expression Containers (#4731)" (#4736)
This reverts commit 12046cd01b.
2018-06-22 10:32:38 -06:00
tyrerexus 12046cd01b Ternary Operators in JSX Expression Containers (#4731)
This pull request aims to fix the issue of excessive nesting brought up in the following comment: https://github.com/prettier/prettier/issues/737#issuecomment-392541493

This "fix" is very simple. It adds a new possible way to activate JSX mode for ternary operators. If the first non-conditional parent of the expression is a JSX expression container, then JSX mode gets activated.

This branch also contains a test case for said scenario.
2018-06-22 10:30:53 -06:00
David Gomes 9e0b1223cd Update postcss-scss parser version to 1.0.6 (with test for it). (#4733) 2018-06-22 13:42:15 +03: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
Ika b99de9811b
feat(graphql): support pragma (#4699) 2018-06-17 14:04:48 +08:00
Ika 4109abf4dd
feat(javascript): support BigIntLiteral (#4697) 2018-06-16 00:20:04 +08:00
Evilebot Tnawi 03a2002348
fix: newline between front-matter and comment (#4701) 2018-06-15 16:27:41 +03:00
Vojtěch Štěpančík 56af3d621d Add support for parsing babylons throwExpressions (#4695) 2018-06-14 21:35:39 -03:00
Ika f6890bd071
feat(css): support pragma (#4688) 2018-06-14 09:51:18 +08:00
Ika 5646573ad7
fix(javascript): preserve parens for type casting for sub-item (#4648) 2018-06-11 19:50:53 +08:00
Lynn Smeria 61d35dd636 fix(typescript): preserve type parameters of import-types (#4656) (#4662) 2018-06-11 11:29:10 +10:00
Ika 98bfd03d93
feat(typescript): support unknown type (#4625) 2018-06-10 00:12:30 +08:00
Lucas Duailibe d013983d8a
Always expand first argument if the second argument is also a call expression (#4657) 2018-06-08 15:16:12 -03:00
Lucas Duailibe cb1c52ad08
Break JSX in arrow functions in JSX expressions (#4601) 2018-06-08 15:15:50 -03:00
Ika 35a42bef24
fix(markdown): better handling for trailing spaces (#4593)
- preserve trailing spaces in html, excluding html comment
- `doc-printer` is now unrelated to `options.parser`
- fix some cases that two trailing spaces are mis-considered as `break`
2018-06-08 00:20:25 +08:00
Aakansha Doshi 8ec5432768 Fix empty file error in json and graphql (#4553)
* Fix empty file error in json and graphql

* fix AST_COMPARE=1 issue

* use tests/empty

* revert

* fix lint
2018-06-06 10:41:12 -03:00
Ika f27f6c525b
fix(typescript): preserve decorator on interface (#4632) 2018-06-05 00:08:24 +08:00
Lucas Duailibe a4da6e6c8e
Inline _ or $ in the root of a method chain (#4621) 2018-06-01 12:51:06 -03:00
Ika b55997eb3d
fix(multiparser): no additional trailing newline for graphql in js (#4616)
Fixes #4615

The root cause is the output doc from graphql printer does not match the desired input from `stripTrailingHardline`.

a9b21a01e2/src/doc/doc-utils.js (L167-L180)
2018-06-01 00:38:39 +08:00
Ika e74e6565b4
fix(markdown): respect blank line between block htmls (#4609)
Fixes #4605 

The AST here is actually two `html`s and it did follow the [CommonMark spec](https://spec.commonmark.org/0.28/#html-blocks), so I ended up with respecting the blank line between block `html`s.
2018-06-01 00:33:37 +08:00
Evilebot Tnawi 9387e9d833
fix: comment type for scss (#4598) 2018-05-30 23:22:18 +03:00
Ika 8abbc5d4b0
fix(javascript): regression for `hasOwnProperty` (#4603) 2018-05-31 00:39:39 +08:00
Evilebot Tnawi 3d60871458
fix: output color adjusters (#4494) 2018-05-29 15:24:38 +03:00
Lucas Duailibe b8ded70848 Handle comments in assignments before template literals (#4580)
Closes #4560
2018-05-29 00:08:18 +10:00
Lucas Duailibe a6db391556
Short rule should only apply to the first identifier (#4575) 2018-05-27 21:52:42 -03:00
Kevin Donnelly 16a84e88d6 Improve format when passing ts arrow function with return type as an argument (#4228)
* Add various tests for ts type annotated function properties.

* Improve format when passing ts arrow function with return type

* Add test for case from #2581.
2018-05-27 20:39:08 -03:00
Jed Fox a1e8d586ad
Add a single test suite for blank files in all parsers (#4562)
* Add a single test suite for blank files in all parsers

The parsers that don’t yet support blank files have been filtered out of the list until they do.

* Don’t directly `require()` Prettier

* Update `require`

* Add missing Babylon parser

* Update snapshots
2018-05-27 08:22:25 -04:00
Lucas Azzola b0cb63a7bb
Use destructuring for imports (#4554)
* Use destructuring for imports

* Clean up integration tests

* Use moduleNameMapper for require_prettier
2018-05-27 21:36:12 +10:00
Brian Ng fda7bf59f4
Add support for Flow's proto modifier syntax (#4551)
Flow commit: eb815be907

Babel PR: https://github.com/babel/babel/pull/7978
2018-05-25 17:23:17 -05: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
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
Brian Ng 61b39749a1
Add support for flow explicit type arguments (#4540)
Fixes #4489.

Babylon support landed in `beta.48` just now but requires a few other fixture changes, so I'm going to follow this up with another PR.
2018-05-25 08:55:39 -05:00
Lucas Duailibe c2202efd54
Do not remove parens for ?. operator (#4542) 2018-05-24 23:27:49 -03: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
Dray Lacy bb6d130b5b Fix printing of `{{{raw}}}` handlebars expressions (#4535)
Previously, `{{{raw}}}` would be output as `{{raw}}`.
2018-05-24 11:16:50 -07:00
James Henry 88b71481fa New: Format Angular Component styles (#4361)
* New: Format Angular Component styles and template

* Clean AST

* Cleanup
2018-05-23 19:08:40 -06:00
Lucas Duailibe 5c6e0802af
Don't default parser to babylon (#4528)
* Don't default parser to babylon

* Different default values according to version

* Fix error logging

* Add tests specifically for parser inference

* Add another test case

* Add API test
2018-05-23 16:55:06 -03:00
Evilebot Tnawi 9db668702c
refactor: `less` extend (#4526) 2018-05-23 19:28:18 +03:00
Evilebot Tnawi 0b8a8d84f6
fix: scss interpolation in string (#4490) 2018-05-22 16:05:47 +03:00
Ika 553e9bb1ac
fix(typescript): preserve quoted class property (#4517) 2018-05-21 18:57:30 +08:00
Aakansha Doshi 3fc4c527d3 Add spec for multiple items in class attributes in handle bars (#4509) 2018-05-20 19:53:01 -03:00
Aakansha Doshi 31f79fbc22 Don't add new lines after unless present in graphql (#4512)
* Don't add new lines after unless present in graphql

* fix logic and add more specs

* use index
2018-05-20 13:44:49 -04:00
Ika a9eb68296c
fix(markdown): do not merge continuous cjk if proseWrap=preserve (#4504)
* test: add tests

* fix(markdown): do not merge continuous cjk if proseWrap=preserve

* fix: remove trailing comma for node4
2018-05-19 13:53:34 +08:00
Lucas Duailibe ea01781d8c
Only break chains with short names if inside ExpressionStatement (#4505) 2018-05-18 21:44:15 -03:00
Joseph Frazier 6d49a224c9
Don't format range if required pragma is missing outside range (#3996)
* Add tests demonstrating --require-pragma behavior with range

* Don't format range if required pragma is missing outside range

Fixes https://github.com/prettier/prettier/issues/3985
2018-05-17 13:38:50 -04:00
Georgii Dolzhykov c6e8177282 Inline AngularJS tests that use `inject` (#4495)
* Inline AngularJS tests that use `inject`

See https://docs.angularjs.org/guide/unit-testing#using-beforeall- for a code example.

* More meaningful function name, minor refactoring

* Linting

* Minor regexp improvement

* address review comments
2018-05-17 12:09:20 -03:00
Evilebot Tnawi a8b0e55205
fix: better output scss maps (#4487) 2018-05-17 13:39:22 +03:00
Lucas Duailibe 7bc5ec2dc6
Preserve Liquid tags contents (#4484) 2018-05-15 14:22:41 -03:00
Brian Ng 857c55bd61
Keep parens around do-expressions inside ExpressionStatement (#4479) 2018-05-15 11:41:17 -05:00
Lucas Duailibe 983202413c
Refactor frontmatter handling (#4482) 2018-05-14 22:17:15 -03:00
Evilebot Tnawi 9d41f1355a
refactor: parser-postcss (#4478) 2018-05-15 00:00:45 +03:00
Aakansha Doshi f99aee8e46 refactor: use `postcss-values-parser` for `@import` at rule (#4435)
* update to postcss value parser for @import and at rule

* fix specs

* Add rule for @import url and fix specs

* fix more specs

* fix more specs

* import check

* fix specs and add more specs

* remove console.log

* review fixes

* update snapshots

* remove bad code

* fix spec

* remove code

* Add comment

* fix comment

* lint fix
2018-05-14 22:54:34 +03:00
Nicolò Ribaudo bcfe2257f5 Wrap ?() => T in parens when needed. (#4475) 2018-05-14 11:25:16 -03:00
Evilebot Tnawi 6cd6ea383e
fix: characters escaping (#4472) 2018-05-14 13:47:46 +03:00
Jed Fox dc68a3d9a6
Break link definitions onto multiple lines when needed (#3531)
* Break link definitions onto multiple lines when needed

* Simplify the conditional for breaking the title

* Don’t print the title if it’s blank

* Revert "Don’t print the title if it’s blank"

This reverts commit 2a8d0dd9995a2e5ab8e6d888c07b88dda058637f.

* Add another test

* Fix title printing

* Second time’s the charm

* Third time’s the charm?

* Fix snapshot

* Prettify

* Don’t break unless `proseWrap` is `always`

* Test `proseWrap: never` on link references
2018-05-14 06:17:37 -04:00
Ika 1062f2a889
feat: support JSON.stringify formatting (#4450)
* test: move tests

* feat: support legacy JSON formatting

* fix: add missing assertion

* test: fix coverage

* fix: same output as JSON.stringify

* refactor: fix linting

* refactor: rename to json-stringify

* refactor: fix linting

* fix: should fix the production build

* docs: remove outdated name

* fix(playgound): add lib/parser-json-stringify.js

* feat(playgound): add example for json-stringify

* fix: no error on singleQuote string

* fix(playground): correctly load json-stringify

* fix: identifier is only allowed in ObjectProperty.key

* refactor: clearer
2018-05-14 09:12:25 +08:00
Evilebot Tnawi bc2f57dcf9
fix: css variables and scss interpolation (#4471) 2018-05-12 22:38:28 +03:00
Elias Meire 2f5c00ad18 Fix: not greedy match the frontmatter in postcss parser (#4457) 2018-05-10 13:50:19 -03:00
Ika 6447d30b0b
feat(markdown): change unordered list symbol to hyphen (#4440) 2018-05-10 14:32:52 +08:00
Soo Jae Hwang ee96e97c77 Fix: Group long name method in bind expressions (#4447)
* Fix: Group long name method in bind expressions

* Add test for short name method in bind expressions
2018-05-09 10:42:16 -06:00
tjallingt 8cf591447c Added support for the graph ql comment tag (#4395)
* Added support for the graph ql comment tag

As described in the issue https://github.com/prettier/prettier/issues/4360
Prettier still adds a space inbetween the comment tag and the template literal.

* Added comment explaining the random spaces around GraphQL

* Fixed failing AST_COMPARE tests
2018-05-09 01:52:35 -06:00
Nicolò Ribaudo ab452ddc38 Fix: Correctly break class prperties initializer. (#4442) 2018-05-08 20:35:49 -04:00
Ika 76a5f3c7b6
fix(typescript): add missing `qualifier` and `typeof` in TSImportType (#4438) 2018-05-08 12:35:12 +08:00
Kevin Donnelly c6e7c1966e Improve formatting of TS casts with generics and unions (#4219)
* Add tests showing existing behavior of various TS casts.

* Improve formatting of TS casts with generics and unions.

By adding a soft break between the cast and the expression. Also
includes wrapping parentheses for clarity as suggested in #4171.

Avoids changing behavior at all though if casting an array or object
literal because those already have good behavior where the array or
object literal breaks before the cast does so including them would just
result in a pointless extra layer of parentheses that would add no
clarity.

* Update tests in prepation for updating long cast format.

* Update so nested breaks inside type cast are indented.

* Add tests where expression being cast is too long itself.

* Update cast formatting to only sometimes break after cast.

Specifically it will break after the cast if that makes the cast itself
fit on a single line. If the cast itself won't fit on a single line then
the expression being cast will be placed directly after the `>` at the
end of the cast.
2018-05-07 22:26:01 -06:00
Suchipi ed18f9f7d7
Add heuristic to format functional composition more nicely (#4431)
* Add heuristic to format functional composition more nicely

* Regex -> array

* Use object instead of array for faster lookup

* Remove empty lines

* Add redux connect

Also add comments for libraries
2018-05-07 21:46:30 -06:00
Lucas Duailibe f6b22e3fd1 feat: support styled-components Foo.extend.attrs()`` (#4434)
* Support styled-components Foo.extend.attrs()``

* update snapshot
2018-05-07 12:38:19 +03:00
Ika cc4392e5c0
feat(typescript): support TSImportType (#4429)
* feat(typescript): support TSImportType

* test: add singleQuote test
2018-05-07 07:57:57 +08:00
Aakansha Doshi 299cc97ceb Fix spacing issue in postcss simple vars (#4408) 2018-05-06 13:51:28 +02:00
Ika 7e81a613b5
feat(javascript): support jest-each template string (#4423)
* feat(javascript): support jest-each

* test: add trailing newline

* fix: there can be no trailing newline

* refactor: simplify regex

* refactor: Array.from

* refactor

* fix: print quasis safely
2018-05-06 14:52:34 +08:00
Lucas Duailibe 5776c8405a
Fix TSMappedType comments (#4418) 2018-05-05 15:43:53 -03:00
Lucas Duailibe 8e1b60e943
Fix trailing JSDoc comments with trailing regular comments (#4414) 2018-05-04 10:15:30 -03:00
Lucas Duailibe bafa76f613
Wrap modulo operation in parens inside additive operation (#4413) 2018-05-03 12:28:37 -03:00
Lucas Duailibe e3223fe9af Prevent flattening multiplicative operations (#4407) 2018-05-02 23:48:40 +02:00
Lucas Duailibe 32900842e3
Apply destructuring rules in functions to catch param (#4385) 2018-05-01 10:24:46 -03:00
David Sheldrick d77f5e9c3a Fix cursor offset tracking (#4397)
* handle cusor position relative to comments correctly

* use more robust method of cursor offset tracking

* add support for cursorOffset with rangeStart/End

* add tests for cursorOffset

* use old JS syntax for node4

* add another cursor offset test case

* remove trailing whitespace in cursor tests

* fix null findNodeAtOffset handling

* remove dead code

* add more test cases

* use indexOf for node4

* revert comments.js

* add more comment tests

* change tests infra

* Fix AST_COMPARE

* move CURSOR to top level of file

* mutate result

* use es6 property shorthand

* simplify diff offset calculation

* put remaining test cases in individual files
2018-05-01 09:42:59 -03: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
Nate Pendleton 91c701886d fix(glimmer): preserve leading/trailing spaces in text nodes undernea… (#4288)
* fix(glimmer): preserve leading/trailing spaces in text nodes underneath attribute nodes when next to mustache statements.

* fix(glimmer): format printer-glimmer.js

* fix(glimmer): lint fix

* fix(glimmer): removed decomposition assignments to be compatible with Node 4

* fix(glimmer): Array.includes() -> indexOf() for Node 4
2018-04-27 14:20:10 -06:00
Huy Vo 2ad7576d3a Remove newline in empty .md files (#4388)
* Remove newline in empty .md files

* Fix cannot read property 'type' of undefined bug
2018-04-27 15:01:14 +08:00
Ika ff38aaff95 fix(javascript): correct escape for markdown in js (#4381)
* test: add tests

* fix(javascript): correct escape for markdown in js

* test: add trailing newline
2018-04-26 13:22:43 +03:00
Evilebot Tnawi 58a91cc570
feat: improve `@support` at-rule output (#4372) 2018-04-25 20:41:41 +03:00
Ika 289b98c125
feat(json): enforce StringLiteral-style property key (#4371)
* test: add tests

* feat(json): enforce StringLiteral-style property key
2018-04-26 00:00:07 +08:00
Ika 317f3a3c56
feat: split out JSON5 (#4367)
* feat: split out JSON5

* test: update snapshots

* test: update debug-check tests

* feat(playground): use JSON's code sample for JSON5

* fix: add missing trailing newline
2018-04-25 22:10:22 +08:00
Ika 6a17474e37 feat(typescript): support generic JSX element (#4268)
* feat(typescript): support generic JSX element

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

* chore(deps): update typescript-eslint-parser
2018-04-24 08:45:31 -05: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
Lucas Duailibe 50101e98c6
Fix pragma detection/insertion for JSON (#4333) 2018-04-24 10:10:16 -03:00
Adam Pearce 09ac476a32 Nicer line wrapping for d3 (#4285)
* d3 counts as a constructor

* adds test

* Tweak wording

* docs: fix linting

* updates test

* no $ special case

* renames function

* shorter function name

* removes trailing white space
2018-04-24 06:54:45 -04:00
Brian Ng 7cb6790ce0
Merge pull request #4326 from existentialism/flow70
Bump flow to 0.70
2018-04-18 17:04:14 -05:00
Aakansha Doshi 7f20ffc7f5 Allow trailing comma in scss list and maps (#4317)
* Allow trailing comma in scss list and maps

* fix #4076

* triple equalto

* newline

* linting

* review fixes

* print trailing comma only when options.tralingComma is not none

* Add nested maps and lists

* add isSCSS() check

* linting

* Add utils for isSCSS() in language-css

* lint
2018-04-18 17:40:01 -03:00
Brian Ng 7ab3e94fbb
Ensure mixins before implements 2018-04-16 21:28:56 -05:00
Brian Ng e22ec0b9b9
Bump flow to 0.70 2018-04-16 20:53:07 -05:00
Christopher Chedeau 02a1db8c9f
[flow] Fix union indent inside of function param with a name (#4325)
Fixes #4323

See #4323 for all the context
2018-04-16 18:47:05 -07:00
Zach Gawlik 0a22f5ec15 Wrap awaits in unary expressions (#4315) 2018-04-14 15:27:18 -04:00
Evilebot Tnawi 7c0dee617b
refactor: `parseNestedCSS` function (#4208) 2018-04-13 22:12:59 +03:00
Evilebot Tnawi 47cb5ad298
fix: correct prettier placeholder regex (#4302) 2018-04-12 18:25:25 +03:00
Jed Fox 63a2ded4c9
Never print a semicolon after `export default interface Foo {}` (#4128)
* Never print a semicolon after `export default interface Foo {}`

* Add test
2018-04-11 06:38:02 -04: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
Lucas Duailibe 57bc700602
Stop marking all comments in named exports as leading comments (#4292) 2018-04-10 17:05:49 -03:00
Aakansha Doshi 6794a14554 Inline Angular async tests and beforeEach, etc. (#4241)
* fix #3791 and refactor isTestCall

* typo

* remove default value

* add safe check if parent exists

* add spec

* better comment
2018-04-11 00:06:42 +08:00
Ika c052d9c086
test(markdown): update snapshot (#4283) 2018-04-09 08:20:29 +08:00
Nate Pendleton 28e4b07b17 fix(issue-3982): Glimmer printer now properly handles else-if blocks without else block … (#4256)
* fix(glimmer): Now properly handles else-if blocks without else block and block statements as root of else.

* run prettier on printer-glimmer.js
2018-04-08 11:36:37 -06:00
Ika 0c1d62079e
feat(markdown): support hasPragma/insertPragma (#4275)
* feat(markdown): support hasPragma/insertPragma

* test: add require-pragma tests

* feat: support pragma with front matter

* feat: support pragma in multiline comment
2018-04-09 00:10:24 +08:00
Lucas Duailibe f3626611a3
Handle ContinueStatement and BreakStatement comments (#4279) 2018-04-07 13:38:37 -03:00
Ika 4bc80d8c64
fix(markdown): remove unnecessary empty line in front matter (#4280)
* test: add tests

* fix(markdown): remove unnecessary empty line in front matter
2018-04-08 00:05:27 +08:00
Lucas Duailibe a92838facf
Prevent formatting GraphQL embedded in JS if it contains invalid escape sequences (#4278) 2018-04-07 12:03:56 -03:00
Lucas Duailibe 18aaee594f
Break object destructuring with nested destructuring (#4267) 2018-04-06 11:57:37 -03:00
Lucas Duailibe 2e73164b81
Fix embedded GraphQL in JS with backticks (#4265) 2018-04-05 17:52:09 -03:00
Lucas Duailibe fa089f5bb6 If consequent is a block statement, treat as trailing comment 2018-04-05 17:22:10 -03:00
Lucas Duailibe 88489a9afe Handle comments before `else` 2018-04-05 16:06:18 -03:00
Lucas Duailibe e17bb5e947 Break nested ternaries (#4120) 2018-04-04 18:50:15 -06:00
Alexander Ryzhikov 6d7bc4402f fix: don't lowercase custom selectors variable name #4254 (#4255)
* fix: don't lowercase custom selectors variable name #4254

* proper fix for camelCased custom selector

* Move customs-selectors case snapshots to correct place
2018-04-04 15:19:51 +03:00
Evilebot Tnawi c9bb96cd52
fix: don't break value property with inlined URL (#4236) 2018-04-02 14:16:39 +03:00
Evilebot Tnawi f2f2390114
fix: inline comments in lists and maps (#4205) 2018-03-31 17:18:23 +03:00
Evilebot Tnawi 30bcd110e4
fix: mangles template literal when you use `prettier-ignore` (#4220) 2018-03-30 21:40:14 +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
Ika 1b09fde361
feat(markdown): support top-level `prettier-ignore-start/end` (#4202)
* test: add tests

* feat(markdown): support top-level `prettier-ignore-start/end`

* docs(ignore): add range ignore
2018-03-27 00:03:28 +08:00
Jeff Lau 24f45d1b50 Require parenthesis around "TSAsExpression" inside an "UpdateExpression" (#4183) 2018-03-21 11:38:10 -03:00
Brian Ng 4553b88bd4
Merge pull request #4156 from Cryrivers/master
feat(typescript): support TSMinusToken and TSPlusToken
2018-03-21 09:06:06 -05:00
Evilebot Tnawi 190d34fa46
tests: comments with `CRLF` (#4145) 2018-03-21 12:04:57 +03:00
Evilebot Tnawi 31530259a1 feat: indent in discriminant switch (#4165) 2018-03-19 23:50:24 +11:00
Wang Zhongliang 5eea8aa2f5 feat(typescript): support TSPlusToken 2018-03-16 14:08:25 +08:00
Wang Zhongliang 67277f7477 feat(typescript): support TSMinusToken 2018-03-16 10:46:12 +08:00
Ika 0c09e150ba
feat(markdown): support fenced codeblock lang followed by attributes (#4153)
* test: add tests

* feat(markdown): support fenced codeblock lang followed by attributes
ref: https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk

* refactor: set limit
2018-03-16 00:25:39 +08:00
Evilebot Tnawi 5537140296
fix: don't lowercase variable in css modules (#4152) 2018-03-15 18:16:28 +03:00
Evilebot Tnawi e2373206bc
fix(html): support comment on top (#4141) 2018-03-13 19:47:48 +03:00
Evilebot Tnawi 8686653433
tests(html): aurelia non standard attributes (#4142) 2018-03-13 19:03:44 +03:00
Lucas Duailibe 13103101eb
Move pragma detection/insertion to plugins (#3685)
New pragma infrastructure, only JS and JSON has detection/insertion implemented
2018-03-08 13:50:33 -03:00
Evilebot Tnawi 94ec29dac7
fix: handle `unicode-range` (#4117) 2018-03-07 21:15:06 +03:00
Ika 836fd1ddcf
fix(markdown): correct html indentation (#4115)
* test: add test case

* fix(markdown): correct html indentation
2018-03-08 00:06:22 +08:00
Lucas Duailibe 550904d588 Fix self-closing style tags in vue 2018-03-06 09:38:15 -03:00
Lucas Duailibe 41098a06b5
Prevent "over-indenting" class properties values (#4085) 2018-03-02 11:28:27 -03:00
Anthony Sottile a02094961a pre-commit.com is now served on https (#4088) 2018-03-02 07:26:36 -05:00
Evilebot Tnawi 19d7d881a7
chore: update `postcss-scss` to latest version (#4084) 2018-03-01 21:00:51 +03:00
Ika 2b283908cf fix(markdown): print literalline for newline instead of hardline (#4083)
* test: add tests

* fix(markdown): print literalline for newline instead of hardline

* test: add tests
2018-03-01 14:42:20 +02:00
Evilebot Tnawi 4ddf1a6e84 fix: don't lowercase nesting selector (#4048) 2018-02-26 18:13:02 -07:00
Eric Anderson efd5bde713 Fix(typescript) non-null identifier same line in chain (#4052) 2018-02-26 15:12:03 -03:00
Evilebot Tnawi 65b988a989
feat: ignore non standard IE filter values (#4028) 2018-02-26 14:58:38 +03:00
Ika b6c27893cc
fix(markdown): list prefix alignment: count spaces from correct place (#4041)
* test: add tests

* fix(markdown): list prefix alignment: count spaces from correct place

* docs: codeblock -> code block
2018-02-26 08:53:09 +08:00
Ika ca81bef73e
fix(markdown): list prefix: no unnecessary trailing spaces (#4042)
* fix(markdown): list prefix: no unnecessary trailing spaces

* refactor
2018-02-26 08:52:49 +08:00
Ika c1107a86dd feat(markdown): respect tabWidth for list items (#3990)
* feat(markdown): respect tabWidth for list items

* test: ensure no regression for #3459
2018-02-24 19:13:02 +11: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
Evilebot Tnawi 7b457fd3b8
refactor: at rules parse (#4023) 2018-02-22 12:49:03 +03:00
Lucas Azzola b7f0794ad5
Handle definite variable declarations (#4025)
* Handle definite variable declarations

* printDefinite -> isDefinite
2018-02-22 13:03:35 +11:00
Evilebot Tnawi e1491d0f95
fix(css): comments in at rules (#3920) 2018-02-21 21:36:09 +03:00
Ika 8f6a32853c
feat(typescript): support definite assignment (`!:`) (#4020) 2018-02-22 01:40:57 +08:00
Lucas Duailibe 974b27dac2
Break JSX element if a string literal prop has a newline (#4011) 2018-02-21 10:52:30 -03:00
Eric Anderson 051a488bbd fix(typescript): properly chain when there is a TSNonNullExpression (#4005)
* fix(typescript): properly chain when there is a TSNonNullExpression

* No need to pass args

* PR feedback

* Fix lint
2018-02-20 12:37:11 -03:00
Lucas Azzola 417c50aa84
Keep parens around Unary and Update Expressions (#3989) 2018-02-18 00:22:35 +11:00
Brian Ng a8fe401b26 Fix cases with missing semi when printing DeclareExportDeclaration (#3979) 2018-02-17 17:40:43 +11:00
Evilebot Tnawi 86f0b93e29
feat(css): improve math output (#3984) 2018-02-16 21:58:21 +03:00
Evilebot Tnawi 0ee9959bd6
tests(css): trailing comma (#3843) 2018-02-16 17:56:11 +03:00
Evilebot Tnawi 0f067d3832
feat(css): improve `@nest` at rule output (#3976) 2018-02-15 20:45:33 +03:00
Evilebot Tnawi cce8924ef3
fix(css): `@nest` at rule (#3975) 2018-02-15 15:19:28 +03:00
Jed Fox 78a4f51662
Wrap ternaries in Flow typecasts in parens (#3940)
* Wrap TypeCastExpression in parens

* Tests
2018-02-14 11:19:39 +00: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 11a8d586b8
tests(css): source map comment (#3962) 2018-02-12 21:42:01 +03:00
Evilebot Tnawi c30d28003b
chore(css): update `postcss-values-parser` to latest version (#3960) 2018-02-12 20:46:54 +03:00
Evilebot Tnawi c36cb7670a
tests(css): postcss popular plugins (#3959) 2018-02-12 20:12:09 +03:00
Evilebot Tnawi bff7de3ea2
tests(css): more tests around pseudo-classes and pseudo-elements (#3957) 2018-02-12 20:11:55 +03:00
Evilebot Tnawi f5cfa96878
tests(css): colors (#3958) 2018-02-12 18:56:25 +03:00
Evilebot Tnawi ec4f4eb6d3
fix(css): don't eat selector namespace (#3956) 2018-02-12 18:39:03 +03:00
Lucas Azzola 2313574fcc
Fix flow maybe object return type (#3948) 2018-02-11 17:46:00 +11:00
Lucas Azzola f87cbcf76e
Bump jest-docblock to 22.2.2 (#3947) 2018-02-11 17:42:08 +11:00
Evilebot Tnawi 1bb5cbaa4c
fix(css): space after math operations before parens (#3945) 2018-02-10 20:57:06 +03:00
Evilebot Tnawi 087b68d183
fix(css): scss interpolation (#3943) 2018-02-10 02:05:48 +03:00
Evilebot Tnawi d716c84156
fix(css): space and newlines before parenthesis (#3930) 2018-02-09 15:28:55 +03:00
Evilebot Tnawi 26ceb854c2
tests(css): more comments tests (#3922) 2018-02-07 21:31:00 +03:00
Evilebot Tnawi bc027bd661
fix(css): space after `if` in `else` at rule (#3921) 2018-02-07 19:53:28 +03:00
Evilebot Tnawi 517db8f5db
tests(css): comments in selectors (#3917) 2018-02-07 15:05:29 +03:00
Evilebot Tnawi 0e1358b5ca
Improve the printing of CSS at-rules (#3896)
fix(css): improve at rules print
2018-02-07 13:33:10 +03:00
Evilebot Tnawi 9e6bd15ade
fix(css): comments in selectors (#3909) 2018-02-07 13:20:13 +03: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 a6ab8a7e32
refactor(tests): restructure `at rules` tests (#3892) 2018-02-06 19:03:36 +03:00
Evilebot Tnawi 0bdceaa158
tests(css): declaration comments (#3906) 2018-02-06 18:48:24 +03:00
Evilebot Tnawi 1b13dc8974
fix(css): declaration comments (#3897) 2018-02-06 18:09:42 +03:00
Evilebot Tnawi 0e8f3acb59
tests(css): custom media (#3879) 2018-02-03 18:04:59 +03:00
Evilebot Tnawi ed2a9be58e
fix(css): stringify unquoted data urls (#3877) 2018-02-02 20:39:53 +03:00
Evilebot Tnawi f5e74cd70a
fix(css): at rules improve formatting and tests (#3828) 2018-02-02 18:06:47 +03:00
Lucas Duailibe aac38fca49 Force break if comment in return argument (#3665)
* Force break if comment in return argument

* add test case
2018-01-31 12:00:29 -05:00
Lipis 7a7eb17082
fix: Proper case for Prettier, JavaScript, TypeScript, GitHub, Less (#3848) 2018-01-31 11:56:05 +01:00
Evilebot Tnawi ed5f68844f
fix(css): scss `global` flag (#3844) 2018-01-30 17:53:37 +03:00
Evilebot Tnawi 22ba2bcb64
fix(css): don't remove semicolon in `less` ruleset declaration (#3841) 2018-01-30 14:16:07 +03:00
Evilebot Tnawi 386e2a9bd4
tests(css): attr function (#3825) 2018-01-30 14:06:52 +03:00
Salem 8c792121f2 Treat define calls like require (#3830)
* Treat define calls like require

See issue #3829. This commit keeps define calls as a unit when possible,
to prevent an extra indent in the body of an AMD-style define.

Rather than adding the "define" check in the same case as the existing
"require" check, I added a separate condition to explicitly call out the
fact that this checks for both AMD and CommonJS modules.

`yarn test -u` yields no changes, and `yarn lint` passes successfully.

* Added tests for define and require amd formatting

This tests the solution for issue #3829.

* Add babylon interpreter to require-amd test

* Merge require and define checks
2018-01-29 16:44:32 -05:00
Ika b529c634d1
fix(markdown): print multiline content correctly in footnoteDefinition (#3787)
* fix(markdown): print multiline content correctly in footnoteDefinition

* refactor: replace `ifBreak(line)` with `softline`

* refactor: fix linting
2018-01-27 00:48:47 +08:00
Evilebot Tnawi 640ffa949d
tests(css): `font-face` at rule (#3826) 2018-01-26 15:53:08 +03:00
Evilebot Tnawi e3369db2c1
fix(css): handle namespace in attribute selector (#3810) 2018-01-26 13:00:20 +03:00
Ika 03292a6488
fix(javascript): ternary with `--use-tabs` (#3745)
* test: add test cases

* test: add test cases

* fix(javascript): ternary with `--use-tabs`

* chore: add istanbul ignore comment

* fix: remove unnecessary condition

* docs(commands): update `align`

* fix: do not transform the middle part

* refactor: markAsRoot

* fix: print tabs in sub-ternaries

* docs(commands): update

* test: add a cool test case
2018-01-26 10:02:42 +08:00
Evilebot Tnawi acf5e66408
tests(css): prefixes property (#3822) 2018-01-25 15:56:28 +03:00
Evilebot Tnawi e90f766459
tests(css): `viewport` at rule (#3817) 2018-01-25 14:59:38 +03:00
Evilebot Tnawi ca949a46d2
tests(css): `supports` at rule (#3816) 2018-01-25 12:53:34 +03:00
Evilebot Tnawi a3bf378259
fix: handle YAML front matter block (#3802) 2018-01-24 19:44:09 +03:00
Evilebot Tnawi 5008836dc2
fix(css): remove whitespaces before ":" in scss maps (#3814) 2018-01-24 18:48:54 +03:00
Evilebot Tnawi b48fb2015a
tests(css): variables (#3813) 2018-01-24 17:00:02 +03:00
Evilebot Tnawi 2b300a0f40
tests(css): namespace at rule (#3811) 2018-01-24 16:27:02 +03:00
Evilebot Tnawi 4bffe76a42
tests(css): function parens (#3809) 2018-01-24 16:06:05 +03:00
Evilebot Tnawi 4c90608d11
fix: keep space between deep selector `>>>` (#3792) 2018-01-24 14:53:22 +03:00
Evilebot Tnawi 7797c93489
fix(css): ignore `media` params with scss interpolation (#3801) 2018-01-24 12:31:30 +03:00
Evilebot Tnawi d3004b51ea
feat: remove extra spaces in `url` inside `@import` (#3793) 2018-01-23 23:33:19 +03:00
Evilebot Tnawi d1f9598d68
tests(css): newlines around multiple and combinator selectors (#3800) 2018-01-23 21:12:45 +03:00
Evilebot Tnawi fc200c9432
fix(css): remove other types of whitespace in `clean` (#3799) 2018-01-23 20:57:23 +03:00
Evilebot Tnawi a52747eaec tests: multiple selector (#3796) 2018-01-23 10:35:00 -05:00
Evilebot Tnawi 11dd57e8ff tests: parens spaces (#3795) 2018-01-23 10:34:36 -05:00
Brian Ng a8fb1863a2
Merge pull request #3797 from prettier/feat-css-lowercase-wide-keywords
feat(css): lowercase wide keywords
2018-01-23 09:33:01 -06:00
Evilebot Tnawi b2e8c6d374 feat: remove extra spaces in attribute selector (#3794) 2018-01-23 10:30:20 -05:00
evilebottnawi 591ee5a425 feat(css): lowercase wide keywords 2018-01-23 18:10:39 +03:00
Evilebot Tnawi 3bc3e801c8
tests: `scss` syntax (#3757) 2018-01-23 14:33:18 +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
Evilebot Tnawi 105914e45c fix: don't handle args of `@warn` and `@error` directives as media query list (#3769) 2018-01-19 17:00:06 -07:00
Evilebot Tnawi dbb494ed30 tests: `less` syntax (#3766) 2018-01-19 16:57:57 -07:00
Evilebot Tnawi 12441eb2dd fix: don't add comma after `url` in `@import` directive (#3770) 2018-01-19 16:56:28 -07:00
Evilebot Tnawi 17b3df9b8e tests: `@media` directive (#3772) 2018-01-19 21:31:20 -02:00
Evilebot Tnawi 74d25c37f0 fix: don't change case of function name (#3768) 2018-01-19 15:39:44 +01:00
wonderful-panda 3f788d4fb6 fix: *.vue with `lang='tsx'` is not formatted (#3763) 2018-01-18 00:20:55 -02:00
Ika de6bc4448f
fix(multiparser): respect 0-indent markdown-in-js (#3676)
* fix(multiparser): respect 0-indent markdown-in-js

* fix: use literalline for 0-indent

* test: add unexpected case

* fix: 0-indent

* test: add failing test

* refactor: simplify

* fix(doc): literallines respect `ind.root`

* docs: update commands

* fix: what a magic...
2018-01-17 12:52:42 +08:00
Ika 2dd311d554
fix(javascript): indentation for sub-ternaries (#3747)
* test: add test cases

* test: add test cases

* fix(javascript): indentation for sub-ternaries

* test: update test cases

* fix: no extra tab for `tabWidth: 4`
2018-01-16 11:32:25 +08:00
Evilebot Tnawi 64f1c06727 fix(scss/less): space after combinator operator (#3738) 2018-01-13 13:17:29 -02:00
Thorben von Hacht 1a1de60491 Prettier extends and implements when not fitting in same line (#3689)
* Added prettier layout for class extends and implements

* Added prettier layout for class extends and implements, fix with keeping it in online if it fits

* Added prettier layout for class extends and implements, fixed tests as a side change

* Extends implements comments in same line fix

* Extends implements comments in same line without ugly workaround

* added empty line to test typescript_class/extends_implements.ts

* If only one extends keep old behaviour

* Removed console logs
2018-01-13 16:31:51 +11:00
Quinn Hoyer aa0437cc60 Add support for skip() (#3706) (#3735)
* Add support for skip() (#3706)

* Fix regex & add tests
2018-01-13 13:02:31 +11:00
Evilebot Tnawi 934f679705 fix(scss): `!default` directive (#3724) 2018-01-12 22:12:02 +11:00
Daniel Heckrath 2155465c88 Enable PostCSS in VUE SFC (#3715)
* Enable PostCSS in VUE SFC

* Add test that verifies that postcss style blocks are parsed

* Move postcss check to same condition as the css check
2018-01-12 17:05:22 +11:00
Aleks Hudochenkov b67fd8e155 Don't add end of line to empty CSS (#3723)
Fixes #3440.
2018-01-11 16:05:57 -05:00
Lucas Duailibe 46baad09cd
Fix vue print error with self-closing tags (#3705) 2018-01-10 17:41:11 -02:00
Ika 3df7d60a7f feat(markdown): respect `tabWidth` for list indentation (#3694)
* test: add test case

* feat(markdown): respect `tabWidth` for list indentation

* test: add extreme `tabWidth` test case
2018-01-10 18:45:22 +11:00
Lucas Azzola b1a7787e87
Fix vue self-closing tags (#3693) 2018-01-10 18:44:18 +11:00
Lucas Duailibe 01a59eeee3
Wrap conditionals and await in parens in spread property (#3681) 2018-01-09 01:45:51 -02:00
Christopher Chedeau a4dd86436a
[scss] Print comments inside of selector as is (#3649)
Fixes #3647
2018-01-04 19:03:04 -08:00
Lucas Duailibe 7f75499dd2 Prevent adding softline after arrow attribute with comments (#3641)
* failing test

* fix
2018-01-03 12:12:01 -08:00
Lucas Duailibe 157df6e3fd
Print imageReference with no alt in Markdown (#3643) 2018-01-03 13:54:53 -03:00
Lucas Duailibe 7d3a30615b
Don't add () in JSX attributes with elements (#3640) 2018-01-03 11:36:25 -03:00
Lucas Duailibe 6a953e47b5
Print description of enum and input for GraphQL (#3633) 2018-01-03 01:29:11 -03:00
Christopher Chedeau 5356db0e69
Normalize GraphQL multi-line strings (#3632)
* Normalize GraphQL multi-line strings

See discussion in https://github.com/prettier/prettier/pull/3605#discussion_r159120321

* split
2018-01-02 11:55:53 -08: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
Lucas Duailibe 51744e1008 Print parens in FunctionTypeAnnotation when arrowParens is "always" (#3616)
* add test case

* print parens in function type annotation
2017-12-31 16:01:21 +01:00
Ika 6872ed8310 fix(markdown): replace newlines with hardlines in multiparser (#3611)
* test: add failing test

* fix(markdown): replace newlines with hardlines in multiparser
2017-12-30 10:33:58 -05:00
Christopher Chedeau 7eca8011bc Inline do expressions inside of JSX (#3607)
Fixes #3602
2017-12-29 18:58:01 -03:00
Jimmy Jia cfb8987ecd Revert Relay Classic non-support (#3606)
This reverts commit e8551b994d313ea023855a790c87acc4833150f9.
2017-12-29 21:14:08 +01: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 bd78b3bfbe
Remove ALL_PARSERS, print ~ printWidth times (#3596) 2017-12-29 08:25:11 +11:00
Jimmy Jia bbfc450cd2 Support Relay Classic (#3595) 2017-12-28 14:20:25 -03: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
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
Christopher Chedeau c40b061b80
[vue] Introduce proper support for Vue Single File Components (SFC) (#3563)
There's a lot of demand for vue sfc (#2097). This introduces partial support for them: all the html is printed as is, except for the script and style tags which are printed using prettier. I believe that this should cover a lot of the use cases while being simple to support and if we want we can extend to more in the future.

I copy pasted the html parser used by vue (it's just a single 400 lines file) so that we don't run the chancesof conflicts. I'm also very conservative: I only print the style and script at the top level and for the lang attributes we support.

I expect this to be landable as is and provide value, review welcome :)
2017-12-25 01:15:33 +01:00
Jed Fox 5ccc213a21 Conform the quotes in Markdown link titles to the singleQuote option (#3481)
* Add an option to utils.printString to use the passed string as-is

* Conform the quotes in Markdown link titles to the singleQuote option

* Don’t use destructuring

* Add some tests

* Format util.js

* Use custom string-printing logic

* Add some more tests

* Fix tests

* Address review comments

* Revert "Format util.js"

This reverts commit d2533ef7fb9231e2f733ece7decac9b923cf6941.

* Revert "Don’t use destructuring"

This reverts commit a5d3b0ac76a076e9a89cffc8cec396cabeacd1ee.

* Revert "Add an option to utils.printString to use the passed string as-is"

This reverts commit ef8e8322609ca3c2808885f3fadcd03f0790078c.

* Even more tests
2017-12-24 15:44:38 +01:00
Lucas Azzola d1c97b3622
Convert eslint config and users/languages/editors files to YAML (#3516)
* YAML all the things

* Cleanup website data files

* Update edit links
2017-12-18 21:55:10 +11:00
Lucas Duailibe 4d23e9081d
Print flow type annotation comments as comments (#3449) 2017-12-15 05:11:48 -02: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 7c83ac782e Regression test for #1473 2017-12-12 01:30:20 -02:00
Lucas Duailibe 694f9c8588
Print comment after arrow function params (#3444) 2017-12-12 01:26:41 -02:00
Lucas Duailibe d00d09bb87
Don't break single argument destructuring arguments (#3443) 2017-12-10 12:29:09 -02:00
Brian Ng 38c8286907 Fix closing parens on multi-line intersection/union type (#3436) 2017-12-10 22:32:17 +11:00
Lucas Duailibe 3fa2229a62 Fix printing union types inside a function param type (#3446)
* Fix printing union types inside a function param type

* fix alignment
2017-12-10 20:22:13 +11:00
Lucas Duailibe dbf22eb41a
Fix printing separator in objects with prettier-ignore (#3448) 2017-12-10 02:57:42 -02:00
Lucas Duailibe 69f05e42c9
Consider TSNonNullExpression part of member chain (#3442) 2017-12-10 02:41:53 -02:00
Lucas Duailibe 934e4d3027
Fix babylon misplacing comments (#3441)
* Fix comments in class method args

* Fix comments in obj property
2017-12-09 15:43:19 -02:00
Lucas Duailibe 69f6ee7829
Only prevent lone `get` and `set` if property has no value (#3434) 2017-12-07 11:03:55 -02:00
Lucas Duailibe 90e8b13e86
Ignore whitespace in docblock right after /** (#3430) 2017-12-07 03:28:29 -02:00
Lucas Duailibe 7cff189dd8
Print trailing comma when last arg is arrow (#3428) 2017-12-07 02:48:11 -02:00
Lucas Azzola 829616dd6c Fix multiparser trailing comma regression (#3405)
* Fix multiparser trailing comma regression

* Refactor trailing comma application
2017-12-05 19:01:00 +01:00
Ika e09359d242
fix(doc-printer): no wrong function call (#3401) 2017-12-05 20:09:36 +08:00
Lucas Duailibe 66c9315d13
Don't default print comments for JSXFragments (#3398) 2017-12-05 08:41:45 -02:00
Ika 1122701053 fix(doc-printer): respect indent/align order (#3383) 2017-12-05 08:59:27 +11:00
Kevin Gibbons 8e377a1e56 Add support for flow mixins when using babylon (#3391) 2017-12-05 08:58:14 +11:00
Lucas Duailibe ceabc48e01
Format CSS prop for emotion (#3381) 2017-12-03 03:25:17 -03:00
Ika c1623d88e6 feat(markdown): preserve `break` style (#3325) 2017-12-03 15:02:13 +11:00
Lucas Azzola 8524ed5b6f
Fix printing of comments around decorators and class properties (#3382) 2017-12-03 14:59:35 +11:00
Lucas Duailibe a9be90c5d4 Format CSS prop for emotion 2017-12-02 22:50:07 -03:00
Simon Lydell d80728b5ff Support toplevel interpolations in graphql tags (#3370)
* Refactor multiparser

* Add support for toplevel interpolations in graphql tags

* Update snapshots

* Fix JSX-in-markdown special-case
2017-12-03 12:31:23 +11:00
Ika 073c0b16d8 feat(markdown): add `proseWrap: "preserve"` option (#3340)
* test: add test case

* feat(markdown): add `proseWrap: "preserve"` option

* test: add tests

* docs(options): update `proseWrap`

* feat(markdown): change default to `proseWrap: "preserve"`

BREAKING CHANGE

* docs(options): update `proseWrap`

* test: specify option explicitly

* Fix lint after merge

* Fix error after merge
2017-12-02 09:48:40 +11:00
Brian Ng d52d721cd1 Bump babylon to 7.0.0-beta.33 (#3372) 2017-12-02 09:39:10 +11:00
Lucas Duailibe f119d4a90f
Change run_spec to have explicit parser list (#3356) 2017-11-30 03:31:52 -03:00
Lucas Duailibe b2cca7eacc
Add support for JSX fragments (#3237) 2017-11-30 00:09:45 -03:00
Ika 7670024292 fix(markdown): do not break before special prefix (#3347) 2017-11-30 08:43:22 +11:00
Ika fbbfa52517 fix(markdown): do not print linebreaks in heading (#3343) 2017-11-29 22:13:38 +11:00
Alex Rattray 606c5abbfc
Merge pull request #3324 from suchipi/arrow_parens
Simple arrow function parens option
2017-11-28 10:23:56 -05:00
Jacky Ho a02e3b3464 Fix format of comment in paren of call expression in arrow expression (#3334) 2017-11-28 21:58:39 +11:00
Suchipi Izumi 6abdd2c6b7 PR feedback 2017-11-27 22:27:34 -07:00
Stephen Scott a6c12ca7a9 Inline type parameters in test callback 2017-11-27 22:27:34 -07:00
Stephen Scott e4eb8a4065 Add implementation for arrow parens option
Based on https://github.com/prettier/prettier/pull/2676

* Thread `path` and `options` through helpers so we don't need to add `needsParens` onto the AST node anymore (mutation)
* Pull test call detection logic out into helper method so it can be re-used for arrow function parens
* Add arrow function parens option implementation (avoid/always)
* Don't break arrow function parens around (done) in test call
2017-11-27 22:27:34 -07:00
Stephen Scott 9a1e408a3f Add option and specs (no implementation yet)
These new snapshots are from https://github.com/prettier/prettier/pull/2676
2017-11-27 22:26:58 -07:00
Artem Sapegin 172d34e43d Do not prepend / append with a semicolon the only JSX element in a program (#3330)
* Do not prepend / append with a semicolon the only JSX element in a program

Fixes #3196

* Limit single JSX element without semicolon to Markdown only

* Fix tests
2017-11-27 22:04:12 -07:00
Simon Lydell 56951a71b4
Don't lowercase element names and attribute names in selectors (#3317)
* Don't lowercase element names and attribute names in selectors

https://www.w3.org/TR/css3-selectors/#casesens

> All Selectors syntax is case-insensitive within the ASCII range (i.e.
> [a-z] and [A-Z] are equivalent), except for parts that are not under the
> control of Selectors. The case sensitivity of document language element
> names, attribute names, and attribute values in selectors depends on the
> document language. For example, in HTML, element names are
> case-insensitive, but in XML, they are case-sensitive.

Fixes #3304.

* Fix number normalization in selector interpolation
2017-11-27 13:28:03 +01:00
Lucas Azzola 2dd76c6a95
Print parens around type assertions for decorators (#3329) 2017-11-27 23:10:33 +11:00
Ika 9b4ecec183 fix(markdown): preserve non-breakable whitespaces (#3327) 2017-11-27 19:37:52 +11:00
Lucas Duailibe f9f056612f
Update flow to 0.59.0 (#3238) 2017-11-26 23:14:45 -03:00
Lucas Duailibe 742a5c3d02
Don't add trailing comma after object rest spread in TypeScript (#3313) 2017-11-23 12:54:21 -02:00
Anton a0c95cf862 UTF8-BOM - if input string has BOM that mean output string also should have it (#3283)
The issue that prettier lost BOM and mean convert UTF-8 with BOM to just UTF-8
2017-11-21 14:38:21 -07:00
Lucas Duailibe 759953ef6d
Template literals: Don't break on identifiers but break if comments (#3299) 2017-11-21 15:51:15 -02:00
Ika d5a3abd7a6
fix(markdown): only indent the first non-list node in checkbox list item (#3297)
* fix(markdown): do not indent checkbox

* fix: keep alignment for first non-list node

* fix: force whitespaces
2017-11-22 00:01:59 +08:00
Ika 3cbbac3d08
fix(multiparser): fix markdown error and remove trailing new line (#3293) 2017-11-21 00:19:49 +08:00
Ika b6f126eb29 feat(markdown): support TOML (#3290) 2017-11-19 17:38:25 +11:00
Christopher Chedeau 4b070c3a93
[flow] Do not break on empty type parameters (#3281)
Not only does breaking look bad but when you have trailing comma enabled, it puts a comma there which is not valid.
2017-11-16 14:36:37 -08:00
Ika 378cfee508
refactor(markdown): expose `hasPunctuation` to AST for better debugging (#3272)
* refactor(markdown): extract `punctuationRegex`

* refactor: expose `has(Leading|Trailing)Punctuaion` to AST for better debugging

* refactor: tweak

* refactor: tweak

* fix: no regression

* test: fix typo
2017-11-16 13:59:01 +08:00
Lucas Duailibe 482c83df20
Don't break self closing elements with no attributes (#3250) 2017-11-13 02:20:17 -02: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 Duailibe ece764a049
Preserve intentional new lines in GraphQL (#3252)
* Preserve intentional new lines in GraphQL

* Move function to bottom

* Rename arg

* Refactor

* Add comments in tests and support for arguments
2017-11-12 02:10:54 -02:00
Ika bddbd1914d
fix(markdown): no extra whitespace between ascii punc and CJK char (#3249)
* fix(markdown): no extra whitespace between ascii punctuation and CJK character

* test: update snapshot
2017-11-12 00:38:18 +08:00
Ika 4ae52c5aa6
fix(markdown): do not enable splitText in inlineCode (#3243) 2017-11-12 00:29:59 +08:00
Ika 1cde865a11
fix(markdown): no extra whitespace between non-cjk and cjk-punctuation (#3244)
* fix(markdown): no extra whitespace between non-cjk and cjk-punctuation

* fix: no node v4 unsupported feature
2017-11-12 00:08:24 +08:00
Ika 4c6a7e8749
fix(markdown): escape all emphasis-like text (#3246)
* fix(markdown): escape all emphasis-like text

* test: add test case
2017-11-12 00:07:58 +08:00
Ika 92459047ed
fix(markdown): force print spaces (#3225) 2017-11-11 15:05:07 +08:00
Ika 49f578fb91
fix(markdown): do not break `inlineCode` (#3230) 2017-11-11 12:50:40 +08:00
Lucas Duailibe 658886aab1
Prevent adding semi in TypeScript interfaces when type has prettier-ignore (#3103) 2017-11-09 21:52:47 -02:00
Mitermayer Reis 813d9b93eb Fix typos (#3212)
* Adding --stdin-filepath option in order to enable filetype inference from
stdin

* Fixing typo on the documentation

* Fixing typos - fixing some typos

* Restoring static lib files back since they are artifacts
2017-11-09 11:44:24 +11:00
Ika 7fb8e3fe43 fix(markdown): no break on link (#3204)
* fix(markdown): link/image url head is breakable

* fix(markdown): no break on link
2017-11-09 08:19:35 +11:00
Ika 4f1a2c4108 feat(markdown): add `--no-prose-wrap` option (#3199)
* feat(markdown): add `--no-prose-wrap` option

* refactor: fix typo

* refactor: fix typo

* refactor: reduce duplicate code

* docs: mention the option is for markdown
2017-11-08 21:01:06 +11:00
Lucas Duailibe a35257bacf Print JSON top comments as leading comments of root node (#3187)
* Make JSON top comments be leading comments of root node

* Update snapshot
2017-11-08 09:01:09 +11:00
Lucas Duailibe 68a99cf4b2 Parenthesis around TSAsExpression inside TSAbstractClassDeclaration (#3191) 2017-11-08 08:59:15 +11:00
Ika ec7eced099
test: lowercase the test file to avoid cross platform issue (#3189) 2017-11-07 22:07:01 +08:00
Ika 18345817d8 fix(markdown): allow more cases that `_`-style emphasis is available (#3186)
* fix(markdown): add more cases `_`-style emphasis is available

* refactor: fix naming style
2017-11-07 23:33:29 +11:00
Lucas Duailibe 49b07c3983 Don't add trailing commas in JSXAttribute for arrow functions (#3181) 2017-11-07 22:37:36 +11:00
Ika ffd198beaa fix(markdown): handle additional spaces before `code` (#3180)
* fix(markdown): handle additional spaces before `code`

* test: update snapshots

* fix: ignore leading `\n` from indented `code`

* docs: add comment
2017-11-07 22:25:20 +11:00
Lucas Azzola e733a7706d
Force JSON to no trailing comma in multiparser (#3182)
* Force JSON to no trailing comma in multiparser

* Switch to mutate next.options
2017-11-07 22:01:40 +11:00
Ika 9d616817be fix(markdown): do not break on unbreakable place (#3177) 2017-11-07 21:10:41 +11:00
Ika 2bdb652667 fix(markdown): do not break before special prefix (#3172)
* fix(markdown): do not break before special prefix

* fix: add more cases
2017-11-07 20:40:09 +11:00
Lucas Duailibe 8249b1c841 Add support for JSXSpreadChild and fix comments inside JSXSpread (#3163)
* Add support for JSXSpreadChild and fix comments inside JSXSpread

* Dangling comments

* Use another approach
2017-11-07 14:23:10 +11:00
Lucas Duailibe 2c5a792d9a fix(jsx): Break opening elements with single text attribute if there's a comment (#3154)
* fix(jsx): Break opening elements with single text attribute if there's a comment

* Single text attribute with a comment on the JSXElement name

* Consolidate rules of comments in JSX
2017-11-07 08:05:59 +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
Ika ec8deb6c0b fix(markdown): print `---`-style thematic break (#3148)
* fix(markdown): print `---`-style thematic break

* test: fix diff
2017-11-05 20:50:10 +11:00
Christopher Chedeau ec18ebc6c6
[Graphql] Escape strings (#3143)
When I ran it on all the graphql files of fb, none of them had escape, but someone reported this issue!
2017-11-04 11:04:45 -07:00
Lucas Duailibe 1dfffd14e7 Don't inline trailing } for arrow functions in JSX 2017-11-04 01:52:27 -02:00
Lucas Duailibe 979b86944d Consider [0] to be part of the first member group 2017-11-02 14:42:13 -02:00
Lucas Duailibe 538ce6d209 Preserve line breaks in css grid declaration 2017-11-02 00:21:41 -02:00
Lucas Duailibe 21c6d4f501 Prevent inlining JSXAttribute if it has comments (#3132) 2017-11-01 09:56:04 -06:00
Lucas Duailibe 38b15f7899 Improve template literal expresions line breaks (#3124) 2017-10-31 14:31:27 -06:00
Christopher Chedeau 777090ca99
Make the factory detection handle multiple elements (#3112)
This was only accounting for a single element in the first group. Now it handles arbitrary elements. Only the last element being capitalized matters.

This fixes one issue in #3107
2017-10-27 09:05:40 -07:00
Lucas Duailibe 6ccf5c0246 fix(jsx): Don't inline trailing } for arrow functions attributes (#3110) 2017-10-26 11:32:57 -06:00
Lucas Azzola 1d3c86be4d Fix util.getStringWidth for falsy input (#3092) 2017-10-24 15:19:27 +11:00
Lucas Azzola c0aaa0fa52 Don't print JSX bracket on same line when it has trailing comments (#3088) 2017-10-23 17:13:12 +11:00
Ika 11d7213862 test(markdown): rename test case to avoid confusing (#3086) 2017-10-23 09:49:13 +08:00
Lucas Duailibe 878412c680 Break parens for binaries in member expression (#2958)
* Break parens for binaries in member expression

* Add test case

* Update snapshot
2017-10-22 17:29:13 -06:00
Cyril Junod e589babeaf Split source elements relative to their language. (#3069)
* Split source elements relative to their language.

Colliding node types which are not source elements in every language.
Example ObjectExpression in JSON / JS

* Node4's Array.prototype.includes

* Ensure there is no confusion

ObjectExpression vs BlockStatement & LabeledStatement
2017-10-22 20:04:06 +11:00
Karl O'Keeffe fa83ce3f3f Fix calculation of whether doc parts fit (#3081) 2017-10-22 07:54:23 +01:00
Andy Mockler c6d97abf95 Format SCSS maps like CSS rules (#3070)
* Format SCSS maps like CSS rules

* Ensure parent value starts with $ before formatting map with hardlines
2017-10-22 12:35:22 +11:00
Lucas Duailibe b53a426e15 Prevent breaking MemberExpression inside NewExpression (#3075)
* Test case

* Prevent breaking MemberExpression inside NewExpression
2017-10-22 10:30:05 +11:00
Mutasem Aldmour 54bdd30595 Fix first argument left behind when line breaks (#3079)
* fixing issue #2984

* removed typescript from test #2984

* prettier

* removed obsolete test copied from another

* added verification parsers

* added new line
2017-10-21 23:12:26 +11:00
Lucas Duailibe 465729685f Fix indentation of intersection object types (#3074) 2017-10-21 17:45:41 +11:00
Brian Ng 12f028cd46 Fix formatting styled(Foo).attrs(...)`` (#3073) 2017-10-21 09:10:55 +11:00
Jacky Ho 5b7b012fcd Account for empty lines in long member call chain (#3035)
* Account for empty lines in member chain

* Add tests

* Account for parens

* Improve tests

* Add some comments

* Remove an outdated comment

* Fix lint errors

* Refactor a line of code

* Add one more comment for clarification
2017-10-19 09:25:51 +11:00
Lucas Azzola 7162e1ecc8 Keep parens around TSAsExpression in ConditionalExpression (#3053) 2017-10-18 20:03:58 +11:00
Lucas Azzola 624d89e7a5 Print pipeline and nullish-coalescing operators (#3036) 2017-10-16 09:13:25 +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 c3b965145b feat(markdown): auto-detect which number style of ordered list to be used (#3029) 2017-10-14 22:53:58 +11:00
Ika c4118edbe7 fix(markdown): print auto-link as-is (#3032) 2017-10-14 22:49:12 +11:00
Ika 5c789b2dfc fix(markdown): use the most popular unordered list style (#3027) 2017-10-14 22:41:25 +11: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
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