Commit Graph

1522 Commits (master)

Author SHA1 Message Date
Georgii Dolzhykov 6ba4be015b fix: numeric separators were removed from BigInt literals (#6796) 2019-11-04 18:21:29 +01:00
Georgii Dolzhykov 12ba997207 disable optimization from #6229 for calls with type arguments (#6791) 2019-11-03 13:05:08 +01:00
Simon Lydell 677b46df71
Update angular-html-parser (#6785)
Fixes #6749. Closes #6784.
2019-11-02 15:58:28 +01:00
Sosuke Suzuki cf32f29d41 Flow: Keep parentheses wrap specific FunctionTypeAnnotation (#6717)
Co-Authored-By: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2019-11-02 09:39:18 +01:00
Georgii Dolzhykov ea6ae31ba0
test: fix a FIXME, add typescript (#6744)
* test: fix a FIXME, add typescript

* tests/es6modules

* tests/no-semi

* tests/array_spread
2019-11-01 18:43:03 +02:00
Sosuke Suzuki f2c6b94ee7 TypeScript: Keep semi for a class property before index signatu… (#6728)
* Modify to add semi to prop before TSIndexSignature

Co-Authored-By: Simon Lydell <simon.lydell@gmail.com>
2019-10-29 07:17:29 +01:00
Zhongliang Wang 2cfd8fb518 Support TypeScript 3.7 (and drop Node 6 support for direct inst… (#6657)
* WIP: Support TypeScript 3.7

* Add support for `asserts` keyword; Update snapshots

* Update typescript-estree to v2.5.0 to remove the dependency on chokidar

* Update TypeScript

* Update CHANGELOG.unreleased.md

* Add examples for TypeScript 3.7

* Update TypeScript 3.7 to latest dev version

* Correct wording

* Support `declare` keyword on class members (TypeScript 3.7 feature)

* Update Changelog and downgrade TypeScript from 3.8.0-dev to 3.7.1-rc

* Add a note regarding to dropping Node 6 support for direct installation

* tweak build config to repair build

* update CHANGELOG.unreleased.md

* TSTypePredicate microrefactoring

* fix formatting

* clean up tests

* fix parens for optional chaining inside computed properties

* update CHANGELOG.unreleased.md

* unify output across parsers for template literals

* enable more tests with optional chaining

* fix unneeded parens inside computed key of OptionalMemberExpression

* fix paren issues for OptionalCallExpression

* more fixes for OptionalCallExpression

* @typescript-eslint/typescript-estree 2.5.1-alpha.4

* fix lint

* revert build hacks

* fix one more parens issue

* @typescript-eslint/typescript-estree 2.5.1-alpha.5, remove loggerFn override

* drop node 6 for direct installing from github

* fix another parens issue, disable some tests for flow

* workaround for flow bug

* fix issues with comments


Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2019-10-28 17:53:57 +01:00
Zaven Muradyan 4e46f92b86 Add formatting for i18n attributes. (#6695)
* Add formatting for i18n attributes.

Previously, Prettier would largely ignore i18n attributes, not even
wrapping their content, which wasn't ideal since i18n descriptive text
can sometimes get long.

After this, Prettier will auto-wrap the contents of i18n attributes once
they exceed the line length.

Fixes #5875.
2019-10-25 22:10:43 +03:00
Sosuke Suzuki f207e665bc JavaScript: Break arrays of arrays/objects if each element has more than one element/property (#6694)
* Modify to define isJestEachFunctionCall

* Modify to break ArrayExpression when parent is jest each function

* Add tests

* Update CHANGELOG.unreleased.md

* Fix comment

* Add pr number

* Update CHANGELOG.unreleased.md

* Remove hasNewLineInRange

* Modify to change logic for breaking jest each call function

* Modify to add logic for breaking ArrayExpression

* Modify to avoid mixed nested array

* Modify to remove changes for jest

* Update CHANGELOG.unreleased.md

* Update CHANGELOG.unreleased.md
2019-10-25 19:12:07 +03:00
Sosuke Suzuki 7f68db8e88 JavaScript: arguments with object contains newline in arrow function (#6382)
* Modify to fix arguments with object contains newline in arrow function(nested)

* Update CHANGELOG.unreleased.md

* Update tests

* Modify to refactor

* Modify to refactor

* Add pr number and link

* Update CHANGELOG.unreleased.md

* Modify to remove unnecessary null checking

* Fix for ArrayPattern

* Fix for RestElement

* Fix for AssignmentPattern

* Update tests

* Fix for nested array and object

* Update tests

* Fix for nested array pattern

* Update tests

* Modify to discard unnecessary node type check

* Fix for rest element

* Fix for array in rest

* Fix for array in assignment pattern

* Update tests

* Fix for CallExpression with Assignment

* Fix for ArrowFunction with AssignmentPattern

* Update tests

* Modify to support generally pattern

* Update tests

* Modify to use path.each instead of path.map

* Fix for multi arguments

* Fix typo, Argments => Arguments
2019-10-22 16:05:10 +03:00
Chad Carbert a7cae47cdf Glimmer: Improve whitespace handling (#6354)
* Improve curly and whitespace handling

* Refactoring and clean up

* Collapse elements with non-whitespace children

* Clean selfClosing check in AST compare

selfClosing tags can't be considered when using AST_COMPARE=1.
The new AST may have a Glimmer component that has been collapsed,
ie: <HelloWorld></HelloWorld> -> <HelloWorld />

These result in different ASTs and thereofre we need to clean the
check that compares self-closing in the before and after ASTs

Co-authored-by: Jamie White <jamie@jgwhite.co.uk>

* Add istanbul ignore for ternaries in utilities

* Improve handling around whitespace near elements and block statements

* Update tests after rebasing

* Fix CHANGELOG.unreleased.md after rebase

* Tweak regex around leading and trialing line beraks and update test

Co-authored-by: FabHof <35104465+FabHof@users.noreply.github.com>

* Extract attribute value from concat node
2019-10-21 23:51:41 +02:00
Selvazhagan 10deb1f086 Angular: closing parenthesis on a new line after ternaries passed to pipes (#5902) 2019-10-21 12:38:21 +03:00
JounQin 9a0bdf71cb feat: add support for PartialApplication (#6397) 2019-10-17 16:45:24 +03:00
Georgii Dolzhykov 80260555c9 ts: fix optional computed methods (#6673) 2019-10-17 14:23:14 +03:00
Eric Sakmar 10bd71e478 fix(js): Object destructuring in method shorthand #6515 (#6646) 2019-10-16 10:46:20 +03:00
Georgii Dolzhykov d4537dc5f2
enable the allowUndeclaredExports Babel option (#6660) 2019-10-15 18:32:46 +03:00
Georgii Dolzhykov ab598e6e23
tests: rename duplicate bindings to be ready for #6400 (#6662) 2019-10-15 18:27:39 +03:00
Sosuke Suzuki 3a998df02e
TSX: Fix incorrectly removing parentheses around jsx elements being accessed in tsx file (#6640)
* Modify to wrap jsx element used with member-expression in tsx

* Add tests

* Update CHANGELOG.unreleased.md

* Modify to support no-inline jsx element

* Add pr number

* Fix from lint-docs

* Modify to rename isTsx => isTSXFile

* Modify to no considering file ext

* Support JSXFragment and add tests

* Update CHANGELOG.unreleased.md
2019-10-16 00:11:48 +09:00
Georgii Dolzhykov 977b828666 Get rid of TSParenthesizedType nodes before proceeding with formatting (#6605)
* get rid of TSParenthesizedType nodes before proceeding with formatting

* fix parens for TSIndexedAccessType, TSFunctionType, TSConditionalType

fixes #6603

* workaround edge cases with one-item unions and intersections

* fix parens for TSInferType

* fix parens for rest elements in tuple types

* refactoring

* fix function types in conditional types

* move tests for rest and optional tuple elements

* fix comment issues

* tests for unions and intersections

* add parens around multiline unions in tuple

* move the parens check for TS nodes closer to the one for Flow nodes

* update CHANGELOG.unreleased.md

* remove dead code

* fix parens for TSConstructorType

* better wording in CHANGELOG.unreleased.md
2019-10-14 15:00:21 +03:00
Ingvar Stepanyan 282d1017f3 Add support for V8 intrinsics via Babel (#6496)
This plugin was recently added on Babel side and allows to parse custom syntax for V8 intrinsics.

They don't clash with any real-world JavaScript syntax, so adding this option should be as safe as any other plugin, and would allow to format JavaScript that uses such intrinsics (e.g. code inside Node.js or V8 itself).
2019-10-09 07:29:37 -07:00
fisker Cheung 179943ccba Update `@babel/parser` to v7.6.3 (#6386)
* fix flow_function_parentheses

* fix directives

* fix classes

* fix flow_method

* fix `do`

* fix `decorators`

* fix `comments_closure_typecast`

* fix `comments`

* fix `flow_internal_slot`

* fix `flow_comments`

* fix `flow_type_declarations`

* fix `flow_type_spread`

* fix `functional_composition`

* fix `multiparser_js_css`

* fix `no-semi`

* fix `objects`

* fix `template`

* fix `yield`

* update `flow_method` snap

* fix `empty_paren_comment`

* fix `mdx`

* fix `object_property_comment`

* Update `@babel/parser`

* Update @babel/parser to v7.6.2

* Update yarn.lock

* fix `nullish_coalescing` test

* fix `flow_class_field` test

* fix snapshot

* @babel/parser v7.6.3

* fix tests

* update snap
2019-10-09 14:52:11 +03:00
Martin Donath 385c2dcc4f [typescript, flow]: double indent for unions inside of tuples (#6381) 2019-10-08 17:37:40 +03:00
Sosuke Suzuki 02cbd15ec2 TypeScript: Fix incorrectly removes double parentheses around types (#6604) 2019-10-08 16:56:08 +03:00
fisker Cheung 3f13d2ec1b Support typescript 3.6 (#6519) 2019-10-03 15:24:03 +03:00
Brian Kim 38ae5d5210 Javascript: Use function literals in arguments to detect function composition (#6033) 2019-10-01 13:53:45 +03:00
Cyrille David 7cb0c23774 fix(handlebars): Use quotes from config in AttrNode (#6377) 2019-09-30 17:08:58 +03:00
Matthew Leffler bb037eb218 TypeScript: Improve argument expansion with `as` type expressions (#6471) 2019-09-25 09:51:50 -03:00
Sosuke Suzuki 27e777e476 TypeScript: Keep type parameters inline for a variable declaration (#6467)
* Modify to keep inline type parameter with variable declaration

* Update CHENGELOG.unreleased.md

* Add tests

* Add tests

* Add pr number and link
2019-09-24 18:59:54 +03:00
Sosuke Suzuki 2e2368f5d7 JavaScript: Fix inconsistent indentation in switch statement (#6514)
* Add "SwitchStatement" to isInsideParenthesis

* Change tests

* Add tests

* Update CHANGELOG.unreleased.md

* Add pr number and link
2019-09-23 18:35:06 +02:00
Sosuke Suzuki c5c8862333 JavaScript: Fix Bad format for multi-line optional chaining with comment (#6506) 2019-09-23 15:00:34 +03:00
Sosuke Suzuki 3f89bba231 JavaScript: Fix formatting on long named exports (#6446)
* Modify to put specific export inline

* Add tests

* Fix tests

* Modify to support default exports

* Update CHANGELOG.unreleased.md

* Modify to refactor

* Add pr link

* Modify to rename "content" -> "printed"

* Modify to define canBreak helpter

* Fix from linter

* Update CHANGELOG.unreleased.md

* Add tests
2019-09-11 12:10:34 +03:00
Sosuke Suzuki 8f0fdba4ba JavaScript: Fix ugly formatting parens wrap binary expressions… (#6441)
* Modify to break specific call expression correctly

* Add tests

* Update CHANGELOG.unreleased.md

* Add tests

* Fix tests

* Add pr link
2019-09-07 14:46:00 +02:00
Kevin Gibbons fd6ad2a623 handle empty object param patterns with type annotations (#6438)
* handle object patterns in function parameters with type annotations

* fix lint

* update changelog
2019-09-05 21:56:30 +02:00
Georgii Dolzhykov ff9b2b6cb5 HTML: treat scripts as blocks (not inline) (#6423)
* HTML: treat scripts as blocks (not inline)

Fixes #6393

Signed-off-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>

* update CHANGELOG.unreleased.md
2019-09-05 20:24:20 +02:00
Sosuke Suzuki 2523a017aa JavaScript: object destructuring with parameter decorators (#6411) 2019-08-30 07:07:00 +02:00
Sosuke Suzuki 77e79bbfa5 TypeScript: Fixed to break line and add a semi in one execution on one line long mapped types (#6420) 2019-08-29 20:14:45 +02:00
Kevin Gibbons 01dc7aec65 fix: more readable parentheses for new-call (#6412) 2019-08-28 13:50:24 +03:00
Christopher Chedeau 43d03209d2
Update ?? precedence to match stage 3 proposal (#6404)
The spec was updated ( https://tc39.es/proposal-nullish-coalescing/ ) with the following two changes:
- ?? has lower precedence than ||. (previously equal)
- ?? cannot immediately contain, or be contained within, an && or || operation. (parens are now required)

The safe way to upgrade is to run prettier with just this change so that parenthesis are properly added. Then to upgrade the parser (only flow supports the new precendence in the next release, babel hasn't been updated yet) in prettier so that the new precedence is being used. Failure to do so will result in parse errors because of missing parenthesis so we will not have silent errors.

There was only 44 callsites mixing || and ?? in a confusing way in the Facebook codebase so it shouldn't be a huge deal in practice.
2019-08-20 14:26:21 -07:00
JounQin 68d3e74afe fix(mdx): text with whitespace after JSX trim incorrectly (#6340) 2019-08-14 13:45:59 +03:00
Cyrille David dd64842375 chore(Handlebars): Refactor test suite (#6378) 2019-08-12 10:35:13 -03:00
Sosuke Suzuki 9e5a5435a1 fix(TypeScript): specific union type breaks after opening parenthesis, but not before closing (#6307) 2019-08-08 16:48:37 +03:00
Sosuke Suzuki ce366f0834 fix(JavaScript): bug when arrow fn as function parameter with newline (#6301) 2019-08-08 16:06:28 +03:00
Sosuke Suzuki d66c5f82da fix(HTML, Vue): don't break the template element included in a line shorter than print-width (#6284) 2019-08-08 15:18:37 +03:00
kamilic 7d0175ca90 feat: implement --vue-indent-script-and-style mentioned at pr-#… (#6157)
* feat: implement --vue-indent-script-and-style mentioned at pr-#6077

* docs: --vue-indent-script-and-style

* update new test case

* feat: playground for --vue-indent-script-and-style

* chores: Revert package.json version

* Remove noisy snapshots
2019-08-01 11:06:12 +02:00
JounQin e5fbef238d docs: fix possible typo AFAIK (#6341) 2019-07-30 11:48:14 +02:00
JounQin 998f98aade fix: Adjacent JSX elements should be allowed in mdx (#6332)
* fix: adjacent JSX elements should be allowed in mdx

* chore: update CHANGELOG.unreleased.md for PR

* fix: adjacent JSX elements format issue of line

* fix: get html text from ast correctly

* fix: self closing issue

* fix: finally find out how to get original text from position

* chore: reset unnecessary changes

* fix: additional text after jsx should also be allowed

* fix: regression of empty text

* docs: add missing links

* fix linting...
2019-07-29 14:32:24 +03:00
Matt Kane 7286413ee5 Add JSON script types (#6293)
* Add JSON mimetypes

* Use endsWith

Co-Authored-By: Simon Lydell <simon.lydell@gmail.com>
2019-07-22 16:48:03 +03:00
Joffrey JAFFEUX b557dc3603 [Glimmer/Handlebars] Forces multilines print when almost at max length (#6249) 2019-07-22 10:39:18 -03:00
Lucas Duailibe 91a7aa081e
Fix more bugs with double slash in TSX (#6289) 2019-07-11 11:27:53 -03:00
Sosuke Suzuki 033002cdc3 TypeScript, Flow: Fix breaking ordering comments in React.useEffect (#6270) 2019-07-10 11:34:23 -03:00