Release 2.1.0
This commit is contained in:
1 parent
5223b78dcd
commit
6365138f40
14 files changed
+64
-63
No files matched your search
@@ -26,7 +26,7 @@ Tip! Don't write this stuff manually.
|
||||
|
||||
-->
|
||||
|
||||
**Prettier 2.0.5**
|
||||
**Prettier 2.1.0**
|
||||
[Playground link](https://prettier.io/playground/#.....)
|
||||
|
||||
```sh
|
||||
|
||||
@@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:
|
||||
|
||||
**Environments:**
|
||||
|
||||
- Prettier Version: 2.0.5
|
||||
- Prettier Version: 2.1.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.1.0
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.0.5...2.1.0)
|
||||
|
||||
🔗 [Release Notes](https://prettier.io/blog/2020/08/24/2.1.0.html)
|
||||
|
||||
# 2.0.5
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.0.4...2.0.5)
|
||||
|
||||
+6
-6
@@ -18,8 +18,8 @@ See [Usage](#usage) below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.0.5/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.0.5/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
@@ -46,8 +46,8 @@ prettier.format("query { }", {
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.0.5/standalone.js",
|
||||
"https://unpkg.com/prettier@2.0.5/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.1.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.1.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("query { }", { parser: "graphql", plugins });
|
||||
});
|
||||
@@ -66,7 +66,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.0.5/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.0.5/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.0/parser-graphql.js");
|
||||
prettier.format("query { }", { parser: "graphql", plugins: prettierPlugins });
|
||||
```
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "2.1.0-dev",
|
||||
"version": "2.1.0",
|
||||
"description": "Prettier is an opinionated code formatter",
|
||||
"bin": "./bin/prettier.js",
|
||||
"repository": "prettier/prettier",
|
||||
|
||||
@@ -19,8 +19,8 @@ See [Usage](#usage) below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.0.5/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.0.5/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.1.0/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
@@ -47,8 +47,8 @@ prettier.format("query { }", {
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.0.5/standalone.js",
|
||||
"https://unpkg.com/prettier@2.0.5/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.1.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.1.0/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("query { }", { parser: "graphql", plugins });
|
||||
});
|
||||
@@ -67,7 +67,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.0.5/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.0.5/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.1.0/parser-graphql.js");
|
||||
prettier.format("query { }", { parser: "graphql", plugins: prettierPlugins });
|
||||
```
|
||||
@@ -68,9 +68,9 @@ Console output if some of the files require re-formatting:
|
||||
|
||||
```console
|
||||
Checking formatting...
|
||||
src/fileA.js
|
||||
src/fileB.js
|
||||
Code style issues found in the above file(s). Forgot to run Prettier?
|
||||
[warn] src/fileA.js
|
||||
[warn] src/fileB.js
|
||||
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
|
||||
```
|
||||
|
||||
The command will return exit code 1 in the second case, which is helpful inside the CI pipelines.
|
||||
@@ -173,7 +173,7 @@ Prettier CLI will ignore files located in `node_modules` directory. To opt-out f
|
||||
|
||||
## `--write`
|
||||
|
||||
This rewrites all processed files in place. This is comparable to the `eslint --fix` workflow.
|
||||
This rewrites all processed files in place. This is comparable to the `eslint --fix` workflow. You can also use `-w` alias.
|
||||
|
||||
## `--loglevel`
|
||||
|
||||
@@ -205,3 +205,11 @@ $ cat abc.css | prettier --stdin-filepath abc.css
|
||||
display: none;
|
||||
}
|
||||
```
|
||||
|
||||
## `--ignore-unknown`
|
||||
|
||||
With `--ignore-unknown` (or `-u`), prettier will ignore unknown files matched by patterns.
|
||||
|
||||
```console
|
||||
$ prettier "**/*" --write --ignore-unknown
|
||||
```
|
||||
@@ -8,8 +8,8 @@ Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for co
|
||||
|
||||
- A `"prettier"` key in your `package.json` file.
|
||||
- A `.prettierrc` file written in JSON or YAML.
|
||||
- A `.prettierrc.json`, `.prettierrc.yml`, or `.prettierrc.yaml` file.
|
||||
- A `.prettierrc.js` or `prettier.config.js` file that exports an object using `module.exports`.
|
||||
- A `.prettierrc.json`, `.prettierrc.yml`, `.prettierrc.yaml`, or `.prettierrc.json5` file.
|
||||
- A `.prettierrc.js`, `.prettierrc.cjs`, `prettier.config.js`, or `prettier.config.cjs` file that exports an object using `module.exports`.
|
||||
- A `.prettierrc.toml` file.
|
||||
|
||||
The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.
|
||||
|
||||
@@ -18,7 +18,7 @@ If you’d like to toggle the formatter on and off, install [`vscode-status-bar-
|
||||
|
||||
## Emacs
|
||||
|
||||
Check out the [prettier-emacs](https://github.com/prettier/prettier-emacs) repo, or [prettier.el](https://github.com/jscheid/prettier.el).
|
||||
Check out the [prettier-emacs](https://github.com/prettier/prettier-emacs) repo, or [prettier.el](https://github.com/jscheid/prettier.el). The package [Apheleia](https://github.com/raxod502/apheleia) supports multiple code formatters, including Prettier.
|
||||
|
||||
## Vim
|
||||
|
||||
|
||||
@@ -104,11 +104,13 @@ For example, you can add the following to your `package.json` to have ESLint and
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*": ["eslint --fix", "prettier --write"]
|
||||
"**/*": "prettier --write --ignore-unknown"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> Note: If you use ESLint, make sure lint-staged runs it before Prettier, not after.
|
||||
|
||||
See [Pre-commit Hook](precommit.md) for more information.
|
||||
|
||||
## Summary
|
||||
|
||||
@@ -373,3 +373,22 @@ Valid options:
|
||||
| Default | CLI Override | API Override |
|
||||
| ------- | ----------------------------------------------------------- | ---------------------------------------------------------- |
|
||||
| `"lf"` | <code>--end-of-line <lf|crlf|cr|auto></code> | <code>endOfLine: "<lf|crlf|cr|auto>"</code> |
|
||||
|
||||
## Embedded Language Formatting
|
||||
|
||||
_First available in v2.1.0_
|
||||
|
||||
Control whether Prettier formats quoted code embedded in the file.
|
||||
|
||||
When Prettier identifies cases where it looks like you've placed some code it knows how to format within a string in another file, like in a tagged template in JavaScript with a tag named `html` or in code blocks in Markdown, it will by default try to format that code.
|
||||
|
||||
Sometimes this behavior is undesirable, particularly in cases where you might not have intended the string to be interpreted as code. This option allows you to switch between the default behavior (`auto`) and disabling this feature entirely (`off`).
|
||||
|
||||
Valid options:
|
||||
|
||||
- `"auto"` – Format embedded code if Prettier can automatically identify it.
|
||||
- `"off"` - Never automatically format embedded code.
|
||||
|
||||
| Default | CLI Override | API Override |
|
||||
| -------- | ------------------------------------ | ----------------------------------- |
|
||||
| `"auto"` | `--embedded-language-formatting=off` | `embeddedLanguageFormatting: "off"` |
|
||||
@@ -70,42 +70,7 @@ Copy the following config into your `.pre-commit-config.yaml` file:
|
||||
|
||||
Read more at the [pre-commit](https://pre-commit.com) website.
|
||||
|
||||
## Option 4. [precise-commits](https://github.com/JamesHenry/precise-commits)
|
||||
|
||||
**Use Case:** Great for when you want partial file formatting on your changed/staged files.
|
||||
|
||||
Install it along with [husky](https://github.com/typicode/husky):
|
||||
|
||||
<!--DOCUSAURUS_CODE_TABS-->
|
||||
<!--npm-->
|
||||
|
||||
```bash
|
||||
npm install --save-dev precise-commits husky
|
||||
```
|
||||
|
||||
<!--yarn-->
|
||||
|
||||
```bash
|
||||
yarn add --dev precise-commits husky
|
||||
```
|
||||
|
||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||
|
||||
and add this config to your `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "precise-commits"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Read more at the [precise-commits](https://github.com/JamesHenry/precise-commits#2-precommit-hook) repo.
|
||||
|
||||
## Option 5. [git-format-staged](https://github.com/hallettj/git-format-staged)
|
||||
## 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.
|
||||
|
||||
@@ -139,7 +104,7 @@ and add this config to your `package.json`:
|
||||
{
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "git-format-staged -f 'prettier --stdin --stdin-filepath \"{}\"' ."
|
||||
"pre-commit": "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +114,7 @@ Add or remove file extensions to suit your project. Note that regardless of whic
|
||||
|
||||
To read about how git-format-staged works see [Automatic Code Formatting for Partially-Staged Files](https://www.olioapps.com/blog/automatic-code-formatting/).
|
||||
|
||||
## Option 6. Shell script
|
||||
## Option 5. Shell script
|
||||
|
||||
Alternately you can save this script as `.git/hooks/pre-commit` and give it execute permission:
|
||||
|
||||
|
||||
@@ -34,3 +34,4 @@ original_id: related-projects
|
||||
- [rollup-plugin-prettier](https://github.com/mjeanroy/rollup-plugin-prettier) allows you to use Prettier with Rollup
|
||||
- [jest-runner-prettier](https://github.com/keplersj/jest-runner-prettier) is Prettier as a Jest runner
|
||||
- [prettier-chrome](https://github.com/u3u/prettier-chrome) is an extension that runs Prettier in the browser
|
||||
- [spotless](https://github.com/diffplug/spotless) lets you run prettier from [gradle](https://github.com/diffplug/spotless/tree/main/plugin-gradle#prettier) or [maven](https://github.com/diffplug/spotless/tree/main/plugin-maven#prettier).
|
||||
@@ -7,7 +7,7 @@ original_id: watching-files
|
||||
You can have Prettier watch for changes from the command line by using [onchange](https://www.npmjs.com/package/onchange). For example:
|
||||
|
||||
```bash
|
||||
npx onchange '**/*.js' -- npx prettier --write {{changed}}
|
||||
npx onchange "**/*" -- npx prettier --write --ignore-unknown {{changed}}
|
||||
```
|
||||
|
||||
Or add the following to your `package.json`:
|
||||
@@ -15,7 +15,7 @@ Or add the following to your `package.json`:
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}"
|
||||
"prettier-watch": "onchange \"**/*\" -- prettier --write --ignore-unknown {{changed}}"
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user