Skip to content

Commit

Permalink
2.8 blog post (#13813)
Browse files Browse the repository at this point in the history
* Draft

* Update

* Generate

* Add `truncate`

* Address review

* Regen

* Update

* Reword changelog for #13016

* Edit intro

* Edit changelog for #13019

* Regenerate blog post

* Address review

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
  • Loading branch information
sosukesuzuki and thorn0 committed Nov 23, 2022
1 parent a34272d commit ebd4542
Show file tree
Hide file tree
Showing 5 changed files with 395 additions and 26 deletions.
15 changes: 15 additions & 0 deletions changelog_unreleased/blog-post-intro.md
@@ -0,0 +1,15 @@
---
author: "Sosuke Suzuki (@sosukesuzuki)"
authorURL: "https://github.com/sosukesuzuki"
title: "Prettier 2.8: improve --cache CLI option and TypeScript 4.9 satisfies operator!"
---

This release includes improvements to the `--cache` option added in 2.7. A new `--cache-location` option has been added, and a bug that saved the cache even when `--write` wasn't specified has been fixed.

We're also adding support for TypeScript 4.9 `satisfies` operator!

If you enjoy Prettier and would like to support our work, consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, including [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel).

The Prettier team plans to release 3.0 within the next few months. If you are a plugin developer, get ready for the migration. Visit [the migration guide](https://github.com/prettier/prettier/wiki/How-to-migrate-my-plugin-to-support-Prettier-v3%3F) and issue [#13606](https://github.com/prettier/prettier/issues/13616) for more information.

<!--truncate-->
34 changes: 13 additions & 21 deletions changelog_unreleased/cli/13016.md
@@ -1,29 +1,21 @@
#### Fix `--cache` set only if with `--write` or `--no-different` (#13016 by @Milly)
#### [HIGHLIGHT] Do not save the cache if the `--write` option wasn't specified (#13016 by @Milly)

Do not save formatted cache if without `--write` option and the file is modifies by prettier.
<!-- prettier-ignore -->
```bash
# Prettier stable
$ prettier --cache foo.js
# This shows formatted contents of `foo.js`.
# Then cache is created and `foo.js` is flagged as already formatted.

Before fixed, always save formatted cache if with `--cache` option.
Therefore, unformatted files will never be formatted.

**2.7:**

```
> prettier --cache foo.js
# Show formatted contents of `foo.js`.
# Then the cache is created and `foo.js` is flagged as already formatted.
> prettier --cache --write foo.js
$ prettier --cache --write foo.js
foo.js 2ms (cached)
# "... (cached)" means that the file is already formatted and do nothing this time.
```
# "... (cached)" means the file is already formatted, so nothing is done this time.

**2.8:**

```
> prettier --cache foo.js
# Prettier main
$ prettier --cache foo.js
# Show formatted contents of `foo.js`.

> prettier --cache --write foo.js
$ prettier --cache --write foo.js
foo.js 2ms
# `foo.js` has
# `foo.js` is formatted now.
```
6 changes: 2 additions & 4 deletions changelog_unreleased/cli/13019.md
@@ -1,8 +1,6 @@
#### Add `--cache-location` option (#13019 by @sosukesuzuki)
#### [HIGHLIGHT] Add `--cache-location` option (#13019 by @sosukesuzuki)

Path to the cache file location used by `--cache` flag. If you don't explicit `--cache-location`, Prettier saves cache file at `./node_modules/.cache/prettier/.prettier-cache`.

If a file path is passed, that file is used as the cache file.
By default, Prettier CLI saves the cache file for the `--cache` option at `./node_modules/.cache/prettier/.prettier-cache`. This can be overridden now:

```bash
prettier --write --cache --cache-location=my_cache_file src
Expand Down
2 changes: 1 addition & 1 deletion changelog_unreleased/typescript/13764.md
@@ -1,4 +1,4 @@
#### Support TypeScript 4.9 [`satisfies` operator](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#satisfies) (#13764, #13783, #13872 by @sosukesuzuki)
#### [HIGHLIGHT]Support TypeScript 4.9 [`satisfies` operator](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#satisfies) (#13764, #13783, #13872 by @sosukesuzuki)

<!-- prettier-ignore -->
```tsx
Expand Down

0 comments on commit ebd4542

Please sign in to comment.