Release 2.2.0
This commit is contained in:
1 parent
9bc90cfe7d
commit
42b2195e71
9 files changed
+40
-22
No files matched your search
@@ -26,7 +26,7 @@ Tip! Don't write this stuff manually.
|
||||
|
||||
-->
|
||||
|
||||
**Prettier 2.1.2**
|
||||
**Prettier 2.2.0**
|
||||
[Playground link](https://prettier.io/playground/#.....)
|
||||
|
||||
```sh
|
||||
|
||||
@@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:
|
||||
|
||||
**Environments:**
|
||||
|
||||
- Prettier Version: 2.1.2
|
||||
- Prettier Version: 2.2.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.2.0
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.1.2...2.2.0)
|
||||
|
||||
🔗 [Release Notes](https://prettier.io/blog/2020/11/20/2.2.0.html)
|
||||
|
||||
# 2.1.2
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.1.1...2.1.2)
|
||||
|
||||
+6
-6
@@ -23,8 +23,8 @@ See [Usage](#usage) below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.1.2/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.2/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.2.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.2.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
@@ -51,8 +51,8 @@ prettier.format("query { }", {
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.1.2/standalone.js",
|
||||
"https://unpkg.com/prettier@2.1.2/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.2.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.2.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("query { }", { parser: "graphql", plugins });
|
||||
});
|
||||
@@ -71,7 +71,7 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.1.2/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.2/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.2.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.2.0/parser-graphql.js");
|
||||
prettier.format("query { }", { parser: "graphql", plugins: prettierPlugins });
|
||||
```
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "2.2.0-dev",
|
||||
"version": "2.2.0",
|
||||
"description": "Prettier is an opinionated code formatter",
|
||||
"bin": "./bin/prettier.js",
|
||||
"repository": "prettier/prettier",
|
||||
|
||||
@@ -4,13 +4,18 @@ title: Browser
|
||||
original_id: browser
|
||||
---
|
||||
|
||||
Run Prettier in the browser with the `standalone.js` UMD bundle shipped in the NPM package (starting in version 1.13). The UMD bundle only formats the code and has no support for config files, ignore files, CLI usage, or automatic loading of plugins.
|
||||
Run Prettier in the browser using its **standalone** version. This version only formats the code and has no support for config files, ignore files, CLI usage, or automatic loading of plugins.
|
||||
|
||||
The standalone version comes as:
|
||||
|
||||
- ES modules: `esm/standalone.mjs`, starting in version 2.2
|
||||
- UMD: `standalone.js`, starting in version 1.13
|
||||
|
||||
The [`browser` field](https://github.com/defunctzombie/package-browser-field-spec) in Prettier’s `package.json` points to `standalone.js`. That’s why you can just `import` or `require` the `prettier` module to access Prettier’s API, and your code can stay compatible with both Node and the browser as long as webpack or another bundler that supports the `browser` field is used. This is especially convenient for [plugins](plugins.md).
|
||||
|
||||
### `prettier.format(code, options)`
|
||||
|
||||
Unlike the `format` function from the [main API](api.md#prettierformatsource--options), this function does not load plugins automatically, so a `plugins` property is required if you want to load plugins. Additionally, the parsers included in the Prettier package won’t be loaded automatically, so you need to load them before using them.
|
||||
Unlike the `format` function from the [main API](api.md#prettierformatsource--options), this function does not load plugins automatically, so a `plugins` property is required if you want to load plugins. Additionally, the parsers included in the Prettier package won’t be loaded automatically, so you need to load them as plugins before using them.
|
||||
|
||||
See [Usage](#usage) below for examples.
|
||||
|
||||
@@ -19,8 +24,8 @@ See [Usage](#usage) below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.1.2/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.2/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.2.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.2.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
@@ -34,8 +39,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
### ES Modules
|
||||
|
||||
```js
|
||||
import prettier from "prettier/standalone";
|
||||
import parserGraphql from "prettier/parser-graphql";
|
||||
import prettier from "https://unpkg.com/prettier/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
@@ -47,8 +52,8 @@ prettier.format("query { }", {
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.1.2/standalone.js",
|
||||
"https://unpkg.com/prettier@2.1.2/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.2.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.2.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("query { }", { parser: "graphql", plugins });
|
||||
});
|
||||
@@ -67,7 +72,7 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.1.2/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.2/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.2.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.2.0/parser-graphql.js");
|
||||
prettier.format("query { }", { parser: "graphql", plugins: prettierPlugins });
|
||||
```
|
||||
@@ -212,6 +212,7 @@ Valid options:
|
||||
- `"babel-ts"` (similar to `"typescript"` but uses Babel and its TypeScript plugin) _First available in v2.0.0_
|
||||
- `"flow"` (via [flow-parser](https://github.com/facebook/flow/tree/master/src/parser))
|
||||
- `"typescript"` (via [@typescript-eslint/typescript-estree](https://github.com/typescript-eslint/typescript-eslint)) _First available in v1.4.0_
|
||||
- `"espree"` (via [espree](https://github.com/eslint/espree)) _First available in v2.2.0_
|
||||
- `"css"` (via [postcss-scss](https://github.com/postcss/postcss-scss) and [postcss-less](https://github.com/shellscape/postcss-less), autodetects which to use) _First available in v1.7.1_
|
||||
- `"scss"` (same parsers as `"css"`, prefers postcss-scss) _First available in v1.7.1_
|
||||
- `"less"` (same parsers as `"css"`, prefers postcss-less) _First available in v1.7.1_
|
||||
|
||||
@@ -48,7 +48,9 @@ Providing at least one path to `--plugin-search-dir`/`pluginSearchDirs` turns of
|
||||
|
||||
- [`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-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-jsdoc`](https://github.com/hosseinmd/prettier-plugin-jsdoc) by [**@hosseinmd**](https://github.com/hosseinmd)
|
||||
- [`prettier-plugin-kotlin`](https://github.com/Angry-Potato/prettier-plugin-kotlin) by [**@Angry-Potato**](https://github.com/Angry-Potato)
|
||||
- [`prettier-plugin-package`](https://github.com/shellscape/prettier-plugin-package) by [**@shellscape**](https://github.com/shellscape)
|
||||
- [`prettier-plugin-packagejson`](https://github.com/matzkoh/prettier-plugin-packagejson) by [**@matzkoh**](https://github.com/matzkoh)
|
||||
@@ -56,11 +58,17 @@ Providing at least one path to `--plugin-search-dir`/`pluginSearchDirs` turns of
|
||||
- [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) by [**@eemeli**](https://github.com/eemeli)
|
||||
- [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)
|
||||
- [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) by [**@UnwrittenFun**](https://github.com/UnwrittenFun)
|
||||
- [`prettier-plugin-tailwind`](https://github.com/Acidic9/prettier-plugin-tailwind) by [**@Acidic9**](https://github.com/Acidic9)
|
||||
- [`prettier-plugin-toml`](https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml) by [**@bd82**](https://github.com/bd82)
|
||||
- [`prettier-plugin-organize-imports`](https://github.com/simonhaenisch/prettier-plugin-organize-imports) by [**@simonhaenisch**](https://github.com/simonhaenisch)
|
||||
- [`prettier-plugin-pkg`](https://github.com/rx-ts/prettier/tree/master/packages/pkg) by [**@JounQin**](https://github.com/JounQin)
|
||||
- [`prettier-plugin-sh`](https://github.com/rx-ts/prettier/tree/master/packages/sh) by [**@JounQin**](https://github.com/JounQin)
|
||||
|
||||
## Experimental Plugins
|
||||
|
||||
These plugins provide functionality not supported with Plugin API. Use with caution.
|
||||
|
||||
- [`prettier-plugin-organize-imports`](https://github.com/simonhaenisch/prettier-plugin-organize-imports) by [**@simonhaenisch**](https://github.com/simonhaenisch)
|
||||
|
||||
## Developing Plugins
|
||||
|
||||
Prettier plugins are regular JavaScript modules with five exports:
|
||||
|
||||
@@ -70,8 +70,6 @@ Copy the following config into your `.pre-commit-config.yaml` file:
|
||||
|
||||
Read more at [mirror of prettier package for pre-commit](https://github.com/pre-commit/mirrors-prettier) and the [pre-commit](https://pre-commit.com) website.
|
||||
|
||||
Read more at the [pre-commit](https://pre-commit.com) website.
|
||||
|
||||
## Option 4. [git-format-staged](https://github.com/hallettj/git-format-staged)
|
||||
|
||||
**Use Case:** Great for when you want to format partially-staged files, and other options do not provide a good fit for your project.
|
||||
|
||||
Reference in new issue
Block a user