Release 2.7.0
This commit is contained in:
1 parent
00ee6fb6f8
commit
13dcc16330
9 files changed
+101
-34
No files matched your search
@@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you:
|
||||
|
||||
-->
|
||||
|
||||
**Prettier 2.6.2**
|
||||
**Prettier 2.7.0**
|
||||
[Playground link](https://prettier.io/playground/#.....)
|
||||
|
||||
```sh
|
||||
|
||||
@@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:
|
||||
|
||||
**Environments:**
|
||||
|
||||
- Prettier Version: 2.6.2
|
||||
- Prettier Version: 2.7.0
|
||||
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
|
||||
- Runtime: <!-- Node.js v14, Chrome v83, etc. -->
|
||||
- Operating System: <!-- Windows, Linux, macOS, etc. -->
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
# 2.7.0
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.6.2...2.7.0)
|
||||
|
||||
🔗 [Release Notes](https://prettier.io/blog/2022/06/14/2.7.0.html)
|
||||
|
||||
# 2.6.2
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.6.1...2.6.2)
|
||||
|
||||
+13
-13
@@ -32,8 +32,8 @@ See below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.6.2/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.6.2/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.7.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.7.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -48,8 +48,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.6.2/esm/parser-graphql.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.7.0/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -62,8 +62,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.6.2/standalone.js",
|
||||
"https://unpkg.com/prettier@2.6.2/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.7.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.7.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -88,8 +88,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.6.2/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.6.2/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.7.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.7.0/parser-graphql.js");
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
plugins: prettierPlugins,
|
||||
@@ -102,8 +102,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.6.2/esm/parser-babel.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.7.0/esm/parser-babel.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
@@ -119,9 +119,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.6.2/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.6.2/esm/parser-html.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.7.0/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.7.0/esm/parser-html.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "2.7.0-dev",
|
||||
"version": "2.7.0",
|
||||
"description": "Prettier is an opinionated code formatter",
|
||||
"bin": "./bin/prettier.js",
|
||||
"repository": "prettier/prettier",
|
||||
|
||||
@@ -33,8 +33,8 @@ See below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.6.2/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.6.2/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.7.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.7.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -49,8 +49,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.6.2/esm/parser-graphql.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.7.0/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -63,8 +63,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.6.2/standalone.js",
|
||||
"https://unpkg.com/prettier@2.6.2/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.7.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.7.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -89,8 +89,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.6.2/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.6.2/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.7.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.7.0/parser-graphql.js");
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
plugins: prettierPlugins,
|
||||
@@ -103,8 +103,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.6.2/esm/parser-babel.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.7.0/esm/parser-babel.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
@@ -120,9 +120,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.6.2/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.6.2/esm/parser-html.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.7.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.7.0/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.7.0/esm/parser-html.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
|
||||
@@ -205,3 +205,35 @@ Prevent errors when pattern is unmatched.
|
||||
## `--no-plugin-search`
|
||||
|
||||
Disable plugin autoloading.
|
||||
|
||||
## `--cache`
|
||||
|
||||
If this option is enabled, the following values are used as cache keys and the file is formatted only if one of them is changed.
|
||||
|
||||
- Prettier version
|
||||
- Options
|
||||
- Node.js version
|
||||
- (if `--cache-strategy` is `metadata`) file metadata, such as timestamps
|
||||
- (if `--cache-strategy` is `content`) content of the file
|
||||
|
||||
```bash
|
||||
prettier --write --cache src
|
||||
```
|
||||
|
||||
Running Prettier without `--cache` will delete the cache.
|
||||
|
||||
Also, since the cache file is stored in `./node_modules/.cache/prettier/.prettier-cache`, so you can use `rm ./node_modules/.cache/prettier/.prettier-cache` to remove it manually.
|
||||
|
||||
> Plugins version and implementation are not used as cache keys. We recommend that you delete the cache when updating plugins.
|
||||
|
||||
## `--cache-strategy`
|
||||
|
||||
Strategy for the cache to use for detecting changed files. Can be either `metadata` or `content`.
|
||||
|
||||
In general, `metadata` is faster. However, `content` is useful for updating the timestamp without changing the file content. This can happen, for example, during git operations such as `git clone`, because it does not track file modification times.
|
||||
|
||||
If no strategy is specified, `content` will be used.
|
||||
|
||||
```bash
|
||||
prettier --write --cache --cache-strategy metadata src
|
||||
```
|
||||
@@ -177,9 +177,37 @@ If you’d like a JSON schema to validate your configuration, one is available h
|
||||
|
||||
## EditorConfig
|
||||
|
||||
If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding Prettier configuration. This configuration will be overridden by `.prettierrc`, etc. Currently, the following EditorConfig properties are supported:
|
||||
If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding Prettier configuration. This configuration will be overridden by `.prettierrc`, etc.
|
||||
|
||||
- `end_of_line`
|
||||
- `indent_style`
|
||||
- `indent_size`/`tab_width`
|
||||
- `max_line_length`
|
||||
Here’s an annotated description of how different properties map to Prettier’s behavior:
|
||||
|
||||
```ini
|
||||
# Stop the editor from looking for .editorconfig files in the parent directories
|
||||
# root = true
|
||||
|
||||
[*]
|
||||
# Non-configurable Prettier behaviors
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
# Caveat: Prettier won’t trim trailing whitespace inside template strings, but your editor might.
|
||||
# trim_trailing_whitespace = true
|
||||
|
||||
# Configurable Prettier behaviors
|
||||
# (change these if your Prettier config differs)
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
max_line_length = 80
|
||||
```
|
||||
|
||||
Here’s a copy+paste-ready `.editorconfig` file if you use the default options:
|
||||
|
||||
```ini
|
||||
[*]
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
max_line_length = 80
|
||||
```
|
||||
@@ -61,6 +61,7 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI
|
||||
- [`prettier-plugin-apex`](https://github.com/dangmai/prettier-plugin-apex) by [**@dangmai**](https://github.com/dangmai)
|
||||
- [`prettier-plugin-elm`](https://github.com/gicentre/prettier-plugin-elm) by [**@giCentre**](https://github.com/gicentre)
|
||||
- [`prettier-plugin-erb`](https://github.com/adamzapasnik/prettier-plugin-erb) by [**@adamzapasnik**](https://github.com/adamzapasnik)
|
||||
- [`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) by [**@NaridaL**](https://github.com/NaridaL)
|
||||
- [`prettier-plugin-go-template`](https://github.com/NiklasPor/prettier-plugin-go-template) by [**@NiklasPor**](https://github.com/NiklasPor)
|
||||
- [`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster)
|
||||
- [`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi)
|
||||
|
||||
Reference in new issue
Block a user