From a980caa7dbdf88a896e48532472504b574d9e8b4 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sun, 6 Nov 2022 18:48:44 +0900 Subject: [PATCH] Add missing changelog for #13016 (#13812) * Add missing changelog * Fix --- changelog_unreleased/cli/13016.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 changelog_unreleased/cli/13016.md diff --git a/changelog_unreleased/cli/13016.md b/changelog_unreleased/cli/13016.md new file mode 100644 index 000000000..1f5cff2c0 --- /dev/null +++ b/changelog_unreleased/cli/13016.md @@ -0,0 +1,29 @@ +#### Fix `--cache` set only if with `--write` or `--no-different` (#13016 by @Milly) + +Do not save formatted cache if without `--write` option and the file is modifies by prettier. + +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 +foo.js 2ms (cached) +# "... (cached)" means that the file is already formatted and do nothing this time. +``` + +**2.8:** + +``` +> prettier --cache foo.js +# Show formatted contents of `foo.js`. + +> prettier --cache --write foo.js +foo.js 2ms +# `foo.js` has +```