Commit Graph
301 Commits
Author SHA1 Message Date
fisker Cheungandautofix-ci[bot] b5378edeeb Fix inconsistent member chain format (#17470)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-15 11:27:22 +08:00
SUZUKI Sosukeandautofix-ci[bot] d3332e06d3 Preserve spaces between CSS words and embedded expression (#17398)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-04-25 10:11:50 +08:00
fisker Cheung b289ecbb19 Remove support for tupleAndRecord (#17363) 2025-04-17 04:53:05 +08:00
fisker Cheung 6a3c132be4 Add parentheses to numbers in optional member expression (#17190) 2025-03-05 02:47:46 +08:00
fisker Cheung 73d26d777d Add parentheses to AssignmentExpression in class property keys (#17145) 2025-02-26 14:07:05 +08:00
ff3bb50881 Add parentheses to SequenceExpression in ReturnStatement and ExpressionStatement (#17085)
Co-authored-by: tongyu <tongyu10287@xwtec.cn>
Co-authored-by: fisker <lionkay@gmail.com>
2025-02-26 11:44:37 +09:00
Sosuke Suzuki 3fe8152c5c Clean changelog_unreleased 2025-02-09 20:45:20 +09:00
SUZUKI Sosuke 5ed5dc0b8a Fix a link in changelog (#17088) 2025-02-09 19:58:53 +09:00
Seiyaandfisker Cheung 97d8115d18 Resolve rule of fill violation in JSX and add assertion. (#16700)
* add stricter assertion into fill()

* resolve rule of fill issue. some comments and naming can be problematic.

* cleanup

* update comments

* rename printWhitespace -> printStringOrLine

* refine isValidSeparator() a bit

* remove FIXME comment for fixed issue

* fix idempotency problem in MDX

* add changelog

* rename assertDocFill() -> assertDocFillParts()

* add test for assertDocFillParts()

* replace cleanDoc(doc) === "" by isEmptyDoc(doc)

* Update src/document/utils/assert-doc.js

Co-authored-by: fisker Cheung <lionkay@gmail.com>

---------

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2025-01-21 13:09:32 +09:00
SUZUKI Sosuke 4caa6302c0 Update changelog_unreleased for 3.5 (#17019) 2025-01-16 13:45:32 +09:00
Paul DraperandSosuke Suzuki bef1d61a7a Implement objectWrap config option (#16163)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2025-01-15 16:44:45 +09:00
eed53fc29a Break lines before binary operators (#7111)
* Add additional binary expression comment tests

Refs #3806

These cover a few edge cases I encountered while maintaining
`@btmills/prettier` over the last few years. I'm adding them up front to
demonstrate that the `experimentalOperatorPosition` changes in a later
commit have no effect on this formatting when the flag is not enabled.

* Define experimentalOperatorPosition flag

Refs #3806

This merely defines the flag. A future commit will use it in updated
logic.

* Add experimentalOperatorPosition default tests

Right now, this flag isn't implemented, so these tests duplicate the
existing behavior. I'm adding them now so that when I implement the
flag's logic in a future commit, the changed formatting will be obvious
in the diff and easier to review.

* Implement experimentalOperatorPosition flag

Fixes #3806 as requested in https://github.com/prettier/prettier/pull/7111#issuecomment-2252623779

The flag's tests were already added in a previous commit, so the test
changes you see in this commit are specifically due to the new flag's
implementation.

* Document experimentalOperatorPosition flag

* Change operator position option start|end

In response to https://github.com/prettier/prettier/pull/7111#discussion_r1729382119

* Add TS intersection line wrapping tests

This clones TypeScript's type union operator tests in `union-parens.ts`
and swaps the operators (& <-> |) to test the the type interesection
operator. It also runs intersection tests with the new
`experimentalOperatorPosition: "start"` flag. This does _not_ yet update
the implementation to consider the flag; to ease review, I'll make that
change in the next commit to isolate the impact of the change.

* Apply experimentalOperatorPosition: start to type intersections

The type union operator was already formatted at the beginning of lines
by default, so that logic didn't need to be updated.

* Update 7111.md

* Update tests after rebasing

I rebased from 1dfe28f85 to c7066780e to fix test failures related to
https://github.com/prettier/prettier/pull/16601. The rebase applied
cleanly, and this was the only change to tests. Since the PR has
already been approved, I'll keep this as a separate commit rather than
squashing into the prior commits.

---------

Co-authored-by: fisker Cheung <lionkay@gmail.com>
Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>
2025-01-04 01:30:51 +09:00
fisker 6c7460a5d7 Clean changelog_unreleased 2024-12-04 15:06:20 +08:00
Seiya e13614ffd8 Correct fit() for fill() (#16899)
* add test for #16897

this test fails at this commit.
snapshots are taken at e3b8a16c7f

* Fix #16897

* add changelog

* omit redundant test case
2024-12-01 19:00:35 +09:00
Sosuke Suzuki f53791a2c8 Clean changelog_unreleased 2024-11-26 13:53:25 +09:00
fisker Cheung 6b582a0619 Improve string print perfomance (#16763) 2024-11-04 15:24:02 +08:00
fisker Cheung ab00c1c919 Remove support for "importReflection" (#16705) 2024-10-08 22:03:37 +08:00
fisker Cheung 4b9c16703c Remove support for DecimalLiteral (#16643) 2024-09-29 17:13:12 +08:00
SUZUKI Sosuke 92253a3f40 Improve comment formatting for logical expression in unary expression (#16593) 2024-08-24 08:22:43 +09:00
SUZUKI Sosuke 44a35adfa8 Don't remove uselsess \ in string literals (#16563) 2024-08-14 07:53:22 +09:00
fisker Cheung 820b47bf51 Fix changelog for #13315 (#16524) 2024-07-29 09:34:40 +01:00
Sung Ye Inandfisker Cheung 4a39c117d1 Handle exception in needs parens with optional chaining (#16500)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2024-07-27 15:11:27 +08:00
fisker CheungandAlexander Kachkaev c60eb83d59 Stop mutate doc.parts when printing fill (#13315)
Co-authored-by: Alexander Kachkaev <alexander@kachkaev.ru>
2024-07-26 19:51:00 +08:00
Sosuke Suzuki a0cde0ad88 Clean changelog_unreleased 2024-07-13 21:27:55 +09:00
Christopher Dignamandfisker Cheung 988b43b72d Add parens for nullish coalescing in tenary (#16391)
* add parens for nullish coalescing

fix #4873

* add function

* Update tests/format/js/nullish-coalescing/nullish_coalesing_operator.js

Co-authored-by: fisker Cheung <lionkay@gmail.com>

* update snapshot

* add changelog entry

* fix typo

---------

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2024-06-18 01:47:28 +01:00
fisker cdd480e1b6 Clean changelog_unreleased 2024-06-05 17:23:57 +08:00
fisker CheungandAlexander Kachkaev efc3d053ac Avoid line breaks in import attributes (#16349)
Co-authored-by: Alexander Kachkaev <alexander@kachkaev.ru>
2024-06-05 17:01:58 +08:00
Sosuke Suzuki 2406fee590 Clean changelog_unreleased 2024-06-02 02:04:43 +09:00
fisker Cheung 26f1cd924e Fix dynamic import when the module source is a template literal (#16267) 2024-05-11 09:02:24 +08:00
Keith Layne f62bf4a191 Format embedded GQL in template literal statements (#16064)
Fixes #16007
2024-03-11 13:48:29 +09:00
Kevin Gibbons d50a4e4639 allow linebreaks in member expressions in template interpolations (#16116)
* allow linebreaks in member expressions in template interpolations

* lint

* add changelog
2024-03-10 12:43:37 +09:00
fisker Cheung c4af355521 Fix isStringKeySafeToUnquote (#16058) 2024-02-18 17:59:06 +08:00
Jaswanth-Sriram-Veturiandfisker 2576e11863 Improve formatting of React useImperativeHandle hook (#16070)
Co-authored-by: fisker <lionkay@gmail.com>
2024-02-18 17:25:53 +08:00
SUZUKI Sosukeandfisker a642ecb373 Unquote keys in import attributes (#15888)
Co-authored-by: fisker <lionkay@gmail.com>
2024-02-07 14:54:39 +08:00
Sosuke Suzuki d3be642d3f Clean changelog_unreleased 2024-01-14 12:09:17 +09:00
SUZUKI Sosuke cb8004f3f1 Fix formatting error on optional call expression and member chain (#15920) 2024-01-14 11:50:28 +09:00
Eelco Lempsink 0bfcb2d5a5 Fix css embed in JSX when using (only) a spread attribute (#15896) 2024-01-14 11:42:25 +09:00
Sosuke Suzuki 11aea0df1a Clean changelog_unreleased 2024-01-13 04:18:09 +09:00
SUZUKI Sosuke 7e862bbc41 Fix formatting error on member chain (#15915) 2024-01-13 04:12:55 +09:00
Sosuke Suzuki c52f441846 Clean changelog_unreleased 2024-01-13 01:22:01 +09:00
SUZUKI Sosuke 5c6450db9c Clean changelog for 3.1.1 (#15889)
Clean changelogs
2024-01-07 23:52:00 +09:00
fisker Cheung 5b215c3d26 Fix comment print in if (#15826) 2024-01-03 11:20:17 +08:00
fisker Cheung ff9c0839ac Fix inconsistencies for ChainElements (#15806) 2024-01-03 11:11:32 +08:00
Kevin Gibbons cb6fea81fb Avoid introducing linebreaks in template interpolations (#15209) 2023-12-17 18:10:20 +08:00
fisker Cheung ddf223a3ff Fix formatting of ternary (#15679) 2023-12-13 16:14:44 +08:00
Seiyaandfisker Cheung 224f70fb09 Stabilize member chain with empty line (#15522)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2023-12-13 16:12:03 +08:00
0d1ffb3a91 Consistently use tabs in ternaries when useTabs is true (#15662)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>
2023-12-10 17:10:57 +09:00
fisker Cheung 47ca2c1552 Keep empty import attributes and assertions (#15757) 2023-12-05 17:55:18 +08:00
fisker Cheung 7015f10d8e Keep curly braces and from keyword in empty import statements (#15756) 2023-12-05 16:13:31 +08:00
Sosuke Suzuki a3e1be82b6 Clean changelog 2023-11-13 12:04:23 +09:00